Weekly Qbasic and Qb64 Lesson Topics
January 22, 2018, 04:09:44 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

GarrysGame(catch the bunny)UnseensGDK version (modified)


Pages: [1]
  Print  
Author Topic: GarrysGame(catch the bunny)UnseensGDK version (modified)  (Read 373 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: March 08, 2011, 10:45:48 pm »

Hello All, I hope I am not doing anything wrong here. This is the GDK version
of the Catch the Bunny, or hawk Game,GarrysGame...still being developed,
lots of credit to Unseen, his GDK libraries Oldoslover, and also others at http://www.qb64.net that have helped out,...I added some music, a midi, called "munchies", to be honest, I don't know where I got it, but if and when I remember, where it came from, I will give credit due the .Bas ,source I have posted, remember you need UnseensGDK03, VQB01.bm ,etc...VQB01 is included
in the .rar, along with sound, images, etc. at:
http://dl.dropbox.com/u/15387474/GARRYSGAMEwithsound.rar
I just now downloaded it and ran the execuatble, as a standalone, with no problems on my computer, but can not be responsible, about others, but I would like to know if any one dose have any problem.
Code:
  '// UnseenGDK - Garry's Hawk Game - By John Onyon, a.k.a Unseen Machine

'-----------------------------------------------------code for sound
volume = 1 '                                               full volume
gamestart = False '                                        no game yet
intromusic = _SNDOPEN("munchies.mid", "VOL") '           open intro music
_SNDVOL intromusic, volume '                               set music volume
_SNDLOOP intromusic '
PRINT "This is my Music"



CHDIR "GarrysGame\"
RANDOMIZE TIMER



GDK_Start
GDK_SetScreenRes Main, 800, 600, 32, 0

DIM KB AS KeyBoardState, Hawk AS GameObject, Rabbit AS GameObject, Hillside AS Texture
DIM RabbitDir AS INTEGER, RabbitFrame AS INTEGER, RabbitMoveSpeed AS SINGLE, RabbitIsAlert AS INTEGER, RabbitIsCaught AS INTEGER
DIM HawkFrame AS INTEGER, HawkDir AS INTEGER
DIM SmallCloud(5) AS GameObject, LargeCloud(3) AS GameObject

GDK_NewGameObject Hawk, "Hawk.png", 8, 1, 20, 20, 0, 0
GDK_NewGameObject Rabbit, "Rabbit.png", 6, 4, 400, 550, 0, 0
GDK_NewTexture Hillside, "Hill2.png", 1, 1, 1, 1
GDK_ShowTexture Hillside
GDK_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, 0
NEXT

RabbitFrame = 7
RabbitAnimTimer# = TIMER(.001)
RabbitIsAlert = 0 ' Not true
RabbitIsCaught = 0 'Not true
RabbitAlertTime# = 5 '// Rabbit remains allert for 5 seconds after being allerted (makes him faster and want to hide)
HawkFrame = 1
HawkDir = 0 'Right
HawkAnimTimer# = TIMER(.001)
HawkAnimTime# = .12

DO


    '// 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

    _DISPLAY

LOOP

DrawSky:
FOR i% = 0 TO 600 STEP 10
    LINE (0, i%)-(800, i% + 10), _RGB(0, 0, (255 / 800) * i%) + 20, BF
NEXT
RETURN

MoveClouds:
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 IF
NEXT
RETURN

REM $INCLUDE:'UnseenGDK04.BM'
 
For more detailes and info about GDK Post a reply here,and ask Unseen
Since GDK is under developement, alot has changed,..and there will soon be a new version, see the replys that follow,...
This was still available:
http://dl.dropbox.com/u/8822351/SDL_GDK.h
It is needed to run the .BAS code, as well as qb64.
Guess thats about it, I will modify this post with, links for UnseenGDK03, shortly.
from Garry
P.S. If I forgot anything, please let me know, I am use a midi
sound file, Because there are many images, and I cannot attach a midi file, use the drop box link, the file also has the executable, which dose run by itself.
http://dl.dropbox.com/u/15387474/GARRYSGAMEwithsound.rar
from Garry
« Last Edit: May 18, 2011, 06:49:41 pm by GarrisonRicketson » Report Spam   Logged

Social Buttons

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: May 18, 2011, 12:11:09 am »

I just made a update to this,....It took me awhile to find it,....
also here are the images,..I think that is about it,...the midi file I cannot attach,but one can make one too, and just isert the correct file name
from Garry
« Last Edit: May 18, 2011, 12:17:36 am by GarrisonRicketson » Report Spam   Logged

Unseen Machine
Post Demos
*
Posts: 46


« Reply #2 on: May 18, 2011, 08:06:31 am »

That wont work with the new GDK. I will see about updating it.
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 on: May 18, 2011, 06:42:31 pm »

That wont work with the new GDK. I will see about updating it.
Ok, since I still have the old stuff, in one folder,..everything still,works,
and then the executable, it wouldn't matter,...If you have time, and don't mind, though, that would be nice,...it would also give a example, of the changes, to be able to compare the 2,... Are the links I show,then also no longer of use ? Never mind on that I just checked, and aparrently not,...So when you are ready please let us know ...no hurry though,...and thanks,
from Garry
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines