
-----------------------------------
balofagus
Sat Nov 05, 2005 1:49 pm

Need help with my character jumping... he won't come down!
-----------------------------------
Hey, my name is Sean.  I'm taking TIK 20 (Grade 10 Computer Programming) and we've reached the end of the curriculum so it's Culminating Activity Time (OH YEAH!).  Anywho... we have to make something that includes what we've done thus far... ifs, loops, drawing/animation, GUI, yadaa, yadaa you get the point.  For my last little assignment we did a quick Mario animation.  My teacher told me that he'd like to see me make a mario game (or at least a level) so thats what I'm up to.  Now to the question:

 - I've got mario moving (thanks to the movment Tutorial I found here) and he can jump (all with the arrow keys (up is jump)) but he wont come down.  I've tried putting in the go up thing...then a delay...then go down all when you press the up arrow but nothing happens.  I'm at a loss on how to get him to fall down. Anyone have any ideas?

 - I would also like to know how to get him to fall down after he jumps up onto something (like a ledge) and then gets to the end.

Here's what I have so far:

var key : string (1) := ""
var chars : array char of boolean
var mariox : int := 0                                   
var marioy : int := 15                                  
var mario, backImage, ground : int                          

backImage := Pic.FileNew ("background.jpg") 
ground := Pic.FileNew ("ground.bmp")
mario := Pic.FileNew ("mario_still.bmp")

Pic.SetTransparentColor (mario, 10)

setscreen ("graphics:512;224")                          
setscreen ("offscreenonly")

procedure drawBackGround ()                             
    Pic.Draw (backImage, 0, 0, picCopy)
    Pic.Draw (ground, 0, -30, picCopy)
end drawBackGround

loop
    setscreen ("offscreenonly")
    View.Update
    drawBackGround
    Pic.Draw (mario, mariox, marioy, picMerge)
    key := ""
    if hasch then
        getch (key)
    end if
    if key = (KEY_RIGHT_ARROW) then
        mariox := mariox + 2
    elsif key = (KEY_LEFT_ARROW) then
        mariox := mariox - 2
    elsif key = (KEY_UP_ARROW) then
        marioy := marioy + 30
    end if

end loop


-----------------------------------
Carino
Sat Nov 05, 2005 2:16 pm


-----------------------------------
You have to incorporate gravity to have him jump and at least make it look real, and this luckily is pretty simple. All you have to do is declare another variable that be added to the chars y variable, and have it decrease over time, something like this.


var marioy, marioNewY : int
marioNewY := 6
var jumping : boolean := false

Input.KeyDown (chars)

if chars (KEY_UP_ARROW) then
jumping := true
end if

if jumping == true then
marioy += marioNewY
marioNewY -= 1

if marioy 