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

Username:   Password: 
 RegisterRegister   
 Write a program that bounces a ball across the screen...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sarmi123




PostPosted: Thu Dec 15, 2005 6:10 pm   Post subject: Write a program that bounces a ball across the screen...

NEED HELP TO..Write a program that bounces a ball across the screen. The height of the bounces should decrees on each bounce ( like the cards after winning a game of solitaire).
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu Dec 15, 2005 6:24 pm   Post subject: (No subject)

Welcome to CompSci.ca. Smile

Know that we don't do homework for people. What have you got so far? We'll help, but not do the entire thing and then hand it to you on platter. Wink
sarmi123




PostPosted: Thu Dec 15, 2005 6:35 pm   Post subject: (No subject)

setscreen ("graphics:max;max")

var firstx, firsty : real

var x, y : real := 100

firstx := 3

firsty := 13

loop

x := firstx + x

firsty := firsty - 1

y := firsty + y

if x > maxx or x < 0 then

firstx := -1 * firstx

end if

if y < 0 then

firsty := -1 * firsty

end if

drawfilloval (round (x), round (y), 20, 20, 103)

delay (20)

cls

end loop

%This is wht i have so far... but i need to make dis program bounce really high n come down lower n lower and finish at a really low part by da end of da screen
Cervantes




PostPosted: Sat Dec 17, 2005 3:56 pm   Post subject: (No subject)

Thanks for posting your problem, and the exact same code, twice more. (read with great sarcasm.) They've been removed.

All you have to do is decrease the y_velocity of the ball. It seems that you are using "firsty", whatever that means, for your velocity. Replace the contents of your your if y < 0 statement:
code:

firsty *= -0.98

This way, instead of just reversing it, you are reversing it an decreasing its magnitude by a bit.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: