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.

2D All the way! / Sprite makes map disappear.

Author
Message
Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 20th Jun 2005 10:14
I'm kinda new to Dark Basic (classic) and I'm trying to learn how to do a side scroller. I understand the basics of the character physics (walking and jumping) so now I'm moving on to the maps. I read a lot of other topics and tutorials first, and I finally understood how to make a tile map using data statements. Only problem is, once I add the sprite, the map disappears! I made sure the sprite's backsave state was off and the backdrop was off but the background still disappears. I got the map to reappear by taking the cls command out of the loop, but of course then counters for things like score and time won't work properly because they overlap each other. Is there a way to keep the map from being erased without taking out the cls command?
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 20th Jun 2005 13:07 Edited at: 20th Jun 2005 13:11
Let us see a code snippet here. If you are using BDC, you don't have to worry about the backdrop. DBPRO uses 3D for sprites with DirectX 9.0. unlike DBC which uses actual 2D with DX 7.0. Your problem is definately not associated with the backdrop.

Are you using sprites for the tile system or pasted images?

One suggestion may be to draw your tile matrix first, then your score and time over that, and then your sprites. That way you don't have to use CLS at all. Each time the screen is SYNCed, the background (tiles) would just draw over everything perviously. It just a matter of changing the order of drawing operations in the loop. Of course this would work perfectly, if you are using the entire screen for the tile matrix.
Math89
22
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 20th Jun 2005 23:49
I think you should use only paste image (sprites are really slow on dbc) and draw your map each loop.
Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 21st Jun 2005 01:03
Okay, here's my code. I didn't really feel like uploading all the media, but if its necessary just tell me and I'll upload it.
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 21st Jun 2005 04:51
Sorry, your source code didn't post. You can try posting it as a snippet.

Like this...

Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 21st Jun 2005 07:44
That's strange... I put the code in the code box below the message box... Oh well, guess I'll have to post it again. Maybe it has something to do with the fact that I'm a new member. Since I'm a new member it takes hours for my message to actually be posted because it has to be evaluated, maybe the code was lost during the process. I'll try posting it again. Just so you know, its going to be a Yoshi's Island style game, so that's why there's a lot of images in there titled "Yoshi". Here's the code (hope it works this time!):


It'll be my luck the code doesn't show again even though I've put it in a snippet.
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 22nd Jun 2005 07:34
The reason why your tile matrix is disappearing is because you don't have it inside the game loop. All your graphics will be redrawn on each pass of the game loop frame by frame.

You could do something like this:

Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 22nd Jun 2005 11:15
I went and tried what you suggested, but the tile matrix still disappears.
Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 23rd Jun 2005 08:21
Sorry to double post, but for some reason I can't edit my previous post, so...I found out the whole problem is the CLS command. Removing it, the matrix shows, but the counters are messed up. I tried your trick of putting first the map, then the counters, then the player, but the counters are still messed up. So the tile matrix disappearing problem: solved. Now the problem is keeping the counters refreshed. Even though those debug counters won't be there forever, there's going to be some lives or a score counter... I experimented, only having the CLS command in operation when I pressed control, and then the matrix disappeared, even after I stopped pressing control. It seems like even when you have the map data read while in the loop, the map is only drawn once. So... Is there a way to refresh the counters without using CLS?
D Ogre
22
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Jun 2005 10:28
I am sorry, I forgot to mention that you must reset the DATA pointer for the READ command using RESTORE before the tile matrix. After looking at the code again, you should have got some kind of runtime error because of this. Very strange... This might be why your having problems, otherwise I don't see why it wouldn't work.

Garfield rules
20
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 27th Jun 2005 13:59
It works! Thank you so much D Ogre for all your help!

Login to post a reply

Server time is: 2026-06-12 13:03:10
Your offset time is: 2026-06-12 13:03:10