Computer Science Canada

mario needs to jump :(

Author:  Kactus [ Wed Apr 19, 2006 9:13 pm ]
Post subject:  mario needs to jump :(

so ive have been working on my mario mini game for a bit now and its was going really well untill now. I can make mario jump but if you hold the Up button he floats in the air Confused can anyone suggest a way to get around this?

PS what do you think of it so far?

Author:  Kactus [ Wed Apr 19, 2006 9:18 pm ]
Post subject: 

forgot to include the keys to play:

left arrow = walk left
right arrow = walk right
up arrow = jump
down arrop = crouch
ctrl = run

Author:  NikG [ Wed Apr 19, 2006 10:33 pm ]
Post subject: 

First off, let me say, this looks very promising!

Second, don't use processes!

Third (solution to your problem), keep a boolean variable that turns true once up is pressed and is false otherwise.
So when up is pressed and the boolean is already true, you know not to jump.

Author:  neufelni [ Thu Apr 20, 2006 11:05 am ]
Post subject: 

Here is a mario game that I made. It's not that great and it uses processes but the jumping works fine.
http://www.compsci.ca/v2/viewtopic.php?t=11197

Author:  do_pete [ Thu Apr 20, 2006 11:55 am ]
Post subject: 

Wow that looks very nice! First of, you don't need to have left and right images, you only need to have one direction and then you can create a mirrored version by using Pic.Mirror. Secondly, in order for Mario to jump, you should have a y-velocity variable. You would add this to your y variable every loop. Here's and example:
code:
View.Set ("offscreenonly,nobuttonbar,graphics:150,100")

const GRAVITY : real := 0.1
const RADIUS : int := 10
var y_velocity : real := 0
var y : real := RADIUS
var keys_pressed : array char of boolean

loop
    Input.KeyDown (keys_pressed)
    if y > RADIUS then
        y_velocity -= GRAVITY
    else
        y_velocity := 0
    end if

    if y_velocity = 0 and keys_pressed (KEY_UP_ARROW) then
        y_velocity := 2
    end if

    y += y_velocity

    Draw.FillOval (maxx div 2, round (y), RADIUS, RADIUS, black)
    View.Update
    cls
    delay (10)
end loop

Author:  Kactus [ Thu Apr 20, 2006 12:07 pm ]
Post subject: 

thanks for the help guys!

Author:  Imm0rtal [ Sat Apr 22, 2006 1:56 am ]
Post subject: 

Mari Goes down the Tube.. Mario Jumps back out the Tube.. Mario Goes down the Tube.. Mario Jumps back out the tube..

hehe.. Nice graphics though!

Author:  Kactus [ Sat Apr 22, 2006 12:47 pm ]
Post subject: 

haha thanks for pointing that out!


: