ThaliaUWU's profile picture

Published by

published

Category: Games

Hehehe coding using qb64

run my source code and build on to the game in qb64 basic. Its a maze game just use the line code to create lines and pills which change your color to go through the same colored lines:


Screen 12 ' Set screen to graAphics mode                                            WW


Dim x As Integer, y As Integer ' Declare integer variables for x and y

Dim k$ ' Declare k$ to hold the key press (string)

Dim L As Integer

x = 320 ' Set the initial x coordinate (center of the screen)

y = 0 ' Set the initial y coordinate (center of the screen)

L = 15


Do

    Cls ' Clear the screen for each loop iteration

    Line (150, 150)-(500, 150), 4

    ' Draw the circle at (x, y) with radius 20 and color 15

    Circle (x, y), 20, L

    Line (200, 155)-(210, 160), 4, B

    Line (200, 350)-(210, 380), 15, B

    Line (150, 400)-(500, 400), 15


    ' Capture the key pressed and stWWWWWWWWWWWWWWWWWWWWWore it in k$

    k$ = InKey$ ' Store the key press as a string in k$

    If ((y = 390) And (y < 400) And (x > 150) And (x < 500) And (L <> 15)) Then y = 380

    If ((y = 410) And (y > 400) And (x > 150) And (x < 500) And (L <> 15)) Then y = 420


    If ((y = 140) And (y < 150) And (x > 150) And (x < 500) And (L <> 4)) Then y = 120

    If ((y = 155) And (y > 150) And (x > 150) And (x < 500) And (L <> 4)) Then y = 170

    If ((y > 150) And (y < 170) And (x > 200) And (x < 210)) Then L = 4

    If ((y > 350) And (y < 380) And (x > 200) And (x < 210)) Then L = 15

    ' If a key was pressed (k$ is not empty), convert it to the keycode (ASCII value)

    If k$ <> "" Then

        keycode = Asc(k$) ' Convert the key press (k$) to its ASCII value (keycode)


        ' Check the key code and move the circle accordingly

        If keycode = 87 Then y = y - 5 ' W key (move up)

        If keycode = 83 Then y = y + 5 ' S key (move down)

        If keycode = 65 Then x = x - 5 ' A key (move left)

        If keycode = 68 Then x = x + 5 ' D key (move right

        ' Exit the loop if the ESC key is pressed

        If keycode = 27 Then Exit Do ' Escape key (exit program)

    End If


    Sleep 1 ' Delay to make it easier to see movement


Loop Until FALSE ' Infinite loop until ESC is pressed


End


0 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )