Units in Game Editor

Game Editor comments and discussion.

Units in Game Editor

Postby SuperSonic » Thu Mar 08, 2012 7:38 pm

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
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Units in Game Editor

Postby phyzix5761 » Thu Mar 08, 2012 10:21 pm

I like it! Thanks!
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: Units in Game Editor

Postby SuperSonic » Fri Mar 09, 2012 5:53 pm

Thanks. Glad you like it ^^
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest