News:

Function Finder  Find all the functions within source code files

Main Menu

map possibility

Started by blackmeadow, January 14, 2008, 06:06:18 PM

Previous topic - Next topic

blackmeadow

hey, guys, i've been thinking about an idea where you have a side-scroller  (with a very limited, finite amount of tiles) that is perceived as persistent.  i was wondering how to, in theory, do this?  i'm not using mappy, i'll be using pb's map support commands and i'd like to know where the map commands read from?  would i just use a .txt file?  if i were to use a .txt file is there a way to shift the "grab spectrum?"  like instead of reading lines 1 - 10 jump to 11 - 20?

kevin

#1
Quotehey, guys, i've been thinking about an idea where you have a side-scroller  (with a very limited, finite amount of tiles) that is perceived as persistent.  i was wondering how to, in theory, do this?  i'm not using mappy, i'll be using pb's map support commands and i'd like to know where the map commands read from?  

   Maps house the Blocks/  Animation and Levels (tile maps) internally.   However for what you're asking all need to do is draw the backdrop displaced and wrap the scrolling position.  

   I.e.

PlayBASIC Code: [Select]
 Width=800
Height=600

OpenScreen Width,Height,32,1

Backdrop=NewImage(Width,Height)
rendertoimage BackDrop

TileHeight=16
TileWidth=16
; Fill the backdrop with coloums to represent tiles
For ylp=0 to Height-1 step TileHeight
For xlp=0 to width-1 step TileWIdth
Boxc Xlp,ylp,Xlp+TileWidth,Ylp+TileHeight,true,RNDRGB()
Next Xlp
next


rendertoscreen


setfps 60

Do

; Draw the bhackdrop twice, Each time offset from scroll position
drawimage Backdrop,-ScrollX,0,false
drawimage Backdrop,-ScrollX+Width,0,false

; Bump scroll X value and wrap it with the Screen width
ScrollX=mod(ScrollX+1,Width)

Sync
loop




  To make infinite scrolling with 'random' data the  traditional approach is via implementing paging.  The scramble demo uses a variation of it.

 Scramble Source Code Example




Quotewould i just use a .txt file?  if i were to use a .txt file is there a way to shift the "grab spectrum?"  like instead of reading lines 1 - 10 jump to 11 - 20?

  You can save the data any way you like.  Whatever is easier for you edit during development. PB supports random access so you can move the file pointer forward back during file access.  If you're jumping forward through a text file say, this can be difficult as the rows of text wouldn't necessarily be the same length.

   BTW,  the MAPS slib includes  SAVE + LOAD level functions.