Computer Science Canada

Problems with jumping in my platform game.

Author:  GlobeTrotter [ Sat Jun 12, 2004 11:10 pm ]
Post subject:  Problems with jumping in my platform game.

This is my mario-style game.
Why is it that:
A) When you hold up and down at the same time you sort of fly.
B) When you jump from high enough and hold up, you double jump in mid-air sometimes.

Any help would be appreciated.

code:

setscreen ("offscreenonly")
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var jump := true
var cheats : string

x := xsize + 20
y := ysize + 100
vx := 0
grav := 0.3

loop
    delay (20)
    cls
    Input.KeyDown (chars)
    if chars (KEY_CTRL) then
        get cheats
        if cheats = "nogravity" and grav ~= 0.07 then
            grav := 0.07
        else
            grav := 0.3
        end if
    end if

    if chars (KEY_UP_ARROW) and not jump then
        vy := 5
        jump := true
    elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
        ysize := 7
    elsif chars (KEY_DOWN_ARROW) and jump then
        vy := -5
        ysize := 8
    elsif chars (KEY_DOWN_ARROW) and not jump then
        ysize := 5
    else
        ysize := 10
    end if

    if chars (KEY_LEFT_ARROW) then
        vx := -3
    elsif chars (KEY_RIGHT_ARROW) then
        vx := 3
    else
        vx := 0
    end if
    if jump then
        y += vy
        vy -= grav
    else
        vy := 0
    end if
    ysize += round (vy / 2)
    x += vx



    drawfillbox (0, 0, maxx, 100, 7)
    drawfillbox (80, 120, 150, 140, 7)
    drawfillbox (10, 160, 50, 180, 7)
    drawfillbox (400, 190, 110, 200, 7)
    drawfillbox (350, 110, 390, 122, 7)
    drawfillbox (0, 0, 20, maxy, 7)
    drawfillbox (maxx, 0, maxx - 20, maxy, 7)

    for i : 0 .. 5
        drawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
    end for
    drawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 7)
    drawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 7)
    drawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
    drawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
    drawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 7)
    if whatdotcolor (round (x), round (y) + ysize + 1) ~= 0 then
        y -= 1
    end if
    if y - ysize <= 100 or whatdotcolor (round (x), round (y) - ysize - 1) ~= 0 then
        jump := false
    elsif whatdotcolor (round (x), round (y) - ysize - 1) = 0 then
        jump := true
    end if
    if whatdotcolor (round (x), round (y) + ysize + 1) ~= 0 then
        vy := -0.5
    elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) ~= 0 then
        y += 1
    end if

    if chars (KEY_LEFT_ARROW) and whatdotcolor (round (x) - xsize - 1, round (y)) ~= 0 then
        x -= vx
    end if
    if chars (KEY_RIGHT_ARROW) and whatdotcolor (round (x) + xsize + 1, round (y)) ~= 0 then
        x -= vx
    end if
    View.Update
end loop



Author:  Cervantes [ Sun Jun 13, 2004 8:23 am ]
Post subject: 

oh my, I love your character! You are truly an artist!!
but, unfortunately, in your attempt to give him a mouth, you created the problem that led you here.
When your character jumps and you hit down, he looks down. ie, his eyes and mouth move under his body kinda. nice looking, but it screws things up. because then when the program asks,
code:

if y - ysize <= 100 or whatdotcolor (round (x), round (y) - ysize - 1) ~= 0 then

the whatdotcolour says is checking right where that pesky mouth is and it says "no, it's not = 0" and it therefore goes into that if statement, and does this:
code:
jump := false

Now that jump is false, both of these conditions:
code:
if chars (KEY_UP_ARROW) and not jump then

can be satisfied, since jump was made false.

your second problem is the same. after a while, his mouth and eyes aim downwards if he's in the air long enough. hitting down just accelerates how long it takes before his eyes and eyebrow are underneath him.

So, basically, he's jumping off of his own mouth. Laughing
to fix it, comment out this line
code:
drawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 7)

now he has no eyebrows, and his eyes aren't a problem because no part of them is exactly in the centre of his body (when using whatdotcolour, you check at x, the exact middle of his body. the eyes are on either side). I guess the easiest way to fix this is chaning the colours around a bit. Make his mouth a dark brown or something and incorporate that into the whatdotcolour collision.

now its time for my question(s):
in an if statement when you're comparing two things, what does ~= do? Thinking I guess its like not but im not sure. I'm ~ sure? Laughing
and what's with the ~ before chars in this if statement:
code:
elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) ~= 0 then



Cheers

Author:  SuperGenius [ Sun Jun 13, 2004 9:10 am ]
Post subject: 

I like the complex animation of the character, in only a few lines. good job on that.

Author:  mynameisbob [ Sun Jun 13, 2004 10:02 am ]
Post subject: 

Cervantes, I think your talking about his mouth.

Author:  Cervantes [ Sun Jun 13, 2004 12:44 pm ]
Post subject: 

erg, i tihnk that you will have to do the same thing with the eyes, because if you are moving left or right one part of the eyes will have the same x value as the centre of the character..
in other words, you can do the double jump if you are moving left or right.

Author:  GlobeTrotter [ Sun Jun 13, 2004 1:25 pm ]
Post subject: 

Thanks. I figured it out from there. I simply changed all ~= 0 to = 7 basically. Then I changed the color of my mouth and eyes so that they are different from the bricks. As for ~=, it is the same as not =.
Here is an updated example.

code:

setscreen ("graphics:650;510,nobuttonbar,nocursor,noecho,offscreenonly")
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var exsize, eysize : int
var win, jump, dying, dead := true
var cheats, temp : string
var enemies, ecount := 5
var ecolor : array 1 .. enemies of int
var ex : array 1 .. enemies of real
var ey : array 1 .. enemies of real
var evy, evx : array 1 .. enemies of real
var ejump, edead : array 1 .. enemies of boolean
var mx, my, mb : int
var mlocate := false
var bgcolor, brickcol, lavacol, doorcol : int
procedure InitRoom1
    brickcol := 7
    doorcol := 4
    lavacol := 12
    bgcolor := 51
    exsize := 8
    eysize := 6
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 218
    ex (2) := 317
    ex (3) := 508
    ex (4) := 45
    ex (5) := 120
    ey (1) := 429
    ey (2) := 298
    ey (3) := 129
    ey (4) := 135
    ey (5) := 433
    ecount := 5
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 1
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
end InitRoom1
procedure DrawRoom1
    drawfillbox (648, 97, -29, -22, brickcol)
    drawfilloval (277, 97, 107, -19, lavacol)
    drawfillbox (128, 139, 168, 122, brickcol)
    drawfillbox (186, 165, 218, 146, brickcol)
    drawfillbox (243, 192, 270, 176, brickcol)
    drawfillbox (354, 161, 382, 140, brickcol)
    drawfillbox (398, 194, 437, 173, brickcol)
    drawfillbox (455, 236, 530, 216, brickcol)
    drawfillbox (545, 275, 605, 255, brickcol)
    drawfillbox (399, 110, 383, 89, brickcol)
    drawfillbox (172, 112, 151, 84, brickcol)
    drawfillbox (519, 311, 437, 296, brickcol)
    drawfillbox (387, 276, 200, 263, brickcol)
    drawfillbox (387, 290, 373, 276, brickcol)
    drawfillbox (209, 293, 199, 270, brickcol)
    drawfilloval (289, 274, -17, -4, lavacol)
    drawfilloval (237, 276, -14, -2, lavacol)
    drawfilloval (346, 275, -13, -2, lavacol)
    drawfillbox (154, 316, 116, 305, brickcol)
    drawfillbox (56, 345, 98, 331, brickcol)
    drawfillbox (16, 384, 60, 366, brickcol)
    drawfillbox (76, 413, 252, 401, brickcol)
    drawfillbox (252, 432, 235, 401, brickcol)
    drawfillbox (89, 433, 76, 402, brickcol)
    drawfillbox (153, 369, 211, 355, brickcol)
    drawfilloval (180, 368, 21, -6, lavacol)
    drawfillbox (159, 429, 168, 411, brickcol)
    drawfillbox (193, 428, 206, 409, brickcol)
    drawfillbox (295, 420, 339, 403, brickcol)
    drawfillbox (373, 418, 408, 401, brickcol)
    drawfillbox (428, 440, 459, 426, brickcol)
    drawfillbox (470, 456, 499, 442, brickcol)
    drawfillbox (506, 477, 545, 463, brickcol)
    drawfillbox (572, 478, 654, 460, brickcol)
    drawfillbox (626, 478, 656, 526, doorcol)
    drawfilloval (633, 496, 2, 2, yellow)
    drawfillbox (169, 421, 192, 388, bgcolor)
    drawfillbox (187, 409, 195, 379, bgcolor)
    drawfillbox (199, 376, 158, 391, bgcolor)
    drawfillbox (634, 96, 649, 463, brickcol)
    drawfillbox (12, 95, -6, 527, brickcol)
end DrawRoom1


loop
    InitRoom1

    vx := 0
    grav := 0.3
    dying := false
    dead := false
    win := false

    loop
        delay (20)
        cls
        Input.KeyDown (chars)
        if chars ('p') then
            loop
                exit when hasch
                locatexy (maxx div 2, maxy div 2)
            end loop
        end if
        if chars (KEY_CTRL) then
            get cheats
            if cheats = "gravity" then
                get grav
            end if
            if cheats = "locate" then
                mlocate := true
            end if
            if cheats = "locatexy" then
                get x, y
            end if
            if cheats = "killall" then
                for i : 1 .. enemies
                    edead (i) := true
                    ecount -= 1
                end for
            end if
            if cheats = "color" then
                get temp
                if temp = "background" then
                    get bgcolor
                elsif temp = "brick" then
                    get brickcol
                elsif temp = "door" then
                    get doorcol
                elsif temp = "lava" then
                    get lavacol
                end if
            end if
        end if

        if mlocate then
            mousewhere (mx, my, mb)
            if mb = 1 then
                x := mx
                y := my
            end if
        end if

        if chars (KEY_UP_ARROW) and not jump then
            vy := 5
            jump := true
        elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
            ysize := 7
        elsif chars (KEY_DOWN_ARROW) and jump then
            vy := -5
            ysize := 8
        elsif chars (KEY_DOWN_ARROW) and not jump then
            ysize := 5
        else
            ysize := 10
        end if

        if chars (KEY_LEFT_ARROW) then
            vx := -3
        elsif chars (KEY_RIGHT_ARROW) then
            vx := 3
        else
            vx := 0
        end if
        if jump then
            y += vy
            vy -= grav
        else
            vy := 0
        end if
        if vy < -9 then
            dying := true
        end if
        ysize += round (vy / 2)
        x += vx

        %ENEMY STUFF
        for i : 1 .. enemies
            if not edead (i) then
                ex (i) += evx (i)
                if ejump (i) then
                    ey (i) += evy (i)
                    evy (i) -= grav
                else
                    evy (i) := 0
                end if
            end if
        end for


        DrawRoom1



        for i : 1 .. enemies
            if not edead (i) then
                for k : 1 .. 5
                    drawfilloval (round (ex (i)), round (ey (i)), exsize - k, eysize - k, RGB.AddColor (k / 5 * ecolor (i), k / 5, k / 5 * ecolor (i)))
                end for
                drawfilloval (round (ex (i) + (evx (i)) * 3), round (ey (i)), 1, 1, 7)
                drawline (round (ex (i) + (evx (i)) * -6), round (ey (i)) - 1, round (ex (i) + (evx (i)) * -9), round (ey (i)) - 1, 7)
            end if
        end for
        for i : 0 .. 5
            drawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
        end for
        drawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
        drawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
        drawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
        drawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
        drawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 4)
        if whatdotcolor (round (x), round (y) + ysize + 1) = brickcol then
            y -= 1
        end if
        if y - ysize <= 100 or whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
            jump := false
        elsif whatdotcolor (round (x), round (y) - ysize - 1) = bgcolor then
            jump := true
        end if
        if whatdotcolor (round (x), round (y) + ysize + 1) = brickcol then
            vy := -0.5
        elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
            y += 1
        end if

        if chars (KEY_LEFT_ARROW) and whatdotcolor (round (x) - xsize - 1, round (y)) = brickcol then
            x -= vx
        end if
        if chars (KEY_RIGHT_ARROW) and whatdotcolor (round (x) + xsize + 1, round (y)) = brickcol then
            x -= vx
        end if
        if whatdotcolor (round (x), round (y) - ysize - 1) = brickcol and dying then
            dead := true
        end if
        if whatdotcolor (round (x), round (y) - ysize - 2) = lavacol then
            dead := true
        end if
        %ENEMY STUFF
        for i : 1 .. enemies
            if not edead (i) then
                if whatdotcolor (round (ex (i)), round (ey (i)) - eysize - 1) = bgcolor then
                    ejump (i) := true
                else
                    ejump (i) := false
                end if

                if whatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = brickcol or whatdotcolor (round (ex (i)) + 9, round (ey (i))) = brickcol then
                    evx (i) *= -1
                end if
                if sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy < -1.3 then
                    edead (i) := true
                    ecount -= 1
                    vy := 4
                elsif sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy > -1.3 then
                    dead := true
                end if
            end if
        end for
        if ecount = 0 and whatdotcolor (round (x) + xsize + 4, round (y)) = doorcol then
            win := true
        elsif whatdotcolor (round (x) + xsize + 4, round (y)) = 4 and ecount ~= 0 then
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (i / 10, i / 10, 0))
                delay (100)
                View.Update
            end for
            colorback (0)
            x := xsize + 20     %Player's starting position
            y := ysize + 100     %Player's starting position
        end if
        View.Update
        exit when dead or win
    end loop
    if dead then
        for i : 1 .. 10
            cls
            colorback (RGB.AddColor (i / 10, 0, 0))
            delay (100)
            View.Update
        end for
    else
        for i : 1 .. 10
            cls
            colorback (RGB.AddColor (0, i / 10, 0))
            delay (100)
            View.Update
        end for
    end if
    colorback (0)
    exit when not dead
end loop

Author:  SuperGenius [ Sun Jun 13, 2004 2:43 pm ]
Post subject: 

Wow i like what you did with it.

Author:  GlobeTrotter [ Sun Jun 13, 2004 9:20 pm ]
Post subject: 

I added another level, and I have another question.
How would it be possible to stop my guy from bouncing? I may keep him bouncing since he is a ball, but for gameplay's sake, I'd like to see how the game plays without the bouncing. I didn't program the bounce intentionally, so I don't know how to stop it. Help please.

code:

setscreen ("graphics:650;510,nobuttonbar,nocursor,noecho,offscreenonly")
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var exsize, eysize : int
var win, jump, dying, dead := true
var cheats, temp : string
var enemies, ecount := 5
var ecolor : array 1 .. enemies of int
var ex : array 1 .. enemies of real
var ey : array 1 .. enemies of real
var evy, evx : array 1 .. enemies of real
var ejump, edead : array 1 .. enemies of boolean
var mx, my, mb : int
var mlocate, nofalldie := false
var bgcolor, brickcol, lavacol, doorcol : int
const dyingspeed := 10
procedure InitRoom1
    brickcol := 7
    doorcol := 4
    lavacol := 12
    bgcolor := 51
    exsize := 8
    eysize := 6
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 218
    ex (2) := 317
    ex (3) := 508
    ex (4) := 45
    ex (5) := 120
    ey (1) := 429
    ey (2) := 298
    ey (3) := 129
    ey (4) := 135
    ey (5) := 433
    ecount := 5
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 1
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
end InitRoom1
procedure InitRoom2
    brickcol := 7
    doorcol := 4
    lavacol := 12
    bgcolor := 51
    exsize := 8
    eysize := 6
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 406
    ex (2) := 575
    ex (3) := 125
    ex (4) := 212
    ex (5) := 254
    ey (1) := 353
    ey (2) := 388
    ey (3) := 433
    ey (4) := 246
    ey (5) := 171
    ecount := 5
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 2
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
end InitRoom2
procedure DrawRoom1
    drawfillbox (648, 97, -29, -22, brickcol)
    drawfilloval (277, 97, 107, -19, lavacol)
    drawfillbox (128, 139, 168, 122, brickcol)
    drawfillbox (186, 165, 218, 146, brickcol)
    drawfillbox (243, 192, 270, 176, brickcol)
    drawfillbox (354, 161, 382, 140, brickcol)
    drawfillbox (398, 194, 437, 173, brickcol)
    drawfillbox (455, 236, 530, 216, brickcol)
    drawfillbox (545, 275, 605, 255, brickcol)
    drawfillbox (399, 110, 383, 89, brickcol)
    drawfillbox (172, 112, 151, 84, brickcol)
    drawfillbox (519, 311, 437, 296, brickcol)
    drawfillbox (387, 276, 200, 263, brickcol)
    drawfillbox (387, 290, 373, 276, brickcol)
    drawfillbox (209, 293, 199, 270, brickcol)
    drawfilloval (289, 274, -17, -4, lavacol)
    drawfilloval (237, 276, -14, -2, lavacol)
    drawfilloval (346, 275, -13, -2, lavacol)
    drawfillbox (154, 316, 116, 305, brickcol)
    drawfillbox (56, 345, 98, 331, brickcol)
    drawfillbox (16, 384, 60, 366, brickcol)
    drawfillbox (76, 413, 252, 401, brickcol)
    drawfillbox (252, 432, 235, 401, brickcol)
    drawfillbox (89, 433, 76, 402, brickcol)
    drawfillbox (153, 369, 211, 355, brickcol)
    drawfilloval (180, 368, 21, -6, lavacol)
    drawfillbox (159, 429, 168, 411, brickcol)
    drawfillbox (193, 428, 206, 409, brickcol)
    drawfillbox (295, 420, 339, 403, brickcol)
    drawfillbox (373, 418, 408, 401, brickcol)
    drawfillbox (428, 440, 459, 426, brickcol)
    drawfillbox (470, 456, 499, 442, brickcol)
    drawfillbox (506, 477, 545, 463, brickcol)
    drawfillbox (572, 478, 654, 460, brickcol)
    drawfillbox (626, 478, 656, 526, doorcol)
    drawfilloval (633, 496, 2, 2, yellow)
    drawfillbox (169, 421, 192, 388, bgcolor)
    drawfillbox (187, 409, 195, 379, bgcolor)
    drawfillbox (199, 376, 158, 391, bgcolor)
    drawfillbox (634, 96, 649, 463, brickcol)
    drawfillbox (12, 95, -6, 527, brickcol)
end DrawRoom1

