Legacy GM GM8 - Image angle fix to grid?

R

Retro_Dude

Guest
I'm fiddling with a Pac-man-esque game, and I got the "ghosts" wandering around the maze in a random fashion simply by checking if they hit a wall, and if they do, they randomly choose to go up, down, left or right and align to the grid. No problems at all.

But, when I introduced directional change to the animation I ran into trouble. I'm changing the direction of the animation by having an event set at "Begin step" and then executing this code: image_angle = direction+360. What happens is that the "ghosts" get missaligned and rotates until they find a way back to the grid, IF they find a way back to the grid. Any thoughts?
 

Nidoking

Member
image_angle = direction+360
I've got two questions:

Why are you adding 360 to an angle?

Also, why are there directions other than the four cardinal directions operating in a Pac-man-esque game? image_angle, sure, but if you're setting a different direction, of course they're misaligned with the grid. But rotating the sprite rather than spriting an animation for turning is rotating the sprite's hitbox. It's colliding with walls in ways you didn't plan for.
 
R

Retro_Dude

Guest
I'm adding 360 degrees to an angle as to have the sprite rotated the way I wish as to have it look like in an old arcade game, there's most likely a better way I am sure, it's just what I found that worked.
char.png

There aren't more directions then up, down, left and right. I suppose I will have to do an animation for each direction then, I figured rotating the sprite would be a shortcut so I wouldn't have to make a lot of sprites, no big deal, though.
 
R

Retro_Dude

Guest
"Shrugs" Then it must be something else I did that makes the sprite rotate
 
Top