I Wanna Be The Forums!

Please login or register.

Login with username, password and session length
Advanced search  

News:

Gaiden 1.2 patch released. Click here to download!

Pages: [1] 2 3 4

Author Topic: double jump on "game maker"  (Read 55016 times)

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
double jump on "game maker"
« on: July 12, 2008, 11:26:55 am »

how to do an easy double jump on game maker?

create an object with a sprite who will be your character.
create an object with a sprite who will be the earth (don't forget it's a solid object).

ADD EVENT: create object
actions:
set variable earth to 0
set the gravity (direction 270, gravity 1.3) you could change the gravity if you want.

ADD EVENT: collision the_earth
actions:
set the vertical speed to 0
set variable earth to 0

ADD EVENT: <no key>
actions:
if variable vspeed is larger than 14
set variable vspeed to 14 (to limit the speed of the fall)

ADD EVENT: <any key>
actions:
if variable vspeed is larger than 14
set variable vspeed to 14

jump with not relative: (all vars are not relative)
Quote
ADD EVENT: press <space> (you can choose another key for the jump)
actions:
if earth is equal to 0
_start of a block (first jump)
_set variable earth to 1
_set the vertical speed to -16
_play sound jump (not necessary)
_end of a block
else
_start of a block
_if earth is equal to 1
__start of a block (second jump)
__set variable earth to 2
__set the vertical speed to -16
__play sound jump (not necessary)
__end of a block
_end of a block

jump with relative:
Quote
ADD EVENT: press <space>
actions:
if earth is not equal to 2
_start of a block
_set variable earth to 1 (relative)
_set the vertical speed to -16 (not relative)
_play sound jump
_end of a block

I use that to do a double jump on game maker and it works really good

NOTE: for "ADD EVENT: press <space>" it's the event 'press <space>' that you have to use and not the event: '<space>'
« Last Edit: July 14, 2008, 11:29:15 am by zebdal »
Logged

Zaraki

  • Hero Member
  • *****
  • Posts: 957
    • View Profile
Re: double jump on "game maker"
« Reply #1 on: July 12, 2008, 11:46:25 am »

Uhhhh..... Ithought that I could use GM but that is just.... It flew so far over my head
Logged

dsk

  • Lawful Evil Moderator
  • Global Moderator
  • The Guy
  • *****
  • Posts: 3655
  • Like a phoenix
    • View Profile
    • Youtube videos!
Re: double jump on "game maker"
« Reply #2 on: July 12, 2008, 01:11:46 pm »

Thanks, hopefully we won't get many threads about it anymore. Stickied.
Logged

ninjafetus

  • Full Member
  • ***
  • Posts: 232
    • View Profile
    • NES 50
Re: double jump on "game maker"
« Reply #3 on: July 12, 2008, 06:52:55 pm »

ADD EVENT: press <space> (you can choose another key for the jump)
actions:
if sol is equal to 0
_start of a block (first jump)
_set variable sol to 1
_set the vertical speed to -16
_play sound jump (not necessary)
_end of a block
else
_start of a block
_if sol is equal to 1
__start of a block (second jump)
__set variable sol to 1
__set the vertical speed to -16
__play sound jump (not necessary)
__end of a block
_end of a block

Are you sure this works?  It would seem that you could jump infinitely many times, since you set your flag "sol" to 1 after your second jump.... and that's the conditions for your second jump to occur.

My double jump code (without sound) is like this in GM:

