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

Username:   Password: 
 RegisterRegister   
 Need help with creating enemies in game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hinaspins




PostPosted: Wed Jan 04, 2012 1:08 am   Post subject: Need help with creating enemies in game

What is it you are trying to achieve?
I'm trying to achieve getting bullets to come down the screen to hit the player.

What is the problem you are having?
I am wondering if there is a better way of putting enemies in without having to individually put each enemy in.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
drawfilloval (reloc, fall - 1, 5, 5, black)
drawfilloval (reloc, fall + 10, 5, 5, white)

fall := fall - 1

if fall = -50 then
fall := fall + 400
reloc := Rand.Int (40, 360)
end if
if Math.Distance (reloc, fall, X, Y) < 5 * 2 then
drawfilloval (reloc, fall, 12, 12, white)
score := score + fail
reloc := Rand.Int (40, 360)
fall := fall + 400

end if
If the player get's hit by the bullet coming down the screen it will take away 25 points and make the enemy go up by 400y and pick a new x cord for the bullet to come down.
I'm wondering if theres a way to put more of those in without typing this out everytime for a new enemy.
Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jan 04, 2012 1:30 am   Post subject: Re: Need help with creating enemies in game

hinaspins @ Wed Jan 04, 2012 1:08 am wrote:

I am wondering if there is a better way of putting enemies in without having to individually put each enemy in.

Perhaps with a loop.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
mirhagk




PostPosted: Wed Jan 04, 2012 12:48 pm   Post subject: RE:Need help with creating enemies in game

loops and arrays. Also if you're daring enough you could read info in from a text file
Wakening




PostPosted: Wed Jan 04, 2012 10:30 pm   Post subject: Re: Need help with creating enemies in game

Using loops greatly help with repeated actions, such as many enemy clones doing the same thing (eg. shooting the player). Arrays provide a way to create many items with similar characteristics but are ultimately different. An array for the position of each enemy, an array for the health of each enemy, etc.
More detail on those here:

Loops
http://compsci.ca/v3/viewtopic.php?t=3678

Arrays
http://compsci.ca/v3/viewtopic.php?t=14333
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  [ 4 Posts ]
Jump to:   


Style:  
Search: