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

Username:   Password: 
 RegisterRegister   
 Ball bouncing around the screen
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lufthansa747




PostPosted: Tue Dec 01, 2009 8:51 pm   Post subject: Ball bouncing around the screen

Here is my program that makes a ball bounce around

View.Set ("graphics:max;max,offscreenonly,nobuttonbar")
var x : int := maxx div 2
var y : int := maxy div 2
var radius : int := 20
var xint, yint : int := 5
var upState, sideState : int := -1
Draw.FillBox (0, 0, maxx, maxy, black)
Draw.FillOval (x, y, radius, radius, white)
loop
if x - xint <= 0 and sideState = -1 then %Check left wall
sideState := 1
end if
if x + xint >= maxx and sideState = 1 then % check right wall
sideState := -1
end if
if y + yint >= maxy and upState = 1 then %check top wall
upState := -1
end if
if y - yint <= 0 and upState = -1 then % check bottom wall
upState := 1
end if
Draw.FillOval (x, y, radius, radius, black)
x += xint * sideState
y += yint * upState
Draw.FillOval (x, y, radius, radius, white)
View.Update
delay (10)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Kharybdis




PostPosted: Tue Dec 01, 2009 9:34 pm   Post subject: RE:Ball bouncing around the screen

Congrats. Now try to make a ping pong game Smile
apomb




PostPosted: Wed Dec 02, 2009 8:50 am   Post subject: Re: Ball bouncing around the screen

For the love of all things holy, do not make another pong game... PLEASE think of something a little more inspired.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: