Computer Science Canada Make this program asd good as possible ie) bricks work |
Author: | Codi [ Tue May 09, 2006 8:42 am ] |
Post subject: | Make this program asd good as possible ie) bricks work |
%paddle global vaariables var pwidth : int := 75 % paddle width var plen : int := 20 %paddle length var pclr : int := brightgreen % paddle color var pxpos : int := maxx div 2 % the paddle starts in the middle of the screen var pypos : int := 50 % the paddle is 50 high of of the ground %ball variables var count : int := 0 const right := 2 const left := -2 var bxpos, bxpostest : int := maxx div 2 var bypos, bypostest : int := maxy div 2 var bsize := 10 var bclr := yellow var direction : int := left var angle : real := 315 var hitBrick : boolean := false var counter : int :=0 var lives : int := 3 proc Bricks for x : 0 .. maxx by 50 for y : 250 .. maxy - 40 by 20 Draw.FillBox (x, y, x + 45, y + 15, black) end for end for end Bricks proc menu var start : string put " Would You Like to Play X-Treme Brick?" put " Press Y For Yes And N for No" get start if start = "N" or start = "n" then locate (25,24) put " Poo Head!" delay (2000) quit end if cls end menu menu Draw.Line (0, maxy - 40, maxx, maxy - 40, black) Bricks proc Lives Draw.FillOval (10, maxy - 20, 5, 5, black) Draw.FillOval (30, maxy - 20, 5, 5, black) Draw.FillOval (50, maxy - 20, 5, 5, black) end Lives Lives % paddle proc proc drawpaddle Draw.FillBox (pxpos, pypos, pxpos + pwidth, pypos + plen, pclr) end drawpaddle proc death lives := lives - 1 locate (20, 20) put " YoU DieS " delay (500) cls Bricks Lives if lives = 2 then Draw.FillOval (10, maxy - 20, 5, 5, black) Draw.FillOval (30, maxy - 20, 5, 5, black) Draw.FillOval (50, maxy - 20, 5, 5, white) Draw.Line (0, maxy - 40, maxx, maxy - 40, black) elsif lives = 1 then Draw.FillOval (10, maxy - 20, 5, 5, black) Draw.FillOval (30, maxy - 20, 5, 5, white) Draw.FillOval (50, maxy - 20, 5, 5, white) Draw.Line (0, maxy - 40, maxx, maxy - 40, black) elsif lives = 0 then Draw.FillOval (10, maxy - 20, 5, 5, white) Draw.FillOval (30, maxy - 20, 5, 5, white) Draw.FillOval (50, maxy - 20, 5, 5, white) Draw.Line (0, maxy - 40, maxx, maxy - 40, black) end if bxpos := maxx div 2 bypos := maxy div 2 if lives = 0 then locate (20, 20) put " You have No Lives Left ![]() delay (1000) cls Bricks end if end death proc pmove (ch : string (1)) if ord (ch) = 203 then % move the paddle left Draw.FillBox (pxpos + pwidth - 10, pypos, pxpos + pwidth, pypos + plen, white) % erase the right end of the paddle pxpos := pxpos - 10 % move to the left if pxpos < 0 then %redraws the paddle in new position pxpos := 0 % the paddle can't go outside of the screen boundaries on the right end if end if if ord (ch) = 205 then % paddle moves to the right Draw.FillBox (pxpos, pypos, pxpos + 10, pypos + plen, white) % erase the left end of the paddle pxpos := pxpos + 10 % redraws the paddle in new position if pxpos > maxx - pwidth then pxpos := maxx - pwidth % the paddle can't go outside of the screen boundaries on the left end if end if drawpaddle % procedure end pmove %bouncing off a horizontal surface proc angleMod1 %for hitting bricks paddle or roof angle := 360 - angle end angleMod1 %bouncing off a vertical surface proc angleMod2 if angle <= 180 then angle := 180 - angle elsif angle <= 360 then angle := 180 elsif angle = 225 then angle := 315 elsif angle = 315 then angle := 225 end if end angleMod2 proc bmove %change 125 to change speed of ball %move the ball Draw.FillOval (bxpos, bypos, bsize, bsize, white) %erase ball bxpos := bxpos + round (cosd (angle)) %new position bypos := bypos + round (sind (angle)) bxpostest := bxpos + round (10 * cosd (angle)) bypostest := bypos + round (10 * sind (angle)) if bxpostest > 0 and bxpostest < maxx and bypostest > 0 and bypostest < maxy then if View.WhatDotColour (bxpostest, bypostest) not= white then %hit paddle angleMod1 %bounce end if end if Draw.FillOval (bxpos, bypos, bsize, bsize, bclr)%redraw if bxpos > maxx or bxpos < 0 then angleMod2 %vertical bounce if ( angle < 0) or( angle> 270 and angle> 360) then angleMod2 end if if angle = 170 or angle = 180 then angle:= 315+ end if if bypos > maxy then angleMod1 %horizontal bounce end if if bypos <= 0 then death end if end if put "You are travaling at a " ,angle, " degree angle" end bmove var ch : string (1) := " " var x, y : int %mainline loop locate (1,30) if hasch then getch (ch) if ord (ch) = 203 or ord (ch) = 205 then %left/right pmove (ch) end if else ch := " " end if counter := counter + 1 drawpaddle if counter = 50 then bmove counter := 0 end if end loop |
Author: | timmytheturtle [ Tue May 09, 2006 8:58 am ] |
Post subject: | |
First, use the code tags. Second, wrong forum, this belongs in [Turing Help] Third, we don't do people's homework |