Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: madradubhcroga on Wed 16/05/2012 22:29:29

Title: Timelimit bar
Post by: madradubhcroga on Wed 16/05/2012 22:29:29

Hi.

Does anybody know how to make a bar that gets shorter as the time runs out?

I'm looking at the "Topic: How to make a bar that shows an int value?"

and I think half the answer is there... but I don't quite understand it/how to adapt it.

Eg: 10 seconds = full bar (unclipped image)
        5 seconds = half bar (50% clipped)
        1 scond    =  10% bar


thankyou
Title: Re: Timelimit bar
Post by: Khris on Thu 17/05/2012 01:52:51
The easiest way to show a clipped image is putting it on a button and changing its dimensions.

Code (ags) Select
// inside game_start
  bMyFirstBar.ClipImage = true;


Code (ags) Select
// inside repeatedly_execute
  if (player.Room == 5 && deadly_mechanism_activated) {
    time_left--;  // one frame
    bMyFirstBar.Width = time_left/40;   // one pixel per second
    if (bMyFirstBar.Width == 0) GameOver();
  }
Title: Re: Timelimit bar
Post by: madradubhcroga on Thu 17/05/2012 18:17:07
Thankyou, I'll try that.
Title: Re: Timelimit bar
Post by: madradubhcroga on Fri 18/05/2012 19:19:52


is bMyFirstBar defined in the GlobalScript.ash header?


something like this


bMyFirstBar=gGui2;



or

bMyFirstBar=(29);




maybe?


Title: Re: Timelimit bar
Post by: Khris on Fri 18/05/2012 22:12:51
First of all, stop putting ( and ) around fixed values. Round brackets are needed for conditions, functions parameters and arithmetics only. 29 is 29, even for AGS.

bMyFirstBar is the button's name; when you create your Timelimit GUI, put a button on it and call it bMyFirstBar for the code to "work".
By giving a name to a button (or any other GUI element / character / object / what have you) in its properties pane, you can use that name to do stuff to the button in scripts. It's not something you need to define yourself, like a global variable. Basically, AGS already knows which button you're talking about.

The code I posted won't work as-is; the main problem here is that you've bitten off more than you can chew. You want to make a quiz game with timed events, a questions database, special puzzle rooms, etc. while you don't really have any programming skills.

My point is, in order to help you get this game done, we need to code half of it for you. That's not really the purpose of this forum. You seem to be a quick learner, but you're still missing A LOT of the basics. Take it down a notch and try to get a decent grip of the syntax first, and of how AGS works.
Title: Re: Timelimit bar
Post by: Kweepa on Fri 18/05/2012 22:47:40
Also, to get to work, use [ code=AGS][/code], or press the # button (with the 'Insert Code' tooltip) towards the right hand side of the message composition toolbar.