Computer Science Canada

tripy ball program

Author:  WhatAmIDoing [ Fri Feb 27, 2004 2:36 pm ]
Post subject:  tripy ball program

hey this is my first program (screen saver) so tell me what you think of it

setscreen ("graphics")
%starting coordinates
var y, y2, x2, x, x3, y3, y4, x4, c : int := 10
y := 40
x := 40
x2 := maxx - 40
y2 := maxy - 40
y3 := maxy - 40
x3 := 40
y4 := 40
x4 := maxx - 40
%gets speed and clears the screen
var ySpeed, xSpeed : int := 10
var y2Speed, x2Speed : int := 10
var y3Speed, x3Speed : int := 10
var y4Speed, x4Speed : int := 10
%moves ball and bounces off side
loop
%ball_1
randint (c, 1, 50)


if y >= maxy - 30 or y <= 30 then
ySpeed := -ySpeed
end if
if x >= maxx - 30 or x <= 30 then
xSpeed := -xSpeed
end if
y := y + ySpeed
x := x + xSpeed
drawfilloval (x, y, 30, 30, c)
delay (10)
drawfilloval (x, y, 30, 30, c)
%ball_2
if y2 >= maxy - 30 or y2 <= 30 then
y2Speed := -y2Speed
end if
if x2 >= maxx - 30 or x2 <= 30 then
x2Speed := -x2Speed
end if
y2 := y2 + y2Speed
x2 := x2 + x2Speed
drawfilloval (x2, y2, 30, 30, c)
delay (10)
drawfilloval (x2, y2, 30, 30, c)
%ball_3
if y3 >= maxy - 30 or y3 <= 30 then
y3Speed := -y3Speed
end if
if x3 >= maxx - 30 or x3 <= 30 then
x3Speed := -x3Speed
end if
y3 := y3 + y3Speed
x3 := x3 + x3Speed
drawfilloval (x3, y3, 30, 30, c)
delay (10)
drawfilloval (x3, y3, 30, 30, c)
%ball_4
if y4 >= maxy - 30 or y4 <= 30 then
y4Speed := -y4Speed
end if
if x4 >= maxx - 30 or x4 <= 30 then
x4Speed := -x4Speed
end if
y4 := y4 + y4Speed
x4 := x4 + x4Speed
drawfilloval (x4, y4, 30, 30, c)
delay (10)
drawfilloval (x4, y4, 30, 30, c)
end loop

Author:  shorthair [ Fri Feb 27, 2004 3:28 pm ]
Post subject: 

This does not belong in here , but anyways its a nice little thing , i guess if your new i should be impressed , but its not that great

Author:  Paul [ Fri Feb 27, 2004 5:12 pm ]
Post subject: 

Yea, trippy alright, but if you make it move in different patterns after a while, it would be better.


: