• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

New and looking for a bit of help.

H

HenkQQ

Guest
Hey,

looking for a bit of help with GML, I'm an artist so pretty new to coding and trying to learn.

I'm just wondering if someone could either help with what I'm trying to do or point me in the right direction on what to look at on the game maker documentation?

player - I need to make the player jump on start then if the player collides with another object it jumps again.

( I have this working sort of but the player continuously just keeps going so I think I just need to add a max height variable to sort that.)

level - with mouse/gesture rotate the level on x axis. (holding mouse button down you can rotate the level left and right freely.

If you need me to explain any further please do let me know and I'll try my best.

Thanks :)
 

samspade

Member
Hey,

looking for a bit of help with GML, I'm an artist so pretty new to coding and trying to learn.

I'm just wondering if someone could either help with what I'm trying to do or point me in the right direction on what to look at on the game maker documentation?

player - I need to make the player jump on start then if the player collides with another object it jumps again.

( I have this working sort of but the player continuously just keeps going so I think I just need to add a max height variable to sort that.)

level - with mouse/gesture rotate the level on x axis. (holding mouse button down you can rotate the level left and right freely.

If you need me to explain any further please do let me know and I'll try my best.

Thanks :)
What does jump on start mean? In other words, what is start? The start button on a controller? The start of a level? The start of a game? What does your jump code look like in general?

Without knowing anything more it is hard to give much of an answer but a very simple way of doing a jump is this:

Code:
if (jump) {
    vsp = jumpspeed; //where jumpspeed is negative
}

vsp += grav; //where grav is a positive number likely less than 1
y += vsp;
In this version of the code jump 'adds' (actually subtracts because y increases going down) to vsp, gravity subtracts (actually adds) from vsp, and the y position is updated accordingly. Normally you would have some other code that prevents the player from falling forever, e.g. collision with a ground object. Really, any of the many platformer tutorials would be fine for this.

What does rotate the level on the x axis mean? Do you mean the world is 3D? Do you mean a level selection screen?
 

KPJ

Member
I agree with what samspade said. As for the "player jump when collision with object" part, simply put the jump code into a collision event between the player and the object you want to collide with. I am confused about the "level" part as well. Could you please further explain? Thanks!
 
H

HenkQQ

Guest
What does jump on start mean? In other words, what is start? The start button on a controller? The start of a level? The start of a game? What does your jump code look like in general?

Without knowing anything more it is hard to give much of an answer but a very simple way of doing a jump is this:

Code:
if (jump) {
    vsp = jumpspeed; //where jumpspeed is negative
}

vsp += grav; //where grav is a positive number likely less than 1
y += vsp;
In this version of the code jump 'adds' (actually subtracts because y increases going down) to vsp, gravity subtracts (actually adds) from vsp, and the y position is updated accordingly. Normally you would have some other code that prevents the player from falling forever, e.g. collision with a ground object. Really, any of the many platformer tutorials would be fine for this.

What does rotate the level on the x axis mean? Do you mean the world is 3D? Do you mean a level selection screen?
I agree with what samspade said. As for the "player jump when collision with object" part, simply put the jump code into a collision event between the player and the object you want to collide with. I am confused about the "level" part as well. Could you please further explain? Thanks!


6Hey Samspade & KPJ,

Thanks for the replies,

With the the "jump on start" I did mean at the start of the level and thanks for the advise I'll give that a try.

With rotating the level I wasn't referring to rotating in a 3d space (sorry my bad, I should have explained it a bit better.)

I mean moving the level on the x axis left and right.

Example:

So the player jumps from platform to platform however instead of controlling the player to move to the next platform you control the level moving it left and right. (hopefully that explains it a bit better?)
 

samspade

Member
You'll probably need a more sophisticated solution later but either of these two ideas would work on a small scale.

Option 1: Manually move them with inheritance.

Code:
///a controller object's step event
var move = keyboard_check(vk_right) - keyboard_check(vk_let) * spd;
if (move != 0) {
    with (moving_objects) {
        x += move;
    }
}
Option 2: adjust an offset and have all moveable objects x location be equal to their xstart + offset

Code:
///some controler object
global.offset += keyboard_check(vk_right) - keyboard_check(vk_let) * spd;

///step event of all moveable objects
x = xstart + global.offset
Even though it's not really what you want, watching a basic platformer tutorial might be helpful as many of the ideas would directly correlate to what you want to do.

If the first example doesn't make sense I would recommend reading this:

Addressing Variables in Other Instances

and watching this:

 
V

VagrantWhaleGames

Guest
create two sprites...spr_player and spr_block
create two objects obj_block and obj_player

obj_player
Code:
///
//create
gravity=1;
jump_speed=5;
//destroy
instance_create(32,160,obj_player);
//collide with obj_block
vspeed-=jump_speed;
//outside room
instance_destroy();
obj_block
Code:
///obj_block
//create
xx=xstart-room_width/2
//step
x=(xx+mouse_x);
place some blocks and the player in a default room and mess around
 

KPJ

Member
You could have a check, for example: if the player isn't on a level or colliding with a level, then do normal movement, else (if the player is on a level) then control the level with the arrow keys. A great way to do this is using state machines.
 
Top