
-----------------------------------
hinaspins
Wed Jan 04, 2012 1:08 am

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

-----------------------------------
Tony
Wed Jan 04, 2012 1:30 am

Re: Need help with creating enemies in game
-----------------------------------

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.

-----------------------------------
mirhagk
Wed Jan 04, 2012 12:48 pm

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
Wed Jan 04, 2012 10:30 pm

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
