Page 1 of 1

the death problem

PostPosted: Thu Dec 20, 2012 3:11 pm
by sonicforvergame
ok here is the thing :

using variables i want that when my characther " die " wich (i mean when he touch a enemy ) he do this :

after actor touch enemies--->nothing happens when you press any button--->up path(know how to do this)--->change animation(duh)--->restart level

I want too that when you die more than three time game over

Re: the death problem

PostPosted: Thu Dec 20, 2012 9:02 pm
by skydereign
sonicforvergame wrote:after actor touch enemies--->nothing happens when you press any button--->up path(know how to do this)--->change animation(duh)--->restart level

By up path do you mean similar to how sonic dies and goes flying off screen? Anyway, this is very simple if you have an understanding of variables. So create one called lives or similar, that way we know its value represents how many lives the player has. At the start of the game, you should set lives equal to three (so if you don't have a menu, you can just put it in the view's create actor event). Now whenever the player dies, you can reduce the variable, and before restarting, check if it is greater than zero.
Code: Select all
lives--; // reduces lives by 1

if(lives>0) // if the player still has lives
{
    // restart the level
    // not sure how you are doing this, but it goes here within the brackets
}

Re: the death problem

PostPosted: Fri Dec 21, 2012 4:48 am
by sonicforvergame
Awesome i might give you final demo of "green hill zone act1 sonic 1 hd "
yeah big title :P

Re: the death problem

PostPosted: Sat Dec 22, 2012 10:17 am
by sonicforvergame
Euhhh didn't work can you be more specified like :

say where to put the code
and i am not very good with variables

Re: the death problem

PostPosted: Sat Dec 22, 2012 10:33 am
by skydereign
sonicforvergame wrote:say where to put the code

You won't learn if I do all your coding for you. This is pretty simple, and when you get it, should help you a lot in the future. Also, you shouldn't ever need to be told where code should go. If you know what the code does, then you should know where a good place to put it is. Do you know what that code does?

sonicforvergame wrote:Euhhh didn't work can you be more specified like :

That isn't very specific either. It is helpful if you tell us how things don't work. Due to errors, or the game does nothing?

Anyway, you can think of a variable as a piece of paper. When you create the paper (creating a variable) you give it a name. That way you can find it whenever you need it. On this sheet of paper you have something written on it. Normally you'll be dealing with integer variables, so a number is written on it. In your game, you'll have many of these papers.

Now in your case you wanted to be able to keep track of the number of lives the player has. So, you need to create an integer variable (sheet of paper) called lives. By default the paper says 0. We though want to set the number of lives to 3, so in the view's create actor, we use the following code.
Code: Select all
lives = 3;

With that, the game erases the number that was on the sheet, and replaces it with the number 3. Now whenever we want to check how many lives the player has, the paper will have 3 written on it.

From there, we can use lives exactly as you think they should be used. When the player dies, you reduce it by one. Right after reducing it by one, we want to check if the player still has lives. If they do, restart the level, otherwise don't do anything. Does that make sense?

Re: the death problem

PostPosted: Sat Dec 22, 2012 12:30 pm
by sonicforvergame
just tell me already :shock:
]
jow do you want me to know if i don't understand variables
okay i will try:
i put the

"lives=3;" code in the view actor
after that i put
"lives--; // reduces lives by 1

if(lives>0) // if the player still has lives
{
// restart the level
// not sure how you are doing this, but it goes here within the brackets
}
"code in draw actor of sonic (the player)

RIGHT ???

Re: the death problem

PostPosted: Sat Dec 22, 2012 5:45 pm
by Soullem
Almost Right!!!, but the decreasing of the lives is in the wrong location.
Always think to yourself when "this" happens i want "that" to happen.

Put the lives--; in the action that causes a decrease in life.

Re: the death problem

PostPosted: Sat Dec 22, 2012 6:14 pm
by sonicforvergame
Atta boy soullem thanks for the tip
i was going to put a demo of my next game"sonic 1 hd "(i am getting tired of saying this )
without health and that would be really boring but now i can :P
Game editor users you are going to get a "High deffinition sonic game " game directly from my computer
hell yeah

by the way so i wont be selfish
thanks Skyderieng for your awesome code :)

Re: the death problem

PostPosted: Sun Dec 23, 2012 1:31 am
by skydereign
sonicforvergame wrote:just tell me already :shock:
]
jow do you want me to know if i don't understand variables

That is why I tried to explain variables to you. That explanation usually is the easiest for people to understand who don't have any coding background. So, do you now understand?

Re: the death problem

PostPosted: Sun Dec 23, 2012 11:03 am
by sonicforvergame
Yup it's more easy now but if i want to use a variable that is not for Number "integer" i think
what do i use "string or real" variable??

Re: the death problem

PostPosted: Sun Dec 23, 2012 11:10 am
by skydereign
If you want a decimal number, you can use a the variable type real. If you want a string, you use string. If you don't already know, a string is actual text, for instance "hello" is a string. If you only want a single character, you have to declare it in global code using the type char.

Re: the death problem

PostPosted: Sun Dec 23, 2012 1:55 pm
by sonicforvergame
OK thanks
but if i want to make a variable called "Die"
in that case i want that when my actor touch any enemie he "die"
what kind of variable should i use and how do i put it in a code ?

Re: the death problem

PostPosted: Sun Dec 23, 2012 9:10 pm
by skydereign
sonicforvergame wrote:what kind of variable should i use and how do i put it in a code ?

That is something you are going to have to tell me.

sonicforvergame wrote:but if i want to make a variable called "Die"

So you want to create one of these pieces of paper in the game to track some information, and you want to call it Die. Why are you having the game keep track of this variable? What do you want it to store?

sonicforvergame wrote:in that case i want that when my actor touch any enemie he "die"

In what case? If the Die variable exists? Why does this need a variable?

Re: the death problem

PostPosted: Sun Dec 23, 2012 10:47 pm
by sonicforvergame
oh no this is past stuff i wanted to make clear but it's not important anymore i found out how to work things up :mrgreen: