
-----------------------------------
master-awesome
Wed Dec 24, 2014 4:00 pm

My Game Crashes When I Move My Character About 95 Times! How To Fix!
-----------------------------------
I was hoping that when my game restarts, this would get rid of the problem, but it is still giving me the same error. How do I fix this?

-----------------------------------
Zren
Wed Dec 24, 2014 5:07 pm

RE:My Game Crashes When I Move My Character About 95 Times! How To Fix!
-----------------------------------
Since others are lazy, I'll just paste your code here.


% Name: Master-Awesome
% Updated Date: 12/23/2014

import GUI
View.Set ("graphics:720;580")

% Declare Variables
var picID : int
var x : int := 1
var y : int := 36
var dx : int := 600
var dy : int := 36
var xm : int := 720
var ym : int := 360
var dxm : int := 720
var dym : int := 200
var key : string (1)
var mlives : int := 3
var dmlives : int := 9
var steps : int := 94
var fireblastx : int := 600
var fireblasty : int := 80
var fireblastshape : int := 30
var gravity : int := 20
var ground : int := 36
var jump : int := 200

procedure background
    % Background
    GUI.SetBackgroundColour (7)
    picID := Pic.FileNew ("Dark-Castle.jpg")
    Pic.Draw (picID, 215, 370, picCopy)
    colourback (20)
    locate (35, 1)
    put ""
    colourback (20)
    locate (36, 1)
    put ""
    drawfillbox (1, 34, 720, 360, 7)

    % Mario
    drawfillbox (x, y, 720, 200, 7)
    picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-1.jpg")
    Pic.Draw (picID, x, y, picCopy)

    % Display Lives
    % Mario Lives
    colour (0)
    colourback (7)
    locate (2, 8)
    put "Mario = ", mlives
    picID := Pic.FileNew ("Mario/Icon/Mario-icon.jpg")
    Pic.Draw (picID, 20, 400, picCopy)

    % Dark Mario Lives
    colour (0)
    locate (2, 70)
    put "Dark Mario = ", dmlives
    picID := Pic.FileNew ("Dark Mario/Icon/Mario-icon.jpg")
    Pic.Draw (picID, 540, 400, picCopy)

    % Display Steps
    colour (0)
    colourback (20)
    locate (35, 35)
    put "Mario Steps = ", steps
end background

% When Game Is Over, This Is Used To Restart

procedure Try_Again
    steps := 94
    mlives := 3
    dmlives := 9
    background
    drawfillbox (1, 34, 720, 360, 7)
    loop
        getch (key)
        if ord (key) = 205 then % right
            % Steps
            steps := steps - 1
            cls
            background
            % Controls
            drawfillbox (x, y, xm, ym, 7)
            x := x + 40
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-2.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-3.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-1.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            % Dark Mario
            drawfillbox (dx, dy, dxm, dym, 7)
            randint (dx, 1, 600)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-2.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-3.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-1.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
        elsif ord (key) = 203 then % left
            % Steps
            steps := steps - 1
            cls
            background
            % Controls
            drawfillbox (x, y, xm, ym, 7)
            x := x - 40
            picID := Pic.FileNew ("Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-2.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-3.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-1.jpg")
            Pic.Draw (picID, x, y, picCopy)
            % Dark Mario
            drawfillbox (dx, dy, dxm, dym, 7)
            randint (dx, 1, 600)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-2.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-3.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-1.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
        elsif ord (key) = 32 then    % Space To Shoot
            drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 7)
            fireblastx := fireblastx - 10
            drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 41)
            % Controls
            drawfillbox (x, y, xm, ym, 7)
            % Apply Gravity For Character Fall
            y -= gravity
            if y < ground then
                y := ground
            end if
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-1.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
        elsif ord (key) = 208 then   % Down To Reset Shoot Position
            drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 7)
            fireblastx := 600
            drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 41)
        elsif ord (key) = 200 and y = ground then  % Up To Jump
            % Steps
            steps := steps - 1
            cls
            background
            % Controls
            drawfillbox (x, y, xm, ym, 7)
            y := jump
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-2.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-3.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            picID := Pic.FileNew ("Mario/Mario Walking Original/Walking-Mario-1.jpg")
            Pic.Draw (picID, x, y, picCopy)
            delay (50)
            % Dark Mario
            drawfillbox (dx, dy, dxm, dym, 7)
            randint (dx, 1, 600)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-2.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-3.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
            delay (50)
            picID := Pic.FileNew ("Dark Mario/Mario Walking Opposite Direction/Mario-Walking-Opposite-Direction-1.jpg")
            Pic.Draw (picID, dx, dy, picCopy)
        end if

        % Display Fire Blast
        drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 7)
        fireblastx := fireblastx - 10
        drawfilloval (fireblastx, fireblasty, fireblastshape, fireblastshape, 41)

        % Apply Gravity For Character Fall
        y -= gravity
        if y < ground then
            y := ground
        end if

        % Lives
        if x = dx and y = dy then
            mlives := mlives - 1
            steps := steps - 1
            cls
            background
        elsif fireblastx < dx then
            dmlives := dmlives - 1
            delay (20)
            cls
            background
            fireblastx := 600
        end if
        % Game Over
        if mlives 