'// UnseenGDK - Garry's Hawk Game - By John Onyon, a.k.a Unseen Machine'-----------------------------------------------------code for soundvolume = 1 ' full volumegamestart = False ' no game yetintromusic = _SNDOPEN("munchies.mid", "VOL") ' open intro music_SNDVOL intromusic, volume ' set music volume_SNDLOOP intromusic 'PRINT "This is my Music"CHDIR "GarrysGame\"RANDOMIZE TIMERGDK_StartGDK_SetScreenRes Main, 800, 600, 32, 0DIM KB AS KeyBoardState, Hawk AS GameObject, Rabbit AS GameObject, Hillside AS TextureDIM RabbitDir AS INTEGER, RabbitFrame AS INTEGER, RabbitMoveSpeed AS SINGLE, RabbitIsAlert AS INTEGER, RabbitIsCaught AS INTEGERDIM HawkFrame AS INTEGER, HawkDir AS INTEGERDIM SmallCloud(5) AS GameObject, LargeCloud(3) AS GameObjectGDK_NewGameObject Hawk, "Hawk.png", 8, 1, 20, 20, 0, 0GDK_NewGameObject Rabbit, "Rabbit.png", 6, 4, 400, 550, 0, 0GDK_NewTexture Hillside, "Hill2.png", 1, 1, 1, 1GDK_ShowTexture HillsideGDK_SetTextureAlpha Hillside, _RGB(255, 0, 255)FOR i% = 0 TO 4 GDK_NewGameObject SmallCloud(i%), "Cloud1.png", 1, 1, (RND * 800), 30 + (i% * (RND * 40) + 5), 0, 0 IF i% < 3 THEN GDK_NewGameObject LargeCloud(i%), "Cloud3.png", 1, 1, (RND * 800), 30 + (i% * (RND * 40) + 5), 0, 0NEXTRabbitFrame = 7RabbitAnimTimer# = TIMER(.001)RabbitIsAlert = 0 ' Not trueRabbitIsCaught = 0 'Not trueRabbitAlertTime# = 5 '// Rabbit remains allert for 5 seconds after being allerted (makes him faster and want to hide)HawkFrame = 1HawkDir = 0 'RightHawkAnimTimer# = TIMER(.001)HawkAnimTime# = .12DO '// User input GDK_GetKeyboardState KB IF KB.CTRL THEN GDK_AutoRectangle Hawk.Texture, Hawk.Vector, Hawk.Rect GDK_AutoRectangle Rabbit.Texture, Rabbit.Vector, Rabbit.Rect IF GDK_DoesRectangleIntersect(Hawk.Rect, Rabbit.Rect) THEN 'The hawk is in contact with the rabbit RabbitIsCaught = -1 END IF ELSE IF RabbitIsCaught THEN RabbitIsAlert = -1 RabbitAlertTimer# = TIMER(.001) END IF RabbitIsCaught = 0 END IF '// Check for hawk shadow and rabbits distance from it. Make him alert if to close and run towards nearest hidey hole. IF Hawk.Vector.Y >= 330 THEN END IF '// Rabbit movement and animation IF RabbitIsAlert AND TIMER(.001) - RabbitAlertTimer# < RabbitAlertTime# THEN RabbitMoveSpeed = 5.4 RabbitAnimTime# = .09 ELSE RabbitMoveSpeed = 3.2 RabbitAnimTime# = .15 END IF IF TIMER(.001) - RabbitAnimTimer# >= RabbitAnimTime# AND NOT RabbitIsCaught THEN IF Rabbit.Vector.Y < 550 THEN Rabbit.Vector.Y = Rabbit.Vector.Y + 8 RabbitAlertTimer# = TIMER(.001) ELSE IF RabbitDir = 0 THEN ' Move rabbit right IF Rabbit.Vector.X + (Rabbit.Texture.Width / 6) < 800 THEN Rabbit.Vector.X = Rabbit.Vector.X + RabbitMoveSpeed! ELSE RabbitDir = 1 IF RabbitFrame < 12 THEN RabbitFrame = RabbitFrame + 1 ELSE RabbitFrame = 7 ELSEIF RabbitDir = 1 THEN ' Move rabbit left IF Rabbit.Vector.X > 0 THEN Rabbit.Vector.X = Rabbit.Vector.X - RabbitMoveSpeed! ELSE RabbitDir = 0 IF RabbitFrame < 6 THEN RabbitFrame = RabbitFrame + 1 ELSE RabbitFrame = 1 ELSEIF RabbitDir = 2 THEN 'paused right ELSEIF RabbitDir = 3 THEN 'paused left END IF END IF RabbitAnimTimer# = TIMER(.001) ELSEIF TIMER(.001) - RabbitAnimTimer# >= RabbitAnimTime# AND RabbitIsCaught THEN Rabbit.Vector.X = Hawk.Vector.X + 5 Rabbit.Vector.Y = Hawk.Vector.Y + Hawk.Texture.Height - 20 RabbitFrame = 1 END IF '// Hawk Movement and animation IF TIMER(.001) - HawkAnimTimer# >= HawkAnimTime# THEN IF KB.Left AND NOT KB.Right THEN IF Hawk.Vector.X > 0 THEN Hawk.Vector.X = Hawk.Vector.X - 6 IF HawkFrame < 5 THEN HawkFrame = 8 HawkDir = 1 ELSEIF KB.Right AND NOT KB.Left THEN IF Hawk.Vector.X + (Hawk.Texture.Width / 8) < 800 THEN Hawk.Vector.X = Hawk.Vector.X + 6 IF HawkFrame > 4 THEN HawkFrame = 1 HawkDir = 0 END IF IF KB.Up AND NOT KB.Down THEN IF Hawk.Vector.Y > 0 THEN Hawk.Vector.Y = Hawk.Vector.Y - 4 ELSEIF KB.Down AND NOT KB.Up THEN IF Hawk.Vector.Y + Hawk.Texture.Height < 560 THEN Hawk.Vector.Y = Hawk.Vector.Y + 8 END IF IF HawkDir = 0 THEN IF HawkFrame < 4 THEN HawkFrame = HawkFrame + 1 ELSE HawkFrame = 1 ELSEIF HawkDir = 1 THEN IF HawkFrame > 5 THEN HawkFrame = HawkFrame - 1 ELSE HawkFrame = 8 END IF HawkAnimTimer# = TIMER(.001) END IF GOSUB MoveClouds '//Draw the background, hawk, hawks shadow(if applicable) , Bushes , tree, nest , clouds and the rabbit GOSUB DrawSky GDK_DrawTextureXY Hillside, 0, 569, 0, 0 IF Hawk.Vector.Y >= 330 THEN GDK_EllipseFill Hawk.Vector.X + 22, 585, 24, 9, _RGBA(180, 180, 180, 255), _RGBA(180, 180, 180, 120) END IF FOR i% = 0 TO 4 GDK_DrawGameObject SmallCloud(i%), 0 IF i% < 3 THEN GDK_DrawGameObject LargeCloud(i%), 0 NEXT GDK_DrawGameObject Rabbit, RabbitFrame GDK_DrawGameObject Hawk, HawkFrame _DISPLAYLOOPDrawSky:FOR i% = 0 TO 600 STEP 10 LINE (0, i%)-(800, i% + 10), _RGB(0, 0, (255 / 800) * i%) + 20, BFNEXTRETURNMoveClouds:FOR i% = 0 TO 4 IF SmallCloud(i%).Vector.X + SmallCloud(i%).Texture.Width > 0 THEN SmallCloud(i%).Vector.X = SmallCloud(i%).Vector.X - ((RND * 1.2) + .2) ELSE SmallCloud(i%).Vector.X = 800 END IF IF i% < 3 THEN IF LargeCloud(i%).Vector.X + LargeCloud(i%).Texture.Width > 0 THEN LargeCloud(i%).Vector.X = LargeCloud(i%).Vector.X - ((RND * 1.2) + .2) ELSE LargeCloud(i%).Vector.X = 800 END IF END IFNEXTRETURNREM $INCLUDE:'UnseenGDK04.BM'