Liberty BASIC Community Forum
« Tumbler Jump »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 5:44pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Tumbler Jump  (Read 155 times)
kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Tumbler Jump
« Thread started on: Jun 20th, 2017, 09:11am »

here is a little game that I made out of a Demo that if found on the JB Tutorial sight

with added Barel

the cave man sprite can be found on the jb sight
Code:
   Nomainwin
' OldKey holds last pressed key
    OldKey = 0

' xDir and yDir hold moving directions
    xDir = 0: yDir = 0
    UpperLeftX = 10
    UpperLeftY = 10
    WindowWidth = 757
    WindowHeight = 595

    UpperLeftX = Int((DisplayWidth - WindowWidth) /2)
    UpperLeftY = Int((DisplayHeight - WindowHeight) /2)
    'Barel1

    Menu #demo, "&Options", "E&xit", [Quit]
    Graphicbox #demo.gb1, 0, 0, 750, 550

    Open "Controlling Sprites" for Window as #demo
    #demo, "Trapclose [Quit]"
          '=================================


    hndl = hwnd(#demo)
    struct winRect, orgX as long, orgY as long, cornerX as long, cornerY as long
    calldll #user32, "GetClientRect", hndl as ulong, winRect as struct, result as boolean
    winx=winRect.cornerX.struct-winRect.orgX.struct
    winy=winRect.cornerY.struct-winRect.orgY.struct
    'notice "inside of window frame width = "; x; " height = "; y
         '=================================

' Load the background bmp
    Loadbmp "bg", "SPRITES\BG1.bmp"

    Loadbmp "Barel1", "SPRITES\Barel1.bmp"
    Loadbmp "Barel2", "SPRITES\Barel2.bmp"
    Loadbmp "Barel3", "SPRITES\Barel3.bmp"

    #demo.gb1, "Addsprite Barel Barel1 Barel2 Barel3"

percent=35
    #demo.gb1, "spritescale Barel ";percent

    #demo.gb1, "cyclesprite Barel -1"
   ' #demo.gb1, "cyclesprite Barel 1 once"




    x=670:y=470
    #demo.gb1, "spritexy Barel ";x;" ";y


    #demo.gb1, "Down; Background bg; Drawsprites"

' Load the sprites
    Loadbmp "cm1", "SPRITES\cave1.bmp"
    Loadbmp "cm2", "SPRITES\cave2.bmp"
    #demo.gb1, "Addsprite cm cm1 cm1 cm2 cm2"

' Set the initial cyclesprite command to 0
    #demo.gb1, "Cyclesprite cm 0"

' Set inital x, y variables (cm facing right to start)
    #demo.gb1, "Spritexy cm 350 450"

' Trap keypresses
    #demo.gb1, "When characterInput [KeyPress]"
    #demo.gb1, "Setfocus"

' Set the timer
    Timer 20, [SeeSprites]
    Wait

[Quit]
    Timer 0
    Unloadbmp "bg"
     unLoadbmp "Barel1"
      unLoadbmp "Barel2"
       unLoadbmp "Barel3"
    Close #demo
    End

[KeyPress]
    NewKey = Asc(Right$(Inkey$, 1))
    #demo.gb1, "Spritexy? cm x y"
    Select Case NewKey
        Case 37
            #demo.gb1, "Spriteorient cm mirror"
            If OldKey = NewKey Then
                xDir = 0
                NewKey = 0
            Else
                xDir = 1
            End If
        Case 38
            yDir = 1
        Case 39
            #demo.gb1, "Spriteorient cm normal"
            If OldKey = NewKey Then'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

                xDir = 0
                NewKey = 0
            Else
                xDir = 2
            End If
    End Select
    OldKey = NewKey
    Wait

[SeeSprites]
#demo.gb1, "spriteround Barel";
#demo.gb1, "spriteround cm";


#demo.gb1, "centersprite cm"
#demo.gb1, "centersprite Barel"
'COLLISION DITTECTION
#demo.gb1, "spritecollides cm list$";
IF list$ = "Barel" THEN TIMER 0


#demo.gb1 "spritexy? cm x y"
if x > 700 then
cmx=1
cmy=450
#demo.gb1, "spritexy cm ";cmx;" ";cmy
end if

#demo.gb1 "spritexy? Barel x y"
if x < 1 then
#demo.gb1, "spritexy Barel 750 470";
end if
'#demo.gb1, "spritexy Barel 100 137";
'#demo.gb1,"spritexy Barel 100 137";
#demo.gb1, "spritemovexy Barel -2 0";
'IF SPRITE < 1 REPEAT
#demo.gb1 "spritexy? Barel x y"
'if x <5 then
    #demo.gb1, "Spritexy? cm x y"
    Select Case yDir
        Case 1 ' Up
            y = y - 10
            If y < 350 Then
                yDir = 2
                y = 350
            End If
        Case 2 ' Down
            y = y + 10
            If y > 450 Then
                yDir = 0
                y = 450
            End If
    End Select
    Select Case xDir
        Case 1 ' Left
            x = x - 7
            If x < 5 Then
                xDir = 0
                x = 10
            End If
        Case 2 ' Right
            x = x + 7
            If x > 710 Then
                xDir = 0
                x = 700
            End If
    End Select
    If xDir + yDir > 0 Then
        #demo.gb1, "Cyclesprite cm 1"
    Else
        #demo.gb1, "Cyclesprite cm 0"
    End If
    #demo.gb1, "Spritexy cm ";x;" ";y
    #demo.gb1, "Setfocus; Drawsprites"
    Wait
 


Kevin
User IP Logged

KEVIN
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls