
-----------------------------------
magicman
Thu May 20, 2004 9:06 am

Moving Levels.
-----------------------------------
I'm making a level for my game. It's a long level. When the player reaches the end of the screen, i want it to move with the player. What is the code to do that???Â¿Â¿Â¿
thanks for the help.

-----------------------------------
Tony
Thu May 20, 2004 12:39 pm


-----------------------------------
you keep the player in the center of the screen and draw the level relative to the player.

-----------------------------------
magicman
Thu May 20, 2004 2:53 pm


-----------------------------------
How would you make the player jump???Â¿Â¿Â¿

-----------------------------------
SuperGenius
Thu May 20, 2004 2:58 pm


-----------------------------------
have it check for the up button(or whichever button) being pressed, and then have the y coord of the sprite/picture increase and then decrease

-----------------------------------
magicman
Mon May 31, 2004 6:59 am


-----------------------------------
What kind of coding would i have to do for the y coord to increase and decrease??

-----------------------------------
SuperGenius
Mon May 31, 2004 2:52 pm


-----------------------------------
Here's a diagram. Dont let it confuse you because it has nothing to do with the x coord. It is a rough parabola. It would be a little tough to do because for every unit of time the change in position is a different amount. I'll give you an example. (keyword example)


yheight=timeelapsed**


time elapsed is the time that has passed since the jump started (when the key was pressed. You will also need to add a constant to the y value (unless your man normally walks at coord (x,0). The constant you need to add is the height of the ground that you used in your game (ex if he is running on a flat surface, that is the number that I am talking about)

-----------------------------------
Cervantes
Mon May 31, 2004 3:07 pm


-----------------------------------
erg,  personally I wouldn't use Time.Elapsed.  
IMO, here's a simpler way of doing it.


setscreen ("offscreenonly")
var keys : array char of boolean
var jump := false %boolean. since it's declared as false turing knows its boolean
var x, y, vy : real %vy = velocity in the y plane.  aka, the upwards velocity of the player.
x := 100
y := 100
const gravity := 0.1

loop

    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) and not jump then %"and not jump" is the same as "and jump = false"
        jump := true
        vy := 5
    end if
    if jump then %"if jump then" is the same as "if jump = true then"
        y += vy % same as y := y + vy
        vy -= gravity % same as vy := vy - gravity
        if y  100 then
            boxx1 -= 1
            boxx2 -= 1
        end if
    elsif chars (KEY_LEFT_ARROW) then
        xchange += -1
        boxx1 += 1
        boxx2 += 1
    end if
    if jump = true then
        bally += vy
        vy -= gravity
        if bally  boxx1 - 15 and ballx < boxx2 + 15 and bally < 200 then
        ballx := boxx1 - 15
    end if
    drawfillbox (boxx1, 85, boxx2, 185, blue)
    drawfilloval (round (ballx), round (bally), 15, 15, red)
    delay (10)
    View.Update
    drawfillbox (boxx1, 85, boxx2, 185, white)
    drawfilloval (round (ballx), round (bally), 15, 15, white)
end loop


-----------------------------------
guruguru
Mon May 31, 2004 6:19 pm


-----------------------------------
This topic had the similary problem of moving the background relative to the player. 
procedure ballJump
    vy := 5
    loop 
        bally += vy        
        vy -= gravity
        cls
        Draw.FillOval (round(ballx), round(bally), 15, 15, red)
        View.Update
        delay(10)
        exit when bally 