REM GameLearn007'Demonstartes creating image surfaces,loading graphics to those pages'Create a game loop and shows the background'Show hawk animation, create master hawk X and Y for screen placement'create a sub to move hawk horizontally and vertically with the arrow keysDEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG typesCONST True = -1, False = NOT (True) 'constants for logicVideo& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colorsSCREEN Video& 'make this the surface the user sees on monitorBackground& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background pageGraphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet pagecycle = 0 'variable to indicate the frame of hawk graphic to usehX = 100: hY = 100hhdir = 1 'hhdir =hawk direction 1=east , -1=westhvdir = 1 'hvdir =hawk direction 1=down , -1=upDO 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 GOSUB Getkey GOSUB MoveHawk _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 (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background CASE 2 _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background END SELECT LOCATE 20, 1: PRINT "Use arrow keys to move HAWK" PRINT " Note the hawk DESTINATION co-ords are (hX, hY) and hhdir="; hhdir; "hvdir="; hvdir PRINT "_putimage ("; hX; ","; hY; "),SourcePage,DestinationPage,(SOURCE co-ords)" PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) " _DISPLAY 'update the monitorLOOP UNTIL _KEYDOWN(27) 'escape key to exitSLEEPSYSTEMMoveHawk:'Horizontal (L and R)collision testsIF hX >= 630 THEN hX = 630: hhdir = -1 'test collision with right side, toggle hhdir to minusIF hX <= 10 THEN hX = 10: hhdir = 1 'test collision with left side, toggle hhdir to plus'Vertical (U and D)collision testsIF hY >= 470 THEN hY = 470: hvdir = -1IF hY <= 10 THEN hY = 10: hvdir = 1RETURNGetkey:'Arrow keysIF _KEYDOWN(20480) THEN hY = hY + 1 'down arrow key so add 1IF _KEYDOWN(18432) THEN hY = hY - 1 'up arrow key so minus 1IF _KEYDOWN(19200) THEN hX = hX - 1 'left arrow key so minus 1IF _KEYDOWN(19712) THEN hX = hX + 1 'right arrow key so add 1IF _KEYDOWN(32) THEN Wantacapture = True 'spacebarIF _KEYDOWN(100305) THEN Wantarelease = True 'right control buttonRETURN