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

Username:   Password: 
 RegisterRegister   
 bouncing ball off of walls
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
iop




PostPosted: Wed May 19, 2004 7:08 pm   Post subject: bouncing ball off of walls

I have a ball that starts out in the middle of the screen, drops down. From there, I need the ball to start bouncing around the whole screen. My problem is that the screen isnt the average Turing screen. I have mine edited to cover the whole area of the computer screen of the computer that my program is running on. I would love some help on how I could make the ball bounce around the whole screen.
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed May 19, 2004 7:19 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=75

Collision detection.

Also:

- you most likely will need to check for the ball's position. So...

code:

var ballX, ballY : int := 0

%...some code drawing ball etc.

if ballX < maxx then
ballX += 1
else
ballX -= 1
end if
% This checks to see if the ball has reached the end of the screen...this
% is really not good code...don't use it...it's just demonstrating how things
% would be done.

PhOeNiX-47




PostPosted: Wed May 19, 2004 8:08 pm   Post subject: (No subject)

Well, first of all ur ball needs to go in a direction using a variable. Make sure the if u hit a wall make the direction change Very Happy Let me show you.

code:

View.Set ("offscreenonly")

var row_change := 1
var row := 200

loop
cls
    row := row + row_change

    drawfilloval (300, row, 25, 25, black)

    if row = 25 then
        row_change := row_change * -1
    elsif row = maxy - 25 then
        row_change := row_change * -1
    end if
    View.Update
    delay (1)
end loop


Hope that helps you...
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  [ 3 Posts ]
Jump to:   


Style:  
Search: