This document provides instructions for modifying a Paddle game program written in Small Basic. It includes 5 parts:
1. Changing the code so the paddle size decreases every 3 points instead of every 5 points.
2. Adding code to increase the game speed each time the score reaches 6 points.
3. Adding a "click" sound effect when the ball hits the paddle or screen edges.
4. Adding a chime sound when the paddle size decreases.
5. Adding background music that plays when the player loses.
This document provides instructions for modifying a Paddle game program written in Small Basic. It includes 5 parts:
1. Changing the code so the paddle size decreases every 3 points instead of every 5 points.
2. Adding code to increase the game speed each time the score reaches 6 points.
3. Adding a "click" sound effect when the ball hits the paddle or screen edges.
4. Adding a chime sound when the paddle size decreases.
5. Adding background music that plays when the player loses.
When finished keying, SAVE your program into your own folder then try running it 'Paddle 'your name here GraphicsWindow.BackgroundColor = "yellow" GraphicsWindow.BrushColor = "darkblue" gameSpeed=3 'The higher the number the slower the play padSize=120 paddle = shapes.AddRectangle(padSize, 12) ball = shapes.AddEllipse(16, 16) GraphicsWindow.MouseMove = OnMouseMove x = 0 y = 0 deltaX = 1 deltaY = 1 gw = GraphicsWindow.Width gh = GraphicsWindow.Height While y < gh x = x + deltaX y = y + deltaY If (x >= gw - 16 Or x <= 0) Then 'change direction if hit the left or right side deltaX = -deltaX 'set to minus (opposite direction) EndIf padX = Shapes.GetLeft(paddle) ' If checks if ball hit the paddle If ((y >= gh - 28 + 2) And x >= padX And x <= padX + padSize) Then y = gh - 28 + 2 deltaX = deltaX - 2 + (x - padX) / 30 ' Add some skill score = score + 1
'score a point for hit the ball
If Math.remainder(score,5) = 0 then 'every 5 points make the paddle size smaller
padSize=padSize - 10 shapes.Remove(paddle) GraphicsWindow.BrushColor = "darkblue" paddle = shapes.AddRectangle(padSize, 12) endif PrintScore() 'call score sub program deltaY = -deltaY 'Change the ball direction endif If (y <= 0) Then 'if ball hits top of screen change the ball direction deltaY = -deltaY EndIf shapes.Move(ball, x, y) Program.Delay(gameSpeed) endwhile GraphicsWindow.ShowMessage("You Lose", "Paddle") Program.End() Sub OnMouseMove paddleX = GraphicsWindow.MouseX shapes.Move(paddle, paddleX - padSize/2, GraphicsWindow.Height - 12) EndSub Sub PrintScore ' Clear the score first and then draw the real score text GraphicsWindow.BrushColor = "yellow" GraphicsWindow.FillRectangle(10, 10, 200, 20) GraphicsWindow.BrushColor = "Black" GraphicsWindow.DrawText(10, 10, "Score: " + score) EndSub
Part II Lets make the paddle change size every 3 point scored Find the line below and change the 5 to a 3 If Math.remainder(score,5) = 0 then 'every 5 points make the paddle size smaller
Part III Changing the speed
Lets make the game speed go faster each time you score 6 points Add the following three lines just before the line you changed in Part II above If Math.Remainder(score,6)=0 then gameSpeed = gameSpeed - 1 endif If Math.remainder(score,3) = 0 then 'every 3 points make the paddle size smaller
Part IV Adding sound
Each time the ball hits the paddle or the top or sides of the screen lets have it make a click sound. Using the statement Sound.playclick() There are two places in the program where deltaX is changed deltaX= ~~~~~~~~ And one place where deltaY is changed deltaY = ~~~~~~~ This does NOT include the two lines near the top deltaX = 1 and deltaY = 1 Find the three places where deltaX & deltaY are changed and then add the new line below each Sound.playclick()
Part V more sound
Try adding the Sound.PlayChime() Try adding the Sound.PlayMusic("