procedure DrawRoom2
    drawfillbox (648, 25, 0, 0, lavacol)
    drawfillbox (25, 508, -2, -5, brickcol)
    drawfillbox (622, 508, 677, -19, brickcol)
    drawfillbox (25, 43, 91, -6, brickcol)
    drawfillbox (143, 71, 194, 46, brickcol)
    drawfillbox (92, 125, 137, 101, brickcol)
    drawfillbox (69, 152, 16, 179, brickcol)
    drawfillbox (272, 207, 69, 232, brickcol)
    drawfillbox (234, 162, 266, 136, brickcol)
    drawfillbox (296, 121, 415, 93, brickcol)
    drawfillbox (139, 188, 224, 171, brickcol)
    drawfillbox (139, 185, 140, 179, brickcol)
    drawfillbox (139, 186, 151, 211, brickcol)
    drawfillbox (295, 121, 266, 93, brickcol)
    drawfillbox (399, 137, 414, 119, brickcol)
    drawfillbox (141, 270, 150, 232, brickcol)
    drawfillbox (258, 249, 270, 230, brickcol)
    drawfilloval (145, 270, 4, -4, lavacol)
    drawfillbox (255, 137, 269, 118, brickcol)
    drawfilloval (332, 120, 40, -2, lavacol)
    drawfilloval (433, 96, 22, -23, brickcol)
    drawfilloval (490, 84, 25, -19, brickcol)
    drawfilloval (529, 140, 22, -17, brickcol)
    drawfilloval (480, 181, 11, -7, brickcol)
    drawfilloval (510, 228, 21, -14, brickcol)
    drawfilloval (561, 259, 20, -13, brickcol)
    drawfilloval (503, 323, 10, -10, brickcol)
    drawfilloval (480, 284, 10, -10, brickcol)
    drawfilloval (543, 303, 8, -9, brickcol)
    drawfillbox (522, 372, 622, 345, brickcol)
    drawfillbox (273, 411, 477, 427, brickcol)
    drawfillbox (333, 396, 142, 381, brickcol)
    drawfillbox (41, 430, 169, 417, brickcol)
    drawfillbox (318, 410, 330, 395, brickcol)
    drawfillbox (139, 417, 156, 393, brickcol)
    drawfillbox (521, 367, 529, 388, brickcol)
    drawfilloval (399, 347, 75, 23, brickcol)
    drawfillbox (452, 339, 350, 388, bgcolor)
    drawfillbox (296, 292, 424, 258, brickcol)
    drawfillbox (95, 473, 624, 485, brickcol)
    drawfillbox (605, 485, 625, 510, doorcol)
    drawfilloval (609, 500, 2, 2, yellow)
    drawfilloval (358, 292, 60, 8, lavacol)
end DrawRoom2

for level : 1 .. 2
    loop
        if level = 1 then
            InitRoom1
        elsif level = 2 then
            InitRoom2
        end if

        vx := 0
        grav := 0.3
        dying := false
        dead := false
        win := false

        loop
            delay (20)
            cls
            Input.KeyDown (chars)
            if chars ('p') then
                loop
                    exit when hasch
                    locatexy (maxx div 2, maxy div 2)
                end loop
            end if
            if chars (KEY_CTRL) then
                get cheats
                if cheats = "gravity" or cheats = "grav" then
                    get grav
                end if
                if cheats = "locate" then
                    if ~mlocate then
                        mlocate := true
                    else
                        mlocate := false
                    end if
                end if
                if cheats = "locatexy" then
                    get x, y
                end if
                if cheats = "killall" then
                    for i : 1 .. enemies
                        edead (i) := true
                        ecount -= 1
                    end for
                end if
                if cheats = "nextlevel" then
                    for i : 1 .. enemies
                        edead (i) := true
                        ecount -= 1
                    end for
                    drawfilloval (round (x) + xsize + 4, round (y), 4, 4, doorcol)
                end if
                if cheats = "color" then
                    get temp
                    if temp = "background" then
                        get bgcolor
                        colorback (bgcolor)
                        cls
                    elsif temp = "brick" then
                        get brickcol
                    elsif temp = "door" then
                        get doorcol
                    elsif temp = "lava" then
                        get lavacol
                    end if
                end if
                if cheats = "nofalldie" then
                    if ~nofalldie then
                        nofalldie := true
                    else
                        nofalldie := false
                    end if
                end if
                if cheats = "restart" then
                    if level = 1 then
                        InitRoom1
                    elsif level = 2 then
                        InitRoom2
                    end if
                end if
            end if

            if mlocate then
                mousewhere (mx, my, mb)
                if mb = 1 then
                    x := mx
                    y := my
                    vy := 0
                end if
            end if

            if chars (KEY_UP_ARROW) and not jump then
                vy := 5
                jump := true
            elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
                ysize := 7
            elsif chars (KEY_DOWN_ARROW) and jump then
                vy := -5
                ysize := 8
            elsif chars (KEY_DOWN_ARROW) and not jump then
                ysize := 5
            else
                ysize := 10
            end if

            if chars (KEY_LEFT_ARROW) then
                vx := -3
            elsif chars (KEY_RIGHT_ARROW) then
                vx := 3
            else
                vx := 0
            end if
            if jump then
                y += vy
                vy -= grav
            else
                vy := 0
            end if
            if ~nofalldie and vy < -dyingspeed then
                dying := true
            end if
            ysize += round (vy / 2)
            x += vx

            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    ex (i) += evx (i)
                    if ejump (i) then
                        ey (i) += evy (i)
                        evy (i) -= grav
                    else
                        evy (i) := 0
                    end if
                end if
            end for

            if level = 1 then
                DrawRoom1
            elsif level = 2 then
                DrawRoom2
            end if



            for i : 1 .. enemies
                if not edead (i) then
                    for k : 1 .. 5
                        drawfilloval (round (ex (i)), round (ey (i)), exsize - k, eysize - k, RGB.AddColor (k / 5 * ecolor (i), k / 5, k / 5 * ecolor (i)))
                    end for
                    drawfilloval (round (ex (i) + (evx (i)) * 3), round (ey (i)), 1, 1, 7)
                    drawline (round (ex (i) + (evx (i)) * -6), round (ey (i)) - 2, round (ex (i) + (evx (i)) * -9), round (ey (i)) - 2, 7)
                end if
            end for
            for i : 0 .. 5
                drawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
            end for
            drawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            drawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            drawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
            drawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
            drawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 4)
            if whatdotcolor (round (x), round (y) + ysize + 1) = brickcol and whatdotcolor (round (x), round (y) - ysize - 1) ~= brickcol then
                y -= 1
            elsif whatdotcolor (round (x), round (y) + ysize + 1) = brickcol and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 1
            end if
            if whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                jump := false
            elsif whatdotcolor (round (x), round (y) - ysize - 1) = bgcolor then
                jump := true
            end if
            if whatdotcolor (round (x), round (y) + ysize + 1) = brickcol then
                vy := -0.5
            elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 2
            end if

            if chars (KEY_LEFT_ARROW) and whatdotcolor (round (x) - xsize - 1, round (y)) = brickcol then
                x -= vx
            end if
            if chars (KEY_RIGHT_ARROW) and whatdotcolor (round (x) + xsize + 1, round (y)) = brickcol then
                x -= vx
            end if
            if whatdotcolor (round (x), round (y) - ysize - 1) ~= bgcolor and dying then
                dead := true
            end if
            if whatdotcolor (round (x), round (y) - ysize - 1) = lavacol then
                dead := true
            end if
            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    if whatdotcolor (round (ex (i)), round (ey (i)) - eysize - 1) = bgcolor then
                        ejump (i) := true
                    else
                        ejump (i) := false
                    end if

                    if whatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = brickcol or whatdotcolor (round (ex (i)) + 9, round (ey (i))) = brickcol then
                        evx (i) *= -1
                    end if
                    if sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy < -1.3 then
                        edead (i) := true
                        ecount -= 1
                        vy := 4
                    elsif sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy > -1.3 then
                        dead := true
                    end if
                end if
            end for
            if ecount = 0 and whatdotcolor (round (x) + xsize + 4, round (y)) = doorcol then
                win := true
            elsif whatdotcolor (round (x) + xsize + 4, round (y)) = 4 and ecount ~= 0 then
                for i : 1 .. 10
                    cls
                    colorback (RGB.AddColor (i / 10, i / 10, 0))
                    delay (100)
                    View.Update
                end for
                colorback (bgcolor)
                x := xsize + 20     %Player's starting position
                y := ysize + 100     %Player's starting position
            end if
            View.Update
            exit when dead or win
        end loop
        if dead then
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (i / 10, 0, 0))
                delay (100)
                View.Update
            end for
        else
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (0, i / 10, 0))
                delay (100)
                View.Update
            end for
        end if
        colorback (0)
        exit when not dead
    end loop
end for

Author:  mynameisbob [ Sun Jun 13, 2004 10:32 pm ]
Post subject: 

they both look like the same level...
i think ive found a bug in ur game. Usually when the player falls from a high place he dies, but if you hold down while falling he doesnt die.

Author:  GlobeTrotter [ Sun Jun 13, 2004 11:11 pm ]
Post subject: 

I will try and fix the bug. It is caused by: When the player hits down and he's in mid-air it sets his vertical velocity to a certain amount (less than the max speed before he is killed). The only thing I can think of is so that when you press down in mod-air, you can can only press it once per jump.

As for them both being the same level, you have to beat the first level to get to the second.

Author:  Cervantes [ Mon Jun 14, 2004 8:25 am ]
Post subject: 

this game has lots of potential! keep working on it.

