real Time Clock - Am and PM, not militarry!

Learn how to make certain types of games and use gameEditor.

real Time Clock - Am and PM, not militarry!

Postby Hblade » Fri Sep 11, 2009 3:53 am

Hi guys, I found a way to be able to read REAL TIME CLOCK, not militarry time. So in other words it wont be saying stuff like, 22:22, it'll say 11:22 PM :D Anyways, here's the code
Code: Select all
int Hour;
int Mode;
void DisplayTime()
{
    stTime u = getTime();
    if (Mode == 0)
    {
    sprintf(text, "%d:%d:%d AM", Hour, u.min, u.sec);
    }
    if (Mode == 1)
    {
        sprintf(text, "%d:%d:%d PM", Hour, u.min, u.sec);
    }
    if (u.hour<13)
    {
        Hour = u.hour;
    }
    if (u.hour>12)
    {
        Mode = 1;
    }
    if (u.hour<12)
    {
        Mode = 0;
    }
    if (u.hour == 12)
    {
        Mode = 1;
    }
    switch(u.hour)
    {
        case 13:
        Hour = 1;
        break;
        case 14:
        Hour = 2;
        break;
        case 15:
        Hour = 3;
        break;
        case 16:
        Hour = 4;
        break;
        case 17:
        Hour = 5;
        break;
        case 18:
        Hour = 6;
        break;
        case 19:
        Hour = 7;
        break;
        case 20:
        Hour = 8;
        break;
        case 21:
        Hour = 9;
        break;
        case 22:
        Hour = 10;
        break;
        case 23:
        Hour = 11;
        break;
        case 24:
        Hour = 12;
        break;
    }
}


