Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include once "fbgfx.bi"
- screenres 1024, 768, 32
- type base_tile
- as string*1 texture
- end type
- type advanced_tile extends base_tile
- as integer isAnimated
- as string*1 textures(any)
- as double timed
- as integer curTile
- declare sub update()
- end type
- declare sub init( tiles() as advanced_tile )
- dim as advanced_tile tiles(49,49)
- init( tiles() )
- do
- 'update loop
- 'always call an update in a separate loop like this, before drawing
- for y as integer = 0 to ubound(tiles,2)
- for x as integer = 0 to ubound(tiles,1)
- tiles(x,y).update()
- next
- next
- 'drawing loop
- 'never call the update function in this loop,
- 'as it may display incorrect data to the player
- screenlock
- cls
- for y as integer = 0 to ubound(tiles,2)
- for x as integer = 0 to ubound(tiles,1)
- draw string (x*8,y*8), tiles(x,y).texture
- next
- next
- screensync
- screenunlock
- sleep 3,1
- loop until multikey(FB.SC_ESCAPE)
- sub advanced_tile.update()
- if isAnimated then
- if timer>timed then
- timed = timer+rnd*5
- curTile+=1
- if curTile>ubound(textures) then
- curTile = 0
- end if
- texture = textures(curTile)
- end if
- else
- texture = textures(0)
- end if
- end sub
- sub init( tiles() as advanced_tile )
- for y as integer = 0 to ubound(tiles,2)
- for x as integer = 0 to ubound(tiles,1)
- with tiles(x,y)
- if x = 0 or y = 0 or x = ubound(tiles, 1) or y = ubound(tiles, 2) then
- .isAnimated = false
- redim .textures(0)
- .textures(0) = chr(219)
- else
- if int(rnd*3) = 0 then
- .isAnimated = true
- redim .textures(2)
- .textures(0) = chr(178)
- .textures(1) = chr(177)
- .textures(2) = chr(176)
- else
- .isAnimated = false
- redim .textures(0)
- .textures(0) = chr(219)
- end if
- end if
- end with
- next
- next
- end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement