code prob

Game Editor comments and discussion.

code prob

Postby DarkParadox » Sun Feb 25, 2007 10:55 am

at the begining i set life=3
whats wrong with this code ???
Code: Select all
if(stab==1)
{
    DestroyActor("enemy1");
}
else
{
    life-1;
}

(by the way i set it on collision)
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Postby DilloDude » Sun Feb 25, 2007 11:06 am

Try
Code: Select all
life -= 1;
(or -- is the same as -= 1)
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DarkParadox » Sun Feb 25, 2007 11:37 am

:( it did not work
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Postby Troodon » Sun Feb 25, 2007 11:53 am

Try
life = life - 1
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby Sgt. Sparky » Sun Feb 25, 2007 1:24 pm

tekdino wrote:Try
life = life - 1

Code: Select all
life -= 1;
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby irblinx » Sun Feb 25, 2007 1:34 pm

Code: Select all
life--;


should also do the same thing
irblinx
http://www.irblinx.me.uk/Crania.htm
Current projects: Crania deluxe for Mac, iCrania
User avatar
irblinx
 
Posts: 122
Joined: Wed Apr 19, 2006 11:15 am
Location: Manchester, UK
Score: 6 Give a positive score

Postby Sgt. Sparky » Sun Feb 25, 2007 1:44 pm

is that still valid C?
:)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Kodo » Sun Feb 25, 2007 4:07 pm

Sgt. Sparky wrote:is that still valid C?
:)


life++;
life = life + 1;
life += 1;
Are all ways of adding 1 to life


life--;
life = life - 1;
life -= 1;
Are all ways of subtracting 1 from life

All three methods are valid C, how you write it is all down to preference. Usually you'll start out writing the long version ( life = life - 1; ) just because its easily understandable, but all methods provide the same result :)
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby Game A Gogo » Sun Feb 25, 2007 11:17 pm

their also Valid C++ ;)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Mon Feb 26, 2007 12:00 am

I was only askin' bout' the -- :P




:D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby DilloDude » Mon Feb 26, 2007 2:08 am

diormeh wrote::( it did not work
What is it doing?
Last edited by DilloDude on Tue Feb 27, 2007 1:32 am, edited 1 time in total.
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby HillBilly » Mon Feb 26, 2007 2:51 am

Did you rember so set up the "Life" variable in global?
HillBilly
 
Posts: 68
Joined: Thu Jun 08, 2006 4:31 am
Location: OHIO, USA
Score: 4 Give a positive score

Postby Sgt. Sparky » Mon Feb 26, 2007 3:14 am

or as an actor var if you have many actors :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby DarkParadox » Wed Feb 28, 2007 11:25 pm

noothiing worrksss :cry: :cry: :cry: :cry:
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Postby DilloDude » Thu Mar 01, 2007 12:01 am

Which part isn't working? is the actor not destoying? Is life not changing? or all of the above?
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron