{=================================================================== graphics3.p Started by Jeff Ondich on 1/25/95 Last modified 10/11/96 1. Compile it, run it, figure out how it works and how to stop it. 2. Complain about the flickering. Try to get the ball to bounce from side to side instead of up and down. Can you get the colors to change gradually from red to blue instead of abruptly? ===================================================================} #include program Bounce(Input, Output); import graphics; const radius = 40; windowWidth = 600; windowHeight = 600; windowBottom = 100; windowLeft = 100; var x, y : integer; red, blue, green : real; goingUp : boolean; {=================================================================== StartGraphics initializes the graphics package and opens a black window for drawing. ===================================================================} procedure StartGraphics; begin initializegraphics; createwindow( windowLeft, windowBottom, windowLeft + windowWidth, windowBottom + windowHeight ); setrgbcolor( 0.0, 0.0, 0.0 ); flood; flushgraphics end; procedure NewCenter( var horiz, vert : integer ); begin if goingUp then vert := vert + 1 else vert := vert - 1; if vert >= windowHeight - radius then begin goingUp := false; red := 1.0; blue := 0 end else if vert <= radius then begin goingUp := true; red := 0; blue := 1.0 end end; {=================================================================== main program ===================================================================} begin StartGraphics; x := windowWidth div 2; y := radius; goingUp := true; red := 0.0; blue := 1.0; green := 0.0; while true do begin setrgbcolor( red, green, blue ); circle( x, y, radius ); flushgraphics; setrgbcolor( 0, 0, 0 ); circle( x, y, radius ); flushgraphics; NewCenter( x, y ) end end.