How can i add lives to character??

Talk about making games.

How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 1:16 am

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?
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby asmodeus » Mon Dec 17, 2007 1:40 pm

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
Attachments
s1.png
Click on "variables" in the script editor.
s2.png
Call the variable "lives_count".
s3.png
Click on "Text" and write any text.
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 2:50 pm

Is "coins_count" a new variable?
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby Kalladdolf » Mon Dec 17, 2007 2:51 pm

yeah, should be.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: How can i add lives to character??

Postby asmodeus » Mon Dec 17, 2007 2:53 pm

Yes. Add it on the same way as "lives_count". Of course you can use other names for the variables, if you want.
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 3:00 pm

How about game over when there are no more lives??
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby Kalladdolf » Mon Dec 17, 2007 3:03 pm

Code: Select all
if(lives_count < 0)
{//write your game over action here\\ ;}
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 3:07 pm

Ok, and how about restart level?
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby Kalladdolf » Mon Dec 17, 2007 3:11 pm

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)
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: How can i add lives to character??

Postby asmodeus » Mon Dec 17, 2007 3:12 pm

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)
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 3:17 pm

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!
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby Kalladdolf » Mon Dec 17, 2007 3:19 pm

so, you mean, you entered the code, but there's some bug?
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: How can i add lives to character??

Postby asmodeus » Mon Dec 17, 2007 3:20 pm

Write computer.x = ? and computer.y = ? in the script editor.
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Re: How can i add lives to character??

Postby Sondise » Mon Dec 17, 2007 3:26 pm

Ok, if there's another problem, I'll post.
User avatar
Sondise
 
Posts: 94
Joined: Thu Nov 01, 2007 11:04 pm
Location: South america
Score: 0 Give a positive score

Re: How can i add lives to character??

Postby asmodeus » Mon Dec 17, 2007 3:29 pm

I'll ever help if I can. :D
User avatar
asmodeus
 
Posts: 483
Joined: Thu Oct 11, 2007 5:04 pm
Location: Germany
Score: 43 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron