im making a game where at the start theres a cpu button and a 2 player button. so far the cpu button works, how do i make the sprite that currently chases another sprite switch to player controls if a button is pressed when the game is started?
Offline
ok nvm but how do i only enable moving with arrow keys when i receive a certain broadcast??
Offline
something a bit more specific plz
Offline
Give the sprite a binary or boolean variable. Binary will be 0 or 1, boolean True or False. I'll use a boolean for this example. Make a variable called CPU on the sprite. Then, if the player selects to control the sprite, set the CPU variable to False. If the player doesn't select it and the game will control the sprite, set this variable to True.
In game, use this to assign control to the player or CPU, for example if the sprite has the CPU variable as True, then don't let the player control it. An easy way to do this is by using the 'If else" control block. If CPU = True, execute the game controls; Else allow the player to control it.
Hope you can follow this
Offline
possibly following it, not sure if i am
Offline
ok, i have
when i receive 1 player set CPU to True
Offline
ok that didnt work
on the chasing sprite i have when i recieve a certain broadcast from the cpu button to set the variable CPU to True
and when i recieve a broadcast from the 2 player button to set it to False
when gf clicked hide variable CPU
when gf clicked if CPU = True
blank
Offline
Make the player only able to control it if CPU = False, eg:
Forever
If CPU = False
player controls, eg if right arrow clicked etc
ELSE
CPU controls
Offline
ok now how do i put player controls inside an if/else?
Offline
if-else didnt work so i used a forever with double ifs
btw thx for all ur help prestige
Offline
so i need to know how to put key controls inside an if
Offline
FOREVER
IF CPU = False
if right key pressed
change x by 1
if left key pressed
change x by -1
ELSE
CPU controls
Last edited by Prestige (2012-07-16 17:17:24)
Offline
thx a lot prestige, my game works
Offline