Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Make enemies shoot at me
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
allenh98




PostPosted: 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
Sponsor
sponsor
DifinityRJ




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: