[HALF SOLVED] How do I make an in-game store?

Mattcus

  • Posts: 24
Hi i am new to Stencyl although i have used other game making programs and a bit of coding.

But as part of my game i would like it that it has an in-game store where you earn money or something by collecting them in levels and defeating enemies and stuff like that, then you can spend those points earned on things like new characters to play as or new levels or weapons and stuff like that. If anyone would be able to help me that would be much appreciated and i could give you credit in my game if you would like.

Thanks!

EDIT: By Half Solved i mean that i have the scoring system working but i don't know you to make it able to buy stuff.

« Last Edit: November 03, 2011, 11:10:58 pm by Mattcus »

Unit158

  • Posts: 17
Set up a coin system (on touch coin or what ever add so much to game attribute money)
Make actors for buying etc.
when bought -money and set game attrubute boolean to true
have actors check if the boolean is true and if so, implement effects. Inefficient but it works. I made this just to tell you a system so it isn't great but it will work.

Mattcus

  • Posts: 24
Thanks for replying but i am a little bit confused i will try it now to see if i understand what you said (and to see if it works) but could you put up a picture because that would really help me out.

Mattcus

  • Posts: 24
I tried making a behaviour that when created sets money to 0 and when the coin collides with an actor then (Using a custom block) it adds 1 to money and kills itself. I also made it draw the text in position 0,0 but that made each coin have a 0 on it and when the player collides with the coin the money doesn't rise and the coin doesn't kill itself.

I don't think i made the behaviour correctly.

rob1221

  • *
  • Posts: 9473
You probably want to draw the money amount in a scene behavior, not an actor behavior, especially since the actor is going to die anyway.  You can send a message to the scene behavior to increment the money amount, or you can make a game attribute (they're purple) to use in both behaviors.  The money amount doesn't rise because you didn't indicate how to do so or by how much (for example,[increment [money] by [amount]].  The coin doesn't kill itself because you didn't tell it to (non-orange blocks outside orange blocks do nothing).

« Last Edit: October 31, 2011, 10:52:34 pm by rob1221 »

Mattcus

  • Posts: 24
Oh ok thanks i'll try that now

Mattcus

  • Posts: 24
Great thanks that works but how will i be able to have the money not go to 0 at the start of each scene. because i want an in-game store that you can access at any scene and spend the money you have earned (I said all this in the first post) How do i do this?

Mattcus

  • Posts: 24
By the way with collecting the coins when i collect a coin it slows down the player. Is there any way around this?

rob1221

  • *
  • Posts: 9473
Remove the "set money to 0" block then.  I'm not sure what is causing the player to slow down; make the coin a sensor if you haven't done that already.

Mattcus

  • Posts: 24
Yes that fixed everything thanks. Now i just need to find out how to access a store, buy stuff and then once an item has been bought take away money and not make that item buyable anymore.

Mattcus

  • Posts: 24
I have found a problem with the coin system.

When you collect coins then go to the next level you keep the same amount of coins (Which is good)
But when you die then the level restarts but you keep the same amount of coins. i need to be able to set the money to what it was at the start of the level so when you die it goes to that instead of keeping the same money or starting from 0.

rob1221

  • *
  • Posts: 9473
Well that makes things a bit more complicated.  I think you can set up local attributes for every level to store the current amount of money.  At the beginning of each level, set the local attribute to the game attribute.  At the end of each level, set the game attribute to the local attribute.  When the level is restarted, the current money will go back to the amount it had when the level started.

Mattcus

  • Posts: 24
Thanks for your help but again i am confused. How would i do this. i have tried and it just made it that when you pick up the coins the money stays 0 and how would i be able to tell when the end of the level is when making the behaviour. pictures would be very helpful.

« Last Edit: November 01, 2011, 01:45:24 pm by Mattcus »

rob1221

  • *
  • Posts: 9473
Hmm I guess both would have to be game attributes; do the new images make things clearer?

Mattcus

  • Posts: 24
Thanks those images do make things clearer but  with the level end. in my game when you enter a region you go to the next level. how would say to set money to current money when you hit the region?