Make enemies shoot at me
Author |
Message |
allenh98
|
Posted: Mon Jun 11, 2007 10:25 pm Post subject: Make enemies shoot at me |
|
|
Basically, what I want for my program is to have my enemies shoot at me. For example, if soldierX (which is the enemies X co-ords) is between say 500 and 600 (to make it shoot at a random time each time), how can I make my program shoot a sprite at me? What happens currently is this in pseudocode
if soldierX = 600 then
enemyMissilex = soldierX
enemyMissilex := enemyMissilex - 10
end if
the point to enemyMissilex := enemyMissilex - 10 is because I want it to go faster than my soldier, *which is soldierX := soldierX - 5). However, what ends up happening is that only while soldierX is 600 will it shoot. Is there a way for when soldierX is 600 to make it shoot the entire length of my screen? I hope you guys understand what I'm talking about. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DifinityRJ

|
Posted: Tue Jun 12, 2007 6:02 am Post subject: Re: Make enemies shoot at me |
|
|
if soldierX = 600 then
enemyMissilex = soldierX
enemyMissilex := enemyMissilex - 10
end if
Well first off your doing something wrong, your making enemyMissilex = soldierX, so even if you decrease enemyMissilex position your always reseting it back to soldierX. |
|
|
|
|
 |
Clayton

|
Posted: Tue Jun 12, 2007 11:16 am Post subject: RE:Make enemies shoot at me |
|
|
code: | if soldierX = 600 then |
Your problem lies right here. You only ever shoot if you're at 600. Instead, you need to have a range to shoot within, represented by the inequality 500 <= x <= 600, I'm sure you can figure it out from here. |
|
|
|
|
 |
|
|