• 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!

Legacy GM Pulling Gravity in Room 2

S

sniper4627

Guest
Show your obj_husky Code

Code:
Information about object: obj_husky
Sprite: spr_husky_down
Solid: false
Visible: true
Depth: -10
Persistent: true
Parent:
Children:
Mask:

Physics
Start Awake: true
Is Kinematic: false
Is Sensor: false
Density: 0.5
Restitution: 0.1
Group: 0
Linear Damping: 0.1
Angular Damping: 0.1
Friction: 0.2
Shape: Box
Points:

(4, 0)
(30, 0)
(30, 42)
(4, 42)

Create Event:

execute code:

//Set fix rotatir
phy_fixed_rotation = true;
spd = 10;
image_speed = 0;



Step Event:

execute code:

image_speed = 0;

//MOVE UP
if keyboard_check(ord('W')) {
    phy_position_y -=  spd ;
    if place_meeting(x, y, obj_wall2)
        y += 32 - (bbox_top & 31);
    sprite_index = spr_husky_up;
    image_speed = 0.2;
}

//MOVE LEFT
if keyboard_check(ord('A')) {
     phy_position_x-= spd;
    if place_meeting(x, y, obj_wall2)
        x += 32 - (bbox_left & 31);
    sprite_index = spr_husky_left;
    image_speed = 0.2;
}
//MOVE DOWN
if keyboard_check(ord('S')) {
     phy_position_y+= spd;
    if place_meeting(x, y, obj_wall2)
        y -= (bbox_bottom + 1) & 31;
    sprite_index = spr_husky_down;
    image_speed = 0.2;
}
//MOVE RIGHT
if keyboard_check(ord('D')) {
     phy_position_x+= spd;
    if place_meeting(x, y, obj_wall2)
        x -= (bbox_right + 1) & 31;
    sprite_index = spr_husky_right;
    image_speed = 0.2;
}

//Stop animating
if !keyboard_check(ord('W')) and !keyboard_check(ord('A')) and !keyboard_check(ord('S')) and !keyboard_check(ord('D')) {
  image_speed = 0;
  image_index = 0;
}

Collision Event with object obj_wall2:

execute code:

//


Collision Event with object obj_warp:

execute code:

//go throught the door
if (room_exists(other.new_room)){
          room_goto(other.new_room);
         x = other.new_x;
         y = other.new_y;
}

Collision Event with object obj_building:

execute code:

//

Other Event: Room Start:

execute code:

phy_fixed_rotation = true;

Draw GUI Event:

execute code:

draw_set_color(c_red);
draw_rectangle(bbox_left, bbox_top, bbox_right + 1, bbox_bottom + 1, false);
draw_self();
 

Jezla

Member
I'm not sure why you're using physics in the first place, but since you are, check the gravity setting for your room 2. If you're making a top-down RPG type game, you should have gravity x and y set to 0.

If you do insist on using the box2d physics, get rid of all those place_meeting checks. That's non-physics collision detection that doesn't apply to physics objects.
 
Top