Basic Chase and Prize Game
#1
Did not like key action in Bandit so I tried a Keypad setup and got bonus of arrow keys working too Smile
Code: (Select All)
_Title "Basic Chase and Prize Game" ' b+ 2023-03-24
Randomize Timer
Screen _NewImage(640, 480, 32) '80 cols X 30 rows
_ScreenMove 250, 100
Locate 7, 20: Print "*** Basic Chase and Prize Game ***"
Locate 10, 20: Print "H = Hero"
Locate 12, 20: Print "* = Prize"
Locate 14, 20: Print "X = Doom!"
Locate 18, 20: Print "Object: Use NumberPad to Collect prizes,"
Locate 19, 28: Print "don't let Doom come to Hero!"
Locate 25, 20: Print "press any to start...."
Sleep
DoomMoves = 20
HeroX = 40: HeroY = 15
PrizeX = Int(Rnd * 80) + 1: PrizeY = Int(Rnd * 30) + 1
DoomX = Int(Rnd * 80) + 1: DoomY = Int(Rnd * 30) + 1
Do
    Cls ' screen update
    Locate HeroY, HeroX: Print "H";
    Locate PrizeY, PrizeX: Print "*";
    Locate DoomY, DoomX: Print "X";
    If HeroX = PrizeX And HeroY = PrizeY Then
        score = score + 1
        PrizeX = Int(Rnd * 80) + 1: PrizeY = Int(Rnd * 30) + 1
        DoomX = Int(Rnd * 80) + 1: DoomY = Int(Rnd * 30) + 1
        If DoomMoves > 5 Then DoomMoves = DoomMoves - 1
    ElseIf HeroX = DoomX And HeroY = DoomY Then
        Locate 15, 35: Print "Game Over"
        Beep: _Delay 8: _KeyClear: Sleep: Exit Do
    End If
    _Title "Prizes:" + Str$(score)
    kh& = _KeyHit
    Select Case kh& ' top left to bottom right
        Case 55, 18176 ' up and left
            DX = -1: DY = -1
        Case 56, 18432 ' up
            DX = 0: DY = -1
        Case 57, 18688 ' up and right
            DX = 1: DY = -1
        Case 52, 19200 ' left
            DX = -1: DY = 0
        Case 54, 19712 ' right
            DX = 1: DY = 0
        Case 49, 20224 ' left and down
            DX = -1: DY = 1
        Case 50, 20480 ' down
            DX = 0: DY = 1
        Case 51, 20736 ' down and right
            DX = 1: DY = 1
        Case Else
            DX = 0: DY = 0
    End Select
    testX = HeroX + DX: testY = HeroY + DY
    If testX > 0 And testX < 81 And testY > 0 And testY < 31 Then
        HeroX = testX: HeroY = testY
    Else
        Beep
    End If
    lc = lc + 1
    If lc = DoomMoves Then
        DoomX = DoomX + Sgn(HeroX - DoomX): DoomY = DoomY + Sgn(HeroY - DoomY)
        lc = 0
    End If
    _Limit 30
Loop Until _KeyDown(27)
b = b + ...
Reply


Messages In This Thread
Basic Chase and Prize Game - by bplus - 03-23-2023, 09:23 AM
RE: Basic Chase and Prize Game - by DANILIN - 03-23-2023, 11:18 AM
RE: Basic Chase and Prize Game - by mnrvovrfc - 03-24-2023, 04:24 AM
RE: Basic Chase and Prize Game - by mnrvovrfc - 04-01-2023, 09:55 PM
RE: Basic Chase and Prize Game - by bplus - 03-23-2023, 12:36 PM
RE: Basic Chase and Prize Game - by DANILIN - 03-23-2023, 12:49 PM
RE: Basic Chase and Prize Game - by mnrvovrfc - 03-23-2023, 05:02 PM
RE: Basic Chase and Prize Game - by bplus - 03-23-2023, 03:20 PM
RE: Basic Chase and Prize Game - by bplus - 03-23-2023, 04:10 PM
RE: Basic Chase and Prize Game - by vince - 03-23-2023, 05:17 PM
RE: Basic Chase and Prize Game - by bplus - 03-24-2023, 05:10 AM
RE: Basic Chase and Prize Game - by vince - 03-24-2023, 05:16 AM
RE: Basic Chase and Prize Game - by bplus - 03-24-2023, 05:18 AM
RE: Basic Chase and Prize Game - by DANILIN - 03-24-2023, 05:19 AM
RE: Basic Chase and Prize Game - by mnrvovrfc - 03-24-2023, 05:49 AM
RE: Basic Chase and Prize Game - by vince - 03-24-2023, 05:54 AM
RE: Basic Chase and Prize Game - by bplus - 03-24-2023, 06:10 AM
RE: Basic Chase and Prize Game - by bplus - 04-02-2023, 12:03 AM
RE: Basic Chase and Prize Game - by bplus - 04-02-2023, 01:13 AM
RE: Basic Chase and Prize Game - by bplus - 06-13-2023, 10:19 PM
RE: Basic Chase and Prize Game - by bplus - 06-13-2023, 10:23 PM



Users browsing this thread: 7 Guest(s)