Frame rate for the game? aka graphics rendering

Started by Karsten75, September 12, 2010, 11:52:03 AM

Previous topic - Next topic

thepenguin

I've seen that when the game is paused and spores are in flight, they seem to jump a few pixels every second, is this a result of low framerates, or just your algorithim
We have become the creeper...

UpperKEES

Quote from: virgilw on September 12, 2010, 03:20:12 PM
Score wise, there is no frame reason for the way it is on CW1.  I basically just focused on "score" not time.  I had web site score integration in mind.  Time in CW2 (for scoring purposes) is calculated by the number of elapsed frames since mission start.  So it's a pretty accurate thing.  Scores reduce this accuracy by mashing a very accurate frame count into an exponentially decaying range of 10000 to 0.

Quote from: virgilw on September 12, 2010, 04:04:46 PM
Yes, the score is calculated off of "seconds" not frames.  So precision is lost there.  To get those extra points you have to shave off enough to keep the time from advancing once second more.

I'm not sure if I understand the exact relationship between above two quotes. Is time in CW1 also calculated by the number of elapsed frames since mission start? If so, i.e. 378 frames would be equal to 10.5 seconds, which could be converted into a precise score, right? (And yeah, I know it's too late for that now. I noticed it before, but I never said anything. ;)) Thanks again for all your answers!

Quote from: Karsten75 on September 12, 2010, 04:47:19 PM
Next question: Can I find the frame rate delivered on my system somewhere?

I wondered the same thing. I always had it on display when tweaking my Half Life setup years ago.

Quote from: thepenguin on September 12, 2010, 05:05:39 PM
I've seen that when the game is paused and spores are in flight, they seem to jump a few pixels every second, is this a result of low framerates, or just your algorithim

This is just animation. They spin a little and because this animation isn't fluent (the end doesn't come back to the starting point exactly) the spore seems to 'jump' a little, but it doesn't actually move. Let the game run (in paused mode) for a while and you'll see they're still at the same spot.
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

knucracker

Yes, the score could be based on frame precision timing, it just isn't.  It's based off of the number of seconds that have elapsed.  So I take the frames counted, turn this into seconds and then use that to show the elapsed time and to calculate score.

Tap the "=" key during a mission then look in the lower hand corner and you will see the frame rate.  Keep in mind you may see fluctuations up and down... this is normal.  You may also see a number less than 36, and that is perfectly fine too.  The average person will probably see around 32-33 fps.  I've played the game down below 30 before.  Also note that the frame rate will appear to double when you activate double speed.

Karsten75

Quote from: virgilw on September 12, 2010, 08:08:56 PM
Yes, the score could be based on frame precision timing, it just isn't.  It's based off of the number of seconds that have elapsed.  So I take the frames counted, turn this into seconds and then use that to show the elapsed time and to calculate score.

Tap the "=" key during a mission then look in the lower hand corner and you will see the frame rate.  Keep in mind you may see fluctuations up and down... this is normal.  You may also see a number less than 36, and that is perfectly fine too.  The average person will probably see around 32-33 fps.  I've played the game down below 30 before.  Also note that the frame rate will appear to double when you activate double speed.

Easter Egg!  Nice one, Oh Sneaky One!  :P

UpperKEES

Quote from: virgilw on September 12, 2010, 08:08:56 PM
Tap the "=" key during a mission then look in the lower hand corner and you will see the frame rate.

Nice indeed! And very useful now I'm testing something:

Quote from: virgilw on September 12, 2010, 02:23:24 PM
Some units check things only every 36 frames.

