How do I reward the player with a point bonus for destroying all enemies in a formation

0 favourites
  • 8 posts
From the Asset Store
Give your players time based rewards, checks how long player has been away to display time remaining to reward.
  • this is probably super easy but I am having trouble with it I am making a shmup and when I spawn 3 or 4 enemies in a formation I want to reward the player when he destroys the entire formation like in the classic arcade game Darius. SO I tried giving all the enemies an instance variable called squadron and gave the first ship a random number but how do I give the other ships the same squadron number

    and then how to make it that when a player destroys an enemy it adds one to the kill count off that specific squadron of enemy fighters and when it reaches the right amount so if you kill every member of the enemy formation it recognizes that and gives you a point bonus

  • Your logic should work with a tweak since Squad is likely a local or global variable, so your logic on the other ships should also be set squad to Squad, not set squad to sprite.squad. Another way of doing it since you are doing a function is determine the squad number before you call the function then send it through function as a parameter. Then every ship created in the function can be assigned param(0).

    To actually calculate it there are a bunch of ways to do it. Easiest way is probably on enemy destroyed, take its squad number and then determine if any other enemies with that squad number exist. If no other enemies exist with that squad number then grant the bonus. But that's based on the gameplay and if enemies can die in other ways that do not grant the bonus or if they die off screen.

  • Thanks, buddy but how do I check if there are other members of the squad exist?

  • If you do pick by evaluate, pick sprite_fighter where sprite_fighter.squad=x. Then set a variable to sprite_fight.pickedcount, the variable is the number of sprite_fighters where squad=x. You can then use this variable to compare if its 0.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I know it is 3 months since I last posted on this but I just could not figure out how to get this running then I got a new idea and moved on to a new game well I went back to this one and I still can't get my head around this could I possibly have a demonstration capx or perhaps you could just get it running and take a screenshot of the code if it is not to much trouble

  • What specifically do you need help with? All the events are with you..

  • so I get the idea of using a parameter in the function to set the global variable for squad number it is just the checking of how many enemies with that number are on screen is where I am failing

    I am reading and rereading your code and I can't make heads nor tails out of it.

    so I use pick by elevated but I can't seem to use the x command I know this is probably super basic stuff but it really is flying over my head

  • Sorry if it wasn't clear, x is supposed to be a number you put in, the squad number to look for. So if you were looking for other members of a squad you could run a function with this logic in it and pass the squad number through as a parameter and replace x with function.param(0).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)