Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Best methods for creating 2d tile based maps in AGK

Author
Message
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 3rd Nov 2012 21:13
I'm am at the stage where I'm developing a 2D game map for AppGameKit but am in need of some direction.

Are there any examples of how AppGameKit loads and executes a game map that was created in say the "Tiled Map Editor", Or by hand for that matter....?

I've purchased the Hands ON AppGameKit book and done all but 9 of the exercises (in the 800 some odd pages), so I have some experience w/the AppGameKit environment and I'm investing in it, but I'm not quite sure how to get off the ground with the game maps.

I'm looking for a quick start if such a thing exists, a working demo would be awesome...

Many thanks in advance ....

----
From the Desk of Prof Versaggi ...
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 4th Nov 2012 04:37 Edited at: 4th Nov 2012 04:42
A tile map is just a grid of images. I'd start off with an array that is the size of your map and then fill it with the images of each (x,y) location on your map. I'm using image 0 just to demonstrate. you of course would have to load your own images and use them.



Then you can just write out the array to a file and back in later when you want load your map



Auger
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 4th Nov 2012 20:10
Awesome! I'll try it out immediately.

A followup question is .... well ... is this the *only* way? Are there better ways to execute a game map/environment? Perhaps preferable to this one?

----
From the Desk of Prof Versaggi ...
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 4th Nov 2012 22:12
Quote: " is this the *only* way?"

Not by a long way, mapping is a whole subject on its own.

It really depends on what you want to map and to what detail, which ultimately depends on what you will be doing with it.

For such as an RPG adventure type game, you will probably want to map interiors of building, dungeons etc. as well as villages, towns and vast open areas of countryside.

Clearly you can't map an entire country with the same level of detail as a dungeon level and hope to fit it on a phone

So the general approach is to store only what you need to and use other techniques to fill the gaps.

I don't know how far you want to delve into this, or what will fit your needs, but subjects you could look into further include;

Procedural mapping - generating maps mathematically or other coding methods
Perlin Noise - used a lot in procedural generation of landscapes, textures and a load of other stuff.
L.O.D. Mapping - (Level of Detail) used to optimise texture use in complex scenes, is also used to limit the detail needed on complex maps.

In short, the more you can whip up out of thin air, the less you need to store.

As to a working example, there was a good one posted on here a bit back by Van B.

http://forum.thegamecreators.com/?m=forum_view&t=198399&b=41
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 5th Nov 2012 00:00 Edited at: 5th Nov 2012 02:00
I'd say the one I posted is the easiest. You'll probably not want to show your whole map at once so what you'll need to do is use SetViewOffset( x, y ) to scroll around the map. Then you could also us SetViewZoom() to zoom your map in and out.

I've included some code to scroll the map and zoom it along with the original code I posted earlier.



