reversing variables

You must understand the Game Editor concepts, before post here.

reversing variables

Postby Kalladdolf » Thu Sep 04, 2008 9:17 am

NOTE: WHO DOESN'T WANT TO READ ALL THIS TEXT CAN JUST LOOK AT THE DEMO I POSTED!

This is actually so simple it doesn't even deserve to be posted in the advanced section.
But as my experience proved there has been a lot of confusion about that matter these days.

What someone wants to do:
He has one var which is hundred.
He has another var which is something between hundred and zero.
still with me?
He has a scale from zero to hundred and another variable which he can place anywhere between zero and hundred as he likes:

0.......................var1...............100
0..........var1............................100
0.............................var1.........100

And that isn't very hard to make.

Now here's the problem:
He has another variable, let's call it var2.

he wants var2 to have exactly the opposite value to var1.

like this:

0..........var1............................100
0............................var2..........100

or like this:

0.var1.....................................100
0.....................................var2.100

or like this:

0..................var1....................100
0..................var2....................100


the formula is (big deal X_X):

Code: Select all
var2 = var1*(-1)+100; // hundred can be replaced with a variable depending whether you also wanna change it.


For those guys who are better at learning by seeing:
here's a small demo:
r_vars.zip
O_O
(742.4 KiB) Downloaded 142 times


the question is:
what is this good for?

- if you made a health bar and saved the frames in the wrong order
- enemy avoiding techniques
- and much more

I betcha most of you knew this before... but anyway... here goes :D
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: reversing variables

Postby Azou » Thu Sep 04, 2008 11:11 am

It's usefull!Thanx,Kall!! :D
User avatar
Azou
 
Posts: 514
Joined: Thu Sep 13, 2007 1:12 pm
Score: 35 Give a positive score

Re: reversing variables

Postby DilloDude » Sun Sep 07, 2008 2:15 pm

Or just simply
Code: Select all
var2 = 100 - var1;
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: reversing variables

Postby Kalladdolf » Sun Sep 07, 2008 3:32 pm

thanks, that makes it less complicated :D
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest