2 Questions:Archives Forums/BlitzPlus Programming/2 Questions:
| 1. For a space game without the "drift" effect, should I keep speed "constant" with Delay, a timer, or Krylar's RealTime thing?|
2. Since I don't feel like typing, my other question is at the end of the topic entitled "Making a sidescroller."
IMO, Delay is not a good method to use as it really keeps the entire program from being responsive. I would use timers to determine how often keys are read and also use those timers to determine how often objects are moved in game.
If lag ever becomes an issue, you would also need use TimerTicks(:Timer) to check what number of ticks needs to be made up for; this also may lead to having a cap on how far the engine will compensate for lag so that the program will not stop responding.
The use of timers also cuts down on CPU usage and can keep many people from overheating needlessly, getting a thousand fps, etc.
To get more advanced, use some methods such as always checking time passed since last simulation and moving objects according to (speed)*(changed time). However, you must be careful about rounding off milliseconds differently on different machines because this "improved algorithm" can cause inconsistencies without careful coding.
Delay is bad, it is not for anything but the crudest of programs.
Moving a "speed" per timer tick (sometimes multiples ticks) is probably the easiest way to do things.
Checking milliseconds passed since last check can cause inconsistencies on different machines without expert understanding of how fractions of a ms can get lost, and so is difficult.
Using arrays is more efficient and can lead to things such as Falling Sand Game. However, most users prefer action games without integer values for movement, speed, etc. For any non-board game, arrays should be avoided for representing the free motion of game objects. RectsOverlap checks and line collision, point-to-line distance checks are quite good and fast enough on this decade's computers to have good gameplay.
However, plenty of board-based algorithms can go on in the background for massive speedup (pathfinding comes to mind).
As far as collisions go, the operations in rectsoverlap are mostly trivial and even line-testing functions are not very expensive.
Arrays are good for simplification (but can detract from presentation)
Algorithms for line-testing are definitely out there and are quite easy to use.
Use floats for representing position, speed, etc. of game objects and some simple checks to collide them.
| What exactly is TimerTicks(:Timer)?|
What is the falling sand game?
Thanks a lot for the answer, Rck.
| TimerTicks is a BlitzPlus function that takes a timer and returns how many times it has ticked since it was last reset (ResetTimer(:Timer)). By :Timer I meant that it is passed a timer.|
Browse the help on it in the BlitzPlus "Command Reference".
As for "falling sand", a simple internet search can go a long way.
It is a simulation of materials which is interactive and fun.
Look up "cellular automata" on a place like Wikipedia for more.
| My guilty secret: I actually don't have BlitzPlus. (The truth comes out!) I simply program strictly 2D games in Blitz3D (for now) and I couldn't find TimerTicks. I only use this forum because it's most relevant to what I do. Thanks a bunch. |
| The Blitz3D forum is also for 2D projects... |
| Really? I was under the impression that the 3D forum only dealt with 3D games. Thanks! |