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 / Tile Map Help

Author
Message
Mmarzex
11
Years of Service
User Offline
Joined: 26th Feb 2013
Location:
Posted: 10th Mar 2013 18:35
So I am trying to draw a tile map to the screen. My initial idea was to create a text file using numbers to represent certain tiles. It works for certain ones but if I have a file like this drawn



It turns out like this


I can't seem to understand why. My current process is I create an instance of my level class. Then within each instance of a level is an array to store all of my numbered tiles for any given level, a 2d array to store the numbers from any tilemap txt file like above. Then an array to store all the sprites for the tilemap.

So the code to load the tiles is this


The code to load the file is this


And to draw the tiles is this


If I keep it under a certain number of rows and columns then it draws correctly but like the picture shows, it does not draw correctly here.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 10th Mar 2013 18:49
Looks to me that you have 19 tiles in the grid rows but you're multiplying by 16 in the draw routine.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Mmarzex
11
Years of Service
User Offline
Joined: 26th Feb 2013
Location:
Posted: 10th Mar 2013 18:52
That's for drawing the tiles themselves. All The tiles are 16x16 pixels and I just have it that they are drawn so they are next to each other. The 19 is what I have set as the size of the array though in the header file.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Mar 2013 19:14
What are "MAX_TILES" and "SCALE" defined as?

Will you show the header file where all the arrays and constants are defined?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Mmarzex
11
Years of Service
User Offline
Joined: 26th Feb 2013
Location:
Posted: 11th Mar 2013 05:07
Yeah Sorry I should have included that, here is the Level.h header file


I'm thinking maybe dynamically declaring it will be better but I'm not sure of that. I thought of doing a vector too but I'm also not sure of that.
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 11th Mar 2013 13:59 Edited at: 11th Mar 2013 14:00
you start with width 0

but at the start of each row you reset it to 100

So the first row will be 100 left of the rest?

which is what the display appears to show.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 11th Mar 2013 14:15
Well done, Marl. Spot on!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Mmarzex
11
Years of Service
User Offline
Joined: 26th Feb 2013
Location:
Posted: 11th Mar 2013 20:01
Thanks Marl, that works! That was stupid of me. I was doing stuff getting the height right and must have changed that be accident.

Login to post a reply

Server time is: 2024-05-03 07:33:29
Your offset time is: 2024-05-03 07:33:29