Image_angle for collision

NazGhuL

NazTaiL
Hi again! Rotating an object's sprite using image_angle changes its mask used for collision. (Obviously stretch its bbox). I'm wondering which one of those should I use. Maybe you can share me what would you use if you want, let say a tank, to move around.(With movement on both X/Y and rotation)

1-Change it's image_angle (That will change it's bbox)
2-Plan to add 360 frames to it's sprite (so bbox won't change)
3-Draw_sprite_ext on draw event to draw its sprite on the desired angle (Won't change bbox)

Thx.
 
I

iMilchshake

Guest
Well, image_angle is the easiest and performance-friendliest as far as i know.. i dont quite understand what the problem with a bbox change is, hitboxes change as objects turn, so i see no point in that.
Also creating 360 images is stupid, they will all get saved as separated pictures.. :D
 
Z

zendraw

Guest
maybe you shuldnt use image angle but rotate a manually drawn sprite using a variable and that variable to set the angle of the manually drawn sprite, and for the mask you use another sprite specificly for being a mask, which you dont rotate.
 
I

iMilchshake

Guest
maybe you shuldnt use image angle but rotate a manually drawn sprite using a variable and that variable to set the angle of the manually drawn sprite, and for the mask you use another sprite specificly for being a mask, which you dont rotate.
Yeah, if not changing the bbox for some reason is nessesary that one should be fine!
 
S

Snail Man

Guest
I'd go with the third option: it's fast, and changing collision boxes really screw things up sometimes, so I'd stay away from that
 

KurtBlissZ

Member
I always use draw_sprite_ext to change the rotation instead of using image_angle, image_xscale, and image_yscale if I want to use collisions for an movement engine. Most of the time this is a good way to make your player not to get stuck in walls along with setting a mask.

Here's one time I used image_angle for a movement engine for driving a car... I use image_anlge along with game makers bounce function for collisions. Definitely not the best but it was a ok place holder.

The Step Event
Code:
///Movement

//Car Stats
acc = 2;
maxspeed = 24;
friction = 1;
steering = 3;

//Gas
var spd = (keyboard_check(ord("W"))-keyboard_check(ord("S")))*acc;
motion_add(image_angle, spd);

//Limit Speed
speed = clamp(speed,-maxspeed/2,maxspeed);

//Steer Car
if abs(speed)>2 {
    turn = (keyboard_check(ord("A"))-keyboard_check(ord("D")))*steering*sign(spd);
    var angle = image_angle;
    image_angle += turn;
    while place_meeting(x,y,par_wall) {
        turn -= sign(turn);
        image_angle = turn+angle;
        if turn == 0 break;
    }
}

//Collision
with (par_wall) solid = true;
move_bounce_solid(false);
 
Top