GameLearn003,
REM GameLearn003
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types
CONST True = -1, False = NOT (True) 'constants for logic
Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor
Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page
cycle = 0 'variable to indicate the frame of hawk graphic to use
DO
cycle = cycle + 1 'increment cycle variable
IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show
_LIMIT 30 '30 frames per second
_PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
_CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)
SELECT CASE cycle 'logic branch based on what cycle is
CASE 1
_PUTIMAGE (100, 100)-(187, 159), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
CASE 2
_PUTIMAGE (100, 100)-(187, 159), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
END SELECT
LOCATE 20, 1: PRINT " The hawk animation is achieved by showing each frame one after another"
PRINT "_putimage(DESTINATION co-ords),SourcePage,DestinationPage,(SOURCE co-ords)"
PRINT "The destination co-ords stay the same =(100, 100)-(187, 159) "
PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "
_DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM