Hi.
I'm doig a breakout game using DirectX and DirectDraw. I have used the keyboard to move the pad and the ball. But the problem is that when the ball is moving, if i try to move the pad the ball will stop in its place. Can someone plz help me with my problem? This is very urgent.
I would appreciate it also if someone has a breakout game made using DX and DirectDraw that I can base my work on.
Thank you a lot.
Hmm, I'm not sure I understand the problem exactly - is this right? The ball stays stationary while you move the paddle, and doesn't continue to move until you leave the paddle still?
If I've understood correctly, then it sounds like you need to collect your input and act on it a little differently. Generally you shouldn't act on your input as soon as you collect it, you store the input and then apply changes to the components of the game (the paddle, ball and bricks in this case) all at the same time, once you have collected the input. Your architecture should look something like this:
Code:
Do While Game.Running = True
CollectInput()
PerformGameLogic()
RenderGraphics()
WaitForNextCycle()
Loop
That's a very simple example. Is this more or less how you are doing it?
Here you go. I've basically changed the input code to assign an array of 256 booleans (each representing a keycode) a value of true or false. When a key is pressed, key(keycode) is assigned true, and when the key is released the value is assigned false. Take a look through the code, I've commented some of it out and added some new code.