Solved Time Up text

Question that is answered or resolved.

dantedevil

Well-known member
I am currently working on the bonus stage and I see that when the time is up, the Stage ends quickly.
It would be good if, when the time was up, the text "TIME UP" would appear.
I have tried to do it, but I have not succeeded.
 
Last edited:
Solution
I've done making the timer and here it is:

Code:
name    	Timer
health	 	100
type    	none
antigravity	100
subject_to_wall	0
offscreenkill	3000
animationscript	data/scripts/prscript.c
load		DTime
script	@script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


anim	idle
@script
    if(frame==2){
      void self = getlocalvar("self");
      int Health = getentityproperty(self, "health");

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
@end_script
	delay	1
	offset	1 1
	frame...
Dante, I've made something like this on my game (works for stage clear), but you can adapt it for time over.

DC had included the game time as a openborvariant, so you can check it and make that message to appear.
 
O Ilusionista said:
Dante, I've made something like this on my game (works for stage clear), but you can adapt it for time over.

DC had included the game time as a openborvariant, so you can check it and make that message to appear.

Thanks friend!
It seems to be just what I need.
I've seen how the messages work in your bonus stage and it's great.
I'm not sure I understand exactly what it means: "DC had included the game time to openborvariant, so you can check it and make that message to appear."
I have been studying how the system works and I have no idea how to use it when time is running out.
 
It's not that complex. Take a look:

You can spawn a fake entity on the stage, right on start. That entity would check the new openborvariant game_time, added by DC in 4456 build.

Make it get the game_time in the first frame, than make it check for the game_time in the next frame (make it loop with 2 frames for checking). When it detects the game_time is zero, make it change to another aniation where it spawns a text type entity (as I do in my game) to show the animation you want.

if you take closer to the entity I made, I even finish the stage by script
Code:
@cmd	finishlevel
 
O Ilusionista said:
It's not that complex. Take a look:

You can spawn a fake entity on the stage, right on start. That entity would check the new openborvariant game_time, added by DC in 4456 build.

Make it get the game_time in the first frame, than make it check for the game_time in the next frame (make it loop with 2 frames for checking). When it detects the game_time is zero, make it change to another aniation where it spawns a text type entity (as I do in my game) to show the animation you want.

if you take closer to the entity I made, I even finish the stage by script
Code:
@cmd	finishlevel

Thanks for your explanation, although it really is not very clear to me.
Also, I have not updated my mod for the new builds.
I'm still using OpenBOR_v3.0_Build_4432, since it seems too much work to have to adapt all things to work properly.
Like the new bbox system, etc. There are too many changes and I do not think it's worth so much work.
 
It's the same verison I still use.
Like the new bbox system
It's optional.

So you have two options:

1- Use the same techinique I've used on my game (although its for stage clear, not time over)
2- Use a fake entity with a long delay on the first frame (the same ammount of time you have on the stage, for example). On the second frame, spawn the text type entity animation and end the level with the script above.

The problem with option 2 is - if you have pause/freeze codes (like pausing everyone during a fatality), maybe it would pause the fake entity and the counter will get out of sync. But I think you can add that non-freeze code on it and it should work.
 
Thanks for the info about the new bbox system.

So let me see if I understood well:

The best method is the first.
But if I want to use it for the time up, do I need to change to build 4456 build?

 
I have second method and it works ok.I set time to 30
Code:
anim	attack4
	loop	0
	offset	65 164
	bbox	14 14 104 154 40
				@script
                void self = getlocalvar("self");
 	if( frame == 1 ){
    	settextobj(1,	290 , 420 , 0, -1, "FIND YOUR WAY OUT BEFORE TIME RUNS OUT !" , openborvariant("elapsed_time")+2500);
	}
    	if( frame == 3 ){
    	settextobj(1,	430 , 230 , 3, -1, "YOU FAILED !!!" , openborvariant("elapsed_time")+2500);
	}

	@end_script	
        delay	20
	frame	data/sprites/sbox1.gif
	delay	5700
	frame	data/sprites/sbox1.gif
	delay	20
	frame	data/sprites/sbox1.gif
	sound	data/sounds/bou.wav
	frame	data/sprites/sbox1.gif
	frame	data/sprites/sbox1.gif
	frame	data/sprites/sbox1.gif
	frame	data/sprites/sbox1.gif
 
I've done making the timer and here it is:

Code:
name    	Timer
health	 	100
type    	none
antigravity	100
subject_to_wall	0
offscreenkill	3000
animationscript	data/scripts/prscript.c
load		DTime
script	@script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


anim	idle
@script
    if(frame==2){
      void self = getlocalvar("self");
      int Health = getentityproperty(self, "health");

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
@end_script
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
	delay	99
	frame	data/chars/misc/empty.gif
	delay	1
	frame	data/chars/misc/empty.gif
	@cmd	spawn05 "DTime" 160 0 190 320
	frame	data/chars/misc/empty.gif
	@cmd	jumptobranch "Lanjut" 1
	frame	data/chars/misc/empty.gif

anim	spawn
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif

spawn05 function is for spawning Time Up message (DTime entity). It can be replaced with spawnframe function
This timer can be set like delay e.g

spawn Timer
health 200
coords 160 200
at 0

Timer will wait for 20 seconds before showing Time Up message and ends current level
Unlike delay, Timer is not enemy type so it will be ignored by group

Oh yes, Timer also has time display similar to default timer which shows how many time left in seconds
 
Solution
Back
Top Bottom