Page 1 of 1

Units in Game Editor

PostPosted: Thu Mar 08, 2012 7:38 pm
by SuperSonic
Hey guys! =D

I was doing some thinking today and I thought "Hey, wouldn't it be cool if you could use units like centimeters and seconds in GE?". So I created some simple code that let's you do just that. Here it is ^.^
Code: Select all
#define GAMESCALE 1

#define MM  (0.43    * GAMESCALE)
#define CM  (43      * GAMESCALE)
#define M   (4300    * GAMESCALE)
#define KM  (4300000 * GAMESCALE)

#define IN  (108     * GAMESCALE)
#define FT  (1296    * GAMESCALE)
#define MI  (6842880 * GAMESCALE)

#define MS  (real_fps / 1000)
#define SEC (real_fps       )
#define MIN (real_fps * 60  )
#define HR  (real_fps * 360 )


Now here is how everything works. First of all, you have your "GAMESCALE". This is basically the proportion of your game reletive to the real world. So when it's set to 1, that means that everything is the same as in real life. Now after that, you have all of your units. Here is some example code showing how to use them.

global code:
Code: Select all
int time = 0;

Player -> Create Actor -> Script Editor
Code: Select all
x += 1 * IN;//This makes the player move to the side one inch

Player -> Draw Actor -> Script Editor
Code: Select all
i++;
if(i > 1 * MIN)//After one minute...
{
    b = 0;//...The actor will turn yellow
}
y += 2 *CM/SEC;//The actor moves down two centimeters per second

So yeah, that's it. I hope you can find useful in some way -_^

SuperSonic

Re: Units in Game Editor

PostPosted: Thu Mar 08, 2012 10:21 pm
by phyzix5761
I like it! Thanks!

Re: Units in Game Editor

PostPosted: Fri Mar 09, 2012 5:53 pm
by SuperSonic
Thanks. Glad you like it ^^