Computer Science Canada I NEED HELP....and fast(pong game) |
Author: | Code_Urban [ Wed Nov 03, 2004 11:43 pm ] |
Post subject: | I NEED HELP....and fast(pong game) |
I need a pong game...im in grd 10 and we are making pong..and ive checked ur Source Codes and there 2 advance for me and my classs....i need sumthing thats extremely basic commands....this is what i have...and i need help like hell and these are the commands we basically using... View.Set ("graphics:640:480") var ballx, bally, xrad, yrad : int var xstep, ystep, y1, y2, pmove, x1, x2 : int var colourpad, colourpad1, ballcolour, ballcolour1 : int var key : string (1) ballx := 310 bally := 270 xrad := 5 yrad := 5 ballcolour := 2 ballcolour1 := 0 ystep := 8 xstep := 10 pmove := 10 y1 := 200 y2 := 170 x1 := 20 x2 := 620 colourpad := 12 colourpad1 := 0 loop drawfillbox (0, 640, 0, 480, 43) drawfilloval (ballx, bally, xrad, yrad, ballcolour) drawfillbox (x1, y1, x1 - 10, y1 + 50, colourpad) drawfillbox (x2, y1, x2 + 10, y1 + 50, colourpad) View.Update delay (40) drawfillbox (0, 640, 0, 480, 43) drawfilloval (ballx, bally, xrad, yrad, ballcolour1) drawfillbox (x1, y1, x1 - 10, y1 + 50, colourpad1) drawfillbox (x2, y1, x2 + 10, y1 + 50, colourpad1) ballx := ballx + xstep bally := bally + ystep %Left Paddle MOVE if hasch then getch (key) if key = "w" or key = "W" and y1 < 420 then y1 := y1 + 20 elsif key = "s" or key = "S" and y1 > 0 then y1 := y1 - 20 end if %Right Paddle MOVE if hasch then getch (key) if key = chr (200) and y2 < 420 then y2 := y2 + 20 elsif key = chr (208) and y2 > 0 then y2 := y2 - 20 end if %Wall Bounce if ballx > 630 or ballx < 5 then xstep := -xstep end if if bally > 475 or bally < 5 then ystep := -ystep end if end if end if end loop the ball wont bounce, if i use w and s BOTH padlles move plus the go off the screen, but my basics concern is my ball bouncing off the screen...so if some1 can reply...plz.. and thank you..and i need help bad!! peace Code Urban |
Author: | apomb [ Thu Nov 04, 2004 12:31 am ] |
Post subject: | |
first of all, im just going to say what is needed to say ... too late for reading un-tagged code... ne way 1-use tags 2-use KEY_DIRECTION cmd, F10 works perfectly for finding this! 3- dont hardcode so much, try some for loops and maxy/maxx for boundaries 4- (interchangeable with 3) draw a border ... then use whatdotcolor to find boundaries ... also for paddles hope this is not too complicated ... and it helps -CompWiz |
Author: | cop_mike [ Thu Nov 04, 2004 3:38 pm ] |
Post subject: | |
dave!!! lol i need help to so everyone heres my pong game i need to know how to score the points in the game easily and shit like that can u guys help me finish my game can u help me ??!?!?!?!?! View.Set ("graphics:640;480") var x, y, xr, yr, c, x1, y1, x2, y2 : int var xstep, ystep : int := 5 var key : string (1) ystep := 6 x := 480 y := 240 xr := 8 yr := 8 x1 := 10 y1 := 240 x2 := 620 y2 := 240 loop randint (c,10,69) drawfillbox (640, 420, 0, 480, c) %ball drawfilloval (x, y, xr, yr, c) % right paddle drawfillbox (x1, y1, x1 + 10, y1 + 60,c ) %left paddle drawfillbox (x2, y2, x2 + 10, y2 + 60, c) delay (30) % clear ball drawfilloval (x, y, xr, yr, 0) %clear right paddle drawfillbox (x1, y1, x1 + 10, y1 + 60, 0) %clear left paddle drawfillbox (x2, y2, x2 + 10, y2 + 60, 0) x := x + xstep y := y + ystep if hasch then getch (key) if key = "W" or key = "w" and y1 < 350 then y1 := y1 + 20 elsif key = "S" or key = "s" and y1 > 0 then y1 := y1 - 20 elsif key = chr (200) and y2 < 350 then y2 := y2 + 20 elsif key = chr (208) and y2 > 0 then y2 := y2 - 20 end if end if %bounces ball off walls if x > 630 or x < 10 then xstep := -xstep end if if y > 410 or y < 10 then ystep := -ystep end if %makes bal bounce off paddles if x - 8 <= x1 + 10 then if y >= y1 and y <= y1 + 50 then xstep := -xstep end if end if if x + 8 >= x2 then if y >= y2 and y <= y2 + 50 then xstep := -xstep end if end if end loop |
Author: | Cervantes [ Thu Nov 04, 2004 4:07 pm ] |
Post subject: | |
oww, my siezure hurts. Anyways, CompWiz333 wrote: 1-use tags
He would be referring to the [ code] [ /code] tags, without the spaces. I find it very interesting, cop_mike, that you figured out how to use if statements to make the ball bounce off the wall, but you can't figure out to use if statements to determine whether the ball has passed beyond either of the paddles, and adding one to the appropriate score keeping variable. Yep.. really makes me wonder. As for your question, Code_Urban, I suggest you study cop_mike's use of if statements, specifically lines 47 to 53. |
Author: | cop_mike [ Thu Nov 04, 2004 8:52 pm ] |
Post subject: | |
lol i dunt no it took me a while with alot of the teachers help can u help me or not? |
Author: | AsianSensation [ Thu Nov 04, 2004 8:59 pm ] |
Post subject: | |
no. Because you type like an idiot, your topic violate rules, you probably copied off the code. But I think it was the "You type like an idiot" that gave me reasons to.....LOCK! |