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

Username:   Password: 
 RegisterRegister   
 My Paddle Ball Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
schwarp




PostPosted: Tue Jan 23, 2007 12:44 pm   Post subject: My Paddle Ball Game

/************************************************************
* Paddle Ball Game *
* *
* This game will allow the user to move the paddle on *
*there own, and to try and keep the ball from going beyond. *
*It will also keep score of how many times the ball bounced *
*off the paddle,and will later ask the user if they would *
*like to play again. *
* *
* By: Brandon Stacey *
* 12/01/06 *
************************************************************/

loop
%Key variables
var key : string (1)
var num : int
num := 0
%Paddle Variables
var y1, y2 : int
y1 := 1
y2 := 100
%Ball Variables
var ran1, ran2, randdirx, randdiry : int
var again : string


randint (ran1, 1, 339)
randint (ran2, 1, 639)
randdiry := 3
randdirx := 3
%Title page variables
var title1 : int
title1 := 20
var count : int := 0
%Level Select
var level : int

loop
loop
drawfill (1, 1, 124, 124)
%Name
var font1 : int
font1 := Font.New ("Stencil:20")
assert font1 > 0
Font.Draw ("X-TREME PADDLEBALL!!!", 160, 325, font1, red)
Font.Free (font1)

%Rules
var font2, font3, font4, font5 : int
font2 := Font.New ("AYTMystical:18:bold")
font3 := Font.New ("sarif:12")
font4 := Font.New ("sarif:12")
font5 := Font.New ("sarif:12")
assert font2 > 0
assert font3 > 0
assert font4 > 0
assert font5 > 0
Font.Draw ("Rules", 10, 190, font2, red)
Font.Draw ("1.Arrow Keys are used. Left moves your paddle left, and right moves your paddle right.", 1, 160, font3, yellow)
Font.Draw ("2.If the ball goes by the paddle, the game will end.", 1, 140, font4, yellow)
Font.Draw ("3.Just have FUN!!!", 1, 120, font5, yellow)
Font.Free (font2)
Font.Free (font3)
Font.Free (font4)
Font.Free (font5)

loop
%Title wiper
drawfilloval (title1, 335, 20, 20, 12)
exit when title1 = 600
delay (100)
drawfilloval (title1, 335, 20, 20, 124)
title1 := title1 + 10
end loop

cls
%Level Select
drawfill (1, 399, 12, 12)
colorback (12)
put "Which Difficulty would you like? Please press a NUMBER"
put "1. X-Tremely Easy"
put "2. Easy"
put "3. Medium"
put "4. Hard"
put "5. X-Tremely HARD"
get level
if level = 1 then
y1 := 1
y2 := 300
count := 0
elsif level = 2 then
y1 := 1
y2 := 200
count := 0
elsif level = 3 then
y1 := 1
y2 := 100
count := 0
elsif level = 4 then
y1 := 1
y2 := 50
count := 0
elsif level = 5 then
y1 := 1
y2 := 15
count := 0
end if
exit when level = 1
exit when level = 2
exit when level = 3
exit when level = 4
exit when level = 5
end loop
cls

%Background
drawfill (1, 399, 29, 29)
loop
%Paddle
drawfillbox (y1, 1, y2, 20, 4)
%Ball
drawfilloval (ran2, ran1, 10, 10, 12)
delay (10)
%Paddle Erase
drawfillbox (y1, 1, y2, 20, 29)
%Ball Erase
drawfilloval (ran2, ran1, 10, 10, 29)
%Get Key
if hasch then
getch (key)
num := ord (key)
end if

%Paddle
if num = 203 and y1 >= 0 then
y1 := y1 - 10
y2 := y2 - 10
elsif num = 205 and y2 <= 640 then
y1 := y1 + 10
y2 := y2 + 10
end if
num := 0
%Ball Movement
ran1 := ran1 + randdiry
ran2 := ran2 + randdirx
if ran1 >= 399 then
randdiry := -2
end if
if ran2 >= 639 then
randdirx := -2
end if
if ran2 <= 1 then
randdirx := +2
end if
if ran1 <= 20 and ran1 >= -2 and ran2 >= y1 and ran2 <= y2 then
randdiry := +2
count := count + 1
end if
if ran1 <= -2 then
cls
exit
end if

end loop
exit when ran1 <= -2
cls
end loop
%Score
drawfill (1, 399, 25, 25)
var font1 : int
font1 := Font.New ("Stencil:20")
assert font1 > 0
Font.Draw ("Congrats, You scored", 160, 325, font1, red)
Font.Free (font1)
colorback (25)
locate (7, 30)
put count
delay (5000)
%Play Again?
var font2 : int
font2 := Font.New ("Stencil:18")
assert font2 > 0
Font.Draw ("Do you want to play again?(y/n)", 140, 250, font2, red)
Font.Free (font2)
delay (50)
get again
if again = "n" or again = "N" then
exit
elsif again = "y" or again = "Y" then
cls
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
War_Caymore




PostPosted: Tue Jan 23, 2007 2:29 pm   Post subject: RE:My Paddle Ball Game

Good game. Although you should allow the paddle to continualy move instead of it stalling then moving afterwards, like when u type.

Other than that, the X-treme hard difficulty isn't really that hard Very Happy
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  [ 2 Posts ]
Jump to:   


Style:  
Search: