Timelimit bar

Started by madradubhcroga, Wed 16/05/2012 22:29:29

Previous topic - Next topic

madradubhcroga


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

Khris

The easiest way to show a clipped image is putting it on a button and changing its dimensions.

Code: ags
// inside game_start
  bMyFirstBar.ClipImage = true;


Code: ags
// 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();
  }

madradubhcroga

Thankyou, I'll try that.

madradubhcroga



is bMyFirstBar defined in the GlobalScript.ash header?


something like this
Code: ags


bMyFirstBar=gGui2;



or
Code: ags

bMyFirstBar=(29);
 



maybe?



Khris

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.

Kweepa

Also, to get
Code: ags
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.
Still waiting for Purity of the Surf II

SMF spam blocked by CleanTalk