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

Username:   Password: 
 RegisterRegister   
 Grade 11 Pong Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HighschoolGuy




PostPosted: Thu Dec 03, 2009 11:05 am   Post subject: Grade 11 Pong Game

%This is my first attempt at writing a game.
%Version 1.0
%Author Justin Moen
%Datel; November 10th, 2009

%**************************************************************************************
%This is where i'll declare any global variables.
var fname : string := "Guest"
var answer : string (1)
var movepaddle : int := 165
var font := Font.New ("serif:12:bold")
var font1 := Font.New ("serif:12:italic")
%this will change font face, size and display, it also displays font as a pixel graphic.
var x : int := 70 %This is the x variable where the ball is served from.
var y : int := 175 % This is the y value the ball is served from.
var dx, dy : int := 1
var score : int := 0 %this is our hit counter
var getKey : array char of boolean

View.Set ("offscreenonly")

%*************************************************************************************
%My first task is to draw the court.
%The thing i need to remember is the screen size is 640x480, with 0,0 at the bottom left hand corner.
%My instruction screen.
procedure drawcourt
cls
%locatexy (2,25) %this locates the pixelon an x,y basis
Font.Draw ("Welcome to Pong 1.0", 230, 385, font, black)
% (text to display,xpl,ypl, font var, color)
locate (3, 12)
Font.Draw ("The up & down arrow control the paddle movement.", 165, 355, font1, black)
locate (1, 60)
put fname, "'s hits: "
%need to add the score counter later need to declare variables
%court
drawfillbox (50, 5, 600, 350, black)
%lines
drawfillbox (590, 10, 595, 345, white)
drawfillbox (55, 10, 590, 15, white)
drawfillbox (55, 340, 595, 345, white)
drawfillbox (320, 15, 323, 340, grey)
end drawcourt
%*********************************************************************************
process moveball
randint (y, 20, 280)
randint (x, 320, 325)
locatexy (x, y)
drawfilloval (x, y, 5, 5, yellow)
loop
delay (3)
%this controls the ball bouncing off of the top wall
if
y >= 338 then
dy := -dy
%This controls the bouncing off the back wall
elsif x >= 588 then
dx := -dx
%this controls the ball bouncing off the south wall
elsif y <= 17 then
dy := -dy
elsif y >= movepaddle - 2 and y <= movepaddle + 50 and x <= 72 then
dx := -dx
score := score + 1
locate (1, 76)
put score
elsif x <= 55 then

drawfilloval (x, y, 5, 5, black)
score := 0
locate (1, 76)
put score
randint (y, 20, 280)
randint (x, 320, 325)
delay (500)
drawfilloval (x, y, 5, 5, black)


View.Update




end if
drawfilloval (x, y, 5, 5, yellow)
drawfilloval (x, y, 5, 5, black)

x := x + dx
y := y + dy
drawfilloval (x, y, 5, 5, yellow)
View.Update
%if score =5 then
%dx:=dx+1
%dy:=dy
%end if


end loop
end moveball


%paddles
procedure drawpaddleup (clr : string)
drawfillbox (60, movepaddle, 65, movepaddle + 50, black)
movepaddle += 1
drawfillbox (60, movepaddle, 65, movepaddle + 50, white)
View.Update
end drawpaddleup

procedure drawpaddledown (clr : string)
drawfillbox (60, movepaddle, 65, movepaddle + 50, black)
movepaddle += -1
drawfillbox (60, movepaddle, 65, movepaddle + 50, white)
View.Update
end drawpaddledown

%procedure collects keyboard input abd noves the paddle
procedure slidepaddle
drawpaddleup ("white")
loop
Input.KeyDown (getKey)
if getKey (KEY_UP_ARROW) then
drawpaddleup ("white")
delay (3)
end if
if getKey (KEY_DOWN_ARROW) then
drawpaddledown ("white")
delay (3)
end if
drawfillbox (590, 10, 595, 345, white)
drawfillbox (55, 10, 590, 15, white)
drawfillbox (55, 340, 595, 345, white)
drawfillbox (320, 15, 323, 340, grey)
if (movepaddle <= 16) then
movepaddle := 16
elsif (movepaddle >= 289) then
movepaddle := 289
end if
end loop
end slidepaddle






