the death problem

Non-platform specific questions.

the death problem

Postby sonicforvergame » Thu Dec 20, 2012 3:11 pm

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
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby skydereign » Thu Dec 20, 2012 9:02 pm

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
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: the death problem

Postby sonicforvergame » Fri Dec 21, 2012 4:48 am

Awesome i might give you final demo of "green hill zone act1 sonic 1 hd "
yeah big title :P
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby sonicforvergame » Sat Dec 22, 2012 10:17 am

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

say where to put the code
and i am not very good with variables
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby skydereign » Sat Dec 22, 2012 10:33 am

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: the death problem

Postby sonicforvergame » Sat Dec 22, 2012 12:30 pm

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 ???
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby Soullem » Sat Dec 22, 2012 5:45 pm

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.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: the death problem

Postby sonicforvergame » Sat Dec 22, 2012 6:14 pm

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 :)
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby skydereign » Sun Dec 23, 2012 1:31 am

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: the death problem

Postby sonicforvergame » Sun Dec 23, 2012 11:03 am

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??
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby skydereign » Sun Dec 23, 2012 11:10 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: the death problem

Postby sonicforvergame » Sun Dec 23, 2012 1:55 pm

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 ?
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: the death problem

Postby skydereign » Sun Dec 23, 2012 9:10 pm

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: the death problem

Postby sonicforvergame » Sun Dec 23, 2012 10:47 pm

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:
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron