Not exactly... DX uses hardware acceleration wherever possible. You can't even BitBlt a single 1024x768 front buffers with reasonable performance. However for small games or such where you don't have to draw a full screen in each frame BitBlt is just fine. Though you don't get rotations and all the other nice features when using DXGraphics.
Yes. Use a while loop, but instead of waiting for a specified time to elapse before updating your world state, instead, calculate the elapsed time between frames and update at each loop:
Code:
Dim l As Long
Dim t As Long
Dim delta As Single
...
While running
l = t
t = GetTickCount()
delta = (t - l) / 1000
'Update
'Draw
DoEvents
Wend
You would then use delta in all update caluclations. For instance, an object is supposed to move 10 meters per second. You give that object a normalized (magnitude == 1) direction vector, and a velocity of 10. To calculate the new position of that object at each update you would do this:
Code:
nx = dir.x * vel * delta
ny = dir.y * vel * delta
This gives you correct, frame rate independant movement.
I am not sure why it is doing that. But you have to calculate the width and hight and the X Y coordinates so it can fit on the screen. I can't remember if it is BlTFast or just Blt that has the oppurtunity to have all those values as parameters, but just try with BltFast first.
Got it. As a continue for the game building:
When I want to get as many keys as possible at the same time.
I usually use GetAsyncKeyState, but when I press many keys (3+) it doesn't get them... Maybe it's my comp.
What is the way to get keys from the user?
What should I use in a two or more players game?
DX can handel your keyboard inputs too. But if you don't want to use it, you could always use the Key down and up events.
Set a boolean variable (array?) to true for every key that is pushed in the key down event. Then in the game look, check what keys that is pushed and do what ever it is supposed to do. Then in the key up event set the boolean variables to false. And so on....
Originally posted by Arie Got it. As a continue for the game building:
When I want to get as many keys as possible at the same time.
I usually use GetAsyncKeyState, but when I press many keys (3+) it doesn't get them... Maybe it's my comp.
What is the way to get keys from the user?
What should I use in a two or more players game?
Thank you,
Arie.
The problem with many keys is actually a problem with the wiring in your keyboard... everyone's does that.
Originally posted by NoteMe I managed to make it work with 8 keys on my machine with the messiest code I could think of at this minute....look here....
Right. There is an upper limit on all keyboards. It's a hardware problem.
Originally posted by NoteMe I managed to make it work with 8 keys on my machine with the messiest code I could think of at this minute....look here....
This is a good one NoteMe. Thank you.
Now I want to ask:
How do I test my Direct Play (Multiplayer) without using another comp?
Rotateing at runtime will sow your game down, you need to either load up a series of frames all of different rotation or rotate it before starting the game and rotate it into memory.
Use DXGraphics and simply rotate the edge points of the destination polygons that form your surface. See the Mouse Attack thread and download it's code; the DXGraphics module (especially the Blt function) might be of interest.
No problem. But remember that it is not as fast as if you make 60 pictures of the car at design time, and makes a sprite of all of them, and just changes the picture of the car if it moves....
No that is not what I am saying. First of all, why do you need 360 pictures. You can't need one for every degree. That sounds like to many for a game. An other thing you could do is make a game that rotates and saves a picture in as many angles as you want. And if you are lucky I a have sutch a app....
Last edited by NoteMe; May 30th, 2003 at 08:05 AM.