When I just filled my screen with collectors, reactors and relays only, CW slowed down a lot: 7.5 FPS on my rather fast computer (full screen or windowed very tiny actually didn't matter!). You would expect these rather static units not to affect the FPS too much (I guess CW only needs to check if they are still there and connected to the network, so probably a counter is updated per unit type. Same for speed and storage, so I always wondered why a map with 40 pre-built speed nodes suffers from so much lag. Aren't these the units that you check every 36 frames? Just asking because you might be able to improve this for CW2....
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

knucracker

Units check for connectivity back to OC about once a second.  But, as you add more of them you create a larger graph of nodes.  This makes the "search" for connectivity take longer while at the same time you are increasing the number of units.

I've made great progress increasing performance for cw2 in the A* algorithm and supporting data structures.  I pretty much has to if I wanted to pull of the game I've created in CW2.  Every terrain cell is a node in a graph, and the game space is 32 x 90 (currently).  Packets are also more plentiful in CW2 so they are path finding their way through this array all of the time.

That said, CW1 isn't bad... it gets away with a lot considering only about 25% of the total processing time is devoted to game computation... of that, more than half is devoted the the Creeper CA simulation.  What's left does path finding and everything else.
75% of the cpu load is from the flash player drawing everything.... and that's another reason why when you add more units things get a little slower.

Don't get too caught up with the fps, though.  You'll start experimenting with all kinds of variables (screen size, resolution, color depth, cpu settings, flash versions, air versions, game settings, mission content.....)  It's a black hole... :)

UpperKEES

Quote from: virgilw on September 12, 2010, 11:23:24 PM
75% of the cpu load is from the flash player drawing everything.... and that's another reason why when you add more units things get a little slower.

I'm surprised by that because none of these units have animated graphics, so there's no need to redraw parts of the screen.

Quote from: virgilw on September 12, 2010, 11:23:24 PM
Don't get too caught up with the fps, though.  You'll start experimenting with all kinds of variables (screen size, resolution, color depth, cpu settings, flash versions, air versions, game settings, mission content.....)  It's a black hole... :)

No worries, I won't. I'm done with it now, so back to playing! :)
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

Karsten75

Next question then:

When you animate a blaster in CW, its turret moves in the direction it fires. Do you simply have a library ful lof blasters pointing in the various directions and you replace the graphic, or how is that done?

Echo51

Karsten: im pretty sure its a single frame he rotates on a central pivor in the direction its shooting in
Join the chat! :D
- The only echo present here...

knucracker

Blasters are made of thee sprites, one for the body, one for the gun, and one for the beam.  The body pretty much forms the base, the gun in on top of the body and gets redrawn based on the direction of fire.  The beam sprite sits between the two.  It is transparent most of the time.  When the blaster fires, I draw the line.  I also add a glow filter to the beam sprite to make the line appear to have soft edges.

The game as a whole is made up of several different 'layers'. There is a terrain sprite that holds the background bitmap.  There is a sprite above that which holds the creeper bitmap.  There are several sprite layers for the units (when they are on the ground, when they are moving).  There's a sprite for the mist... then a couple more sprites for things like dialogs and popups.

UpperKEES

Reading all of this I think you're developing damn fast! :o
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

Blaze

I've seen people on A.G take years to develop a game not even half as long as CW1 and nowhere as good.
I say, Virgil is the best developer ever. What was it? About a month or two ago and there were no screen shots, and now, it looks close to being done.

UpperKEES

#27
Quote from: virgilw on September 12, 2010, 02:23:24 PM
Since CW is frame locked, I  do most of the game logic per frame.... just not every frame.  For instance, full creeper updates come only every 8 frames.  Some units check things only every 36 frames.  I literally have a frame counter and may do something like:
if (frameCount % 8 == 0) {
   updateCreeper();
}

[...]

I sometimes mod the frameCount by a prime number (and use different prime numbers for different tasks) to help mix things up.

After trying to determine a few of these prime numbers I found:

- blasters fire every 7 frames (pretty sure about this one)
- mortars fire every 103 frames (could also be 101 or 107)

Is that correct?

How do you solve the +15% firing rate upgrade? Can they still be prime numbers?
My CW1 maps: downloads - overview
My CW2 maps: downloads - overview

Kamron3

Humans can only see 23.7 fps. The more FPS, the higher the quality.

Echo51

Lies kamron, there isent a certain FPS people can see...
Join the chat! :D
- The only echo present here...