
-----------------------------------
darkage43
Wed Jun 15, 2011 6:25 pm

Game Keeps Replaying
-----------------------------------
What is it you are trying to achieve?
Trying not to let the screen go back into playing the game.


What is the problem you are having?
Every time the screen shows you lose or you win the screen would then go back into playing the game. It only stops if I hit the quit button.


Describe what you have tried to solve this problem
I don't know what to do


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



import GUI

var winID : int
winID := Window.Open ("graphics:640;400")

%Setting Variables
var ballx, bally : int := 200 %Coordinates for the ball
var x, y : int := 1 %Speed and direction of the ball
var box : int := 170 %Y-coordinates of pong paddle
var chars : array char of boolean   %Allows the usage of keys
var startTime : int := Time.Elapsed %Gets the current time so we know when the game started
var score : int
var xmouse, ymouse, button : int
var font := Font.New ("Impact:26")
var font2 := Font.New ("Arial:12")
var font3 := Font.New ("Sans Serif:40:bold")
var pic : int := Pic.FileNew ("ping-pong.jpg")
var pic2 : int := Pic.FileNew ("win.gif")
var pic3 : int := Pic.FileNew ("the_gameover.jpg")

%Title
Pic.Draw (pic, -25, -35, 0)
Font.Draw ("POWERPong", 30, 310, font3, 53)
Font.Draw ("POWERPong", 30, 305, font3, 54)
Font.Draw ("POWERPong", 30, 300, font3, 55)

procedure instruction
    Font.Draw ("1. Use up and down arrow key to move", 30, 250, font2, black)
    Font.Draw ("2. Last 60 seconds with POWERPong and you'll win!", 30, 200, font2, black)
    Font.Draw ("3. Remember: The ball comes towards you much faster", 30, 150, font2, black)
    Font.Draw ("4. Hold down the left mouse button to see instructions again in game", 30, 100, font2, black)
end instruction

%Game
procedure game
    loop

        View.Set ("offscreenonly") %Updates window offscreen which causes the animation
        Input.KeyDown (chars) %allows the use of the keyboard to control the paddle
        mousewhere (xmouse, ymouse, button) %Determines the location of the mouse
        const BUTTON_X1 := 1280
        const BUTTON_Y1 := 800
        const BUTTON_X2 := 640
        const BUTTON_Y2 := 400
        drawbox (BUTTON_X1, BUTTON_Y1, BUTTON_X2, BUTTON_Y2, 15)
        Draw.FillBox (0, 0, maxx, maxy, black) %Background colour
        drawfillbox (10, box, 20, box + 95, red) %Pong paddle
        drawfilloval (ballx, bally, 6, 6, white) %Pong ball
        delay (3) %Slows down the speed of the ball

        if chars (KEY_UP_ARROW) then %Paddle movement keys
            box += 2
        elsif chars (KEY_DOWN_ARROW) then
            box -= 2
        end if

        %Pong Ball
        ballx := ballx + x %Causes the ball to move around the screen automatically
        bally := bally + y

        if bally >= 390 then %Creates a top boundary for the ball
            y := -1 %Causes the ball to bounce back against the border
        elsif bally = 635 then %Creates a right boundary for the ball
            x := -3
        end if

        %Pong Paddle
        if box >= 320 then %Creates a top boundary for the paddle
            box := 320
        elsif box 