to stop him from bouncing, try commenting out these lines:
code:
           
elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
            y += 2


hope that helps

Author:  beard0 [ Mon Jun 14, 2004 10:19 am ]
Post subject: 

Great game! I was messing around with your latest version, and found one little bug: When I was falling quickly, I was able to fall through some of a smaller piece of "ground" I'd suggest that you put your whatdotcolor testing in a for loop to check all the pixels between the bottom of your character, and the pixel at which his bottom would next be at the current velocity. But other than that, it looks pretty good to me.

Author:  GlobeTrotter [ Mon Jun 14, 2004 3:12 pm ]
Post subject: 

Cervantes wrote:
this game has lots of potential! keep working on it.

to stop him from bouncing, try commenting out these lines:
code:
           
elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
            y += 2


hope that helps


That doesn't really help, since that is what I use so that when his downward velocity is greater than 1 and he hits the brick in the middle of it, he moves to the top of it. When I uncommented that, and jumped from a relatively high height he went right to the middle of the brick and got stuck.

Author:  beard0 [ Tue Jun 15, 2004 9:39 am ]
Post subject: 

GlobeTrotter:
Try re-commenting that section, and applying my for loop whatdotcolor testing, so that as he falls, you can stop him from getting to the middle of the ground that way. (if there's ground somwhere within the space between him and where he should be in the next frame, just set his y value to be on the ground.
Once you have this all set up, you'll have to make a level editor Very Happy !


Good Luck!

Author:  GlobeTrotter [ Thu Jun 17, 2004 6:44 pm ]
Post subject: 

I managed to stop the bounce. I also added some other features:
-cooler background
-coins
-no longer go through blocks

Here it is. You need to kill all the people to progress to the next level. Try and collect coins too.


code:

setscreen ("graphics:650;530,nobuttonbar,nocursor,noecho,offscreenonly")
var gmaxx, gmaxy : int
gmaxx := 650
gmaxy := 510
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var exsize, eysize : int
var win, jump, dying, dead := true
var cheats, temp : string
var enemies, ecount := 5
var ecolor : array 1 .. enemies of int
var ex : array 1 .. enemies of real
var ey : array 1 .. enemies of real
var evy, evx : array 1 .. enemies of real
var ejump, edead : array 1 .. enemies of boolean
var coins := 10
var cx : array 1 .. coins of int
var cy : array 1 .. coins of int
var cdead : array 1 .. coins of boolean
var coincount : int := 0
var mx, my, mb : int
var mlocate, nofalldie, cheatlevel := false
var bgcolor, brickcol, lavacol, doorcol : int
var starx, stary : array 1 .. 100 of int
var starsize : int
var timer : int := 1
const dyingspeed := 10
procedure InitRoom1
    timer := 1
    grav := 0.3
    brickcol := 2
    doorcol := 4
    lavacol := 12
    bgcolor := 7
    exsize := 8
    eysize := 6
    cheatlevel := false
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 218
    ex (2) := 317
    ex (3) := 508
    ex (4) := 45
    ex (5) := 120
    ey (1) := 429
    ey (2) := 298
    ey (3) := 129
    ey (4) := 135
    ey (5) := 433
    %Coin Positions
    cx (1) := 525
    cy (1) := 490
    cx (2) := 483
    cy (2) := 472
    cx (3) := 207
    cy (3) := 385
    cx (4) := 442
    cy (4) := 457
    cx (5) := 23
    cy (5) := 198
    cx (6) := 83
    cy (6) := 482
    cx (7) := 619
    cy (7) := 115
    cx (8) := 255
    cy (8) := 213
    cx (9) := 199
    cy (9) := 185
    cx (10) := 146
    cy (10) := 162
    for i : 1 .. coins
        cdead (i) := false
    end for

    ecount := 5
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 1
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
    for i : 1 .. 100
        starx (i) := Rand.Int (0, gmaxx)
        stary (i) := Rand.Int (0, gmaxy)
    end for
end InitRoom1
procedure InitRoom2
    timer := 0
    grav := 0.3
    brickcol := 15
    doorcol := 4
    lavacol := 112
    bgcolor := 7
    exsize := 8
    eysize := 6
    cheatlevel := false
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 406
    ex (2) := 575
    ex (3) := 125
    ex (4) := 212
    ex (5) := 254
    ey (1) := 353
    ey (2) := 388
    ey (3) := 433
    ey (4) := 246
    ey (5) := 171
    ecount := 5

    %Coin Positions
    cx (1) := 166
    cy (1) := 87
    cx (2) := 114
    cy (2) := 144
    cx (3) := 163
    cy (3) := 195
    cx (4) := 202
    cy (4) := 197
    cx (5) := 561
    cy (5) := 282
    cx (6) := 424
    cy (6) := 304
    cx (7) := 144
    cy (7) := 292
    cx (8) := 167
    cy (8) := 405
    cx (9) := 305
    cy (9) := 404
    cx (10) := 541
    cy (10) := 327
    for i : 1 .. coins
        cdead (i) := false
    end for
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 2
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
    for i : 1 .. 100
        starx (i) := Rand.Int (0, gmaxx)
        stary (i) := Rand.Int (0, gmaxy)
    end for
end InitRoom2
procedure DrawRoom1
    if timer < 3000 then
        timer += 1
    end if
    bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
    brickcol := RGB.AddColor (timer / 10000, 0.3 + timer / 10000, timer / 10000)
    colorback (bgcolor)
    cls
    for i : 1 .. 100
        randint (starsize, 0, 1)
        drawfilloval (starx (i) - timer div 110, stary (i) - timer div 60, starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
    end for
    for i : 1 .. 25
        drawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
    end for
    for i : 1 .. coins
        if ~cdead (i) then
            drawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
        end if
    end for
    drawfillbox (648, 97, -29, -22, brickcol)
    drawfilloval (277, 97, 107, -19, lavacol)
    drawfillbox (128, 139, 168, 122, brickcol)
    drawfillbox (186, 165, 218, 146, brickcol)
    drawfillbox (243, 192, 270, 176, brickcol)
    %drawfillbox (354, 161, 382, 140, brickcol)
    drawfillbox (398, 194, 437, 173, brickcol)
    drawfillbox (455, 236, 530, 216, brickcol)
    drawfillbox (545, 275, 605, 255, brickcol)
    drawfillbox (399, 110, 383, 89, brickcol)
    drawfillbox (172, 112, 151, 84, brickcol)
    drawfillbox (519, 311, 437, 296, brickcol)
    drawfillbox (387, 276, 200, 263, brickcol)
    drawfillbox (387, 290, 373, 276, brickcol)
    drawfillbox (209, 293, 199, 270, brickcol)
    drawfilloval (289, 274, -17, -4, lavacol)
    drawfilloval (237, 276, -14, -2, lavacol)
    drawfilloval (346, 275, -13, -2, lavacol)
    drawfillbox (154, 316, 116, 305, brickcol)
    drawfillbox (56, 345, 98, 331, brickcol)
    drawfillbox (16, 384, 60, 366, brickcol)
    drawfillbox (76, 413, 252, 401, brickcol)
    drawfillbox (252, 432, 235, 401, brickcol)
    drawfillbox (89, 433, 76, 402, brickcol)
    drawfillbox (153, 369, 211, 355, brickcol)
    drawfilloval (180, 368, 21, -6, lavacol)
    drawfillbox (159, 429, 168, 411, brickcol)
    drawfillbox (193, 428, 206, 409, brickcol)
    drawfillbox (295, 420, 339, 403, brickcol)
    drawfillbox (373, 418, 408, 401, brickcol)
    drawfillbox (428, 440, 459, 426, brickcol)
    drawfillbox (470, 456, 499, 442, brickcol)
    drawfillbox (506, 477, 545, 463, brickcol)
    drawfillbox (572, 478, 654, 460, brickcol)
    drawfillbox (626, 478, 656, 526, doorcol)
    drawfilloval (633, 496, 2, 2, yellow)
    drawfillbox (169, 421, 192, 388, bgcolor)
    drawfillbox (187, 409, 195, 379, bgcolor)
    drawfillbox (199, 376, 158, 391, bgcolor)
    drawfillbox (634, 96, 649, 463, brickcol)
    drawfillbox (12, 95, -6, 527, brickcol)
end DrawRoom1

procedure DrawRoom2
    if timer < 3000 then
        timer += 1
    end if
    bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
    brickcol := RGB.AddColor (0.3 + timer / 10000, 0.3 + timer / 10000, 0.3 + timer / 10000)
    colorback (bgcolor)
    cls
    for i : 1 .. 100
        randint (starsize, 0, 1)
        drawfilloval (starx (i), stary (i), starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
    end for
    for i : 1 .. 25
        drawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
    end for
    for i : 1 .. coins
        if ~cdead (i) then
            drawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
        end if
    end for
    drawfillbox (648, 25, 0, 0, lavacol)
    drawfillbox (25, 508, -2, -5, brickcol)
    drawfillbox (622, 508, 677, -19, brickcol)
    drawfillbox (25, 43, 91, -6, brickcol)
    drawfillbox (140, 71, 194, 46, brickcol)
    drawfillbox (92, 125, 137, 101, brickcol)
    drawfillbox (69, 152, 16, 179, brickcol)
    drawfillbox (272, 207, 69, 232, brickcol)
    drawfillbox (234, 162, 266, 136, brickcol)
    drawfillbox (296, 121, 415, 93, brickcol)
    drawfillbox (139, 188, 224, 171, brickcol)
    drawfillbox (139, 185, 140, 179, brickcol)
    drawfillbox (139, 186, 151, 211, brickcol)
    drawfillbox (295, 121, 266, 93, brickcol)
    drawfillbox (399, 137, 414, 119, brickcol)
    drawfillbox (141, 270, 150, 232, brickcol)
    drawfillbox (258, 249, 270, 230, brickcol)
    drawfilloval (145, 270, 4, -4, lavacol)
    drawfillbox (255, 137, 269, 118, brickcol)
    drawfilloval (332, 120, 40, -2, lavacol)
    %drawfilloval (433, 96, 22, -23, brickcol)
    %drawfilloval (490, 84, 25, -19, brickcol)
    drawfilloval (529, 140, 22, -17, brickcol)
    drawfilloval (480, 181, 11, -7, brickcol)
    drawfilloval (510, 228, 21, -14, brickcol)
    drawfilloval (561, 259, 20, -13, brickcol)
    drawfilloval (503, 323, 10, -10, brickcol)
    drawfilloval (480, 284, 10, -10, brickcol)
    drawfilloval (543, 303, 8, -9, brickcol)
    drawfillbox (522, 372, 622, 345, brickcol)
    drawfillbox (273, 411, 477, 427, brickcol)
    drawfillbox (333, 396, 142, 381, brickcol)
    drawfillbox (41, 430, 169, 417, brickcol)
    drawfillbox (318, 410, 330, 395, brickcol)
    drawfillbox (139, 417, 156, 393, brickcol)
    drawfillbox (521, 367, 529, 388, brickcol)
    drawfilloval (399, 347, 75, 23, brickcol)
    drawfillbox (452, 339, 350, 388, bgcolor)
    drawfillbox (296, 292, 424, 258, brickcol)
    drawfillbox (95, 473, 624, 485, brickcol)
    drawfillbox (605, 485, 625, 510, doorcol)
    drawfilloval (609, 500, 2, 2, yellow)
    drawfilloval (358, 292, 60, 8, lavacol)
end DrawRoom2

for level : 1 .. 2
    loop
        if level = 1 then
            InitRoom1
        elsif level = 2 then
            InitRoom2
        end if

        vx := 0
        vy := 0
        grav := 0.3
        dying := false
        dead := false
        win := false

        loop
            delay (15)
            cls
            Input.KeyDown (chars)
            if chars ('p') then
                loop
                    exit when hasch
                    locatexy (gmaxx div 2, gmaxy div 2)
                end loop
            end if
            if chars (KEY_CTRL) then
                get cheats
                if cheats = "gravity" or cheats = "grav" then
                    get grav
                end if
                if cheats = "locate" then
                    if ~mlocate then
                        mlocate := true
                    else
                        mlocate := false
                    end if
                end if
                if cheats = "locatexy" then
                    get x, y
                end if
                if cheats = "killall" then
                    for i : 1 .. enemies
                        edead (i) := true
                        ecount -= 1
                    end for
                end if
                if cheats = "nextlevel" then
                    cheatlevel := true
                end if
                if cheats = "color" then
                    get temp
                    if temp = "background" then
                        get bgcolor
                        colorback (bgcolor)
                        cls
                    elsif temp = "brick" then
                        get brickcol
                    elsif temp = "door" then
                        get doorcol
                    elsif temp = "lava" then
                        get lavacol
                    end if
                end if
                if cheats = "nofalldie" then
                    if ~nofalldie then
                        nofalldie := true
                    else
                        nofalldie := false
                    end if
                end if
                if cheats = "restart" then
                    if level = 1 then
                        InitRoom1
                    elsif level = 2 then
                        InitRoom2
                    end if
                end if
            end if

            if chars (KEY_UP_ARROW) and not jump then
                vy := 5
                jump := true

            elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
                ysize := 7
                if vy > 0 then
                    vy *= -0.5
                end if
            elsif chars (KEY_DOWN_ARROW) and jump then
                if vy > 0 then
                    vy *= -1
                end if
                ysize := 6
            elsif chars (KEY_DOWN_ARROW) and not jump then
                ysize := 6
            else
                ysize := 10

            end if

            if chars (KEY_LEFT_ARROW) then
                vx := -3
            elsif chars (KEY_RIGHT_ARROW) then
                vx := 3
            else
                vx := 0
            end if
            if jump then
                y += vy
                vy -= grav
            else
                vy := 0
            end if
            if ~nofalldie and vy < -dyingspeed then
                dying := true
            end if
            ysize += round (vy / 2)
            x += vx

            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    ex (i) += evx (i)
                    if ejump (i) then
                        ey (i) += evy (i)
                        evy (i) -= grav
                    else
                        evy (i) := 0
                    end if
                end if
            end for

            if level = 1 then
                DrawRoom1
            elsif level = 2 then
                DrawRoom2
            end if
            drawfillbox (0, gmaxy, maxx, maxy, brickcol)
            if coincount < 10 then
                drawfilloval (maxx - 15, gmaxy + 8, timer mod 4, 5, red)
                locatexy (maxx - 5, gmaxy + 8)
                color (0)
                put coincount
            else
                drawfilloval (maxx - 35, gmaxy + 8, timer mod 4, 5, red)
                locatexy (maxx - 15, gmaxy + 8)
                color (0)
                put coincount
            end if



            for i : 1 .. enemies
                if not edead (i) then
                    for k : 1 .. 5
                        drawfilloval (round (ex (i)), round (ey (i)), exsize - k, eysize - k, RGB.AddColor (k / 5 * ecolor (i), k / 5, k / 5 * ecolor (i)))
                    end for
                    drawfilloval (round (ex (i) + (evx (i)) * 3), round (ey (i)), 1, 1, 7)
                    drawline (round (ex (i) + (evx (i)) * -6), round (ey (i)) - 2, round (ex (i) + (evx (i)) * -9), round (ey (i)) - 2, 7)
                end if
            end for
            for i : 0 .. 5
                drawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
            end for
            drawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            drawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            drawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
            drawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
            drawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 4)

            %Draw.FillOval (round(x+vx), round (y+vy+ysize), 5,5,0)

            if whatdotcolor (round (x), round (y) + ysize + 1) = brickcol and whatdotcolor (round (x), round (y) - ysize - 1) ~= brickcol then
                y -= 1
            elsif whatdotcolor (round (x), round (y) + ysize + 1) = brickcol and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 1
            end if
            if whatdotcolor (round (x), round (y + vy - ysize - 1)) = brickcol then
                jump := false
            elsif whatdotcolor (round (x), round (y + vy - ysize - 1)) = bgcolor then
                jump := true
            end if
            if whatdotcolor (round (x), round (y + vy + ysize + 1)) = brickcol then
                vy := -0.5
            elsif ~chars (KEY_DOWN_ARROW) and whatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 2
            end if

            if chars (KEY_LEFT_ARROW) and whatdotcolor (round (x) - xsize - 1, round (y)) = brickcol then
                x -= vx
            end if
            if chars (KEY_RIGHT_ARROW) and whatdotcolor (round (x) + xsize + 1, round (y)) = brickcol then
                x -= vx
            end if
            if whatdotcolor (round (x), round (y) - ysize - 1) ~= bgcolor and dying then
                dead := true
            end if
            if whatdotcolor (round (x), round (y) - ysize - 1) = lavacol then
                dead := true
            end if
            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    if whatdotcolor (round (ex (i)), round (ey (i)) - eysize - 1) = bgcolor then
                        ejump (i) := true
                    else
                        ejump (i) := false
                    end if

                    if whatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = brickcol or whatdotcolor (round (ex (i)) + 9, round (ey (i))) = brickcol then
                        evx (i) *= -1
                    end if
                    if sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy < -1.3 then
                        edead (i) := true
                        ecount -= 1
                        if chars (KEY_UP_ARROW) then
                            vy := 7
                        else
                            vy := 4
                        end if
                    elsif sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy > -1.3 then
                        dead := true
                    end if
                end if
            end for
            %COIN STUFF
            for i : 1 .. coins
                if whatdotcolor (cx (i), cy (i) - 6) ~= bgcolor and ~cdead (i) then
                    cdead (i) := true
                    coincount += 1
                end if
            end for
            if ecount = 0 and whatdotcolor (round (x) + xsize + 4, round (y)) = doorcol then
                win := true
            elsif whatdotcolor (round (x) + xsize + 4, round (y)) = 4 and ecount ~= 0 then
                for i : 1 .. 10
                    cls
                    colorback (RGB.AddColor (i / 10, i / 10, 0))
                    delay (100)
                    View.Update
                end for
                colorback (bgcolor)
                x := xsize + 20     %Player's starting position
                y := ysize + 100     %Player's starting position
            end if
            if mlocate then
                mousewhere (mx, my, mb)
                if mb = 1 then
                    x := mx
                    y := my
                    vy := 0
                    color (0)
                    locate (1, 1)
                    put "(", mx, ",", my, ")"
                end if
            end if
            View.Update
            exit when dead or win or cheatlevel
        end loop
        if dead then
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (i / 10, 0, 0))
                delay (100)
                View.Update
            end for
        else
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (0, i / 10, 0))
                delay (100)
                View.Update
            end for
        end if
        colorback (0)
        exit when not dead
    end loop
