There is a serious big project I'm working on and I just thought I might need support from you pros out there, Just to help me make it exists.
The problem:
The Bouncing Mechanic
You know how "The Game" works if you compare it with Ducktales with a twist. The character can be able to spin it's tail and can bounce normally (if not doing anything) and in high start (if you keep holding the "JUMP" button).
It wasn't supposed to be a big deal when it comes to a mechanic, but I noticed that he levitated extra bits as I move left and right, which indeed , is unnecessary and could ruin the mechanic just a little.
That's why I need help just to make it smooth and get rid of that minor situation.
Here is the essential parts of my code for my character: //Create Spoiler:
Code:
/// Our protagonist to put an end to Sir Kernolous
//Initialize Variables grav = 1; //Gravity hsp = 0; //Horizontal Speed vsp = 0; // Vertical Speed jumpspeed = 9; // Amount of jumpheight movespeed = 2; // Speed of the player invulnerable = false // Temporary Invincibility jumpland = false // Checking if landed jumpable = true // Able to jump or not. startx = x; // Start of X starty = y; // Start of Y grounded = false; // Check if he's in ground or not duck = false // Check if he is ducking or not bounce_able = true // Able to bounce bounce_attack = false // Activation of "bouncing ability" attack = false // Check if attacking hit = false // If hit... hurt = false // If hurt .... climb = false // Climable climbmovement = true charge = 0 // Charge chargeon = false //Important ----8**-/-*/*/*-/*/* chargetime = 0 // Amount of Charge until "Full" chargeready = 0 // Readiness of Charge chargesound = false stop = false pull = false pullhold = false pullmovement = false hold = false
if jumpland = true && place_meeting(x,y+1,obj_wall) && bounce_attack = false { jumpland = false if climb = false audio_play_sound(snd_player_land,1,0) }
} y += vsp;
//Animation if climb = false // If not in a climb state {
if attack = false // If not attacked { if chargeon = false { if (move!=0) image_xscale = move; if (place_meeting(x,y+1,obj_wall)) { if (move!=0) { if bounce_attack = true and place_meeting(x,y+1,obj_wall) sprite_index = spr_rac_bounced; else sprite_index = spr_rac_walk; image_speed = 0.15; } else { if duck = true {sprite_index = spr_rac_duck image_speed = 0;} else if bounce_attack = true and place_meeting(x,y+1,obj_wall) sprite_index = spr_rac_bounced; else sprite_index = spr_rac_stand; image_speed = 0; } } else
if (vsp < 0) or (vsp > 0) { if bounce_attack = true sprite_index = spr_rac_bounce else sprite_index = spr_rac_jump } } } }
if hit = true // If attacked or hit { if image_xscale = 1 { if hurt = true { if !place_meeting(x-4,y,obj_wall) x -= 4 hurt = false } } else if image_xscale = -1 { if hurt = true { if !place_meeting(x+4,y,obj_wall) x += 4 hurt = false } } } //Prevent from going outside the room (on the side) if x < 3 x = 3 if x > room_width-3 x = room_width-3 if y < -5 y = -5
//--Climb-- if (collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) && keyboard_check_pressed(vk_up) { climb = true // Triggers the activation to climb }
if (climb) // If he is on ladder or climable object { hsp = 0; vsp = 0; jumpable = false if !keyboard_check(vk_up) || !keyboard_check(vk_down) { image_speed = 0 } sprite_index = spr_rac_climb
if climbmovement = true { if keyboard_check(vk_up) { if place_free(x,y-2) image_speed = 0.15; vsp-=2 }
if keyboard_check(vk_down) { if place_free(x,y+2) image_speed = 0.15; vsp+=2 } if (key_up and !collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) or (!collision_line(x, bbox_top, x, bbox_bottom, obj_rope, false, false)) { climb = false; jumpable = true;
Program: Game Maker Studio Standard Also, I'll keep trying to find a solution.
If it was supposed to be in [url=https://phpbb.mfgg.net/viewtopic.php?f=10&t=14053&p=516111#p516111/]here[/url], I'm sorry.
There is a serious big project I'm working on and I just thought I might need support from you pros out there, Just to help me make it exists.
The problem:
[u][size=150][b]The Bouncing Mechanic[/b][/size][/u]
You know how "The Game" works if you compare it with [b]Ducktales[/b] with a twist. The character can be able to spin it's tail and can bounce normally (if not doing anything) and in high start (if you keep holding the "JUMP" button).
It wasn't supposed to be a big deal when it comes to a mechanic, but I noticed that he levitated extra bits as I move [b]left[/b] and [b]right[/b], which indeed , is unnecessary and could ruin the mechanic just a little.
That's why I need help just to make it smooth and get rid of that minor situation.
Here is the essential parts of my code for my character:
//Create
[spoiler][code]/// Our protagonist to put an end to Sir Kernolous
//Initialize Variables
grav = 1; //Gravity
hsp = 0; //Horizontal Speed
vsp = 0; // Vertical Speed
jumpspeed = 9; // Amount of jumpheight
movespeed = 2; // Speed of the player
invulnerable = false // Temporary Invincibility
jumpland = false // Checking if landed
jumpable = true // Able to jump or not.
startx = x; // Start of X
starty = y; // Start of Y
grounded = false; // Check if he's in ground or not
duck = false // Check if he is ducking or not
bounce_able = true // Able to bounce
bounce_attack = false // Activation of "bouncing ability"
attack = false // Check if attacking
hit = false // If hit...
hurt = false // If hurt ....
climb = false // Climable
climbmovement = true
charge = 0 // Charge
chargeon = false //Important ----8**-/-*/*/*-/*/*
chargetime = 0 // Amount of Charge until "Full"
chargeready = 0 // Readiness of Charge
chargesound = false
stop = false
pull = false
pullhold = false
pullmovement = false
hold = false
[/code][/spoiler]
//Step
[spoiler][code]///Logistics of the Raccoon!
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_up = keyboard_check(vk_up);
key_down = keyboard_check(vk_down);
key_jump = keyboard_check_pressed(ord('Z'));
key_jump_held = keyboard_check(ord('Z'));
{
//React to inputs
if pull = false
{
if pullhold = false
{
if duck = false // If not ducking
move = key_left + key_right;
}
}
hsp = move * movespeed;
if climb = false // If not in ropes...
if (vsp < 10) vsp += grav;
//--Duck--
if grounded = true && bounce_attack = false // If on ground but, not bouncing
{
if key_down && place_meeting(x,y+1,obj_wall)
{
duck = true
move = 0
bounce_able = false
}
else
{
duck = false
bounce_able = true
}
}
//--Jump--
if (place_meeting(x,y+1,obj_wall))
{
if grounded = true
{
if bounce_attack = false && (key_jump) && climb = false && chargeon = 0 && attack = false && pull = false{
grounded = false
vsp = -jumpspeed
jumpland = true
}
//--Tail Attack--
if keyboard_check_pressed(ord('X')) && attack = false && !key_down && !place_meeting(x+1,y,obj_pushblock_trigger) && !place_meeting(x-1,y,obj_pushblock_trigger)
{
attack = true
sprite_index = spr_rac_spin
image_speed = 0.4
instance_create(x,y,obj_tailmask)
audio_play_sound(snd_player_spin,1,0)
}
if !keyboard_check(ord('X')) && attack = false
{
if chargeon = true && chargetime < 30
{
chargeon = false
chargetime = 0
charge = 0
}
else if chargeon = true && chargetime >= 30
{
attack = true
sprite_index = spr_rac_chargespin
image_speed = 0.4
image_index = 0
instance_create(x,y,obj_tailmask)
audio_play_sound(snd_player_spin,1,0)
}
}
}
}
else
grounded = true
//---Charging Process---
if chargeon = true && chargeready = 0 && chargetime != 30
{
chargetime += 0.5
}
else if chargeon = true && chargetime >= 30
{
chargetime = 30
chargeready = 1
}
//--Jumping Variable Check--
if (vsp < 0) && (!key_jump_held) vsp = max(vsp,-jumpspeed/4.5)
//--Bouncing Ability--
if keyboard_check(ord('X')) && key_down && bounce_able = true && !place_meeting(x,y-3,obj_wall)
{
bounce_attack = true
chargeon = false
}
else
{
bounce_attack = false
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
if climb = false && chargeon = false
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
if bounce_attack = true && place_meeting(x,y+1,obj_wall)
{
sprite_index = spr_rac_bounced;
if keyboard_check(ord('Z'))
vsp = -vsp-1
else
vsp = -vsp
audio_play_sound(snd_player_bounce,1,0)
}
if bounce_attack = false
vsp = 0;
if jumpland = true && place_meeting(x,y+1,obj_wall) && bounce_attack = false
{
jumpland = false
if climb = false
audio_play_sound(snd_player_land,1,0)
}
}
y += vsp;
//Animation
if climb = false // If not in a climb state
{
if attack = false // If not attacked
{
if chargeon = false
{
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_wall))
{
if (move!=0)
{
if bounce_attack = true and place_meeting(x,y+1,obj_wall)
sprite_index = spr_rac_bounced;
else
sprite_index = spr_rac_walk;
image_speed = 0.15;
}
else
{
if duck = true {sprite_index = spr_rac_duck image_speed = 0;}
else
if bounce_attack = true and place_meeting(x,y+1,obj_wall)
sprite_index = spr_rac_bounced;
else
sprite_index = spr_rac_stand;
image_speed = 0;
}
}
else
if (vsp < 0) or (vsp > 0)
{
if bounce_attack = true
sprite_index = spr_rac_bounce
else
sprite_index = spr_rac_jump
}
}
}
}
if hit = true // If attacked or hit
{
if image_xscale = 1
{
if hurt = true
{
if !place_meeting(x-4,y,obj_wall)
x -= 4
hurt = false
}
}
else if image_xscale = -1
{
if hurt = true
{
if !place_meeting(x+4,y,obj_wall)
x += 4
hurt = false
}
}
}
//Prevent from going outside the room (on the side)
if x < 3 x = 3
if x > room_width-3 x = room_width-3
if y < -5 y = -5
// Mask Change
if bounce_attack = true && duck = false // Climb {SAME} Mask
mask_index = spr_mask
else if duck = true && bounce_attack = false // Crouch Mask
mask_index = spr_mask_crouch
else if duck = false && bounce_attack = false // Normal Mask
mask_index = spr_mask
//--Climb--
if (collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) && keyboard_check_pressed(vk_up)
{
climb = true // Triggers the activation to climb
}
if (climb) // If he is on ladder or climable object
{
hsp = 0;
vsp = 0;
jumpable = false
if !keyboard_check(vk_up) || !keyboard_check(vk_down)
{
image_speed = 0
}
sprite_index = spr_rac_climb
if climbmovement = true
{
if keyboard_check(vk_up)
{
if place_free(x,y-2)
image_speed = 0.15;
vsp-=2
}
if keyboard_check(vk_down)
{
if place_free(x,y+2)
image_speed = 0.15;
vsp+=2
}
if (key_up and !collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false))
or (!collision_line(x, bbox_top, x, bbox_bottom, obj_rope, false, false))
{
climb = false;
jumpable = true;
}
}
if (key_jump)
{
vsp = -jumpspeed
jumpland = true
climb = false
}
}
if global.invincibility = 1
alarm[5] = 1;
}
[/code][/spoiler]
Program: Game Maker Studio Standard
[b][i]Also, I'll keep trying to find a solution.[/i][/b]
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum