Site hosted by Angelfire.com: Build your free website today!

 

 

 CONTENTS OF SITE

HOME
FORUMS
E-MAIL ME
ART
RM2K SECTION
RM2K3 SECTION
OLD NEWS ARCHIVE
E-MAIL UPDATER

24-Hour Date/Time System

Tutorial by: Silicon Hero (siliconhero@skytowergames.net, or waltos_1999@yahoo.com)

You'll probably notice that some of the popular RPGs have their own variations of time flow. The most basic of
these has separate cycles for day and night, which vary in length of time. Well, what if you wanted to add a
clock to your game, to more easily determine when night is falling? The following guide will show you how to
set up your date/time system, and implement it into your game.

1) First, start out by making a common event called "Running Clock", and set the event start condition to
Parallel Process. Create a few variables named TimeMinutes, TimeHours, DateDay, DateMonth, and Date Year. Don't
put them in the common event yet. First, you should have a Wait command. Set a time length for the command to
wait (between 0.5 and 1.0 seconds is good), and then place the event command Change Variable to increment the
minutes by 1. As you do this, the program will add 1 to the number of minutes in your game's world. The code
will look something like this:

////////// COMMON EVENT CODE //////////
<>Wait: 0.5 seconds (or whatever time limit you used)
<>Change Variable: [TimeMinutes] + 1
////////// END COMMON EVENT CODE //////////

Right now, if you want to check the clock to see how many minutes have passed, you can make a map with a
Clock event on it. What you need to do here is show a message displaying the time, by putting a message event
command inside it:

////////// EVENT CODE //////////
<>Show Message: \v[1] minutes have passed.

To show the value of any variable, you would insert \v[##] into your message, with ## being the number of the
variable you used. For this tutorial, I'm using 1 for TimeMinutes, 2 for TimeHours, 3 for DateDay, 4 for
DateMonth, and 5 for DateYear. Your variable numbers may vary, depending on what you've already set up.
This will show you how many minutes (in your game's world) have passed since you started playing.
////////// END EVENT CODE //////////

2) All right, you've got your basic time system ready. Let's spice it up a bit by adding hours, days, months,
and all that other good stuff. This next part will utilize fork conditions inside other forks, so read
carefully.

Underneath the first Variable Change command of your Running Clock common event, put a fork to increment the
TimeHours variable when TimeMinutes is 60 or higher, like this:

////////// COMMON EVENT CODE //////////
<>Fork Condition: If Variable[TimeMinutes] >= 60 // >= stands for "above", meaning that the first variable
is equal to or bigger than the second
<>Change Variable: [TimeMinutes] - 60
<>Change Variable: [TimeHours] + 1
:END Case

Next, we'll add calendar days to the mix. Underneath the second Variable Change command in the TimeMinutes
fork, make another fork to add to DateDay when TimeHours is 24 or higher.

<>Fork Condition: If Variable[TimeHours] >= 24
<>Change Variable: [TimeHours] - 24
<>Change Variable: [DateDay] + 1
:END Case

Once the days have been added, we can put the months in. It'll be a bit complicated to do a calendar that's
exactly like the standard Julian calendar, since you'll have to figure in leap years and months with 31 and
30 days. Let's just assume for your game that all months have an equal number of days (30 sounds reasonable).
Put a new fork inside the TimeHours fork that adds one to DateMonth when DateDay exceeds 30.

<>Fork Condition: If Variable[DateDay] > 30 // stands for "more", meaning that the first variable is greater
than the second
<>Change Variable: [DateDay] - 30
<>Change Variable: [DateMonth] + 1
:END Case

And finally, let's add years to our calendar (which really only involves using another fork). Set up this
one inside the DateDay fork, and make it add to DateYear once DateMonth goes over 12. You can make changes
to this if your game's world has fewer (or more) than 12 months.

<>Fork Condition: If Variable[DateMonth] > 12
<>Change Variable: [DateMonth] - 12
<>Change Variable: [DateYear] + 1
:END Case
////////// END COMMON EVENT CODE //////////

Now, we're going to make a few changes to our clock event, so that it displays the actual time and date.
Change the message in your Clock event to read as follows:

////////// REVISED EVENT CODE //////////
<>Show Message: Time: \v[2]:\v[1]
Date: \v[4]/\v[3]/\v[5]
////////// END REVISED EVENT CODE //////////

When you check out your clock, you should see a message like this one:
Time: 12:46
Date: 7/16/2001

There is one exception to this: if your TimeMinutes variable is less than 10, you may end up with a message
like this one:
Time: 12:4
Date: 7/16/2001

To fix that problem, we're going to - yes, that's right - use another fork. Go back to your Clock event, and
put a Fork in to show a different time message depending on whether or not TimeMinutes is less than 10. Check
the "Add ELSE Case" box when setting up the fork condition. In the top section, copy and paste your original
time message, but alter it slightly to include a zero before the TimeMinutes variable (\v[1]), so that it
looks like this:

////////// REVISED EVENT CODE //////////
<>Show Message: Time: \v[2]:0\v[1]
Date: \v[4]/\v[3]/\v[5]
////////// END REVISED EVENT CODE //////////

Your completed fork will look almost like this:

////////// REVISED EVENT CODE //////////
<>Fork Condition: If Variable[TimeMinutes] < 10
<>Show Message: Time: \v[2]:0\v[1]
Date: \v[4]/\v[3]/\v[5]
:ELSE Case
<>Show Message: Time: \v[2]:\v[1]
Date: \v[4]/\v[3]/\v[5]
:END Case
////////// END REVISED EVENT CODE //////////



 
© 2003-2004 RPG Arena.com

  RM2k New Generation SiteRing The RM2k New Generation SiteRing

This site is owned by

Redd
Previous Site List Sites Random Site Join Ring Next Site