Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smallish Games
#17
Someone showed me some code not working and I updated it to QB64 and had fun doing this

Simple Game Update

Code: (Select All)
_Title "Simple Game Update" ' bplus 2024-07-17

' remember Locate works backwards from all graphics commands
' Y vertical is listed first then x horizontal.
' I call it Row, Col to distinguish from graphics (x, y)

DefInt A-Z ' using default screen 0, simplest of all screen commands is none!
Randomize Timer ' so we start in differnt places on board
Dim maze(1 To 14, 1 To 12) 'this is our game board

For x = 1 To 14 ' marks board borders and draws them
    y = 1
    maze(x, y) = 1
    Locate y, x: Print "#";
    y = 12
    maze(x, y) = 1
    Locate y, x: Print "#";
Next
For y = 2 To 11
    x = 1
    maze(x, y) = 1
    Locate y, x: Print "#";
    x = 14
    maze(x, y) = 1
    Locate y, x: Print "#";
Next
x = Int(Rnd * 7) + 3 ' set a random place to start
y = Int(Rnd * 5) + 3

Do

    Locate 15, 2: Print "score:"; S ' udate score and player
    Locate y, x
    Print Chr$(1); ' this draw a cute little face
    If maze(x, y) = 1 Then
        Locate y, x: Print "*";
        Locate 18, 1: Print "Wall! Game Over!"
        End
    End If
    If maze(x + 1, y) = 1 Then ' is there a place to move
        If maze(x - 1, y) = 1 Then
            If maze(x, y + 1) = 1 Then
                If maze(x, y - 1) = 1 Then
                    Locate 18, 1: Print "Trapped! Game Over!": End
                End If
            End If
        End If
    End If
    kh& = _KeyHit
    Select Case kh&
        Case 18432: dry = -1
        Case 20480: dry = 1
        Case 19200: drx = -1
        Case 19712: drx = 1
        Case 27: End
    End Select
    If drx <> 0 Or dry <> 0 Then GoSub mover
    _Limit 30
Loop

mover:
Locate y, x: Print " ";
x = x + drx
y = y + dry
drx = 0
dry = 0

tryAgain:
newx = x + Int(Rnd * 3) - 1
newy = y + Int(Rnd * 3) - 1
If newy = y And newx = x Then GoTo tryAgain
If maze(newx, newy) = 1 Then GoTo tryAgain
maze(newx, newy) = 1
Locate newy, newx: Print "#"; ' mark new block
S = S + 1 ' increase score
Return

   
b = b + ...
Reply


Messages In This Thread
Smallish Games - by bplus - 04-25-2022, 10:55 PM
Smallish Games - by bplus - 06-12-2022, 12:01 AM
RE: Smallish Games - by johnno56 - 06-12-2022, 07:43 AM
RE: Smallish Games - by bplus - 01-12-2023, 11:48 PM
RE: Smallish Games - by PhilOfPerth - 01-13-2023, 01:25 AM
RE: Smallish Games - by bplus - 01-13-2023, 03:08 AM
RE: Smallish Games - by bplus - 03-01-2023, 05:19 AM
RE: Smallish Games - by PhilOfPerth - 03-01-2023, 06:49 AM
RE: Smallish Games - by bplus - 03-01-2023, 03:54 PM
RE: Smallish Games - by bplus - 07-14-2023, 08:11 PM
RE: Smallish Games - by bplus - 07-14-2023, 08:27 PM
RE: Smallish Games - by mnrvovrfc - 07-14-2023, 09:47 PM
RE: Smallish Games - by bplus - 05-03-2024, 06:35 PM
RE: Smallish Games - by bplus - 05-30-2024, 12:57 PM
RE: Smallish Games - by JRace - 05-31-2024, 03:44 AM
RE: Smallish Games - by bplus - 05-31-2024, 10:07 AM
RE: Smallish Games - by bplus - 07-17-2024, 05:24 PM
RE: Smallish Games - by Pete - 07-17-2024, 06:51 PM
RE: Smallish Games - by bplus - 09-12-2024, 07:09 PM
RE: Smallish Games - by bplus - 09-13-2024, 09:47 AM



Users browsing this thread: 3 Guest(s)