Press SPACE (or whatever jump button you want)
IF there is a collision at position (0,1) (relative) with SOLID_OBJECT  (If I'm on the ground...)
___ (start of a block)
___ Set the vertical speed to -12.5 (or however strong you want your initial jump to be)
___ Set variable double_jump to 1 ('one' being my flag for "another jump available")
___ (end of a block)
ELSE
___ (start of a block)
___ IF double_jump is equal to 1
___ ___ (start of a block)
___ ___ Set variable double_jump to 0 (so that I cannot jump again after -this- double jump)
___ ___ Set the vertical speed to -10 (or however strong you want your second jump to be)
___ ___ (end of a block)
___ (end of a block)

In addition, I have a step event where, if I'm in the air, it makes me fall.  If I'm on the ground, it sets the variable double_jump to equal 1.  This way, if I've been on the ground, and I walk off the edge, I can still use my double jump, but I don't get to jump twice.  Because of this, the part in the first jump where I set the double_jump to equal 1 might be redundant, but it can't hurt.
« Last Edit: July 13, 2008, 04:07:30 pm by ninjafetus »
Logged

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
Re: double jump on "game maker"
« Reply #4 on: July 12, 2008, 08:02:50 pm »

Quote
Are you sure this works?

arff sorry, it's "earth", not "sol".
On my code, the name of this var is "sol", that's why I've written "sol" >_<
Now It's corrected.

Quote
IF there is a collision at position (0,1) with SOLID_OBJECT

I didn't know how to use "if there is a collision" that's why I don't have used that.
but your solution seems to be better.
I'll try that tomorrow.
« Last Edit: July 12, 2008, 08:06:43 pm by zebdal »
Logged

desktopdoodlz

  • Guest
Re: double jump on "game maker"
« Reply #5 on: July 12, 2008, 08:32:19 pm »

HOLY SHIT IT WORKS!!!!!
Logged

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
Re: double jump on "game maker"
« Reply #6 on: July 12, 2008, 08:51:28 pm »

Quote
Are you sure this works?  It would seem that you could jump infinitely many times, since you set your flag "earth" to 1 after your second jump....

If you consider that "earth" is the number of jumps that you've done:
when you hit the ground (the_earth), the number of jumps becomes 0.
when you want to jump:
_if you have jumped 0 or 1 times you can rejump and number of jumps done is increased by 1 (relative)
_for others cases (i.e number of jumps = 2), NULL, because you don't have to do anything and you CAN'T do anything except moving at the left or the right.

and "set variable sol to 1" it's relative of course. I'm not a noob.
if not relative, just "set variable earth to 2" or "set variable earth to anything except 0 and 1)
but that's right, nOObs can not understand this point of view.
so I edit this part with "set variable earth to 2"

now it works.

maybe this shit works too:
Quote
if earth is not equal to 2
_start of a block
_set variable earth to 1 (relative)
_set the vertical speed to -16
_end of a block

it's really shorter and it works for all jumps
« Last Edit: July 12, 2008, 08:57:35 pm by zebdal »
Logged

ninjafetus

  • Full Member
  • ***
  • Posts: 232
    • View Profile
    • NES 50
Re: double jump on "game maker"
« Reply #7 on: July 13, 2008, 02:43:40 am »

Sorry, I forgot about GM's weird code method of "set variable to 1 (relative)" instead of something more intuitive like "add 1 to variable."  I read it how it's written in words, which is the silly "if x == 1; set x = 1;" style loop :p
Logged

Koppis

  • The Guy
  • *****
  • Posts: 1344
  • JAKE ON URPO
    • View Profile
Re: double jump on "game maker"
« Reply #8 on: July 13, 2008, 07:38:15 am »

Unknown variable earth???
Logged
lol

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
Re: double jump on "game maker"
« Reply #9 on: July 13, 2008, 08:22:30 am »

Quote
Unknown variable earth???

no, look at this:
Quote
ADD EVENT: create object
actions:
set variable earth to 0

you declare the variables when the object is created, here it creates the var "earth" = 0

Quote
Sorry, I forgot about GM's weird code method of "set variable to 1 (relative)" instead of something more intuitive like "add 1 to variable."

yeah it's gay, but it's useful.
« Last Edit: July 13, 2008, 08:24:56 am by zebdal »
Logged

Koppis

  • The Guy
  • *****
  • Posts: 1344
  • JAKE ON URPO
    • View Profile
Re: double jump on "game maker"
« Reply #10 on: July 13, 2008, 09:11:55 am »

Can you tell me which ones are supposed to be "relative"?

EDIT: I can only get it to double jump if I fall off a ledge. Plz help.
« Last Edit: July 13, 2008, 09:23:07 am by Kòppís ^^, »
Logged
lol

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
Re: double jump on "game maker"
« Reply #11 on: July 13, 2008, 09:41:56 am »

I've edited my first post, now choose to use or not the relative option.
the 2 methods works.
Logged

desktopdoodlz

  • Guest
Re: double jump on "game maker"
« Reply #12 on: July 13, 2008, 12:31:52 pm »

lol, i screwed up somewhere, and now you can fly... :P
Logged

Koppis

  • The Guy
  • *****
  • Posts: 1344
  • JAKE ON URPO
    • View Profile
Re: double jump on "game maker"
« Reply #13 on: July 13, 2008, 05:39:38 pm »

I don't know what's wrong with this.
http://www.savefile.com/files/1665233
Logged
lol

zebdal

  • Jr. Member
  • **
  • Posts: 90
  • best fan of DJ Sharpnel
    • View Profile
    • Stepmania France
Re: double jump on "game maker"
« Reply #14 on: July 13, 2008, 05:50:04 pm »

it doesn't work because you have created the event "<up>", and this is not "<up>" but "press <up>" that you have to use.
because with "<up>", you jump twice in some milliseconds (because the up key is hold pressed) so you think you have jumped only once but you have jumped twice.
with "press <up>", it's only when you press the up button that you jump, so you have to use that.
« Last Edit: July 13, 2008, 06:18:50 pm by zebdal »
Logged
Pages: [1] 2 3 4