end for

Author:  AsianSensation [ Thu Jun 17, 2004 7:18 pm ]
Post subject: 

I like the polished look, very very nice, I give bits

+20 bits

Author:  Paul [ Thu Jun 17, 2004 11:07 pm ]
Post subject: 

Hm... the collision detection in the latest version you posted isn't workingn for me, I use 4.0.5, once I jump, the guy doesn't stop going down, until it dies. Crying or Very sad

Author:  Cervantes [ Sat Jun 19, 2004 9:44 am ]
Post subject: 

holy shinkies, batman! that code is getting pretty long. and because of that, its starting to run kinda slow Confused

i experienced a bit of what paul said, though it wouldn't always fall all the way to the bottom.
hmm, it appears as though the character only falls through the blocks when up or down is being held.

oh and theres an error with locatexy.

Author:  GlobeTrotter [ Sat Jun 19, 2004 2:18 pm ]
Post subject: 

I wasn't able to recreate your issue with falling through the floor.
I don't know what the problem is if I cant see it. Also, the program works at a fine speed for me. There is a delay in there you can adjust if need be.

What error is there with locatexy?

By the way, have any of you been able to beat both levels while getting all the coins?

Author:  Cervantes [ Sat Jun 19, 2004 2:39 pm ]
Post subject: 

