Weekly Qbasic and Qb64 Lesson Topics

QB64 lessons and tutorials,Games => Games => Topic started by: GarrisonRicketson on January 19, 2011, 10:41:21 pm



Title: GDK Catch the Rabbit,but just the Hawk so far
Post by: GarrisonRicketson on January 19, 2011, 10:41:21 pm
This is a sample of code, that Unseen gave me, useing GDK, you also need to get,  'UnseenGDK_Pro.bm', http://dl.dropbox.com/u/8822351/UnseenGDK_Pro.bm
And should look at Unseens, wiki, to learn more on how to use GDK libraries, and in you code, I think, this is for more advanced "programmers",..but anyway, Unseen is available, to explain more.
http://code.google.com/p/unseen-gdk/
And you need : http://dl.dropbox.com/u/15387474/Hawk.bmp
or you could make your own sprite.
------------------Code---------------
Code:
      GDK_Start
GDK_SetScreenRes GameScreen, 600, 400, 32, 0
DIM Hawk AS GameObject, KbNow AS KeyBoardState
GDK_NewTexture Hawk.Image, "hawk.bmp", 4, 1, 4, 1
GDK_SetTextureVisibility Hawk.Image, -1
GDK_NewVector2D Hawk.Vector, 300, 350, 0, 0
HawkFrame% = 1
HawkDir% = 1 'Right
AnimTimer# = TIMER(.001)
DO
    IF TIMER(.001) - AnimTimer# > .2 THEN
        IF HawkDir% = 1 THEN
            IF HawkFrame% = 1 THEN HawkFrame% = 2 ELSE HawkFrame% = 1
        ELSE
            IF HawkFrame% = 3 THEN HawkFrame% = 4 ELSE HawkFrame% = 3
        END IF
        AnimTimer# = TIMER(.001)
    END IF
    GDK_DrawTexture Hawk.Image, Hawk.Vector, HawkFrame%
    GDK_GetKeyboardState KbNow
    IF KbNow.Left THEN
        IF Hawk.Vector.X > 0 THEN Hawk.Vector.X = Hawk.Vector.X - 1
        HawkDir% = 2 'Left
        IF HawkFrame% = 1 OR HawkFrame% = 2 THEN HawkFrame% = 3
    ELSEIF KbNow.Right THEN
        IF Hawk.Vector.X + (Hawk.Image.Width / 4) < 600 THEN Hawk.Vector.X = Hawk.Vector.X + 1
        HawkDir% = 1 'Left
        IF HawkFrame% = 3 OR HawkFrame% = 4 THEN HawkFrame% = 1
    END IF

    IF KbNow.Up THEN
        IF Hawk.Vector.Y > 0 THEN Hawk.Vector.Y = Hawk.Vector.Y - 1
    ELSEIF KbNow.Down THEN
        IF Hawk.Vector.Y + Hawk.Image.Height < 400 THEN Hawk.Vector.Y = Hawk.Vector.Y + 1
    END IF

    _DISPLAY
    CLS
LOOP
REM $INCLUDE:'UnseenGDK_Pro.bm'
TYPE GameObject
    Image AS Texture
    Vector AS Vector2D
    Rect AS Rectangle
END TYPE
   
I hope later, Unseen will show how to add a object or the rabbit for the hawk to catch. And later I will post a version that includes the background.
Enjoy

Note: Unseens GDK, is still being developed, this sample is for UnseenGDK_Pro.bm and you need it to run the code. However he is now up a ver 3, Which can do even more,...if you are interested in this, follow the links shown above, to get the most current version, and more info.
from Garry



Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: GarrisonRicketson on March 04, 2011, 11:37:02 pm
I have the newer version, that Unseen helped me with, and also I will add the drop box link for the background, and the current version of GDK, can be gotten at the site listed above. Tommorow, or sunday...
from Garry


Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: Dustie Bear on March 10, 2011, 10:40:29 pm

Hi

How do you use the unseen Gdk,

do you make it into a library or bI file?

courious minds want to know/

Thanks
Dustie



Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: GarrisonRicketson on March 11, 2011, 12:19:48 am
Thats about it,but if you have any problems, or further questions, feel free to ask,  and if I can't answer it Then Unseen, should be able to since he deceloped it...
from Garry
P.S welcome Dusty
You should be able to download the packages at the above links.


Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: Dustie Bear on March 11, 2011, 02:05:34 pm

Thanks for the replys

Got it downloaded , will try it out when I learn a bit more about it.

thanks

Dusitie


Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: Dustie Bear on March 11, 2011, 07:46:32 pm


 So is that just another name for a BI file,

If not, how do they differ?


Dustie

Inquiring mind wants to know. LOL


Title: Re: GDK Catch the Rabbit,but just the Hawk so far
Post by: GarrisonRicketson on September 06, 2011, 08:17:08 pm
To be honest , I am not sure, BM is for basic make, useng include, and libraries, they are used,  don't know if BI is the same, but I think it works the same, Unseens tutorial goes into that.