Qbasicnews.com
October 25, 2021, 11:12:40 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Jumping Jack Problem!!!  (Read 5778 times)
nkk_kan
Member
*
Posts: 73


« on: July 14, 2006, 08:21:26 AM »

welll...
I wanted to make a mario-like game
but can anyone tell me how do i make that character jump diagonally??
or do i have to use some equations of parabola?
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: July 14, 2006, 08:59:16 AM »

The way to do it is having a gravity engine and working with horizontal and vertical movement separately.

Establish x, y, vx, vy, (velocities) a (horizontal acceleration) and g (gravity) and use those cinematics equations, those from physics.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
nkk_kan
Member
*
Posts: 73


« Reply #2 on: July 15, 2006, 06:17:49 AM »

Cinematics equations of physics??!??!?!?HuhHuh?

u mean parabola??
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #3 on: July 15, 2006, 07:29:46 PM »

I think he ment sinemactics.. cause it sounds like sinus.. prolly off, never heard the term.. =P

The way I'd do it, is, I would take: cheat.... I'd give the sprite gravity, that holds him to the ground.... then alow it to jump up with enough power to temperaly brake the hold, then drop him back down.... But while he is alowed to jump up and down, alow side to side movents in the air....

Thus, when he jumps up, and your holding over, he'll jump in an arch....

You prolly can sit around, and figure up projectiles: lanch speed, angle, vertical accel, horizontal accel, etc.... But the first method in my post would be more of and "arcade" feel like mario had.... I think.....

Hope that helps some....  :winkwink:
Logged

Kevin (x.t.r.GRAPHICS)

torstum
Member
*
Posts: 62


« Reply #4 on: July 15, 2006, 09:57:25 PM »

It's Kinematics, BTW.
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #5 on: July 16, 2006, 05:05:30 AM »

up key. left/right key. jump.

my work here is done.
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #6 on: July 16, 2006, 09:28:36 AM »

Quote from: "torstum"
It's Kinematics, BTW.

Oops ... That term I have heard before... the C just threw me off... -_- ... I still think that's a bit too detialed for an arcade-style game.... Unless you are making a simulater.... =) ..

Though, more info if you are interested: http://en.wikipedia.org/wiki/Kinematics

 :winkwink:
Logged

Kevin (x.t.r.GRAPHICS)

nkk_kan
Member
*
Posts: 73


« Reply #7 on: July 16, 2006, 11:06:33 AM »

Well... yes..Kinematics include That parabola equations...

And i tried it and it works perfectly..

and hey dio, What do u mean by that

Dio Wrote:
 
Quote
up key. left/right key. jump.

my work here is done.


Huh
 do u mean to say that i should store up,right/left keypresses in
INKEY$ buffer???
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Dio
I hold this place together
*****
Posts: 874



« Reply #8 on: July 17, 2006, 05:10:47 AM »

I repeat: my work here is done.
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #9 on: July 17, 2006, 06:04:45 AM »

Yeah, physics.

Horizontal movement:

In each cycle:

Code:
x = x + vx

If <left key pressed> Then
   vx = vx - a
Else If <right key pressed> Then
   vx = vx + a
Else
   If vx > 0 Then
      vx = vx - f
   Else
      vx = vx + f
   End If
End If

If <collision with map> Then
   <track back to furthest possible location>
End If


Where x is your horizontal coordinate, vx is your horizontal velocity, a is your horizontal acceleration, f is your horizontal friction.

Vertical movement:

In each cycle:

Code:
y = y + vy
vy = vy + g

If <jump key pressed> Then
   If <player standing on a platform Then
      vy = vy - j
   End If
End if

If <collision> Then
   <track back to furthest possible location>
End If


Where y is your vertical coordinate, vy is your vertical velocity, g is gravity, j is jump strength.

It's not hard at all once you understand the equations. This needs decimal variables to work, keep that in mind. Better than using floats would be using some kind of fixed point math, something like using X bits for the decimal part and Y bits for the real part. For example, if you use 16 bits integers and have pixel coordinates in the range of 0-320 (for example), you could multiply/divide by 64 to gain six digits after the decimal point, thus gaining a precision of 1/64 of a pixel.

Code:
xOnScreen = x \ 64
x = xOnScreen * 64


This means that to actually advance one pixel you have to add 64, not 1. But that means that you can get smooth movement 'cause everytime you add 1 to x you are in fact "advancing 1/64 of a pixel".

A good understanding in kinematics helps a tad. Basicly you are using the accelerated movement equations:

Code:
v = v0 + a * t
s = s0 + v0*t + 1/2 * a * t^2


I was planning on writing a tutorial for this on QBE, I have to find time to do it.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
nkk_kan
Member
*
Posts: 73


« Reply #10 on: July 17, 2006, 11:37:36 AM »

Well...ThanX for that awesome and VERY detailed Tutorials

and i recommend you put that in next QBE

And have you noticed that there aren't any tutorials about this..??

Thanx again for that
Logged

\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #11 on: July 17, 2006, 01:02:15 PM »

Actually the guy who posted before you is a master in the art of jumping (nathan).  And he's supposed to finish that platformaer tute in QBE. nudge...nudge...
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #12 on: July 18, 2006, 04:07:31 AM »

I know, rel,  Sad  I feel bad every second I remember that I have TWO unfinished tutorial series at QBE.

I've promised Pete that I will find the time Smiley
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
MystikShadows
Ancient Guru
****
Posts: 542



WWW
« Reply #13 on: July 18, 2006, 09:28:13 PM »

forget Pete...you gotta promise me too....hehe...your biggest fan (literally and figuratively speaking lol)
Logged

hen they say it can't be done, THAT's when they call me ;-).




need hosting:  http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #14 on: July 19, 2006, 11:37:53 PM »

I will try. I have so little spare time right now and I prefer to spend it with friends and people I love when possible, that's why I basicly do nothing Sad Better times will come, I hope. Not in my best moment now - this should change soon.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!