Computer Science Canada Pong Game Need Help |
Author: | legends31 [ Mon Dec 23, 2002 12:12 am ] |
Post subject: | Pong Game Need Help |
am making a pong game for school and i am having some major trouble. I have different logic errors and i am also having trouble with having two actions working at once, eg. animating a box and a ball at the same time. It does the ball, then the box not both at same time. Here is the instructions part of my program. whats wrong with it? Thanks so much setscreen ("graphics:700;500") %=============================== %Makes blinking cursor disappear %=============================== setscreen ("nocursor") %================== %Declares variables %================== var arial, arialbig, arialhuge, arialmedium, arialmicro, arialsmall, x, y, bnum, bud, paddlesize : int %========================== %Makes the background black %========================== drawfillbox (0, 0, maxx, maxy, 7) %=================== %Draws three buttons %=================== drawfillbox (200, 325, 300, 425, 9) drawfillbox (200, 200, 300, 300, 12) drawfillbox (200, 75, 300, 175, 2) %=================================================================== %Assigns font sizes and styles to make using font quicker and easier %=================================================================== arialhuge := Font.New ("arial:50") arialbig := Font.New ("arial:40") arial := Font.New ("arial:30") arialmedium := Font.New ("arial:18") arialsmall := Font.New ("arial:12") arialmicro := Font.New ("arial:8") %============================================== %Draws the words "options", "rules" and "begin" %============================================== Font.Draw ("Options", 200, 350, arial, brightwhite) Font.Draw ("Rules", 210, 225, arial, brightwhite) Font.Draw ("Begin", 210, 110, arial, brightwhite) %=============================== %Waits for the users mouse click %=============================== buttonwait ("down", x, y, bnum, bud) %============================================================================ %Finds out if the user clicked in a specified space and if so applies actions %============================================================================ if x >= 200 and x <= 300 and y >= 325 and y <= 425 then cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("OPTIONS", 250, 400, arialhuge, 9) Font.Draw ("Paddle Size", 30, 300, arialmedium, 44) drawfillbox (200, 300, 250, 325, 9) drawfillbox (275, 300, 325, 325, 12) drawfillbox (350, 300, 400, 325, 2) Font.Draw ("Small", 200, 335, arialsmall, 44) Font.Draw ("Medium", 275, 335, arialsmall, 44) Font.Draw ("Large", 350, 335, arialsmall, 44) buttonwait ("down", x, y, bnum, bud) if x >= 200 and x <= 250 and y >= 300 and y <= 325 then paddlesize := 50 end if if x >= 275 and x <= 325 and y >= 300 and y <= 325 then paddlesize := 75 end if if x >=350 and x <=400 and y >=300 and y <=325 then paddlesize:=100 end if end if %============================== %Finds out click for second box %============================== if x >= 200 and x <= 300 and y >= 200 and y <= 300 then cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("RULES", 250, 400, arial, 12) end if Font.Draw ("The rules of the game are simple...", 50, 300, arial, 9) delay (2000) Font.Draw ("Click for Rules", 50, 275, arialmedium, 8) buttonwait ("down", x, y, bnum, bud) Font.Draw ("Move your paddle accross the screen to stop the ball from going below your paddle", 10, 250, arialmedium, 6) buttonwait ("down", x, y, bnum, bud) Font.Draw ("Move your paddle accross the screen to stop the ball from going below your paddle", 10, 250, arialmedium, 7) Font.Draw ("Advance through the levels by destroying the blocks", 10, 230, arialmedium, 6) buttonwait ("down", x, y, bnum, bud) Font.Draw ("Advance through the levels by destroying the blocks", 10, 230, arialmedium, 7) Font.Draw ("When all of the blocks are destroyed and levels are completed you will become the", 10, 210, arialmedium, 6) Font.Draw ("MX-Ball champion!", 10, 190, arialmedium, 6) %======================= %Finds out for third box %======================= if x >= 200 and x <= 300 and y >= 75 and y <= 175 then cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("BEGIN", 250, 400, arial, 2) end if |
Author: | Tony [ Mon Dec 23, 2002 2:06 am ] | ||
Post subject: | |||
well the code seems to work fine... well other then that 8) part... which I replaced with random color. Here're a few tips though: you can use color names instead of numbers... such as you can put black for color black. 2nd - clear the screen before displaying the rules... otherwise it looks crappy. Also, I think we have 2 pong games available at our FTP site -> ftp://swat@danco.no-ip.com take a look for ideas. About doing multiple stuff at same time... well you can ether use process
or if you just want to draw things at same time without flashing, read the tutorial on smooth animation we got in tutorial section. |
Author: | legends31 [ Mon Dec 23, 2002 4:05 pm ] |
Post subject: | Thanks for your help |
I seem to get proc and process messed up. I will continue to work on my program and it will be a fun one! Thanks for your help process thanks loop put "Thanks!" end loop end thanks process goodbye loop put "Goodbye" end loop end goodbye fork thanks fork goodbye |