Author |
Message |
@DRI@N
|
Posted: Tue May 25, 2004 4:59 pm Post subject: Bouncing Ball Program! |
|
|
This is the basic bouncing ball program...
code: |
setscreen("graphics:640;400")
View.Set ("offscreenonly")
color(white)
colorback(black)
cls
var x : int := 320
var y : int := 350
var xchange:int:=1
var ychange:int:=1
loop
cls
x := x - xchange
y := y + ychange
Draw.FillOval (x, y, 10, 10, white)
delay(5)
if x = 10 or x =630 then
xchange:=xchange*-1
end if
if y = 10 or y = 390 then
ychange :=ychange*-1
end if
View.Update
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
guruguru
|
Posted: Tue May 25, 2004 6:05 pm Post subject: (No subject) |
|
|
Source code. #3 |
|
|
|
|
|
rollerdude
|
Posted: Wed Sep 15, 2004 4:41 pm Post subject: (No subject) |
|
|
what version is this code for, because View.Update comes up as an error |
|
|
|
|
|
Tony
|
|
|
|
|
shorthair
|
Posted: Mon Sep 20, 2004 9:20 pm Post subject: (No subject) |
|
|
Add Plug here , * which was Brought by Justin To COmpsci, thanks to shorthair there was a little more piracy in the world , * but if you need it , ask your teacher to send an email to holfsoft they offer it to all classes that need it , it has major fixes for hte grade 11 curicullem ( cant spell tonight ) |
|
|
|
|
|
lama_daboul
|
Posted: Thu Oct 14, 2004 7:56 am Post subject: Comments |
|
|
Would someone please take 5 minutes to quickly comment or explain to me what each line in the basic bouncing ball program does. I need it for an Assignment |
|
|
|
|
|
josh
|
Posted: Thu Oct 14, 2004 8:34 am Post subject: (No subject) |
|
|
you could also do this using the Pic.New and Pic.Draw commands if u want to practice for more complex animations. U You use Pic.New to take a "Picture" of the part of the screen u want to move (all the objects in it become sotored in one variable) and then Pic.Draw to display everything that was taken in that picture. |
|
|
|
|
|
How U Doin
|
Posted: Tue Oct 26, 2004 8:59 am Post subject: (No subject) |
|
|
This is what I was learning in my computer programming class |
|
|
|
|
|
Sponsor Sponsor
|
|
|
djlenny_3000
|
Posted: Tue Oct 26, 2004 7:22 pm Post subject: (No subject) |
|
|
true you can make it as a picture, but i want to see if you can make it a box, or rectangular shape, and as it hits the wall the rectangle shifts its angle to suit hte new direction |
|
|
|
|
|
gigaman
|
Posted: Wed Oct 27, 2004 11:47 am Post subject: (No subject) |
|
|
DJ in response. you would do sumthing like when it hits the side one side the far side moves faster until it's back at it's original position. if i have time i'll write it up |
|
|
|
|
|
gigaman
|
Posted: Wed Oct 27, 2004 11:58 am Post subject: (No subject) |
|
|
This is the commented version of the ball bouncing that lama_daboul asked for. FYI commenting is not 5 minutes but it is important.
code: |
%Gigaman's commented version
setscreen("graphics:640;400") %sets the screen size and graphics mode
View.Set ("offscreenonly") %this makes it so that the ball doesn't flicker,all commands are done offscreen can also just put ",offscreenonly" in the setscreen command
color(white) %sets the colour of everything on the screen to default white
colorback(black) %sets the background colour to black
cls %clears the screen
var x : int := 320 %starting x cooridinate for the ball
var y : int := 350 %stariting y coordinate for the ball
var xchange:int:=1 %direction of the ball, x
var ychange:int:=1 %direction of the ball, y
loop
cls
x := x - xchange %equation for the x position
y := y + ychange %equation for the x position
Draw.FillOval (x, y, 10, 10, white) %draws the ball (obviously)
delay(5) %delay(duh)
if x = 10 or x =630 then %if for when the ball resches a side
xchange:=xchange*-1 %equation that changes direction
end if
if y = 10 or y = 390 then %if for when the ball reaches ceiling or floor
ychange :=ychange*-1 %equation that changes direction
end if
View.Update %put the ball on the screen
end loop
|
|
|
|
|
|
|
|