
-----------------------------------
poll262
Fri Mar 09, 2012 6:48 pm

Improving my game
-----------------------------------
What is the problem you are having?
I need help improving my Pong program. I need help figuring out how to make the paddles not go off the screen. Also how to make an AI that you can beat. Lastly i can't get rid o the cursor on the screen. This is my first game i made so it may not be the best. I am open to suggestions so please tell me if you think of something I should change/ add

Please specify what version of Turing you are using
Turing 4.1.1 for windows

-----------------------------------
smool
Fri Mar 09, 2012 8:56 pm

RE:Improving my game
-----------------------------------
Well, couple of things:
 -when you randomize the direction of the ball, instead of retrying over and over again, you could do DX := Rand.Int (0, 1) * 2 - 1. That will give you either 1 or -1, never 0.
-For your collisions, instead of saying if ball position = wall boundary, it would be better to say if ball position is equal to or greater than boundary: if y + 5 >= maxy then...
-very well documented, made this really easy to understand. Not enough people document their code (me included :/)

So, in terms of not letting paddles go offscreen: just check to see if the paddle is offscreen, and if it is just reset its position right at the boundary. I'm not sure if there is a way to get rid of the cursor, and if there is I am completely unaware of it.

-----------------------------------
poll262
Fri Mar 09, 2012 9:25 pm

Re: Improving my game
-----------------------------------
Thanks for the help i have figured out how to make sure the paddle doesn't leave the screen now all I want to know is if there is a way to make it possible to beat the computer.

-----------------------------------
Raknarg
Fri Mar 09, 2012 9:28 pm

RE:Improving my game
-----------------------------------
Turing doesnt allow you to change the cursor at all.

And you can, make it so the computer paddle doesnt go quite as fast as the player paddle. Eventually the computer will fail.

-----------------------------------
poll262
Fri Mar 09, 2012 9:47 pm

Re: Improving my game
-----------------------------------
I am trying to do what you said and slow down the second paddle and now the program goes really slow after a couple of second could you help me figure out why?[/quote]

-----------------------------------
smool
Sat Mar 10, 2012 12:15 am

RE:Improving my game
-----------------------------------
Forking music is fine, but NEVER FORK ANYTHING ELSE FORKS ARE EVIL YOU WILL NEVER UNDERSTAND HOW THEY WORK FOR TURING. just integrate it into your program, without a fork.

-----------------------------------
poll262
Sat Mar 10, 2012 9:19 am

Re: Improving my game
-----------------------------------
I don't understand how I could slow dwn the computers paddle without slowing down the whole game.

-----------------------------------
Aange10
Sat Mar 10, 2012 11:04 am

RE:Improving my game
-----------------------------------
Make a timer. A basic timer works like this:


% Make your timer variable
var timer : int := 0
% This is how long you want to wait before you do something
var howLongToWait : int := 20

% this is your 'Main Game Loop'
loop
    % Check your timer.
    if Time.Elapsed () - timer >= howLongToWait then
        %Do whatever you need to do
        %Restart the timer
        timer := Time.Elapsed()
    end if
end loop


-----------------------------------
poll262
Sat Mar 10, 2012 11:49 am

Re: Improving my game
-----------------------------------
Thanks the timer was exactly what I needed
