Page 1 of 1

need explaination on this power-ups example

PostPosted: Mon Apr 27, 2015 2:53 pm
by Masky94
someone showed me this example of power-ups using the stack function, but i still couldnt understand how it works since there is a problem on the "boxes" on the right hand side of the word "inventory", there are the boxes where the power-ups will appear when the player collected the power up, so i'd like some expert to explain to me why it tell me "invalid option to this actor" when i trying to click any of the option under "animation", and the most thing i need to know is how the stack actually works here, and it would be better if someone could tell me how to make this with steps, thank you.

i do understand the stack in the global code, but now what trouble me is the code in the "item", what does " sprintf(powerUp, clonename);" do? also how does the item will appear on the boxes when the player collected the item?

i gonna use the same concept and use it on my simple game, where a car collide with a "shield" power ups, it store in the stack, then when i use the power-up, the shield will appear around the car and protect it while moving, and i need help on how to spawn the "shield" around the car and follows it even it moves when the key is pressed.

Re: need explaination on this power-ups example

PostPosted: Mon Apr 27, 2015 4:18 pm
by koala
You know what? I'll make a tutorial for this file and explain everything in details, how I've made it and all. Expect it in next 24 hours. :mrgreen:

Let's see can I quickly answer some of your questions.

Masky94 wrote:someone showed me this example of power-ups using the stack function, but i still couldnt understand how it works since there is a problem on the "boxes" on the right hand side of the word "inventory", there are the boxes where the power-ups will appear when the player collected the power up, so i'd like some expert to explain to me why it tell me "invalid option to this actor" when i trying to click any of the option under "animation",...
Those boxes are Canvas Actors. They don't have animation.

Masky94 wrote:i do understand the stack in the global code, but now what trouble me is the code in the "item", what does " sprintf(powerUp, clonename);" do?
It prints item's name into string powerUp. It is called when player collides with an item. You need to put that item on stack, to be more precise, that item's name. Name will be an argument of function push. Using sprintf() you copy item's name into powerUp, which is string, and then call push(powerUp), which puts that string, name powerUp on stack.
Here powerUp is a string, it has nothing to do with previous example in this topic where powerUp is a struct.

Masky94 wrote:also how does the item will appear on the boxes when the player collected the item?
Check function draw_from() in Script Reference. It draws actor whose name is an argument into canvas that calls this function.

Masky94 wrote:i gonna use the same concept and use it on my simple game, where a car collide with a "shield" power ups, it store in the stack, then when i use the power-up, the shield will appear around the car and protect it while moving, and i need help on how to spawn the "shield" around the car and follows it even it moves when the key is pressed.?
If you want "shiled" to follow car, then car must be parent of "shield". Right click on the "shield", Actor Control, Parent: car.

:mrgreen:

Re: need explaination on this power-ups example

PostPosted: Thu Apr 30, 2015 1:44 am
by koala
Here's the tutorial - powerUp and stack-inventory Tutorial, although you've already clarified everything to yourself and I've exceeded the deadline. :roll: :mrgreen: