Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 PLZ HELP ME WITH THE PING PONG PROGRAM
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
babyworld




PostPosted: Tue Apr 26, 2005 12:43 pm   Post subject: PLZ HELP ME WITH THE PING PONG PROGRAM

I am not sure how to change the degree of the angle for the bats in this game. And i also want the bats be able to spin for 180 degrees.
Please would anyone help me out?

colourback (black)
colour (black)
cls
colour (12)
locate (3, 22)
put " Welcome to Pong "
locate (25, 17)
put " Written by Hallowedbethyname666, October 7th, 2004 "
locate (10,3)
put "Paddle 1 Controls - f Moves Paddle Up, v moves Paddle Down"
locate (11,3)
put "Paddle 2 Controls - j Moves Paddle Up, n moves Paddle Down"
delay (6100)
cls

%Variables
setscreen ("graphics : 600 ; 300")
var x, y, xp, yp, xa, ya : int
var xstep, ystep, radius : int
var key : string (1)
var score1, score2 : int

score1 := 0
score2 := 0

xp := 20
yp := 190
xa := 620
ya := 190
x := round (maxx / 2)
y := round (maxy / 2)
radius := 5
xstep := 1
ystep := 1
%random moving ball
drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey)
drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey)
drawline (0, 375, maxx, 375, grey)
drawline (1, 375, maxx, 375, grey)
drawline (2, 375, maxx, 375, grey)
drawline (3, 375, maxx, 375, grey)
drawline (4, 375, maxx, 375, grey)
loop
drawline (0, 375, maxx, 375, grey)
drawline (1, 375, maxx, 375, grey)
drawline (2, 375, maxx, 375, grey)
drawline (3, 375, maxx, 375, grey)
drawline (4, 375, maxx, 375, grey)

drawfilloval (x, y, radius, radius, white)
delay (3)
drawfilloval (x, y, radius, radius, black)
x := x + xstep
y := y + ystep
if y > maxy - radius or y < radius then
ystep := -ystep
end if
if x > maxx - radius -1 then
xstep := -xstep
score1 := score1 + 1
x := round (maxx / 2)
y := round (maxy / 2)
elsif x < radius + 1 then
xstep := -xstep
score2 := score2 + 1
x := round (maxx / 2)
y := round (maxy / 2)
end if
%Paddle 1
%Paddle 1 Collison
if whatdotcolour (x - radius + 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x - radius - 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x, y - radius + 1) not= black then
ystep := -ystep
elsif whatdotcolour (x, y - radius - 1) not= black then
ystep := -ystep
elsif whatdotcolour (x + radius + 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x - radius - 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x, y + radius + 1) not= black then
ystep := -ystep
elsif whatdotcolour (x, y - radius - 1) not= black then
ystep := -ystep
end if

%Paddle 1 Movement

if hasch then
getch (key)
if key = "f" then
drawfillbox (xp, yp, xp + 7, yp + 70, black)
yp += 10
drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey)
elsif key = "v" then
drawfillbox (xp, yp, xp + 7, yp + 70, black)
yp -= 10
drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey)
elsif key = "j" then
drawfillbox (xa, ya, xa - 7, ya + 70, black)
ya += 10
drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey)
elsif key = "n" then
drawfillbox (xa, ya, xa - 7, ya + 70, black)
ya -= 10
drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey)
end if

%Paddle 2
if whatdotcolour (x + radius + 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x + radius - 1, y) not= black then
xstep := -xstep
elsif whatdotcolour (x, y + radius + 1) not= black then
ystep := -ystep
elsif whatdotcolour (x, y + radius - 1) not= black then
ystep := -ystep
end if
%Scoring
locate (1, 1)
put "Player 1 Score: ", score1
locate (1, 32)
put "Pong"
locate (1, 63)
put "Player 2 Score: ", score2
end if
end loop


Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Tue Apr 26, 2005 1:36 pm   Post subject: (No subject)

GG, use code tags.

Anyways, you're using whatdotcolor to detect boundaries, so I suggest either making the enitre top part (where scores are) a different color than black, or if y > maxy - 30 (or w/e the distance is) then ystep*=-1, or just use number boundaries to detect everything instead.
jamonathin




PostPosted: Tue Apr 26, 2005 1:46 pm   Post subject: (No subject)

I'd help you but like everyone else, I've done hangman last year for when I first started programming, and found it the most annoying games in the world. Use the search tool, I'm sure you'll find plenty.
http://www.compsci.ca/v2/search.php
mike200015




PostPosted: Fri Apr 29, 2005 1:27 am   Post subject: (No subject)

jamonathin wrote:
I'd help you but like everyone else, I've done hangman


hangman?? Confused
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: