Building a second lose condition help

erest21

  • Posts: 5
Hello Everyone
Super new to this community, but I am in need of some help. I would appreciate anyone's help with an issue I am having trying to build a game.

So I am trying to endless spaceship shooting game, but I am having trouble trying to figure out how to make two lose conditions.
I have one lose condition working where if the player collides with an enemy the player loses a life. Yay that at least works! :D

However, the second lose condition I am trying to create is when an enemy gets past the player then the player loses another life.

Instead the point counter in my game is counting each "killed" enemy that has left the screen as point. Now it is to my understanding that reason you have them "killed" when they have exited the scene is so you don't have a large number of enemies out of frame and inevitably crash the game.

Ideally I would like it to where once the life counter hits zero it will trigger a game over or a restart, but I just am unable to crack this problem.

If you look the screenshots I included you will see what my custom "scene manager" scene behavior is doing to my exiting enemies and the "lose a life" event for the player I was trying to trigger.
 
Again any help would be appreciated either with screenshots or Youtube video links (preferably in English) as to how to created the losing condition I want.

Thank You and have a great day.

Bombini

  • *
  • Posts: 1259
Hi,
i have difficulties undertsanding you. I am there for guessing.
You want to have a game over screen when lifes reach 0?
And you loose a life when an enemy leaves the screen "behind" you`?

Cheers!

erest21

  • Posts: 5
Hello Bombini
First of all thank you for the quick response.

Yes you are guessing correctly that is what I want to happen.

But as I mentioned currently when my enemies leave the screen the point counter I have set up is counting those enemies as kills and the score keeps going up.

JeffreyDriver

  • Posts: 2041
Let's say it's a vertical top-down shooter. When the y-centre value of an enemy becomes greater than the player y-value you want to remove a life from the player but you need to use a boolean to make sure it only happens once per enemy.

If y-centre of self is greater than y-centre of PLAYER
If BEHIND PLAYER (attribute) = false
Set BEHIND PLAYER to true
Decrement PLAY LIVES by 1

As for the score issue. Only increment the score if BEHIND PLAYER equals false when the enemy is killed.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

erest21

  • Posts: 5
Hello Jeffrey
Thank You  for your reply and insight  to my post.

So would the solution you are suggesting be a scene behavior or an actor behavior that I give my enemies?


JeffreyDriver

  • Posts: 2041
Having it as an actor behaviour would probably be a simpler approach.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

erest21

  • Posts: 5
Thanks Jeffrey.
Do you mind taking a look at the attached screenshots to see if I understood you correctly.
My game is a endless x-centre type of game so you will see x instead of y.
 
If I did it wrong do you mind sending a screen shot of what it should look like.
Thank You again for your help and support.

JeffreyDriver

  • Posts: 2041
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

erest21

  • Posts: 5
Greetings Again Jeffrey

First of all thank you for all of your support leading up to this point. But I am still having a bit of trouble with this lose condition.

So when I designed my game I gave my "player" character the ability to fire a projectile. However, this ability is now affecting the last line of code you suggested because now when my enemies are killed it is deducting lives from my player. So to try and combat the issue I tried adapting your code to a "enter or leaves the scene  or screen" actor event for my enemies. (see attachment)

 Should I maybe create two separate events one specifically for when my killed by the projectile actor and then one for when my enemies have left the scene?

Thank you again and I appreciate the help.

corbanwolf

  • Posts: 160
This code looks good so I guess problem is somewhere else. Can you post all events for this actor?

JeffreyDriver

  • Posts: 2041
'Actor' needs to be assigned to something.

You don't need the 'otherwise if' statement but that's not the problem.

What code runs when the actor dies?
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

seoking

  • Posts: 2
Outside of specific professional or academic contexts, writing with a personal style that makes it easier on the reader is more important than pleasing Strunk and White. That said, I also believe you have to know the rules in order to break them. Plus, there are some errors that you’ll never convince anyone that you did intentionally in the name of style (outside of a joke), and even then some people will still assume you’re dumb.