line 431, column 93 is greater than maxcol of 92.

maybe try jumping on the mouse at the start and, while your doing your jump off of the mouse, move over so your over top of the platform. when i do that, i go right through everytime.
oh and i can see the coins only for a second at the start of the prog, then they disappear but i can still collect them. did you do that on purpose?
and finally, you might wanna make ppl lose coins for dying. right now you can get infinate coins by dying and getting coins again. Confused

Author:  GlobeTrotter [ Sat Jun 19, 2004 4:16 pm ]
Post subject: 

That is really weird. I can't recreate any of your errors. My coins are there the whole time. I can't do your jumping thing, and I have no errors with the locatexy. I'm using turing v4.05.

The only thing I can think of is its a problem with RGB.AddColor and maybe the number of colors in the settings for your computer. Not sure though.

The coins problem where you keep them when you die, I realized that after I posted the code. Its not worth reposting the code for that problem though.

Author:  this_guy [ Mon Jun 21, 2004 9:11 am ]
Post subject: 

the first level is unbeatable after u get to the large lava pit.
i dunno if u need more platforms or smthg.
really like ur background.
also, ur smilie dies when he falls off 2 platforms simutaneously.

Author:  GlobeTrotter [ Mon Jun 21, 2004 2:16 pm ]
Post subject: 

It is possible after the lava pit. You need to jump off the bad-guy to get to the next platform. Here are some controls for those of you who need them:

On the Ground
-----------------
up : jump
left : move left
right : move right
down : crouch

In mid-air
-----------------
up : nothing
left : move left
right : move right
down : fall quicker (if pressed early enough in the jump)

Bouncing off Bad-Guys
-----------------
up : jump higher than usual
left : move left
right : move right
down : go through him to the ground
nothing : slight jump

Author:  GlobeTrotter [ Mon Jun 21, 2004 6:22 pm ]
Post subject:  help

Okay, I've run into a major problem while I was trying to make a "view". You'll see what I mean when you run my program. The problem seems to be that whatdotcolor collision detection. My issue is both with my enemies and my coins. Occassionally, I'm not exactly sure when/why all the coins in my current view will disappear. Also, my enemies, when they are outside my view they reverse direction. I'm not sure what my problem is with my coins, so I need help with that. I know what my problem is with my enemies though. How would I be able to make my enemies' vy = 0 when they aren't inside the thing.

PS. I am unable to indent the file, sorry. When I hit F2, I get an error saying that there's not enough memory to indent the file.

PPS. One last question. If possible, I would like to know how to change this line:
code:

var gmaxx, gmaxy, gsizex, gsizey : int
gmaxx := 650
gmaxy := 510
gsizex:=300
gsizey:=300
setscreen ("graphics:300;300,nobuttonbar,nocursor,noecho,offscreenonly")

so that the setscreen thing where it is 300,300 actually includes the variable names. I know its something like +intstr(gsizex) but I can't get the syntax right.


EDIT: nevermind about the setscreen thing. I figured out that I had to put a '+' on both sides of the instr. And the coin problem, I found a way to recreate it. In the first level, move over to the right after killing the first bad-guy. Walk underneath the floating platform to the left of the lava and hold up. All the coins in your view disappear. Again, I have no idea why this happens.


Here's the full code with views:
code:

var gmaxx, gmaxy, gsizex, gsizey : int
gmaxx := 650
gmaxy := 510
gsizex:=300
gsizey:=300
setscreen ("graphics:300;300,nobuttonbar,nocursor,noecho,offscreenonly")
var x, vx, y, vy, grav := 0.0
var chars : array char of boolean
var xsize, ysize := 10
var exsize, eysize : int
var win, jump, dying, dead := true
var cheats, temp : string
var enemies, ecount := 5
var ecolor : array 1 .. enemies of int
var ex : array 1 .. enemies of real
var ey : array 1 .. enemies of real
var evy, evx : array 1 .. enemies of real
var ejump, edead : array 1 .. enemies of boolean
var coins := 10
var cx : array 1 .. coins of int
var cy : array 1 .. coins of int
var cdead : array 1 .. coins of boolean
var coincount, tempcoincount : int := 0
var mx, my, mb : int
var mlocate, nofalldie, cheatlevel := false
var bgcolor, brickcol, lavacol, doorcol : int
var starx, stary : array 1 .. 100 of int
var starsize : int
var timer : int := 1
const dyingspeed := 10

