home *** CD-ROM | disk | FTP | other *** search
-
- 'get the sprite images and background
- loadbmp "smiley1", "sprites\smiley1.bmp"
- loadbmp "smiley2", "sprites\smiley2.bmp"
- loadbmp "smiley3", "sprites\smiley3.bmp"
- loadbmp "smiley4", "sprites\smiley4.bmp"
- loadbmp "landscape", "sprites\bg1.bmp"
-
- 'open a window and graphicbox
- WindowHeight = 300
- WindowWidth = 400
- graphicbox #w.g, 0, 0, 400, 300
- open "sprite test" for window_nf as #w
- print #w, "trapclose [quit]"
-
- 'add a background and 4 sprites and animation cycling
- print #w.g, "background landscape"
- for x = 1 to 4
- spriteName$ = word$("smiley smiler smiled smiles", x)
- print #w.g, "addsprite "; spriteName$; " smiley1 smiley2 smiley3 smiley4"
- print #w.g, "cyclesprite "; spriteName$; " "; x; " once"
- next x
-
- 'set the sprite positions
- print #w.g, "spritexy smiley 0 0"
- print #w.g, "spritexy smiler 100 0"
- print #w.g, "spritexy smiled 0 100"
- print #w.g, "spritexy smiles 100 100"
-
- 'set the sprite movement
- print #w.g, "spritemovexy smiley 1 1"
- print #w.g, "spritemovexy smiler -1 1"
- print #w.g, "spritemovexy smiled 1 -1"
- print #w.g, "spritemovexy smiles -1 -1"
-
- start = time$("ms")
-
- 'set up a timer every 75 milliseconds
- timer 75, [advanceAnimation]
- wait
-
- [advanceAnimation] 'This is where we go at each timer tick
-
- 'draw another cycle of animation
- cycles = cycles + 1
- if cycles = 140 then
- 'set the sprite movement
- print #w.g, "spritemovexy smiley -1 -1"
- print #w.g, "spritemovexy smiler 1 -1"
- print #w.g, "spritemovexy smiled -1 1"
- print #w.g, "spritemovexy smiles 1 1"
- end if
- if cycles = 180 then timer 0 : goto [finish]
- print #w.g, "backgroundxy "; cycles * 4; " 0"
- print #w.g, "drawsprites ; spritecollides smiley list$"
- if list$ > "" then print #w.g, "cyclesprite smiley 1 once"
- wait
-
-
- [finish]
-
- elapsed = (time$("ms") - start) / 1000
- print "Elapsed time: "; elapsed; " seconds"
- print "Frames per seconds: "; cycles / elapsed
- wait
-
- [quit]
-
- close #w
- end
-