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 / Draw Map Loop Problem

Author
Message
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 24th Jun 2009 08:01
Hello!, i am here once again to ask for your help in a (hopefully) simple matter. I have made it so that a succesfully read a file for my map data. I now want it to show tiles on my game screen so that i have a map.

I have searched through a ton of topics, i found many topics asking about this, they either figured it out and provided no code or the code i found was unworking or to confusing. So i have searched and am not wasting your time in vain. So i have decided to make my own, though i am not sure why it is unworking. This example code should in theory write 30 tiles on the top of my game. Could someone please explain the error in my code or provide a better example.



They are 32 x 32 pixel tiles. Thanks for any help i can receive. If i put this code below the while statement it works but for only 1 tile so i want a loop to display a line.




Thank you for any help i receive, i know the topic may be confusing so i hope that i got my point across. Thanks again.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 24th Jun 2009 10:35
And what exactly happens when you try and compile?

Scottie Dog
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 24th Jun 2009 12:58
I think its an image problem...

dbCreateAnimatedSprite ( 90, "GFX/tiles.bmp", 8, 257, 90);

creates your sprite into image 90.

dbCloneSprite ( 90, linedone + 100 );
creates a new sprite of number (linedone +100) using image 90 still.

dbSprite ( linedone + 100, tilegap, 0, linedone + 100 );
Will display sprite (linedone + 100) using image (linedone + 100). however I dont believe we have created that image.

I must admit I've not played with clonesprite before as for tiles I generally just use dbPasteImage (Its faster)
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 24th Jun 2009 19:29 Edited at: 24th Jun 2009 21:10
Ok, taking your advice with DBPaste image i have run into a similer problem.



That shows only 1 tile. Shouldn't it show a entire row? It works if i put it below the while statement and do it by hand. I just dont want to write 30 lines of code to do it for each line. So why does it work when i do the numbers manually but not when i put it in a loop?



So why does it work when i do it manually but not in my loop?

Thanks for the info, any more ideas?
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 24th Jun 2009 21:15


That will redraw the sprite every loop. What you want is to dbPasteSprite() every loop, the difference is that dbSprite() will move the image, dbPasteSprite() simply draw a new one. Why it does that, maybe some can explain to me. But I do know that you want to use dbPasteSprite() for a loop.
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 24th Jun 2009 21:30 Edited at: 24th Jun 2009 21:51


That doesn't show anything for some reason, it works outside of a loop for some reason. Any more ideas? Thank you.


This code works great and does everything i want. I just wish i could get it into a loop.

Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 24th Jun 2009 22:45
Not exactly sure how to fix your problem but this may help. Try loading your map data into an Array first. Then do something like this.


that will draw a 10x10 map, You would read your map data into the array, so each place in the array would be a number that represents the tile you want to use at that place on the map.

Login to post a reply

Server time is: 2024-11-25 08:56:11
Your offset time is: 2024-11-25 08:56:11