Well I'm glad to have the 'stick with it no matter what' attitude. At times you may need that. There will be times when coding something becomes 'un-fun' or you just get stuck. Happens to everyone at all skill levels.

Though I'm sure that you won't need to tell anyone here to screw anything. [size=9px]Unless you have some joint hardware project in mind. )[/size] You'll find that we are all generally friendly and helpful. Dom and I didn't tolerate poor behaviors early on so it seems to be sticking. That and we got lucky and most of those that hang out in these forums are generally good people with kind hearts.

That and I think the average age range has something to do with it. Lets face it the older you get, so the nicer you are... generally. Probably having something to do with the fact that we are all that much closer to death. :lol: I'm kidding there of course, but we are of good intentions and do want to help where we can.

So don't be discouraged, just adjust your strategy for the better. It will happen a lot.


Now to answer you more specific question; How do I make an object move independent of holding down a key?

Well the best way to do that is to have variables that hold the direction/speed of your object. Then you can have your input controls adjust these two values the way you want.

You will also have a separate block of code that handles movement alone. Generally a game's main game loop will look something like this:

[pascal]begin
Init_Game;
Reset_Game_Clock;
while(Quit_Flag = False) do
begin
Read_Player_Controls;

Move_Player;
Move_Objects;

{ ...other functions, etc... }

Clear_Screen;
Draw_Background;
Draw_Environment_or_Map;
Draw_Player;
Draw_Objects;

if (Check_for_GameOver_Conditions = true) then
Quit_Flag := True;
end;
Deinit_Game;
end.[/pascal]

Now this is just an example you may have enemies, or your 'player' might be moved using the same function to move other objects too. It all depends on the type of game you are making.

In the way of pong it's a bit more like this...

[pascal]var
BallCount : Integer = 5;
begin
Init_Game;
while(Quit_Flag = False) do
begin
Read_Player_Controls;

Move_Paddle;
Move_Ball;

Do_Ball_Collision; // involves block/wall/paddle detection, ball reaction, block removal, etc...

Clear_Screen;
Draw_Walls
Draw_Blocks;
Draw_Ball;
Draw_Paddle;

if (Ball_Went_Off_Screen(BallObject) = true) then
begin
dec(BallCount);
if (BallCount <= 0) then
Quit_Flag := True;
end;
end;
Deinit_Game;
end.[/pascal]

Your ball object would have, at least, these variables...

[pascal]var
BallX, BallY: Integer; // The location of your ball on the screen
BallVelX, BallVelY: Integer; // The Speed of your ball along X and Y axis[/pascal]

Now the ball would move on it's own using random speed/direction. You'll want to have a VelX and VelY for the ball. This is the simple 'Velocity' values for your X and Y axis movement. Each 'frame' of movement your ball will move 1 value of VelX along the X axis and 1 value of VelY along the Y axis. Do this once each time through the loop so that it is done independently.

[pascal]BallX := BallX + BallVelX;
BallY := BallY + BallVelY;[/pascal]

Now you are probably wondering "well now it just flies off the screen! What good is that?". That my friend is why you need to add wall detection.

To do this is very simple. You check your BallX and BallY values against the sides of your screen. Which would be (0,0) for your top left and (ScreenWidth,ScreenHeight) for the bottom right.

[pascal]if (BallX <= 0) then // your ball has hit the left wall
BallVelX := BallVelX * -1;// so reverse the direction by switching the sign of it.[/pascal]

See how that works? Now just do it for all 4 walls and you have a bouncing ball program with a simple movement. To turn it into pong all you have to do is add blocks and the paddle and remove the wall which you will add the paddle to. Not very far away at all.

Work with this and see what you can get going. If you have trouble or get stuck just ask and we'll do our best to help. Once you've gotten this working I can elaborate more on how to get it into a pong game. In fact, I might have that tutorial typed up by then.

Oh and if you are using JEDI-SDL have a look in the SDL/Pas folder inside sdl_utils.pas for some handy drawing functions. Namely the circle, rect and line functions. Very similar to what I had when I first learned game programming so you're in luck.