Time

Hi,

I am working on a 2D game and I would like to know how I can make time (from 300 seconds) going down and down untill 0.

Thank you.

I can only waste time, but making one is really difficult ;).

Counting down… simple:

count up and substract the result from your limit:

Property type timer “time” [is counting up]
Property type float “downTime” [to store the count down result]
Always sensor (True Pulse) -> AND-> property actuator mode:[Assign] prop:downTime value:300-time

that didn’t work. does it work with a text convertedto a mesh?
Here is the blend. file:
blender.blend (150 KB)

Text?
That has nothing to do with text. text can be used to display the number.
You requested how to count time.

If you use text object (bge 2.5x only) you need to set the text to display via Python (cont.owner.text = “newValue”).
If you use a Bitmap font object (all BGE versions) you can set a String Property “Text” with the value to be displayed (or Python cont.owner[“Text”]=“newValue”).

i mean how can i make text on the upper right who shows 300 and goes to 299,then 298, then 297, then 296, then 295, etc(the number goes -1 every second)

okay the easiest way to print time on the screen is to print a property (“show debug properties”)
another way is to use a bitmap (looks alot nicer)
you should follow this tutorial
http://www.tutorialsforblender3d.com/GameDoc/Text/Text_GLSL_Steps_1.html

You can do it with meshes, but I assume you’re looking for this:
http://www.tutorialsforblender3d.com/GameDoc/Text/blend/Text_GLSL_BGE.blend

You’d do what monster said, but call the property which has your 300 counting down Text on the object

:smiley:

I mean the thing I want is the number 300 who goes every second -1 number untill zero

Lost in translation?
No, your text object will not work!
You need to apply a special font texture to a plane, and then control the number on that plane with “Properties”, either Logic Bricks or Python scripts!
The users above kindly pointed some useful links about “text on the GE”!
Bye


Here is a really basic example, that counts from 300, once it reaches 0 it stops
How does it work?
Well, you have two properties:
time
enable

enable is the property that says to the script YES YOU CAN COUNT
time is the time property, that is made smaller each second.

The always sensor has true pulse, which means it will execute more than once. (simple explaination). Then, it has the F value set to 60, which means every 60 logic ticks, it sends a True Pulse.
Because logic is executed at rougly 60 hz (60 times a second) this corresponds to 1 pulse per second.
This is linked to an And controller, which checks if the enable property is letting the timer continue, AND if the always sensor has sent a pulse. This AND controller connects to property actuator, which adds a value of (-1) to the time property.
The other logic bricks wait until the timer property is 0, then set enable to FALSE, and stop the countdown.