How to make a Character jump!! in a 2d game, not rpg
How to make a Character jump!! in a 2d game, not rpg
I was wondering the other day how to make a sprite jump, like how to measure the heigth and time in the air, does any1 kno statement or loop to make that possible?
im trying to create some kind of 2d game, but i cant make my char jump
im trying to create some kind of 2d game, but i cant make my char jump
re: making a sprite jump
Jumping can be kind of complicated. In my game, the sprite is made to jump in a parabolic path.
A parabola has the form:
y= (a)x ^ 2 + (b)
Pretty simple if a = 1 and b = 0
So basically, as your sprite moves, calculate the distance travelled in the x direction after you hit the jump button, and make the Height = the square of that amount.
Hope this helps.
A parabola has the form:
y= (a)x ^ 2 + (b)
Pretty simple if a = 1 and b = 0
So basically, as your sprite moves, calculate the distance travelled in the x direction after you hit the jump button, and make the Height = the square of that amount.
Hope this helps.
Actually, it is a bit more complicated than I let on
To make your character jump, remember that "A" must be = -1, and the highest point is where x = 0. Make "B" = the height you want your character to jump. Also, decide how far you want your character to travel when it jumps. Ie, where on the X axis will Y = 0. If you want it to travel 10 pixels, you have to start from x = -5, and calculate things as x increases to +5.
I said it was complicated.
I said it was complicated.
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
No vectors are the way.
Not really that hard. Hope that helps.
Code: Select all
SCREEN 13
power = 12 'power of jump 0=no jump
speed = 4 'speed horizontally of guy
gravity = 1 'gravity value: 0=no gravity
y = 200 'Starting y pos
x = 50 'Starting x pos
xv = speed
yv = power
DO
CLS
y = y - yv
x = x + xv
yv = yv - gravity
PSET (x, y), 15
IF y >= 200 THEN EXIT DO
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
LOOP
"But...It was so beutifully done"
-
- Veteran
- Posts: 1055
- Joined: Sun Jan 02, 2005 2:11 pm
- Location: At my computer
- Contact:
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
wow thanks a lot, it actually works now, but i was wondering if u can move the sprite while it is in the air?
and also were can i put that code that Mitth 'raw' nurodo posted..
and also were can i put that code that Mitth 'raw' nurodo posted..
<b><i> "Rock is the first thing in life, after rock comes the comp...." Rock on Big M</i></b>
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
Hey thanks Mitth 'raw' nurodo. I unterstood the formula u made and now i can make my game cooler.. i just deleted the speed varaiable so the speed is actually the left or rigth, i made a demo for the physisis if any1 wants it
http://www.freewebs.com/mundofr/jumptest.exe
download it
Thanks a lot, post somethign back
http://www.freewebs.com/mundofr/jumptest.exe
download it
Thanks a lot, post somethign back
<b><i> "Rock is the first thing in life, after rock comes the comp...." Rock on Big M</i></b>
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">
- Mitth'raw'nuruodo
- Veteran
- Posts: 839
- Joined: Sat Jan 22, 2005 11:04 am
- Location: Eastern Coast of US
- Contact:
thanks a lot!
<b><i> "Rock is the first thing in life, after rock comes the comp...." Rock on Big M</i></b>
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">
<img src="http://www.freewebs.com/mundofr/bigm2.bmp">