Calvert
Member
Hello, you can call me Calvert, and I am almost totally inexperienced in programming. Especially when it comes to making a platformer engine with gravity and pixel-perfect movements/collision.
Like many people here, I have dreams to make some great games. Since I'm inexperienced with GML, I'm working on a minimalist/micro platformer game with a 4x4 tileset to improve my skills. My goal right now is to make a solid gravity system with pixel-perfect collision. I want a character that can run and jump around a room without having collision issues. This is critical, due to the micro-resolution I am going for.
I have tried many of the platformer codes that all of the "popular Gamemaker experts" have made, but as soon as I want to make some additions to the code I find myself incapable due to not fully understanding it, or I find out that the framework needs to be totally re-written if I am going to add what I want to add. I always end up working with a gamemaker file that is full of random code that doesn't work and it becomes frustrating.
So, today I have decided to create my own platformer from scratch. This way, I can get help from you (the community) without being totally confused, because the code we are working with is code that I'm familiar with. My code is straight-up amateur, basic and embarrassing, but hey, that's okay. We all need to start somewhere.
I started by adding framework for state machines. I don't understand much about them, but I hear it's helpful to have in the long run. Besides having a state machine system that I'm not even really utilizing yet, I have an object that can move horizontally until it hits a wall, falls if it is not standing on a solid object and it can jump. The jumping feels totally unnatural at the moment, so that's what I'm mainly seeking guidance on tweaking right now. it jumps super fast and doesn't go very high. Keep in mind that I have set many values in this system to be very low, because the game is working with a 4x4 grid.
obj_player create event:
obj_player step event:
I have two main scripts at the moment. One handles inputs and some basic variables and the other handles the player's object movement.
scr_player_state:
scr_player_basic:
I would like your input on how I may tweak and simplify/complicate things here. Obviously there are many fatal flaws with this engine, so I'm excited to receive your feedback.
Thoughts?
Like many people here, I have dreams to make some great games. Since I'm inexperienced with GML, I'm working on a minimalist/micro platformer game with a 4x4 tileset to improve my skills. My goal right now is to make a solid gravity system with pixel-perfect collision. I want a character that can run and jump around a room without having collision issues. This is critical, due to the micro-resolution I am going for.
I have tried many of the platformer codes that all of the "popular Gamemaker experts" have made, but as soon as I want to make some additions to the code I find myself incapable due to not fully understanding it, or I find out that the framework needs to be totally re-written if I am going to add what I want to add. I always end up working with a gamemaker file that is full of random code that doesn't work and it becomes frustrating.
So, today I have decided to create my own platformer from scratch. This way, I can get help from you (the community) without being totally confused, because the code we are working with is code that I'm familiar with. My code is straight-up amateur, basic and embarrassing, but hey, that's okay. We all need to start somewhere.
I started by adding framework for state machines. I don't understand much about them, but I hear it's helpful to have in the long run. Besides having a state machine system that I'm not even really utilizing yet, I have an object that can move horizontally until it hits a wall, falls if it is not standing on a solid object and it can jump. The jumping feels totally unnatural at the moment, so that's what I'm mainly seeking guidance on tweaking right now. it jumps super fast and doesn't go very high. Keep in mind that I have set many values in this system to be very low, because the game is working with a 4x4 grid.
obj_player create event:
Code:
grav = 0.5;
spd = 0.5
state = states.basic;
Code:
switch (state)
{
case states.basic: scr_player_basic(); break;
}
scr_player_state:
Code:
// Get Keys
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_down = keyboard_check(vk_down);
key_up = keyboard_check_pressed(vk_up);
key_action = keyboard_check_pressed(ord("X"));
//Get Position
position_ground = (place_meeting(x,y+1,obj_solid));
position_air = (!place_meeting(x,y+1,obj_solid));
position_solidl = (!place_meeting(x-1,y,obj_solid));
position_solidr = (!place_meeting(x+1,y,obj_solid));
// position_solidl and position_solidr checks to see if their is a solid object to the players left and right. This may be a somewhat useless variable but It is easy for me to read by having it at the moment.
Code:
scr_player_state();
//Horizontal Movement & Collision
if position_solidl && key_left
{
x -= spd;
}
if position_solidr && key_right
{
x += spd;
}
//Apply Gravity
if position_air
{
y += grav;
}
//Apply Jump
if position_ground && key_up
{
y -= 4;
}
Thoughts?