Okay, dumb question...

How could I get this to subtract lets say 5.Code:`PlayerX --;`

Thanks!

Printable View

- 03-09-2012, 03:36 AMAlkorAdding/Subtracting a int
Okay, dumb question...

Code:`PlayerX --;`

Thanks! - 03-09-2012, 03:40 AMNormRe: Adding/Subtracting a int
Use an assignment statement.

- 03-09-2012, 04:12 AMAlkorRe: Adding/Subtracting a int
If i assign it then i cant add more to it later on...

- 03-09-2012, 04:15 AMjcarosella10Re: Adding/Subtracting a int
use the -= operator, which is equivalent to

PlayerX = PlayerX - x;

so do

Code:`PlayerX -= 5;`

- 03-09-2012, 04:18 AMNormRe: Adding/Subtracting a intQuote:

i cant add more to it later on..

- 03-09-2012, 04:21 AMjcarosella10Re: Adding/Subtracting a int
hahahahahaha

if i could like that reply, i would. - 03-09-2012, 04:27 AMAlkorRe: Adding/Subtracting a int
Thanks jcarosella10, thats what i was looking for

- 03-09-2012, 04:30 AMjcarosella10Re: Adding/Subtracting a int
your welcome. That works for all the operations like +=, *=, /=

- 03-09-2012, 04:40 AMNormRe: Adding/Subtracting a int
It is still an assignment statement.

- 03-09-2012, 05:05 AMjcarosella10Re: Adding/Subtracting a int
I know. I don't think he knows though

- 03-09-2012, 08:32 AMsunde887Re: Adding/Subtracting a int
@op, *=, +=, -=, /=, and %= are equivalent to

Code:`int x = 1;`

x = x + 1;