Okay, I'm starting a game and I'm n the very beginning of production, when i get this thing.
Okay, here's what it is:
You are the player circle (purple) trying to kill the enemy (blue) by shooting it with fireballs (red). The enemy has 10 hp, and you take away 5 hp from each hit of the fireball. Obviously, it takes two hits to kill. Gameplay goes: you click anywhere (for now) to select the enemy and then press 1 to shoot a fireball.
The problem is that something is up with the syncing, or I made a typo and can't catch or, or what, but it just totally messes up (you'll see if you run it, no media).
Oh, and here's the code:
`Magician game Demo
`Setup
gosub setup
`Main Loop
repeat
cls
gosub draw
gosub check_input
gosub calc_damage
if fireball = 1
gosub move_fireball
endif
sync
until enemy < 1
center text 320,240, "YOU WIN"
end
`Subs
setup:
sync on
sync rate 0
player_x = 200
player_y = 200
player_size = 20
enemy = 1
enemy_x = 400
enemy_y = 400
enemy_size = 10
enemy_health = 10
selected = 0
fireball = 0
fireball_x = player_x
fireball_y = player_y
fireball_size = 5
white = rgb(255,255,255)
blue = rgb(0,0,255)
red = rgb(255,0,0)
purple = rgb(255,0,255)
black = 0
return
draw:
text 5,5, "Left click to select the enemy"
text 5,25, "Then press 1 to launch a fireball at him"
text 5,45, str$(screen fps())
`Draw Player
ink purple,black
circle player_x,player_y,player_size
`Draw Enemy
if enemy = 1
ink blue,black
circle enemy_x,enemy_y,enemy_size
endif
if enemy = 1
ink white,black
center text enemy_x, enemy_y-35,str$(enemy_health)
endif
`Draw Fireball if there is one
if fireball = 1
cls
ink red,black
circle fireball_x,fireball_y,fireball_size
endif
`Draw Selection circle
if selected = 1
ink white,black
circle enemy_x,enemy_y,enemy_size+5
endif
return
check_input:
if mouseclick() > 0
`Commented out for testing
`if mousex() > enemy_x-10 and mousex() < enemy_x + 10 and mousey() > enemy_y - 10 and mousey() < enemy_y + 10
selected = 1
`endif
endif
if selected = 1
if inkey$() = "1"
fireball = 1
change_x = enemy_x - fireball_x
change_y = enemy_y - fireball_y
endif
endif
if enemy = 0
selected = 0
endif
`Commented out for testing
`if mouseclick() > 0
`if mousex() <> enemy_x or mousey() <> enemy_y
`selected = 0
`endif
`endif
return
calc_damage:
if fireball_x = enemy_x and fireball_y = enemy_y
enemy_health = enemy_health-5
fireball = 0
fireball_x = player_x
fireball_y = player_y
endif
if enemy_health < 1
enemy = 0
endif
return
move_fireball:
change_turnx = change_x/10
change_turny = change_y/10
fireball_x = fireball_x+ change_turnx
fireball_y = fireball_y+ change_turny
if fireball_x = enemy_x and fireball_y = enemy_y
fireball = 0
cls
endif
return
~QJ