procedure gdrawline (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
    drawline (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawline
procedure gdrawfilloval (x1 : int, y1 : int, xr : int, yr : int, col : int)
    drawfilloval (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, xr, yr, col)
end gdrawfilloval
procedure gdrawoval (x1 : int, y1 : int, xr : int, yr : int, col : int)
    drawfilloval (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, xr, yr, col)
end gdrawoval
procedure gdrawbox (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
    drawbox (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawbox
procedure gdrawfillbox (x1 : int, y1 : int, x2 : int, y2 : int, col : int)
    drawfillbox (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1, round (maxx - x - (maxx div 2)) + x2, round (maxy - y - (maxy div 2)) + y2, col)
end gdrawfillbox
procedure gdrawdot (x1 : int, y1 : int,col : int)
drawdot (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1,col)
end gdrawdot
function gwhatdotcolor (x1 : int, y1 : int) : int
var col : int
if round (maxx - x - (maxx div 2)) + x1 > 0 and round (maxx - x - (maxx div 2)) + x1 < maxx and round (maxy - y - (maxy div 2)) + y1 > 0 and round (maxy - y - (maxy div 2)) + y1 < maxy then
    col:=whatdotcolor (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
else
    col:= brickcol
end if
result col
end gwhatdotcolor
function coinwhatdotcolor (x1 : int, y1 : int) : int
var col : int
if round (maxx - x - (maxx div 2)) + x1 > 0 and round (maxx - x - (maxx div 2)) + x1 < maxx and round (maxy - y - (maxy div 2)) + y1 > 0 and round (maxy - y - (maxy div 2)) + y1 < maxy then
    col:=whatdotcolor (round (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
else
    col:= bgcolor
end if
result col
end coinwhatdotcolor

%procedure glocatexy (x1:int,y1:int)
%locatexy (maxx - x - (maxx div 2)) + x1, round (maxy - y - (maxy div 2)) + y1)
%end glocatexy

procedure InitRoom1
    timer := 1
    grav := 0.3
    brickcol := 2
    doorcol := 4
    lavacol := 12
    bgcolor := 7
    exsize := 8
    eysize := 6
    cheatlevel := false
    tempcoincount := 0
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 218
    ex (2) := 317
    ex (3) := 508
    ex (4) := 45
    ex (5) := 120
    ey (1) := 429
    ey (2) := 298
    ey (3) := 129
    ey (4) := 135
    ey (5) := 433
    %Coin Positions
    cx (1) := 525
    cy (1) := 490
    cx (2) := 483
    cy (2) := 472
    cx (3) := 207
    cy (3) := 385
    cx (4) := 442
    cy (4) := 457
    cx (5) := 23
    cy (5) := 198
    cx (6) := 83
    cy (6) := 482
    cx (7) := 619
    cy (7) := 115
    cx (8) := 255
    cy (8) := 213
    cx (9) := 199
    cy (9) := 185
    cx (10) := 146
    cy (10) := 162
    for i : 1 .. coins
        cdead (i) := false
    end for

    ecount := 5
    x := xsize + 20     %Player's starting position
    y := ysize + 100 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 1
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
    for i : 1 .. 100
        starx (i) := Rand.Int (0, gmaxx)
        stary (i) := Rand.Int (0, gmaxy)
    end for
end InitRoom1
procedure InitRoom2
    timer := 0
    grav := 0.3
    brickcol := 15
    doorcol := 4
    lavacol := 112
    bgcolor := 7
    exsize := 8
    eysize := 6
    cheatlevel := false
    tempcoincount := 0
    colorback (bgcolor)
    %Enemies' starting positions
    ex (1) := 406
    ex (2) := 575
    ex (3) := 125
    ex (4) := 212
    ex (5) := 254
    ey (1) := 353
    ey (2) := 388
    ey (3) := 433
    ey (4) := 246
    ey (5) := 171
    ecount := 5

    %Coin Positions
    cx (1) := 166
    cy (1) := 87
    cx (2) := 114
    cy (2) := 144
    cx (3) := 163
    cy (3) := 197
    cx (4) := 202
    cy (4) := 197
    cx (5) := 561
    cy (5) := 282
    cx (6) := 424
    cy (6) := 304
    cx (7) := 144
    cy (7) := 292
    cx (8) := 167
    cy (8) := 405
    cx (9) := 305
    cy (9) := 404
    cx (10) := 541
    cy (10) := 327
    for i : 1 .. coins
        cdead (i) := false
    end for
    x := xsize + 20     %Player's starting position
    y := ysize + 50 %Player's starting position
    for i : 1 .. enemies %Initialize enemie's stuff
        edead (i) := false
        ejump (i) := false
        evy (i) := 0
        if i mod 2 = 0 then
            ecolor (i) := 1
            evx (i) := 1.5
        else
            ecolor (i) := 0
            evx (i) := 1.1
        end if
    end for
    for i : 1 .. 100
        starx (i) := Rand.Int (0, gmaxx)
        stary (i) := Rand.Int (0, gmaxy)
    end for
end InitRoom2
procedure DrawRoom1
    if timer < 3000 then
        timer += 1
    end if
    bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
    brickcol := RGB.AddColor (timer / 10000, 0.3 + timer / 10000, timer / 10000)
    colorback (bgcolor)
    cls
    for i : 1 .. 100
        randint (starsize, 0, 1)
        gdrawfilloval (starx (i) - timer div 110, stary (i) - timer div 60, starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
    end for
    for i : 1 .. 25
        gdrawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
    end for
    for i : 1 .. coins
        if ~cdead (i) then
            gdrawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
        end if
    end for
    gdrawfillbox (-gmaxx div 2, -gmaxy div 2,0,gmaxy + gmaxy div 2,brickcol)
    gdrawfillbox (gmaxx + gmaxx div 2, -gmaxy div 2,gmaxx,gmaxy + gmaxy div 2,brickcol)
    gdrawfillbox (-gmaxx div 2, -gmaxy div 2,gmaxx div 2 + gmaxx, 0,brickcol)
    gdrawfillbox (-gmaxx div 2, gmaxy div 2+gmaxy,gmaxx div 2 + gmaxx, gmaxy,brickcol)
    gdrawfillbox (648, 97, -29, -22, brickcol)
    gdrawfilloval (277, 97, 107, -19, lavacol)
    gdrawfillbox (128, 139, 168, 122, brickcol)
    gdrawfillbox (186, 165, 218, 146, brickcol)
    gdrawfillbox (243, 192, 270, 176, brickcol)
    %gdrawfillbox (354, 161, 382, 140, brickcol)
    gdrawfillbox (398, 194, 437, 173, brickcol)
    gdrawfillbox (455, 236, 530, 216, brickcol)
    gdrawfillbox (545, 275, 605, 255, brickcol)
    gdrawfillbox (399, 110, 383, 89, brickcol)
    gdrawfillbox (172, 112, 151, 84, brickcol)
    gdrawfillbox (519, 311, 437, 296, brickcol)
    gdrawfillbox (387, 276, 200, 263, brickcol)
    gdrawfillbox (387, 290, 373, 276, brickcol)
    gdrawfillbox (209, 293, 199, 270, brickcol)
    gdrawfilloval (289, 274, -17, -4, lavacol)
    gdrawfilloval (237, 276, -14, -2, lavacol)
    gdrawfilloval (346, 275, -13, -2, lavacol)
    gdrawfillbox (154, 316, 116, 305, brickcol)
    gdrawfillbox (56, 345, 98, 331, brickcol)
    gdrawfillbox (16, 384, 60, 366, brickcol)
    gdrawfillbox (76, 413, 252, 401, brickcol)
    gdrawfillbox (252, 432, 235, 401, brickcol)
    gdrawfillbox (89, 433, 76, 402, brickcol)
    gdrawfillbox (153, 369, 211, 355, brickcol)
    gdrawfilloval (180, 368, 21, -6, lavacol)
    gdrawfillbox (159, 429, 168, 411, brickcol)
    gdrawfillbox (193, 428, 206, 409, brickcol)
    gdrawfillbox (295, 420, 339, 403, brickcol)
    gdrawfillbox (373, 418, 408, 401, brickcol)
    gdrawfillbox (428, 440, 459, 426, brickcol)
    gdrawfillbox (470, 456, 499, 442, brickcol)
    gdrawfillbox (506, 477, 545, 463, brickcol)
    gdrawfillbox (572, 478, 654, 460, brickcol)
    gdrawfillbox (626, 478, 656, 526, doorcol)
    gdrawfilloval (633, 496, 2, 2, yellow)
    gdrawfillbox (169, 421, 192, 388, bgcolor)
    gdrawfillbox (187, 409, 195, 379, bgcolor)
    gdrawfillbox (199, 376, 158, 391, bgcolor)
    gdrawfillbox (634, 96, 649, 463, brickcol)
    gdrawfillbox (12, 95, -6, 527, brickcol)
end DrawRoom1

procedure DrawRoom2
    if timer < 3000 then
        timer += 1
    end if
    bgcolor := RGB.AddColor (timer / 10000, timer / 10000, timer / 5000)
    brickcol := RGB.AddColor (0.3 + timer / 10000, 0.3 + timer / 10000, 0.3 + timer / 10000)
    colorback (bgcolor)
    cls
    for i : 1 .. 100
        randint (starsize, 0, 1)
        gdrawfilloval (starx (i), stary (i), starsize, starsize, RGB.AddColor (stary (i) / 500, stary (i) / 500, stary (i) / 500))
    end for
    for i : 1 .. 25
        gdrawfilloval (75 - timer div 50, gmaxy - 100 - timer div 50, 50 - i div 2, 50 - i div 2, RGB.AddColor (i / 25, i / 25, i / 35))
    end for
    for i : 1 .. coins
        if ~cdead (i) then
            gdrawfilloval (cx (i), cy (i), timer mod 5, 5, yellow)
        end if
    end for
    gdrawfillbox (-gmaxx div 2, -gmaxy div 2,0,gmaxy + gmaxy div 2,brickcol)
    gdrawfillbox (gmaxx + gmaxx div 2, -gmaxy div 2,gmaxx,gmaxy + gmaxy div 2,brickcol)
    gdrawfillbox (-gmaxx div 2, -gmaxy div 2,gmaxx div 2 + gmaxx, 0,brickcol)
    gdrawfillbox (-gmaxx div 2, gmaxy div 2+gmaxy,gmaxx div 2 + gmaxx, gmaxy,brickcol)
    gdrawfillbox (648, 25, 0, 0, lavacol)
    gdrawfillbox (25, 508, -2, -5, brickcol)
    gdrawfillbox (622, 508, 677, -19, brickcol)
    gdrawfillbox (25, 43, 91, -6, brickcol)
    gdrawfillbox (140, 71, 194, 46, brickcol)
    gdrawfillbox (92, 125, 137, 101, brickcol)
    gdrawfillbox (69, 152, 16, 179, brickcol)
    gdrawfillbox (272, 207, 69, 232, brickcol)
    gdrawfillbox (234, 162, 266, 136, brickcol)
    gdrawfillbox (296, 121, 415, 93, brickcol)
    gdrawfillbox (139, 188, 224, 171, brickcol)
    gdrawfillbox (139, 185, 140, 179, brickcol)
    gdrawfillbox (139, 186, 151, 211, brickcol)
    gdrawfillbox (295, 121, 266, 93, brickcol)
    gdrawfillbox (399, 137, 414, 119, brickcol)
    gdrawfillbox (141, 270, 150, 232, brickcol)
    gdrawfillbox (258, 249, 270, 230, brickcol)
    gdrawfilloval (145, 270, 4, -4, lavacol)
    gdrawfillbox (255, 137, 269, 118, brickcol)
    gdrawfilloval (332, 120, 40, -2, lavacol)
    %gdrawfilloval (433, 96, 22, -23, brickcol)
    %gdrawfilloval (490, 84, 25, -19, brickcol)
    gdrawfilloval (529, 140, 22, -17, brickcol)
    gdrawfilloval (480, 181, 11, -7, brickcol)
    gdrawfilloval (510, 228, 21, -14, brickcol)
    gdrawfilloval (561, 259, 20, -13, brickcol)
    gdrawfilloval (503, 323, 10, -10, brickcol)
    gdrawfilloval (480, 284, 10, -10, brickcol)
    gdrawfilloval (543, 303, 8, -9, brickcol)
    gdrawfillbox (522, 372, 622, 345, brickcol)
    gdrawfillbox (273, 411, 477, 427, brickcol)
    gdrawfillbox (333, 396, 142, 381, brickcol)
    gdrawfillbox (41, 430, 190, 417, brickcol)
    gdrawfillbox (318, 410, 330, 395, brickcol)
    gdrawfillbox (139, 417, 156, 393, brickcol)
    gdrawfillbox (521, 367, 529, 388, brickcol)
    gdrawfilloval (399, 347, 75, 23, brickcol)
    gdrawfillbox (452, 339, 350, 388, bgcolor)
    gdrawfillbox (296, 292, 424, 258, brickcol)
    gdrawfillbox (95, 473, 624, 485, brickcol)
    gdrawfillbox (605, 485, 625, 510, doorcol)
    gdrawfilloval (609, 500, 2, 2, yellow)
    gdrawfilloval (358, 292, 60, 8, lavacol)
end DrawRoom2

for level : 1 .. 2
    loop
        if level = 1 then
            InitRoom1
        elsif level = 2 then
            InitRoom2
        end if

        vx := 0
        vy := 0
        grav := 0.3
        dying := false
        dead := false
        win := false

        loop
            delay (15)
            cls
            Input.KeyDown (chars)
            if chars ('p') then
                loop
                    exit when hasch
                end loop
            end if
            if chars (KEY_CTRL) then
                get cheats
                if cheats = "gravity" or cheats = "grav" then
                    get grav
                end if
                if cheats = "locate" then
                    if ~mlocate then
                        mlocate := true
                    else
                        mlocate := false
                    end if
                end if
                if cheats = "locatexy" then
                    get x, y
                end if
                if cheats = "killall" then
                    for i : 1 .. enemies
                        edead (i) := true
                        ecount -= 1
                    end for
                end if
                if cheats = "nextlevel" then
                    cheatlevel := true
                end if
                if cheats = "color" then
                    get temp
                    if temp = "background" then
                        get bgcolor
                        colorback (bgcolor)
                        cls
                    elsif temp = "brick" then
                        get brickcol
                    elsif temp = "door" then
                        get doorcol
                    elsif temp = "lava" then
                        get lavacol
                    end if
                end if
                if cheats = "nofalldie" then
                    if ~nofalldie then
                        nofalldie := true
                    else
                        nofalldie := false
                    end if
                end if
                if cheats = "restart" then
                    if level = 1 then
                        InitRoom1
                    elsif level = 2 then
                        InitRoom2
                    end if
                end if
                if cheats = "speedup" then
                    get timer
                end if
            end if

            if chars (KEY_UP_ARROW) and not jump then
                vy := 5
                jump := true

            elsif chars (KEY_UP_ARROW) and chars (KEY_DOWN_ARROW) then
                ysize := 7
                if vy > 0 then
                    vy *= -0.5
                end if
            elsif chars (KEY_DOWN_ARROW) and jump then
                if vy > 0 then
                    vy *= -1
                end if
                ysize := 6
            elsif chars (KEY_DOWN_ARROW) and not jump then
                ysize := 6
            else
                ysize := 10

            end if

            if chars (KEY_LEFT_ARROW) then
                vx := -3
            elsif chars (KEY_RIGHT_ARROW) then
                vx := 3
            else
                vx := 0
            end if
            if jump then
                y += vy
                vy -= grav
            else
                vy := 0
            end if
            if ~nofalldie and vy < -dyingspeed then
                dying := true
            end if
            ysize += round (vy / 2)
            x += vx

            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    ex (i) += evx (i)
                    if ejump (i) then
                        ey (i) += evy (i)
                        evy (i) -= grav
                    else
                        evy (i) := 0
                    end if
                end if
            end for

            if level = 1 then
                DrawRoom1
            elsif level = 2 then
                DrawRoom2
            end if
            %gdrawfillbox (0, gmaxy, maxx, maxy, brickcol)
            %if coincount < coins then
            %    gdrawfilloval (gmaxx - 15, gmaxy + 8, timer mod 4, 5, red)
            %    glocatexy (gmaxx - 5, gmaxy + 8)
            %    color (0)
            %    put coincount
            %else
            %    gdrawfilloval (gmaxx - 35, gmaxy + 8, timer mod 4, 5, red)
            %    %locatexy (maxx - 15, gmaxy + 8)
            %    color (0)
            %    put coincount
            %end if



            for i : 1 .. enemies
                if not edead (i) then
                    for k : 1 .. 5
                        gdrawfilloval (round (ex (i)), round (ey (i)), exsize - k, eysize - k, RGB.AddColor (k / 5 * ecolor (i), k / 5, k / 5 * ecolor (i)))
                    end for
                    gdrawfilloval (round (ex (i) + (evx (i)) * 3), round (ey (i)), 1, 1, 7)
                    gdrawline (round (ex (i) + (evx (i)) * -6), round (ey (i)) - 2, round (ex (i) + (evx (i)) * -9), round (ey (i)) - 2, 7)
                end if
            end for
            for i : 0 .. 5
                gdrawfilloval (round (x), round (y), xsize - i, ysize - i, RGB.AddColor (i / 5, i / 5, 0))
            end for
            gdrawfilloval (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            gdrawfilloval (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 2, 2, 1)
            gdrawdot (round (x) - 3 + round (vx), round (y) + 3 + round (vy), 0)
            gdrawdot (round (x) + 3 + round (vx), round (y) + 3 + round (vy), 0)
            gdrawline (round (x) - 2 + round (vx), round (y) - 3 + round (vy), round (x) + 2 + round (vx), round (y) - 3 + round (vy), 4)

            %Draw.FillOval (round(x+vx), round (y+vy+ysize), 5,5,0)

            if gwhatdotcolor (round (x), round (y) + ysize + 1) = brickcol and gwhatdotcolor (round (x), round (y) - ysize - 1) ~= brickcol then
                y -= 1
            elsif gwhatdotcolor (round (x), round (y) + ysize + 1) = brickcol and gwhatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 1
            end if
            if gwhatdotcolor (round (x), round (y + vy - ysize - 1)) = brickcol then
                jump := false
            elsif gwhatdotcolor (round (x), round (y + vy - ysize - 1)) = bgcolor then
                jump := true
            end if
            if gwhatdotcolor (round (x), round (y + vy + ysize + 1)) = brickcol then
                vy := -0.5
            elsif ~chars (KEY_DOWN_ARROW) and gwhatdotcolor (round (x), round (y) - ysize - 1) = brickcol then
                y += 2
            end if

            if chars (KEY_LEFT_ARROW) and gwhatdotcolor (round (x) - xsize - 1, round (y)) = brickcol then
                x -= vx
            end if
            if chars (KEY_RIGHT_ARROW) and gwhatdotcolor (round (x) + xsize + 1, round (y)) = brickcol then
                x -= vx
            end if
            if gwhatdotcolor (round (x), round (y) - ysize - 1) ~= bgcolor and dying then
                dead := true
            end if
            if gwhatdotcolor (round (x), round (y) - ysize - 1) = lavacol then
                dead := true
            end if
            %ENEMY STUFF
            for i : 1 .. enemies
                if not edead (i) then
                    if gwhatdotcolor (round (ex (i)), round (ey (i)) - eysize - 1) = bgcolor then
                        ejump (i) := true
                    else
                        ejump (i) := false
                    end if

                    if gwhatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = brickcol or gwhatdotcolor (round (ex (i)) + 9, round (ey (i))) = brickcol or gwhatdotcolor (round (ex (i)) - exsize - 1, round (ey (i))) = yellow or gwhatdotcolor (round (ex (i)) + 9, round (ey (i))) = yellow then
                        evx (i) *= -1
                    end if
                    if sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy < -1.3 then
                        edead (i) := true
                        ecount -= 1
                        if chars (KEY_UP_ARROW) then
                            vy := 7
                        else
                            vy := 4
                        end if
                    elsif sqrt ((ex (i) - x) ** 2 + (ey (i) - y) ** 2) < ysize + exsize + 1 and vy > -1.3 then
                        dead := true
                    end if
                end if
            end for
            %COIN STUFF
            for i : 1 .. coins
                if coinwhatdotcolor (cx (i), cy (i) - 6) ~= bgcolor and ~cdead (i) then
                    cdead (i) := true
                    tempcoincount += 1
                    coincount += 1
                end if
            end for
            if ecount = 0 and gwhatdotcolor (round (x) + xsize + 4, round (y)) = doorcol then
                win := true
            elsif gwhatdotcolor (round (x) + xsize + 4, round (y)) = 4 and ecount ~= 0 then
                for i : 1 .. 10
                    cls
                    colorback (RGB.AddColor (i / 10, i / 10, 0))
                    delay (100)
                    View.Update
                end for
                colorback (bgcolor)
                x := xsize + 20     %Player's starting position
                y := ysize + 100     %Player's starting position
            end if
            if mlocate then
                mousewhere (mx, my, mb)
                if mb = 1 then
                    x := mx
                    y := my
                    vy := 0
                    color (0)
                    locate (1, 1)
                    put "(", mx, ",", my, ")"
                end if
            end if
            View.Update
            exit when dead or win or cheatlevel
        end loop
        if dead then
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (i / 10, 0, 0))
                delay (100)
                View.Update
            end for
                                    coincount -= tempcoincount
        else
            for i : 1 .. 10
                cls
                colorback (RGB.AddColor (0, i / 10, 0))
                delay (100)
                View.Update
            end for
        end if
        colorback (0)
        exit when not dead
    end loop
end for

Author:  Cervantes [ Mon Jun 21, 2004 7:25 pm ]
Post subject: 

code is getting too long to post as text Confused from now on, plz attach the .t file.

I don't know how you did your View thingy, haven't looked at the code that intensely, but can you not do something like:
code:

if enemy_x > player_x + viewWidth or enemy_x < player_x - viewWidth then
if enemy_y > player_y + viewHeight or enemy_y < player_y - viewHeight then
enemy_vy := 0
end if
end if


can't really help you with the coin thingy though. i can't see the coins ever. Confused

and i noticed that i only have that falling through the ground problem if i have died since i started the program. ie. i start the program and it works fine. but then i die, and it resets itself and puts me back at the start, and then i fall through stuff.

Author:  GlobeTrotter [ Mon Jun 21, 2004 7:36 pm ]
Post subject: 

That won't really work (the vy thing) since the evy is an array of the enemie's vy. I made a new function called gwhatdotcolor that doesn the same thing as normal, except modifies the entered coordinates to fit the view correctly. How can I modify an array from inside a function?


: