December 22, 2024, 08:23:41 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: [1]

Author Topic: Quick question about how GG2 maps are read  (Read 6845 times)

BedtimeGuy

  • New Account
  • Karma: 0
  • Offline Offline
  • Posts: 2
Quick question about how GG2 maps are read
« on: September 30, 2018, 06:14:10 am »

Hi, I'm workin on a game of my own, and I realized that a feature I wanted to implement was very similar to how GG2's maps work. Hopefully it's ok to ask my question here.

Basically, how does GG2 go about reading what looks like a plain old PNG, and generate collision for the walls, and other objects as added in Garrison Builder? I know you have to make a wallmask first, but it seems like magic to me that it ends up being one PNG. Also, surely GG2 is doing something better than reading the image pixel by pixel and making each pixel that needs to be solid/have collison that way. Something involving making a bunch of... fitting rectangles for areas that are black in the wallmask?

Totally understand if y'all tell me to fk off and read the source, I've just never touched GameMaker before at all, so I didn't get much from that lmao
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

MedO

  • Owns this place
  • *****
  • Karma: 151
  • Offline Offline
  • Posts: 1754
Re: Quick question about how GG2 maps are read
« Reply #2 on: September 30, 2018, 06:45:44 am »

Hello, and welcome to the forums.

The trick is that a .png file is more than just the plain image information, it consists of many "chunks" that are used for different purposes. There is one for the actual image data, but there are also others for things like color profiles, thumbnails and so on. When we save a gg2 map, we add a custom text chunk which contains the entity information as well as the wallmask.
The entity information is stored in something similar to JSON (but slightly different so that it maps better to Game Maker data structures), called GGON: https://github.com/Gang-Garrison-2/Gang-Garrison-2/blob/master/Documentation/GGON.md
The wallmask is first converted to a .png of its own first, and then that .png is encoded as something akin to base64 so that we can store it in our text chunk as well.
« Last Edit: September 30, 2018, 06:46:12 am by MedO »
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

BedtimeGuy

  • New Account
  • Karma: 0
  • Offline Offline
  • Posts: 2
Re: Quick question about how GG2 maps are read
« Reply #3 on: September 30, 2018, 06:28:13 pm »

ahhh, that makes a lot of sense! Thanks for the quick and very helpful answers  :smiley16:
And thanks for the welcome to the forums, although I used to be quite active on here many, many moons ago. Not sure I even remember my old username lmao
Logged

#freeprime

  • Junior Member
  • **
  • Karma: 4
  • Offline Offline
  • Posts: 115
  • not arctic
Re: Quick question about how GG2 maps are read
« Reply #4 on: October 14, 2018, 01:26:58 am »

https://github.com/Gang-Garrison-2/Gang-Garrison-2/blob/master/Extensions/GG2DLL/GG2DLL/GG2DLL.cpp#L78 this triggers me can someone fix it

edit: the mixing of tabs and spaces in general triggers me, can someone fix it
« Last Edit: October 14, 2018, 01:27:56 am by arcticc »
Logged

MedO

  • Owns this place
  • *****
  • Karma: 151
  • Offline Offline
  • Posts: 1754
Re: Quick question about how GG2 maps are read
« Reply #5 on: October 14, 2018, 06:43:11 am »

If it bothers you then you can fix it  :hehe:
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.
Pages: [1]
 

Page created in 0.026 seconds with 37 queries.