=]How to use[=
In your text actor, click Add - Draw Actor - Script editor, then put this code in it
DisplayTime();
then click ok, and watch as it displays real time.
here's a screenshot
screenys.jpg



Hehe... I made a lil system clock.
Untitled.jpg


12:00 AM Fix:

I foudn out that uh... if it's 12:00 Am then it uh... sets it'sself to 0, but now I fixed that. here's the code
Code: Select all
int Hour;
int Mode;
void DisplayTime()
{
    stTime u = getTime();
    if (Mode == 0)
    {
    sprintf(text, "%d:%d:%d AM", Hour, u.min, u.sec);
    }
    if (Mode == 1)
    {
        sprintf(text, "%d:%d:%d PM", Hour, u.min, u.sec);
    }
    if (u.hour<13 && u.hour>0)
    {
        Hour = u.hour;
    }
    if (u.hour>12)
    {
        Mode = 1;
    }
    if (u.hour<12)
    {
        Mode = 0;
    }
    if (u.hour == 12)
    {
        Mode = 1;
    }
    if (u.hour == 0)
    {
        Hour = 12;
    }
    switch(u.hour)
    {
        case 13:
        Hour = 1;
        break;
        case 14:
        Hour = 2;
        break;
        case 15:
        Hour = 3;
        break;
        case 16:
        Hour = 4;
        break;
        case 17:
        Hour = 5;
        break;
        case 18:
        Hour = 6;
        break;
        case 19:
        Hour = 7;
        break;
        case 20:
        Hour = 8;
        break;
        case 21:
        Hour = 9;
        break;
        case 22:
        Hour = 10;
        break;
        case 23:
        Hour = 11;
        break;
        case 24:
        Hour = 12;
        break;
    }
}


Anyways, yeah now the clock is fixed :D

Enjoy
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Chai » Fri Sep 11, 2009 11:48 am

It's very good idea
I'm still thinking how to apply this to a game.
Good job.
Thank you very much for your contribution.
User avatar
Chai
 
Posts: 361
Joined: Sat Apr 30, 2005 2:26 pm
Location: Thailand
Score: 30 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Fri Sep 11, 2009 2:22 pm

Thanks :D Anyway, to apply this in your game, simply make a text actor, then go to draw actor, then put DisplayTime();



In Global code you need to put the code up top before you can use DisplayTime();
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby NUTINC » Tue Sep 22, 2009 5:12 am

I can see some uses for this in an economic game :twisted:
To those of you out there, I am not dead. I am a ghost! There is a difference!
Currently Working on: Parts, A self-assembling adventure
User avatar
NUTINC
 
Posts: 98
Joined: Fri Feb 09, 2007 1:06 am
Location: Lost in the deep dark recesses of my mind, wondering why the exit sign leads to brick wall
Score: 6 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby BloodRaven » Fri Oct 02, 2009 6:01 pm

Nice mannn thanks , thanks a lot ......

Really i am looking for a code like this .....
I have created a CLOCK but it is little different becoz of the game.But i am trying to create a clock like a real clock.
I posted a small demo [my clock ] Can you help me in completing that clock to looks like a real clock ...
My clock is set on the HEALTH BAR ....
I am using lines to draw that " tics " ..... Its rotating but it is based on a PATH which is set by me...
I can complete that clock but only using PATHS.

Here is the method :
I created 2 actors [ hidden ]
I set their paths to rotate the base ....
and i set code to draw lines to follow each actor.So it moves....

The speed is adjusted in the path ; can you give any idea how to get the real values else any other method ????
Do you have any idea to create or get values of minutes ; seconds ; and hours separately ????
Attachments
GEClock.rar
This is my clock
(629.21 KiB) Downloaded 265 times
GEClock.jpg
My Clock with Your Clock
blooDRaven
User avatar
BloodRaven
 
Posts: 52
Joined: Sun Jul 26, 2009 11:53 am
Location: India
Score: 1 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Sun Oct 04, 2009 6:10 pm

FREAKIN LONG FOR A SUCH CODE...
Try this one :D
Code: Select all
stTime t=getTime();
sprintf(text,"%i:%i %s",t.hour%12,t.min,(t.hour<12)?"am":"pm");
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Kalladdolf » Mon Oct 05, 2009 7:15 pm

Yea, Bee-ant, that's what I'd have done lol.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Mon Oct 05, 2009 8:41 pm

Whats your clue? :P
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Tue Oct 06, 2009 1:59 pm

Mine looks more pro >.>
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby MrJolteon » Tue Oct 06, 2009 4:44 pm

What's wrong with military clocks?
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Tue Oct 06, 2009 5:03 pm

Hblade wrote:Mine looks more pro >.>

From which point of view? :?
We're talking about eficiency... :P

@Jolty: Making real time clock doesnt mean hate the military one. We are just look for another variation.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Kalladdolf » Tue Oct 06, 2009 6:43 pm

Bee-Ant wrote:
Hblade wrote:Mine looks more pro >.>

We're talking about eficiency... :P

Exactly.
Complicated ≠ Pro (not referring to pyro here).
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Bee-Ant » Tue Oct 06, 2009 11:40 pm

Kalladdolf wrote:(not referring to pyro here).

Looking his codes just make me headache. I wonder where's that boy now?
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby Hblade » Wed Oct 07, 2009 12:52 am

Lol o.o I know but I didnt know you could do that THAT easy lol :O. And yeah Pyro's code gives me a headache too lol.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: real Time Clock - Am and PM, not militarry!

Postby DST » Wed Oct 07, 2009 12:55 am

So this script you wrote:

Code: Select all
   switch(u.hour)
    {
        case 13:
        Hour = 1;
        break;
        case 14:
        Hour = 2;
        break;
        case 15:
        Hour = 3;
        break;
        case 16:
        Hour = 4;
        break;
        case 17:
        Hour = 5;
        break;
        case 18:
        Hour = 6;
        break;
        case 19:
        Hour = 7;
        break;
        case 20:
        Hour = 8;
        break;
        case 21:
        Hour = 9;
        break;
        case 22:
        Hour = 10;
        break;
        case 23:
        Hour = 11;
        break;
        case 24:
        Hour = 12;
        break;
    }


is equal to:
Code: Select all
Hour=u.hour-12;


Just throwing that out there.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest