Page 1 of 2

How can i add lives to character??

PostPosted: Mon Dec 17, 2007 1:16 am
by Sondise
How can i add lives to character (please with lives count by number, example: x3)?? And how can i add lives during the game, for examples, after taking 100 coins?

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 1:40 pm
by asmodeus
First open the script editor and click on "variables". Click on "add" , call the variable "lives_count" and click on "add" again.
To show the lives during the game create an actor and add a text. Then use the draw actor event and open the script editor.
Use this script:
Code: Select all
sprintf(text, "Lives: x%d", lives_count);

To add a life
use this:
Code: Select all
lives_count += 1;

To lose a live write "-= 1" instead of "+= 1".

To get a life with 100 coins use the collision event from your player with the coin and use this script:
Code: Select all
coins_count += 1;
DestroyActor("Collide Actor");
if(coins_count==100)
{
    coins_count = 0;
    lives_count += 1;
}


These codes should help you. :D

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 2:50 pm
by Sondise
Is "coins_count" a new variable?

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 2:51 pm
by Kalladdolf
yeah, should be.

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 2:53 pm
by asmodeus
Yes. Add it on the same way as "lives_count". Of course you can use other names for the variables, if you want.

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:00 pm
by Sondise
How about game over when there are no more lives??

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:03 pm
by Kalladdolf
Code: Select all
if(lives_count < 0)
{//write your game over action here\\ ;}

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:07 pm
by Sondise
Ok, and how about restart level?

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:11 pm
by Kalladdolf
depends on what you wanna restart.
if only specific things, (like score, players position and, coin and live number)
set new numbers for them and move the player to the position you want him to have.
If you wanna reset competely everything, use the loadGame function.
on game over event:
Code: Select all
LoadGame("level1");

(level1 is your game then)

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:12 pm
by asmodeus
Or use this script if you have all levels in one game:
Code: Select all
view.x = ? // x-start position of the view
view.y = ? // y-start position of the view
CreateActor("player", x, y, false); // write x and y start position from the player (x, y)

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:17 pm
by Sondise
In this level, there's a race, you must win the computer, so, when i restart, I return to the initial position, but the computer not!

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:19 pm
by Kalladdolf
so, you mean, you entered the code, but there's some bug?

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:20 pm
by asmodeus
Write computer.x = ? and computer.y = ? in the script editor.

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:26 pm
by Sondise
Ok, if there's another problem, I'll post.

Re: How can i add lives to character??

PostPosted: Mon Dec 17, 2007 3:29 pm
by asmodeus
I'll ever help if I can. :D