3
votes

1.

TIMING in a game: Is there a way to use other then System.Currentmillis()-starttime>XX to update anything in a game? Is it safe or CPU expensive?

2.

In my game I have 20 items (moving square vertexes), when it comes up to 60-70 vertex, the FPS drop down to 30-40 FPS, from 60 FPS. (testing on a galaxy S i9000 phone). Is there a way to my game FPS will be 30FPS? Is it good for update my game to 30 FPS, or I dont need to handle this? (because there will be a lagg on lower FPS - it will be slow)

How I can do to my objects run on the same speed, at any time?

3.

what is the best way: do the phisyx, and all the stupp in onDrawFrame, or: start a Thread what is made the mathematics for me? What is faster and better?

1

1 Answers

11
votes

TIMING in a game: Is there a way to use other then System.Currentmillis()-starttime>XX to update anything in a game? Is it safe or CPU expensive?

You should use a time delta system. There are a lot of tutorials about this. This is a very good tutorial: deWiTTERS Game Loop.

In my game I have 20 items (moving square vertexes), when it comes up to 60-70 vertex, the FPS drop down to 30-40 FPS, from 60 FPS. (testing on a galaxy S i9000 phone). Is there a way to my game FPS will be 30FPS? Is it good for update my game to 30 FPS, or I dont need to handle this? (because there will be a lagg on lower FPS - it will be slow)

That's depending on which method you're using. If 3D, you should consider using Vertex Buffer Objects (VBO:s) (like a Vertex Array but in your device's GPU memory). That makes a huge difference since the CPU doesn't need to copy the data from CPU to GPU every iteration.

If 2D, you can still use VBO:s but if draw_texture is supported on the device that's recommended.

However, the options are:

  • Vertex Arrays (slowest).
  • Vertex Buffer Objects (fastest in 3D, slower than draw_texture in 2D).
  • draw_texture extension (fastest in 2D, but doesn't render 3D stuff).

You can support all of this methods to cover the whole range of Android devices but remember to check the extensions of the device's OpenGL drivers. Some might support all of these, but there can be devices that only support Vertex Arrays and VBO:s (for example).

I've answered a related question here, but just to show you; here's a print from one of Chris Pruett's lectures at Google I/O: drawing stuff

How I can do to my objects run on the same speed, at any time?

You can't. Android is a multi-processing operating system and you have no idea what's going on (maybe another Service application is updating?). What you can do is to use a time delta system, like I mentioned above.

what is the best way: do the phisyx, and all the stupp in onDrawFrame, or: start a Thread what is made the mathematics for me? What is faster and better?

It's recommended to multi-threading (two Thread's running in parallel). Shortly, do your drawing stuff inside onDrawFrame and update stuff inside your own created Thread/Runnable.

Recommended resources: