Community

AGI Programming => Mega Tokyo AGI Archive => Topic started by: gennadiy on March 23, 2004, 02:56:09 AM

Title: Time issue
Post by: gennadiy on March 23, 2004, 02:56:09 AM
Is it possible to add time to your game, like you have 5 minutes to complete the quest or sth?, so what I mean is that time counts from 5 minutes to zero and when it reaches zero then the quest or mission is failed?  ???
Title: Re:Time issue
Post by: Brian Provinciano on March 23, 2004, 02:57:58 AM
Yes, you can look in the docs at the time variables. As well, you can look in such games as Space Quest for how it's done.
Title: Re:Time issue
Post by: Allen on March 23, 2004, 03:12:20 AM
For a timer counting down, try something like this. This code is buggy, because I have no reference right now.
Code: [Select]

if(v12 == 0){   // where v12 is minutes
v30 = 5;        // where 5 is the time you want to count down from
}

if(v11 >= 1){  //v11 is seconds
v31--;          //minuses 1 every second.
}

if(v31 == 0){
v30--;         //takes one minute
v31 = 60;    //sets the seconds back to 60.
}

if(v30 == 0){ // if the minutes are zero
print("THE END");
}
You could also try,
Code: [Select]

if(v12 == 5){
print("THE END");
}
Title: Re:Time issue
Post by: Sami Tervo on March 23, 2004, 05:09:30 AM
Here's lil modification of timecode from my own project.

if(f5){
  load.pic(v0);
  draw.pic(v0);
  discard.pic(v0);
  show.pic();

  reset(f40);
  reset(f41);
  v40 = 0;
  v41 = 0;

  v42 = 5; // Time left (minutes)
  v43 = 0; // Time left (seconds)
}
// Minutes
if(v12 != v40){
  v40 = v12;
  set(f40);
}
if(f40){
  v41--;
  v43 = 60;
}
reset(f40);

// Seconds
if(v11 != v42){
  v42 = v11;
  set(f41);
}
if(f41){
  v43--;
}
reset(f41);

display(24,2," Time remaining [ %v41:%v43 ]  ");

if(v41 == 0 && v43 == 0){print("You ran out of time!");}

return();