Author |
Message |
poll262
|
Posted: Fri Mar 09, 2012 6:48 pm Post subject: 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
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
pong-V1.t |
Filesize: |
2.76 KB |
Downloaded: |
83 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Fri Mar 09, 2012 8:56 pm Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
poll262
|
Posted: Fri Mar 09, 2012 9:25 pm Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Fri Mar 09, 2012 9:28 pm Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
poll262
|
Posted: Fri Mar 09, 2012 9:47 pm Post subject: 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]
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
pong-V2.t |
Filesize: |
3.13 KB |
Downloaded: |
77 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Sat Mar 10, 2012 12:15 am Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
poll262
|
Posted: Sat Mar 10, 2012 9:19 am Post subject: Re: Improving my game |
|
|
I don't understand how I could slow dwn the computers paddle without slowing down the whole game.
|
|
|
|
|
![](images/spacer.gif) |
Aange10
![](http://compsci.ca/v3/uploads/user_avatars/19166165534f400d42de502.png)
|
Posted: Sat Mar 10, 2012 11:04 am Post subject: RE:Improving my game |
|
|
Make a timer. A basic timer works like this:
Turing: |
% 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
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
poll262
|
Posted: Sat Mar 10, 2012 11:49 am Post subject: Re: Improving my game |
|
|
Thanks the timer was exactly what I needed
|
|
|
|
|
![](images/spacer.gif) |
|