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

Username:   Password: 
 RegisterRegister   
 Clicking detection
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
thomasb




PostPosted: Mon May 23, 2011 10:32 am   Post subject: Clicking detection

I want to take this program and make it into a game where you click a certain colour of ball:
const RADIUS : int := 30
const NUM_BALLS : int := 20
var x, y, dx, dy, clr : array 1 .. NUM_BALLS of int
for i : 1 .. NUM_BALLS
x (i) := Rand.Int (RADIUS, maxx - RADIUS)
y (i) := Rand.Int (RADIUS, maxy - RADIUS)
dx (i) := Rand.Int (-3, 3)
dy (i) := Rand.Int (-3, 3)
clr (i) := Rand.Int (1, 15)
end for

% Now, any drawing to the screen won't appear until a
% View.Update is given.
View.Set ("offscreenonly")
loop
cls % Clear the offscreen window
for i : 1 .. NUM_BALLS
if x (i) + dx (i) < RADIUS or
x (i) + dx (i) > maxx - RADIUS then
dx (i) := -dx (i)
end if
if y (i) + dy (i) < RADIUS or
y (i) + dy (i) > maxy - RADIUS then
dy (i) := -dy (i)
end if
x (i) := x (i) + dx (i)
y (i) := y (i) + dy (i)
Draw.FillOval (x (i), y (i), RADIUS, RADIUS, clr (i))
end for
% All the circles have been drawn. Now update the screen.
View.Update
Time.Delay (5)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon May 23, 2011 12:23 pm   Post subject: RE:Clicking detection

Mouse.Where
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: