Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Improving my game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
poll262




PostPosted: 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



pong-V1.t
 Description:
My pong game

Download
 Filename:  pong-V1.t
 Filesize:  2.76 KB
 Downloaded:  83 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
smool




PostPosted: 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.
poll262




PostPosted: 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.
Raknarg




PostPosted: 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.
poll262




PostPosted: 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]


pong-V2.t
 Description:

Download
 Filename:  pong-V2.t
 Filesize:  3.13 KB
 Downloaded:  77 Time(s)

smool




PostPosted: 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.
poll262




PostPosted: 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.
Aange10




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
poll262




PostPosted: Sat Mar 10, 2012 11:49 am   Post subject: Re: Improving my game

Thanks the timer was exactly what I needed
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: