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.

Dark GDK / Array Based 2D Map Editor

Author
Message
tehg00n
15
Years of Service
User Offline
Joined: 4th Jan 2009
Location: Ohio
Posted: 16th Jan 2009 06:00
Ok, I made a little array based method for creating 2D maps for my game. I got it to work pretty good. But the method for drawing the sprite in the correct spot is rather... lengthy.

I was wondering if anyone could figure out a way to shorten this up at all. A 2x2 map is taking almost a hundred lines just to draw the tiles. Look in the case statements, thats where its long.



Sorry if my code is rather sloppy and noobish haha. CC is welcome as always.
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 16th Jan 2009 11:08 Edited at: 16th Jan 2009 20:52
Maybe set the parameters first and just use dbSprite(); one time and the case statements (0, 0; 32, 0; 0, 32; 32, 32) one time. Like this:



Or maybe just do something like that:


Oh, you should replace dbSprite(stringNum + charNum, x, y, img);
with dbSprite(charNum + 1 + (stringNum * 2), x, y, img);

Login to post a reply

Server time is: 2024-09-30 15:28:45
Your offset time is: 2024-09-30 15:28:45