Posts: 3,883
Threads: 174
Joined: Apr 2022
Reputation:
201
Did not like key action in Bandit so I tried a Keypad setup and got bonus of arrow keys working too
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 + ...
Posts: 81
Threads: 8
Joined: May 2022
Reputation:
3
03-23-2023, 11:18 AM
(This post was last modified: 03-24-2023, 05:02 AM by DANILIN.)
Neural network and my artificial intelligence
automated a similar game day before
https://qb64phoenix.com/forum/showthread...3#pid14613
plus it looks like XONIX
https://qb64phoenix.com/forum/showthread.php?tid=519
Code: (Select All) _Title "Basic Chase and Prize.bas 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 * 78) + 2: PrizeY = Int(Rnd * 28) + 2
DoomX = Int(Rnd * 78) + 2: DoomY = Int(Rnd * 28) + 2
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 * 78) + 2: PrizeY = Int(Rnd * 28) + 2
DoomX = Int(Rnd * 78) + 2: DoomY = Int(Rnd * 28) + 2
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)
' Danilin
oy = HeroY:: ox = HeroX
Locate 1, 1: Print oy, ox
Locate oy, ox: Print " ";
If HeroY < PrizeY Then ox = HeroX: oy = HeroY: HeroY = HeroY + 1
Locate HeroY, HeroX: Print "R";
Locate oy, ox: Print " ";
If HeroY > PrizeY Then ox = HeroX: oy = HeroY: HeroY = HeroY - 1
Locate HeroY, HeroX: Print "R";
Locate oy, ox: Print " ";
If HeroX < PrizeX Then ox = HeroX: oy = HeroY: HeroX = HeroX + 1
Locate HeroY, HeroX: Print "R";
Locate oy, ox: Print " ";
If HeroX > PrizeX Then ox = HeroX: oy = HeroY: HeroX = HeroX - 1
Locate HeroY, HeroX: Print "R";
Locate oy, ox: Print " ";
If (HeroY = DoomY And HeroY < 22) Then ox=HeroX: oy=HeroY: HeroY = HeroY+(Int2*Rnd-1.5))
Locate HeroY, HeroX: Print "R";
Locate oy, ox: Print " ";
If (HeroX = DoomX And HeroY < 72) Then ox=HeroX: oy=HeroY: HeroX = HeroX+(Int(2*Rnd-1.5))
Locate HeroY, HeroX: Print "R";
' Danilin
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)
milli gif 35 kB in my automatic neuronet algorithm
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic
Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
Posts: 3,883
Threads: 174
Joined: Apr 2022
Reputation:
201
03-23-2023, 12:36 PM
(This post was last modified: 03-23-2023, 12:38 PM by bplus.)
Quote:plus it looks like XONIX
???
Not in the least! That is just a space filling pattern with 0 user input.
b = b + ...
Posts: 81
Threads: 8
Joined: May 2022
Reputation:
3
I have an version of almost xonix with a stalker
it's easy to make multiple stalkers aiming for a hero
but how to make a hero
exactly running away from several stalkers
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic
Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
Posts: 3,883
Threads: 174
Joined: Apr 2022
Reputation:
201
Odd, every once in a while Doom fails to move towards Hero.
Quiz for day: why?
b = b + ...
Posts: 3,883
Threads: 174
Joined: Apr 2022
Reputation:
201
Fixed I think and added another loop with High Score Tracker:
Code: (Select All) _Title "Basic Chase and Prize Game" ' b+ 2023-03-24
Randomize Timer
Screen _NewImage(640, 480, 32) ' 80 x 30
_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
Do
If score > HiScore Then HiScore = score
DoomMoves = 20: score = 0
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) + Space$(10) + "High Score:" + Str$(HiScore)
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 ' fix with > added to = ??
DoomX = DoomX + Sgn(HeroX - DoomX): DoomY = DoomY + Sgn(HeroY - DoomY)
lc = 0
End If
_Limit 30
Loop Until _KeyDown(27)
Loop Until _KeyDown(27)
b = b + ...
Posts: 1,588
Threads: 59
Joined: Jul 2022
Reputation:
52
(03-23-2023, 12:49 PM)DANILIN Wrote: it's easy to make multiple stalkers aiming for a hero
It's actually called "Robotwar" and there are many versions of it. I played a "cute" version of it on Linux, last tried it on Knoppix but alas, sometimes it crashes back to desktop when I start a new game. IINM there was even a text-mode version which was one of the old "BSD games" that could be optionally installed for Slackware.
I have programmed such a game but it's not very good. I have it in my archives somewhere...
Anyway, my game was trying to replicate one from an old book given to children programming on an Apple ][E or something like that. It had only one player and one enemy, and the logic of the enemy to move toward the player got better the more the player "stole" from the enemy. In fact the original program didn't have a "Robotwar-like" fence, it had an "exit" that the player tried to run into, after he/she felt "stealing" enough before the enemy caught him/her.
Posts: 292
Threads: 15
Joined: Apr 2022
Reputation:
49
nice, but lets see something not given to children
Posts: 1,588
Threads: 59
Joined: Jul 2022
Reputation:
52
(03-23-2023, 11:18 AM)DANILIN Wrote: milli gif 35 kB (link)
Sorry but I'm not going to click an "HTTP" link for a site found in Eastern Europe. Not being homophobic or anything like that. Please upload the GIF into this site if you can.
Posts: 3,883
Threads: 174
Joined: Apr 2022
Reputation:
201
03-24-2023, 05:10 AM
(This post was last modified: 03-24-2023, 05:20 AM by bplus.)
Aha! Danilin has mod the Hero into a Rabbit bouncing to and fro into prize.
Wascally Wabbit! https://library.si.edu/digital-library/e...lly-wabbit
Now I see that AI sorta and the other thing he was seeing, or maybe it's the Covid I've been suffering ;-))
Who says Trix are just for kids LOL!
b = b + ...
|