GMS 2 [SOLVED] Sprite Bouncing On Higher Ground and Cant Jump

T

tomoebi

Guest
3 problems solved.
still have something that im trying to figure out tho. you can delete this thread mod.

but, seriously no one replying here. lol
 
Last edited by a moderator:
T

tomoebi

Guest
Hi, so ive been tinkering with gamemaker since i post my problem yesterday, already can solve 2 of them. but im still need your help if you ever encounter this. because i still cant figure out this one problem.

So, my sprite will bouncing when i try to put it on a higher ground, and it cant jump from there, below is the example.

sorry, using phone camera because my nvidia shadowplay for some reason stop working.



Btw, this is the code im using.
Under Event->Step
/// @description Insert description here
// You can write your code in this editor
var t1 = tilemap_get_at_pixel (tilemap, bbox_left, bbox_bottom + 1) & tile_index_mask;
var t2 = tilemap_get_at_pixel (tilemap, bbox_right, bbox_bottom + 1) & tile_index_mask;
if (t1 != 0 or t2 != 0) {
if (keyboard_check(vk_space)) {
v_speed = -jump_impulse;

}
}

var dx = move_speed * (keyboard_check(vk_right) - keyboard_check((vk_left)));
var dy = v_speed ;
v_speed += grav;

//lompatlompat
y += dy;
if (dy>0) { //kebawah
var t1 = tilemap_get_at_pixel(tilemap, bbox_left, bbox_bottom) & tile_index_mask;
var t2 = tilemap_get_at_pixel(tilemap, bbox_right, bbox_bottom) & tile_index_mask;

if (t1 != 0 or t2 !=0) {
y = ((bbox_bottom & ~31) -1) - sprite_bbox_bottom;
v_speed = 0;
}

} else { //ngatas
var t1 = tilemap_get_at_pixel(tilemap, bbox_left, bbox_top) & tile_index_mask;
var t2 = tilemap_get_at_pixel(tilemap, bbox_right, bbox_top) & tile_index_mask;

if (t1 != 0 or t2 !=0) {
y = ((bbox_top + 32) & ~31) - sprite_bbox_top;
v_speed = 0;

}
}

//nyamping
x += dx ;
if (dx>0) { //nganan
var t1 = tilemap_get_at_pixel(tilemap, bbox_right, bbox_top) & tile_index_mask;
var t2 = tilemap_get_at_pixel(tilemap, bbox_right, bbox_bottom) & tile_index_mask;

if (t1 != 0 or t2 !=0) {
x = ((bbox_right & ~31) -1) - sprite_bbox_right;
}
} else { //ngiri

var t1 = tilemap_get_at_pixel(tilemap, bbox_left, bbox_top) & tile_index_mask;
var t2 = tilemap_get_at_pixel(tilemap, bbox_left, bbox_bottom) & tile_index_mask;

if (t1 != 0 or t2 !=0) {
x = ((bbox_left + 32) & ~31) - sprite_bbox_left;
}
}
Under Event -> Create
//movement goes here
move_speed = 10;
jump_impulse = 35;
grav = 1.8;
v_speed = 0;
//lemme cryin on the floor
var l = layer_get_id("lantai");
tilemap = layer_tilemap_get_id(l);
//
sprite_bbox_left = sprite_get_bbox_left(sprite_index) - sprite_get_xoffset(sprite_index);
sprite_bbox_right = sprite_get_bbox_right(sprite_index) - sprite_get_xoffset(sprite_index);
sprite_bbox_bottom = sprite_get_bbox_bottom(sprite_index) - sprite_get_yoffset(sprite_index);
sprite_bbox_top = sprite_get_bbox_top(sprite_index) - sprite_get_yoffset(sprite_index);
 
Top