Need some help with Score/time keeping

So I'm making a shoot em up game, and I have a few questions about score/time keeping.First, I made a working timer, but when my guy dies and the game resets, the timer is still going. I need to know how to make the timer reset every time the game/scene resets. I would also like to know how to keep score of how many guys he hits, which leads me to my last question. How do I make it so it counts how many bullets he has left, and when he runs out he can't shoot anymore? Thanks for taking the time to read my questions and hopefully someone can answer them. Thanks :)

Comments

  • ktortiktorti Member Posts: 27
    Heres a video about adding score:


    So far as resetting the score, you need to have a game attribute which is an integer. Set it to 0 and in your game rule where you die, do a change attribute of game.Score to 0
  • MichaelSillimanMichaelSilliman Member Posts: 31
    Thanks man that helps a lot
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    If you base your timer on a built-in time attribute such as game.Time, there is no way to reset it. If you need to reset the timer, you'll need to instead use a custom timer. One way to do this is to use a timer set to every 0.1 seconds with change attribute game.customTime (real) to game.customTime + 0.1. You can then change game.customTime to 0 whenever you need to reset it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MichaelSillimanMichaelSilliman Member Posts: 31
    cool thanks. Do you know how to make it so my player only has a certain number of bullets and it tells you how much you have left?
  • 3itg3itg Member, PRO Posts: 382
    edited February 2014
    Hey @MichaelSilliman,
    In my opinion, you should read the cookbook. (http://cookbook.gamesalad.com/tutorials)
    Then read the descriptions of the behaviors in the creator.
    Download and look at how things are done in free templates.
    Learn the basics first as it will save you a lot of time.
    Posting to the forums and waiting for responses will take longer than if you "know" how to do it.
    Once you have learned enough to have a reasonable place to start experimenting, and answering your own questions, you will be able to pick up the pace...

    I mean no offense... it's just... teach a man to fish... ya know.
  • MichaelSillimanMichaelSilliman Member Posts: 31
    thanks 3itg. I started reading the cookbook, it's a lot easier
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    To limit bullets, you'll need two game attributes, both integers: game.bulletCount and game.maxBullets. Set the first to 0 and the second to however many you want to limit it to (e.g. 3).

    In your actor that shoots bullets, add the condition When attribute game.bulletCount < game.maxBullets to whatever rule condition you already have.

    In your bullet actor, add a Change Attribute behavior at the top of its rules and change game.bulletCount to game.bulletCount + 1. When you destroy a bullet (in that actor or another actor, such as when a collision happens), change game.bulletCount to game.bulletCount - 1. You may also need to create a rule for when the bullet is off-screen (either based on self.Time or self.positionX/Y) and subtract one from the bullet count there are well.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.