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.

DarkBASIC Discussion / 2d tile displaying and scrolling

Author
Message
LordDario
22
Years of Service
User Offline
Joined: 26th Apr 2003
Location:
Posted: 1st Jul 2005 16:06
I know this has been posted about like a billion times, but i was wondering if someone has some sort of a tutorial or demo, which shows you how to display tileset gfx onto the screen, and how to scroll through a a map in all 4 directions. I've seen a few tutorials/demos out there, but all the ones ive seen had many more things involved which made it harder to follow. If someone could just explain to me the concept behind how displaying tiles and scrolling works, that would be cool. Thank you

Dario
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 7th Jul 2005 22:30
If I understand you correctly you mean a grid of tiles each having their own X,Y co-ords?
If so i would suggest using a POO (Point Of Origin ) and having all your tiles run from that grid co-ord. That way you only ever have to adjust one set of co-ords and all the other tiles will adjust themselves accordingly. This will work in all four directions.

To scroll a screen, always draw everything first, and use the SYNC command afterwards, and only allow a set degree of movement between each SYNC to enable a smooth scroll.

So to summarise:
To set up your tiles:

DIM screenposX(10) : DIM screenposY(10) ;Co-ords (these will be relative to the DATUM co-ords.

DIM screenbmp(10,10) ;This line will contain what Bitmap is at co-ord X,Y

datumX=0 : datumY=0 ;DATUM co-ords
FOR L=1 TO 10:READ screenposX(L) : READ screenposY(L) : NEXT L
DATA 0,0
DATA 100,100
DATA 200,200
DATA 300,300
etc

SO------->
DO
FOR Y=1 TO 10:FOR X=1 TO 10
SPRITE (X*Y),(datumX+screenposX(X)),(datumY+screenposY(Y)),screenBMP(X,Y):SHOW SPRITE (X*Y)
NEXT X:NEXT Y
SYNC
LOOP

Ok, so now your screen is drawn.
If you are using Keys to scroll the screen, only alter the datumX and datumY values accordingly and then redraw the screen using the procedure above.
If you are experiancing a slow down due to the number of sprites being drawn, then use the SET SPRITE ?,0,0 command for all background sprites. This will turn the Backsave and Transparency Options off and significantly improve your speed.
Hope this is of use and I haven't been asking to suck eggs!

Login to post a reply

Server time is: 2025-05-22 22:17:33
Your offset time is: 2025-05-22 22:17:33