02-25-2024, 07:09 AM
(02-22-2024, 02:16 PM)kevin Wrote: Here's a pool game that I have been working on. You can play against another player, or the computer.
...
Hi Kevin,
You made a cheat_mode in your game ... I like it
Or even you could make it like an easter egg, too ... a secret key F5, so the computer would assist you to play your turn
Code:
'----------------------
' GAME LOOP
'----------------------
do
...
'Secret key F5, so you as Player_1, let the computer plays for you.
if keydown(KEY_F5) then computer_opponent()
...
until keydown(KEY_ESCAPE)
'-----------
' FUNCTIONS
'-----------
function computer_oppenent()
...
if balls[b].active_now
if player1.colour="red" or player2.colour = "red" and can_play = true
if b = 0 or b = 2 or b = 6 or b = 8 or b = 9 or b = 13 or b = 14
target_balls[sizeof(target_balls)] = b
endif
elseif player1.colour="yellow" or player2.colour = "yellow"
if b = 1 or b = 3 or b = 4 or b = 5 or b = 7 or b = 11 or b = 12
target_balls[sizeof(target_balls)] = b
endif
endif
endif
...
'select a target ball, with nothing blocking it, and aim for it
'calculate the unblocked ball that is closest to a pocket
...
endfunc