views:

40

answers:

2

Hey
How do I get accurate counting? My game has is a pass or fail scenario based on time. I need an equation that will work in ActionScript.
Thanks

Timed-scenarios:

'Commence escape within 30 sec or lose 600 life points'

...you see only readout of lifepoints, but time needs to be accurate

I'm not attached to this, it's just an example

var CURRENTCOUNT:int = 0;
var EQUA:int;
//WHERE I WANT TO PUT LINEAR EQUATION
EQUA = 34;//<==EQUATION GOES HERE???
var SPEED:int; 
SPEED = EQUA;
var COUNTDOWN:Number = 600;
var COUNTUP:Number = 0;
//TIMER
var myTimer:Timer = new Timer(SPEED,600);
myTimer.addEventListener(TimerEvent.TIMER,someFunction);
myTimer.start();
//INCREMENTING++
function someFunction(event:TimerEvent) {
//COUNTDOWN stops count going down, COUNTUP stops count going up
CURRENTCOUNT = COUNTDOWN - myTimer.currentCount + COUNTUP;
//Testing with only a text string to rule out cashing issues 
tx.text = String (Math.abs (CURRENTCOUNT));
}

I've tried this
SPEED=DISTANCE/TIME

Other
In place of currentCount, but it's not any more accurate. It adds acceleration

//VoVf
V++;
COUNT = V*V/X;

30 seconds and 600-0 lifepoints and counting
I wanted to explain, because it's not a clock. It's pass or fail. They look at there life drifting away.

Description of lifecount
'scene with Death holding a steampunk style timer or gauge and laughing'
• Player has so many seconds to escape '30 seconds'
• Lifecount displays loss of players total life '600'
• Player can choose between more power or more life if they make it out alive


A: 

Can you clarify the problem a bit? Tell us (without any code) what you want it to do. For example:

A player starts a level with 60 seconds. Once they complete the level I want to award points based on time remaining. The faster they complete the level, the more points they receive. If the player takes more than 60 seconds, they are penalized based on the amount of time they go over by.

EDIT
Not sure how I can be more clear about what I am asking you to provide, so let me give you a real example.

A player starts the level with 60 seconds and whatever life points they have accumulated so far, say 600. As the game is played the counter goes down and the total life points drops in relation to the timer. So, if a player matching the description given has taken 30 seconds (half of the time) then the players life points will drop to 300 (half of their starting points.) If a player takes all 60 seconds, they will have 0 life points.

This is the type of description we would need to even get started in helping. The way you describe the problem makes it very difficult for someone who does not have intimate knowledge of your intentions to help.

sberry2A
@sberry2A, My counters are perfecto, but the the math is not spot on. Please help.
VideoDnd
@sberry2A, your edit's good, I'm not explaining myself
VideoDnd
@sberry2A, I did say 'reward and penalty system', so I see why that was confusing. I wanted an accurate rate of counting first. What your describing is the second phase of what I wanted to do, which is great.
VideoDnd
@VideoDnd - `I GIVE UP`
sberry2A
What's with all the trolls. Grow up!
pixelGreaser
+1  A: 

These links can explain. They go over delta time and explain ideas useful for accurate counting and scoring. I hope this gets you started.
http://www.emanueleferonato.com/2007/02/19/flash-simple-timercountdown/
http://www.allquests.com/question/2589182/how-to-pause-game.html
http://www.kongregate.com/forums/4/topics/1773
http://www.kirupa.com/forum/archive/index.php/t-286177.html

pixelGreaser
@pixelGreaser, Thanks, that look like what I need
VideoDnd