procedure exitgame
cls
locate (13, 25)
put "Good bye."
end exitgame
%**************************************************************************************


locate (12, 20) %For text 25 rows and 80 columns.
procedure opening
View.Set ("nooffscreenonly")
put "Welcome to my first Pong 1.0 Game. "
locate (13, 20)
put "Would you like to play?"
locate (14, 20)
locate (15, 20)
put "Please answer Y or N. " ..
get answer
if answer = "y" then
locate (17, 20)
put "Welcome, what is your name? " ..
get fname
delay (50)
cls
put "Welcome to the game, ", fname





View.Set ("offscreenonly,title:Pong 1.0.1,nobuttonbar,graphics:800;600")
drawfillbox (0, 0, 200, 30, blue)
drawfillbox (5, 5, 195, 25, white)
var x : int := 0
loop
x := x + 1
drawfillbox (4 + x, 5, 5, 25, red)
exit when x = 191
delay (10)
View.Update
end loop










delay (1000)
drawcourt

elsif answer = "n" then
put "Maybe next time, good bye."
exitgame
end if
end opening

%Game call procedures *****************************************************************
opening



drawcourt

fork moveball

slidepaddle
Sponsor
Sponsor
Sponsor
sponsor
apomb




PostPosted: Thu Dec 03, 2009 11:38 am   Post subject: RE:Grade 11 Pong Game

Errily similar to http://compsci.ca/v3/viewtopic.php?t=22901
Khary




PostPosted: Thu Dec 03, 2009 2:59 pm   Post subject: RE:Grade 11 Pong Game

wow, you're right apomb..
andrew.




PostPosted: Thu Dec 03, 2009 5:23 pm   Post subject: RE:Grade 11 Pong Game

Plagiarism? Highschoolguy, if you did copy the code or use it as a base, you should at least give credit to the original creator.
DtY




PostPosted: Thu Dec 03, 2009 6:37 pm   Post subject: RE:Grade 11 Pong Game

Hmmm?

Posted Image, might have been reduced in size. Click Image to view fullscreen.

It's weird that they were posted within five minutes of each other too
andrew.




PostPosted: Thu Dec 03, 2009 6:54 pm   Post subject: RE:Grade 11 Pong Game

Hey DtY, what program is that? I want it! Very Happy

Oh BTW, you blanked out your name on the first part of the window, but you forgot to blank it out on the right side.
DtY




PostPosted: Thu Dec 03, 2009 7:10 pm   Post subject: RE:Grade 11 Pong Game

Thanks for pointing that out! The program's called FileMerge, it comes with the Apple developer tools, it's in /Developer/Applications/Utilities

[edit] In my last post, it said "hmm?" that question mark should have actually benn . . ., which Mac automatically converted to an ellipsis, which compsci.ca seems to have automatically converted to a question mark. (Or maybe I wasn't paying attention and actually typed ?)
HighschoolGuy




PostPosted: Fri Dec 04, 2009 9:56 am   Post subject: RE:Grade 11 Pong Game

The reason both posts seem the same is because were both from the same class, and i wouldn't have been the one to plagiarize anyways, mine was posted first.
Sponsor
Sponsor
Sponsor
sponsor
apomb




PostPosted: Fri Dec 04, 2009 10:05 am   Post subject: RE:Grade 11 Pong Game

same class yet one was "grade 12 blah blah" and yours is "grade 11 blah blah" ...

oh, and if you get rid of the whitespace and use filemerge again, there are only 41 differences.
Zren




PostPosted: Fri Dec 04, 2009 10:34 am   Post subject: RE:Grade 11 Pong Game

With that much commenting. I'm sure the teacher must have instructed most of the code. Big whoop honestly since in the end, it's still Pong.

Which bring me to the fact that the ball ate my paddle. Until I moved it again, it disappeared. Just thought you'd like to know.
HighschoolGuy




PostPosted: Fri Dec 04, 2009 10:35 am   Post subject: RE:Grade 11 Pong Game

Im serious, it's a combined Grade 11 & 12 class, don't be so nieve.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: