Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/26/24 12:45
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Lapsa), 1,268 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Show minutes and seconds #350766
12/19/10 00:00
12/19/10 00:00
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Hey guys!! =)

I have a question. I'm programming a game and want to show the minutes and seconds that are passed since the level started in a panel.

How can I do this? - Only found total_ticks but that's not why I was searching for.

Thanks in advance.

Greetz, Minamato

Re: Show minutes and seconds [Re: Minamato] #350767
12/19/10 00:06
12/19/10 00:06
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You can have a var called "seconds" or something like this. Every frame you add the delta time of the frame (that is time_frame / 16).

Once you need to display the minutes and seconds, its pretty simple math:
Code:
var passedMinutes = seconds / 60;
var passedSeconds = seconds % 60;



Edit: Just found "total_secs" in the manual. You can use this variable instead of counting your own variable up. However, if you want to be able to restart the game, you need to use your own variable so you can set it back any time.

Last edited by JustSid; 12/19/10 00:09.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Show minutes and seconds [Re: WretchedSid] #350780
12/19/10 01:15
12/19/10 01:15
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
thanks and happy birthday =)

Re: Show minutes and seconds [Re: Minamato] #350966
12/20/10 17:26
12/20/10 17:26
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
I think, I'm too stupid =D

If I use "total_secs" in my own var and want to show it in a panel:

Code:
var seconds = total_secs;

PANEL* zeit_pan =
{
	layer = 2;
	pos_x = 50;
	red = 0; green = 0; blue = 0; 
	digits = 0,0,"        %5.0f",fnt_score, 1, seconds;
	flags = SHOW;
}



it doesn't work - but if I use "total_secs" directly in the panel, it works fine...

and I also don't want to just show the seconds (because it isn't really nice to see that you have played 326 seconds since the game started), I want to show minutes : seconds.

need some help here...=D

Re: Show minutes and seconds [Re: Minamato] #350967
12/20/10 17:31
12/20/10 17:31
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
the you just have to divide it with 60 wink
total_secs/60


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Show minutes and seconds [Re: alibaba] #350968
12/20/10 17:44
12/20/10 17:44
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
var seconds = total_secs;


No.

You need to set this in a while (without the the var in the while).

Re: Show minutes and seconds [Re: Rei_Ayanami] #350975
12/20/10 18:22
12/20/10 18:22
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Can you give me an example please?

Re: Show minutes and seconds [Re: Minamato] #350984
12/20/10 18:59
12/20/10 18:59
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Try my example:

Code:
#include <default.c>
#define PRAGMA_PATH "%EXE_DIR%\samples"

var seconds, minutes = -1;

FONT* A20b = "Arial#20b";
PANEL* pInfo;

function main()
{
	fps_max = 60;
	level_load ("small.hmp");
	vec_set(camera.x, vector(0,0,150));
	
	pInfo = pan_create(NULL,0);
	pan_setdigits(pInfo,0,10,10,"SECONDS = %.0f", A20b, 1, seconds);
	pan_setdigits(pInfo,0,10,30,"MINUTES = %.0f", A20b, 1, minutes);
	set(pInfo, OUTLINE|SHOW);
	
	while(level_ent)
	{
		if ((total_frames %  60) == 1) seconds++;
		if ((total_frames % (60*60)) == 1) minutes++;
		wait(1);
	}
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Show minutes and seconds [Re: rojart] #350989
12/20/10 19:54
12/20/10 19:54
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
it works fine - thanks =)

Re: Show minutes and seconds [Re: Minamato] #351002
12/20/10 22:56
12/20/10 22:56
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Rojart, thats evil because you assume that the user always has 60 frames per seconds.
This is a much nicer approach:
Code:
var passedSeconds = 0;

// ...

while(level_ent)
{
	passedSeconds += time_frame / 16;

	minutes = passedSeconds / 60;
	seconds = passedSeconds % 60;
	wait(1);
}




Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1