Auger
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 5th Nov 2012 10:26
I would only add the trivial fact that maybe very expensive to display all map (in term of number of tiles/sprites), especially in case of big worlds. What I have done in my DBPro projects is to display only the images onto the screen plus the ones at the borders. DBPro has "images", in addition to sprites, in that case I used images instead of sprites. If you have to zoom in or out, of course you have to be more "generous". For example, if your world is 1000x1000, and your tile is 10 percentage units, you could create only (10+2*X)x(10+2*X) sprites, where X>=1 and depends on how much zoom do you want to allow.
I do not know if this approach has been followed by other forum mates, as Cliff Mellengards for his noticeable platformer game, I'll ask him only for curiosity...
BTW, are you Italian? (ProfVersaggi?).
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2012 11:07
In AppGameKit you can create your full map (providing it's not absolutely massive) and only set the immediate area active for better speed. Also any sprites that have no transparent areas are best having transparency switched off manually for better performance on slower devices.


this.mess = abs(sin(times#))
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 5th Nov 2012 13:31
Thanks again Gentlemen, I appreciate you assistance...

@Marl: I think what I need is a decent primer on the various mapping methods so I can get a conceptual handle on the topic. What sources would you recommend? Any decent books perhaps, tutorials?

@User: That is good stuff and I'm perusing some of your examples and Van_B's code as well.

@MarcoBruti: Yes, from Chicago, living in the Netherlands, my family ancient origins are from Sicily Italy ...

----
From the Desk of Prof Versaggi ...
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 5th Nov 2012 14:00
if the world is 1000x1000 (reasonable big world), could we create 1M sprites? Even if we set to active (including physics) only a smaller sub-windows of, let's say, 20x20 (625 sprites), AppGameKit has got to store 1MxS, where S is the storage need to save all sprites' data.
My question is: apart tablets, is this approach viable for smartphones, that are short in memory resources and processor speed? Creating a lot of sprites takes time, so the creation of 1M sprites at start-up may take time...
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 5th Nov 2012 19:44 Edited at: 5th Nov 2012 19:47
Perlin Noise

This would be used to generate natural looking landscapes for large open areas. To quote Wiki ( http://en.wikipedia.org/wiki/Perlin_noise );
Quote: " It can be used to simulate elements from nature, and is especially useful in circumstances where computer memory is limited.
"

There are a number of links from wiki, bu I also found a good example of ways to impliment it (with code) at http://devmag.org.za/2009/04/25/perlin-noise/

It's used a lot for 3D terrains, but can be used for tile maps as is shown near the bottom at the above link.

Even if you don't use it in your game, I would definitely look into this. The idea is so simple yet brilliant and can be (and is) used in so many ways.

I honestly believe my programming is improved from having worked on perlin routines in the past.

... and then there is this ....

http://mrl.nyu.edu/~perlin/demox/Planet.html

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 5th Nov 2012 22:12
My tile map for my platformer uses an grid map in this size x=160 y=40.
If o would create sprites for all the tiles so would it work very badly on a mobile device as 160x40 = 6400 sprites.

I create 500 tile sprites i swapp around the screen.

I use an grid map to check if i have positioned a sprite already on that tile,each sprite also have an x and y value So i easy can clear the right tile in the mentioned grid map when i reposition this sprite.

This way so do i clear and occupy this grid map in the same few lines i reposition the tile sprite.

This have worked really well for me on pc and android devices when i look at load times ,framerates and memory usage.

The core of this method is that i only cycle thru the map grid parts that are on screen and not the rest.

This is wath makes it fast at runtime.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 5th Nov 2012 22:54
What I'm trying to do specifically is to create a Battleship (not the board game either) type game where the battleship engages enemies both on shore and in the ocean.

I have spent the last 7 months learning Blender to create my own 3D Mesh Objects, textures, etc ... and am currently reviewing number of Game AI and Game Math primers, as well as the HO AppGameKit Basic book.

I don't think a tiled game map is really what I'm after, I 'think' what I might want to do is create a custom game level map w/water & land components as a game map with overlays of unique 3D Sprite for fortifications and the bad guys.

Is there a formal way to describe what this particular process is?

Does this sound logical, on target or am I really missing something?

Thanks again for all of your help....

FYI ... I have a masters in AI so I'm planning on making the AI component of this game the real mainstay of the project ... hopefully having the bad guys have some decent smarts to them ...

----
From the Desk of Prof Versaggi ...
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 6th Nov 2012 11:53
@baxslash:

How does one set only the immediate area active if they've chosen to load the entire (not massive) map?

Many thanks in advance ...

----
From the Desk of Prof Versaggi ...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Nov 2012 11:55
Just use setSpriteActive()

This will prevent sprites from being included in update.


this.mess = abs(sin(times#))
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 9th Nov 2012 10:14
What is a reasonable size world space in AppGameKit if the game would only be available on a large tablet (10.1 in)? 1024? 2048? 4096?

I'd prefer to go w/4096, load the entire thing and go from there but I'd like to take the pulse of others out there to see what's feasible under *normal* circumstances ...

Many thanks in advance for your insights....

----
From the Desk of Prof Versaggi ...

Login to post a reply

Server time is: 2024-05-07 19:05:03
Your offset time is: 2024-05-07 19:05:03