M
muxebv
Guest
Hello Everyone, First of all thank you for your time to read this topic.
So the issue that we are facing is as follow we have made a platformer setup however there are still 2 bugs that we havent been able to solve.
Issue one is that when you stand directly at the walls and click the jump button once or twice (W) it will dissapear within the wall and after that you can still move around in the game but the character will be gone.
http://muxehub.com/games/Digizones/ On this link you will be able to test the first level of the game to notice the bug I mentioned above. (walking with WASD and Running or shooting with Spacebar).
Issue 2 is that we are loading enemies in the game at a variety of different places. In the room editor we have placed them at their location (however a few of them automatically disappear) others will be there until falling off a wall (leaving them in a small corner). What doesnt make sence is that not all of them are there ( even its the same object).
Some of the codes for subjects:
Issue on jumping:
Code 1 is the create event of the player:
Code 2 is the step event of the player:
Our own assumption is that it gets stuck under the wall of certain objects who are not squared). I think after multi clicking jump that it forces the player to vanish as it gets stuck in the game.
Perhaps anyone knows a good way to solve it. I have tried instance destroy, bounces or bump false for this issue but none are responding to it.
As for issue 2 the enemy it doesnt make sence at all as theres another enemy (which we currently havent placed in the level). Even though the settings are completely the same that other enemy is not having the same bug.
And when game loaded starts like this
http://muxehub.com/games/Digizones/bug2.png
So the issue that we are facing is as follow we have made a platformer setup however there are still 2 bugs that we havent been able to solve.
Issue one is that when you stand directly at the walls and click the jump button once or twice (W) it will dissapear within the wall and after that you can still move around in the game but the character will be gone.
http://muxehub.com/games/Digizones/ On this link you will be able to test the first level of the game to notice the bug I mentioned above. (walking with WASD and Running or shooting with Spacebar).
Issue 2 is that we are loading enemies in the game at a variety of different places. In the room editor we have placed them at their location (however a few of them automatically disappear) others will be there until falling off a wall (leaving them in a small corner). What doesnt make sence is that not all of them are there ( even its the same object).
Some of the codes for subjects:
Issue on jumping:
Code 1 is the create event of the player:
Code:
/// @description Settings
//No animation right now
image_speed = 0;
//This is the current state of the player
int_state = en_states.idle;
//The form of the character (0 for small mario, 1 for big mario, 2 for fire flower mario)
int_form = 0;
//This is how quickly we move horizontally
int_xSpeed = 0;
//This is the gravity aspect of mario
int_gravity = 1;
//For how many frames have we held the jump (w) key?
int_yHeld = 0;
//We use this growState to dictate of how the growth of mario happens (see alarm[0])
int_powerUpOrDownState = 0;
//When I am invincible, when this number is 0 I am visible, when 1 I am invisible. It flips back and forth until I am vulnerable again
int_invisibilityNum = 0;
//When I touch an enemy, briefly allow the player to be invincible to get away
b_invincible = false;
//Array to assign the sprites of mario [form, state]
spr_marioSprite[0, 0] = spr_marioIdleSm;
spr_marioSprite[0, 1] = spr_marioRunSm;
spr_marioSprite[0, 2] = spr_marioJumpSm;
spr_marioSprite[0, 3] = spr_marioSkidSm;
spr_marioSprite[1, 0] = spr_marioIdleLg;
spr_marioSprite[1, 1] = spr_marioRunLg;
spr_marioSprite[1, 2] = spr_marioJumpLg;
spr_marioSprite[1, 3] = spr_marioSkidLg;
spr_marioSprite[1, 4] = spr_marioDuckLg;
spr_marioSprite[2, 0] = spr_marioIdleFLg;
spr_marioSprite[2, 1] = spr_marioRunFLg;
spr_marioSprite[2, 2] = spr_marioJumpFLg;
spr_marioSprite[2, 3] = spr_marioSkidFLg;
spr_marioSprite[2, 4] = spr_marioDuckFLg;
Code:
/// @description Meat and potatoes
/*
We control our character thru what is called an FSM, or a "finite-state-machine".
It works by analyzing the current state of the character and allowing certain actions to happen
based on the actual state the character it is within
*/
var a, b, c, d, e;
//Get keyboard inputs
a = keyboard_check(ord("D")) - keyboard_check(ord("A"));//Which direction am I trying to go? -1 left or 1 right
b = keyboard_check(vk_space);//Am I trying to run? 0 false 1 true
c = keyboard_check(ord("W"));//Am I trying to jump? 0 false 1 true
d = keyboard_check(ord("S"));//Am I trying to duck? 0 false 1 true
e = keyboard_check_pressed(vk_space);//Did I press the space key this frame? 0 false 1 true (This is for shooting fireballs in form 2)
//Activate all objects within this region (We keep them in suspension until they are within range)
instance_activate_region(__view_get( e__VW.XView, 0 ), 0, __view_get( e__VW.XView, 0 ) + __view_get( e__VW.WView, 0 ), room_height, true);
//Flip the sprite based on the character input (make sure it 'a' is NOT 0 - otherwise he will be flat and invisible).
if (a <> 0){
if (int_state <> en_states.jump && int_state <> en_states.fall && int_state <> en_states.death){//Do not allow the player to flip image_xscale if they are jumping or falling
image_xscale = a;
}
if (int_state <> en_states.duck && int_state <> en_states.powerupOrDown && int_state <> en_states.death){//Do not mess with int_xSpeed if I am ducking or powering up or dead
int_xSpeed += a;//Increase xSpeed by a (-1 or 1 until it reaches either -5 / 5, or -7 / 7 if we are sprinting)
}else{
int_xSpeed += -sign(int_xSpeed);
}
}else{
int_xSpeed += -sign(int_xSpeed);//Return x speed to 0
}
//Increase x by int_Xspeed, increase this further if we are running (If b is true - remember it is either a 0 or 1)
if (place_meeting(x + int_xSpeed + b * sign(int_xSpeed), y, par_brick)){
while(!place_meeting(x + sign(int_xSpeed), y, par_brick)){
x += sign(int_xSpeed);
}
int_xSpeed = a;
}else{
x += int_xSpeed + b * sign(int_xSpeed);
}
//Do not allow xSpeed to go higher or lower than -5 or 5 or -7 / 7 if the player is running (shift)
int_xSpeed = clamp(int_xSpeed, -4 + b * -3, 4 + b * 3);
//Shooting a fireball, but only in form 2 and only while I am not ducking
if (int_form == 2 && e && int_state <> en_states.duck){
instance_create(x + image_xscale * 7, y - 48, obj_fireballExpl);
with(instance_create(x, y - 48, obj_fireball)){
int_dir = other.image_xscale;
}
}
//Analyze the state of the player and adjust his mechanics
switch(int_state){
//Idle
case en_states.idle:
if (c){
int_gravity = 0;
int_state = en_states.jump;
}else{
if (d && int_form > 0){
int_state = en_states.duck;
}else{
var t = instance_place(x, y, par_enemy);
if (t > -4 && !b_invincible){
switch(t.object_index){
default:
if (int_form > 0){
alarm[1 + int_form] = 1;
int_state = en_states.powerupOrDown;
}else{
int_gravity = 0;
int_state = en_states.death;
}
break;
case obj_koopa:
if (t.int_state <> 2){
if (int_form > 0){
alarm[1 + int_form] = 1;
int_state = en_states.powerupOrDown;
}else{
int_gravity = 0;
int_state = en_states.death;
}
}else{
t.int_state = 3;
t.int_dir = image_xscale;
}
break;
}
}else{
if (place_meeting(x, y + 1, par_brick)){
if (a <> 0){
int_state = en_states.run;
}else{
sprite_index = spr_marioSprite[int_form, 0];
image_speed = 0;
}
}else{
int_gravity = 0;
int_state = en_states.fall;
}
}
}
}
break;
//Run
case en_states.run:
if (c){
int_gravity = 0;
int_state = en_states.jump;
}else{
if (d && int_form > 0){
int_state = en_states.duck;
}else{
var t = instance_place(x, y, par_enemy);
if (t > -4 && !b_invincible){
switch(t.object_index){
default:
if (int_form > 0){
alarm[1 + int_form] = 1;
int_state = en_states.powerupOrDown;
}else{
int_gravity = 0;
int_state = en_states.death;
}
break;
case obj_koopa:
if (t.int_state <> 2){
if (int_form > 0){
alarm[1 + int_form] = 1;
int_state = en_states.powerupOrDown;
}else{
int_gravity = 0;
int_state = en_states.death;
}
}else{
t.int_state = 3;
t.int_dir = image_xscale;
with(t){
while(place_meeting(x, y, obj_mario)){
x += other.image_xscale;
}
}
}
break;
}
}else{
if (place_meeting(x, y + 1, par_brick)){
if (a <> 0){
if (sign(int_xSpeed) == a){
sprite_index = spr_marioSprite[int_form, 1];
image_speed = .5 + b / 3;
}else{
sprite_index = spr_marioSprite[int_form, 3];
image_speed = 0;
}
}else{
int_state = en_states.idle;
}
}else{
int_gravity = 0;
int_state = en_states.fall;
}
}
}
}
break;
//Fall
case en_states.fall:
if (place_meeting(x, y + 1, par_brick)){
if (a <> 0){
int_state = en_states.run;
}else{
int_state = en_states.idle;
}
}else{
if (d && int_form > 0){
sprite_index = spr_marioSprite[int_form, 4];
}else{
sprite_index = spr_marioSprite[int_form, 2];
}
image_speed = 0;
y += int_gravity;
if (int_gravity < 18){
int_gravity += 1.5;
}
var t = instance_place(x, y, par_enemy);
if (t > -4){
with(t){
event_user(0);
}
y = floor(y);
int_gravity = 6;
int_state = en_states.jump;
}else{
if (place_meeting(x, y, par_brick)){
y = floor(y);
while(place_meeting(x, y, par_brick)){
y --;
}
int_gravity = 0;
}
}
}
break;
//Jump
case en_states.jump:
if (d && int_form > 0){
sprite_index = spr_marioSprite[int_form, 4];
}else{
sprite_index = spr_marioSprite[int_form, 2];
}
image_speed = 0;
y += -18 + int_gravity;
if (int_gravity < 18){
if (c){
int_gravity ++;
}else{
int_gravity += 2;
}
}else{
int_gravity = 0;
int_state = en_states.fall;
}
t = instance_position(x, y - sprite_height, par_brick);
if (t == -4){
t = instance_place(x, y, par_brick);
}
if (t > -4){
y = ceil(y);
if (t.object_index == obj_brickBreak){
with(t){
event_user(other.int_form);
}
}else{
with(t){
event_user(0);
}
}
while(place_meeting(x, y, par_brick)){
y ++;
}
int_gravity = 0;
int_state = en_states.fall;
}
break;
//Duck (only if I am large tho)
case en_states.duck:
if (place_meeting(x, y + 1, par_brick)){
if (d){
sprite_index = spr_marioSprite[int_form, 4];
image_speed = 0;
}else{
if (a <> 0){
int_state = en_states.run;
}else{
int_state = en_states.idle;
}
}
}else{
int_state = en_states.fall;
}
break;
//Power up
case en_states.powerupOrDown:
image_speed = 0;
//Basically do nothing and freeze myself. We will will halt everything until the powerup is complete (take a look at alarms 0 - 3)
break;
//Death
case en_states.death:
sprite_index = spr_marioDead;
int_xSpeed = 0;
y += -18 + int_gravity;
if (int_gravity < 36){
int_gravity ++;
}
if (y > room_height + 100){
room_restart();
}
/// @description Try to consume life and go to
break;
}
/* */
/* */
Our own assumption is that it gets stuck under the wall of certain objects who are not squared). I think after multi clicking jump that it forces the player to vanish as it gets stuck in the game.
Perhaps anyone knows a good way to solve it. I have tried instance destroy, bounces or bump false for this issue but none are responding to it.
As for issue 2 the enemy it doesnt make sence at all as theres another enemy (which we currently havent placed in the level). Even though the settings are completely the same that other enemy is not having the same bug.
And when game loaded starts like this
http://muxehub.com/games/Digizones/bug2.png