Creating a Death Counter

ConocolatePizza

  • Posts: 11
Hi there,

I'm trying to make a death counter that's displayed on the screen and increases by 1 every time the player dies, but I can't figure it out.

I've looked around for ways to do it, and the only one I've found was a forum on here which says;
"Add a global attribute called death counter.
add a scene behaviour called count deaths.
add an event called 'when actor is created or destroyed' and change it to 'when player is destroyed'
then inside put 'death counter = death counter + 1'"

However, I can't find this scene behaviour, and I can't figure out a work around.

Any help is appreciated! Thanks in advance

corbanwolf

  • Posts: 223
In settings you got global attributes. Create number attribute which will store number of deaths of player (death of player = [kill self] block in player actor). And you can increase the number every time the player dies.

Then you need to draw font on screen whenever you need it.

Post your code you got so far
♪♪♪♪♪♪

ConocolatePizza

  • Posts: 11
Are 'global attributes' and 'game attributes' the same thing? I don't have a global attributes option.

I'm not sure what you mean by 'death of player = [kill self] block in player actor'. How can I raise the number every time a player dies?

corbanwolf

  • Posts: 223
Yea, it's the same, sorry.

Change value of this attribute every time a player dies. Use SET value or sth in game attributes bookmark in code editor and use KILL [ACTOR] and of course use IF block.

http://www.stencyl.com/blocks/
And finish crash course tutorial
♪♪♪♪♪♪

ConocolatePizza

  • Posts: 11
Ok I've tried a few more things and figured out one that seems like it should work, but it's not working at the moment. I've attached a screenshot. Could you tell me why this isn't working? I think I'm not fully understanding the 'draw' command.

There is a different event that sets the death counter at the start to 0.

corbanwolf

  • Posts: 223
Draw blocks must be placed in drawing block. Create new event which will be displaying text all the time.
♪♪♪♪♪♪

Luyren

  • *
  • Posts: 2805
Relevant video on the basic events, including the drawing event: https://youtu.be/j10SMwy2prM (explanation on the drawing event starts at around 1:24)
You are using an Image API block in your last example. That does work anywhere, but needs a bit more understanding. I recommend you create a drawing event, and use the blocks under drawing on the palette, as described in the video, to draw your amount of lives.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

ConocolatePizza

  • Posts: 11
Thanks both of you, I figured it out! Actually really simple, feel silly for not understanding initially haha.