Limited moves per scene

mitchewing23

  • Posts: 61
Im making a game where you click to destroy blocks but i want to limit the number of times you can click (destroy blocks) to make it a little harder. I'm not great with making behaviors, but if one already exhists or you can show me a picture that be awesome! Thanks for helping in advance.
Mitchell

gplar

  • Posts: 1115
Assuming you have a behavior that destroys blocks by clicking them:
Add a number, Game attribute, call it Clicks, and set it to 0 on start of level.
Set a condition in your destroy behavior that tests for Clicks:

If Clicks < limit
    Destroy block
    Increment Clicks (or add 1 to Clicks)
Otherwise
draw a message or do whatever you want it to...

There are blocks for all of this. No pictures, though.  :)

mitchewing23

  • Posts: 61
Yes i do already have a "die when clicked" behavior so do i add that to it or make a new behavior with that?
Mitchell

gplar

  • Posts: 1115
You add to it. No need for more behaviors.And you need to do the check for the limit when your user clicks to kill.  :)

mitchewing23

  • Posts: 61
Okay i kind of understand that. I uploaded the current game and you can look at it here: http://www.stencyl.com/game/play/14115

Im thinking i should make a different behavior and attach it to the main square so if you click 5 times then it will kill the main character (Smiley square) instead of putting it on the others that are meant to be destroyed. Do you understand what im saying?
Mitchell

ShivaFang

  • Posts: 248
Nice concept.  Looks solid so far once you add some polish like music and sound effects.

I do understand what you are saying, but for what you are doing they would be more easily handled by separate behaviours.  One that counts different actors you are clicking on, and one that checks the number of clicks on one specific target.

The one on the smiley face would use an internal attribute, rather than an outside one.

(Because of the was *I* code, I would make this one behaviour, but I'd need to use 'tags' to identify each counter and it would get very complicated to explain, and probably would take more time than strictly necessary - so I just recommend making them two behaviours :) )


As a gameplay suggestion, maybe clicking on the actor would give them a 'nudge' to increase their speed a bit to give them that extra oomph, with the 5th time killing the actor.  Although... with your game being frictionless (0 gravity) maybe that's not necessary.  (hate being 2 pixels shy of a goal line or cliff or w/e)
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Thanks for the suggestions, is there a way you could make and take a picture of a simple behavior that kills the actor OR reload the scene after clicking 10 times on the game screne? I believe thats really all I need. I tried to make one, but it doesn't work.
Mitchell

ShivaFang

  • Posts: 248
Yup!  But I'll do it tomorrow :)  I spent more time today debugging other people's problems in this forum than I did on my own stuff :'( - I think that's a kind of perverse form of procrastination though.  (And I'll try to keep it simple - I tend to like to throw in things like an event to fire off an animation and then the actor dies after the animation finishes and then the scene reloads... but that might be a bit much for what you asked for... and why I spent more time writing other people's stuff today than my own stuff.  Blearg)
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Okay thanks a lot man!  :)
Mitchell

ShivaFang

  • Posts: 248
Here you go.  This will reload the game screen if the user clicks 10 times - no matter where on the screen they click.

This is probably best in a scene behaviour - but attaching it to an actor will work too.

To kill the player - change "reload and crossfade" to "kill [self]" in a player behaviour or "kill [(an attribute that links to the player)]" in a scene behaviour.
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

ShivaFang

  • Posts: 248
Added bonus.  This wasn't what you asked for - but I think this will do what you want a little better, I think.

This is a 'custom event' (Add Event -> Advanced -> Custom Event) that will increment the counter every time it is called, and then reload the screen after 10 calls.  (the trigger event that's off on it's own is NOT part of this event - it's just there to show how you would call it).  You want this as a scene behaviour.

In your blocks - in the method you are using to 'destroy' the blocks - put the 'trigger event' block and make sure the text there is EXACTLY the same as the text in the event.

The 'trigger event' block can be found in "Behaviour -> Triggers"  Make sure you grab 'for this scene' and not 'for actor'.

In case it needs to be said - DO NOT put the 'Move Count' trigger inside the 'Move Count' event (unless you know what you are doing with conditional statements and recursive code).  This will cause an dimentional time-space paradox and the world will implode.  Okay, actually it's just an infinite loop which Flash is smart enough to detect and throw a 'stack overflow' before crashing, but still... just don't do it.

« Last Edit: August 14, 2012, 06:49:44 am by ShivaFang »
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Okay i made that behavior and it works, but is there a way i can link it to another one where it has a number somewhere on the screne to show people how many clicks they have left. So everytime they click the number goes down.
Mitchell

ShivaFang

  • Posts: 248
If it's on the scene, I would add (in the same behaviour) a "When Drawing" event.. something like the attachment;

Change the font, colour, and x,y locations to your liking.  (You could do more fancy stuff like draw a border or whatever.  (make sure you use FONT colour - and not just 'change the colour to...' - that one only applies to the fill colour for circles and rectangles.)


If you've applied it to the actor, you could do the same thing (though you'll want to add 'switch to screen space' before you do that)  However it will be drawn on the same 'layer' and if you have anything on the layer above the actor it will 'cover' the drawing.

In that case I would create a scene behaviour with an attribute that links to the player and use the block in Behaviour -> Attributed called "for [actor] get [counter] from behaviour ["behaviour name"]" be sure to use the name of the behaviour you've chosen at the end there.


Also, if you change the attached image where it says "draw text [counter]" to "draw text [10 - [counter] ]" you will get how many moves are left before you lose.

And one last thing - if you create another attribute (NOT hidden) as 'total moves', and change all instances of '10' to use that attribute instead, you can then set the number of allowed moves in each scene right on the 'behaviour' tab in the scene properties, rather than having all scenes allow 10 moves.
EDITED to turn on notifications, because I forgot to when I posted.

« Last Edit: August 14, 2012, 10:43:27 am by ShivaFang »
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Ya I noticed i could change the number of clicks per level which i definately will do. Thanks for all the help. Im going to go and make it now then i may update later so you can see it. :)
Mitchell

mitchewing23

  • Posts: 61
Okay that works good, but i was thinking it should count down instead of up so they know how many moves they have left because the first time they play they will lose becuase they don't know how many times since each scene will be different. Is there a way I can do that?
Mitchell