Detecting front and back?
Posted: Thu Feb 23, 2012 5:09 pm
Hey I am trying to make a simple game in Livecode. I have made a player, and some enemies.
My problem comes when i want to "shoot" enemies down. I have collection check, and they go away when they hit my "player", and also when I shoot. But is there a way to see what way is forward?
Right now i "kill" objects 150 in front of my player. But I want to only be able to shoot the objects that are in front, so if I turn 180 degree I don't want to kill the objects behind me.
I guess I need some way to find out what way my "player" is facing, so I only do a action in one direction.
Btw I am very new, and I am just following the Game academy tutorial and modifying it, but this problem I can't seem to figure out without expert help.
Here is my code that handles my shooting. As I said I am very new in this, so sorry if it does not follow normal conventions for coding
on handleShoot
if sShoot is true then
repeat for each key tEnemy in sEnemyNames
put the right of button "rocket" into tRocketlocRight
add 150 to tRocketlocRight
put tRocketlocRight into field "rocketfield"
if the left of button tEnemy < tRocketlocRight then
add 1 to sPlayerHit
put sPlayerHit into field "enemyfield"
delete button tEnemy
delete variable sEnemyNames[tEnemy]
end if
end repeat
end if
end handleShoot
Any help appreciated
Thx
My problem comes when i want to "shoot" enemies down. I have collection check, and they go away when they hit my "player", and also when I shoot. But is there a way to see what way is forward?
Right now i "kill" objects 150 in front of my player. But I want to only be able to shoot the objects that are in front, so if I turn 180 degree I don't want to kill the objects behind me.
I guess I need some way to find out what way my "player" is facing, so I only do a action in one direction.
Btw I am very new, and I am just following the Game academy tutorial and modifying it, but this problem I can't seem to figure out without expert help.
Here is my code that handles my shooting. As I said I am very new in this, so sorry if it does not follow normal conventions for coding
on handleShoot
if sShoot is true then
repeat for each key tEnemy in sEnemyNames
put the right of button "rocket" into tRocketlocRight
add 150 to tRocketlocRight
put tRocketlocRight into field "rocketfield"
if the left of button tEnemy < tRocketlocRight then
add 1 to sPlayerHit
put sPlayerHit into field "enemyfield"
delete button tEnemy
delete variable sEnemyNames[tEnemy]
end if
end repeat
end if
end handleShoot
Any help appreciated
Thx