Need help to finish my game :)

mynameisacemynameisace Hull, UKMember Posts: 2,484
edited November -1 in Working with GS (Mac)
Alright,

I'm nearing the end of my first game in GS. Just need a little help with randomly picking an enemy actor to spawn.

Basically, I have 5 actors that I want to choose from, lets call them Enemy 1, Enemy 2, Enemy 3, Enemy 4 & Enemy 5.

Every 5 seconds I want GS to randomly spawn one of the enemies and spawn it in a set location. I'm fine with the spawning and the timer, just unsure of the randomness.

Any help would be great. Any help written with a new user in mind would be awesome.

Thanks
Ace

Comments

  • synthesissynthesis Member Posts: 1,693
    spawnID = random(1,5)

    RULE:
    when spawnID == 1 >> spawn Enemy 1
    otherwise:
    when spawnID == 2 >> spawn Enemy 2
    otherwise:
    etc...
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Cheers, I'll try that now and get back to you :)

    Ace
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Right, got GS open and got a Timer set up to every 5 seconds. Run to completion is checked. What behaviours shall I drag in to the timer?

    Sorry for the retardedness, this is my first game (Y)

    Ace
  • synthesissynthesis Member Posts: 1,693
    change attribute game.spawnID to random(1,5)

    RULE:
    when game.spawnID equals 1 then spawn Enemy 1
    otherwise:
    RULE:
    when game.spawnID equals 2 then spawn Enemy 2
    otherwise:
    etc...

    You don't need run to completion checked...since its an every timer and the length of time to execute the sequence is 5 seconds...an eternity on the processor clock.

    Run to completion is used to force all behaviors to execute...even if the timer runs out or a behavioral condition changes within the timer.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    You are my favourite person in the world right now haha.

    Thanks a lot buddy!
    Ace
Sign In or Register to comment.