|
-
[help] game time vs. flash time
I'm working on a strategy game and I set up a "game time" so that it takes a certain amount of time for an hour, day, month, and year to pass. That's not really my problem, though.
My problem is that now I'm building the pseudo-economy that determines how the population grows, what they need to prosper, etc. I tried at first to multiply every calculation by the "day" that is calculated in game-time. But I soon discovered that it only served to give me insane numbers and just generally mess things up.
So then I took all of that out and relied on flash time... 12fps! My functions seem to work, but they go at rapid speed.
So my question is, how can I apply game time to my pseudo-economy? I'm wanting the economy to "update" it's status at the end of every day.
Here's my game time:
Code:
onClipEvent (enterFrame) {
this._x = ((8.2*hour)*-1);
if (_root.speed>0){
counter++;
}
if (counter == (2)) {
hour++;
counter = 0;
}
if (hour == 25) {
day++;
day=day-counter;
}
if (hour == 50) {
day++;
hour=0;
}
}
It seems kind of off, but it's set up for simplicity. Right now it takes about 7 minutes for a year to pass. And it's possible to pause time in case the user wants to take a closer look at something.
Here is the roots of my psuedo-economy as of right now:
Code:
onClipEvent (load) {
popu = 100;
water = 1000;
food = 1000;
electrolysis = 3;
greenhouse = 1;
}
onClipEvent (enterFrame) {
if (_root.speed>0) {
if (electrolysis>0) {
water += 6*electrolysis;
oxygen += 3*electrolysis;
}
if (greenhouse>0) {
water -= .15*greenhouse;
oxygen -= .15*greenhouse;
}
water -= .1*pop;
oxygen -= .1*pop;
if (water<(popu+(greenhouse*.15))) {
popu -= Math.round(popu-water);
}
if (water>(popu+(greenhouse*.15))) {
popu += Math.round(1/3*popu);
}
}
}
It's not exactly how I want it, but until I establish it in terms of game-time I'll be better suited to tweek it. To put it simply, electrolysis creates water and oxygen, the population and greenhouses consume the water and oxygen. If there isn't enough water to go around, population growth stagnates, if there is more than enough, population growth increases.
TIA
Wattz
-
Hmm I dont quite understand the relationship between the in-game time and the "pseudo-economy" so its supposed to get more expensive to buy water and land as time goes by? Because right now the two codes seem to be totally independant from each other.
-
The codes were independent, because I didn't know how to apply gametime to the other.
But I've totally re-vamped the whole thing and taken out some of my sloppiness. I posted for help a bit prematurely, but I'm sure I'll have other questions eventually.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|