04-02-2023, 01:13 AM
Basic Chase and Prize Game - Prize Winning Edition
Code: (Select All)
_Title "Basic Chase and Prize Game - The Prize Winning Edition" ' b+ 2023-03-24, 2023-04-01
Randomize Timer
Type XY
As Long x, y
End Type
Dim doomer(1 To 5) As XY
Dim prize(1 To 5) As XY
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
While _KeyDown(27) = 0
DoomMoves = 20
dooms = 1
HeroX = 40: HeroY = 15
score = 0
prize(dooms).x = Int(Rnd * 80) + 1: prize(dooms).y = Int(Rnd * 30) + 1
doomer(dooms).x = Int(Rnd * 80) + 1: doomer(dooms).y = Int(Rnd * 30) + 1
Do
Cls ' screen update
Locate HeroY, HeroX: Print "H";
For i = 1 To dooms
Locate doomer(i).y, doomer(i).x: Print "X";
Locate prize(i).y, prize(i).x: Print "*";
Next
For i = 1 To dooms
If HeroX = prize(i).x And HeroY = prize(i).y Then
score = score + 1
prize(i).x = Int(Rnd * 80) + 1: prize(i).y = Int(Rnd * 30) + 1
If DoomMoves > 14 Then DoomMoves = DoomMoves - 1
If dooms < 5 Then
dooms = dooms + 1
prize(dooms).x = Int(Rnd * 80) + 1: prize(dooms).y = Int(Rnd * 30) + 1
End If
For j = 1 To dooms
doomer(j).x = Int(Rnd * 80) + 1: doomer(j).y = Int(Rnd * 30) + 1
Next
Else
If doomer(i).x = HeroX And doomer(i).y = HeroY Then
Locate 15, 33: Print "Game Over ...ZZZ"
Beep: _Delay 3: _KeyClear: Sleep: Exit Do
End If
End If
Next
_Title "Basic Chase and Prize Game - Prize Winning Edition 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
End If
lc = lc + 1
If lc >= DoomMoves Then
For i = 1 To dooms
doomer(i).x = doomer(i).x + Sgn(HeroX - doomer(i).x)
doomer(i).y = doomer(i).y + Sgn(HeroY - doomer(i).y)
Next
lc = 0
End If
_Limit 30
Loop Until _KeyDown(27)
Wend
b = b + ...