SOLVED Failed updating of sprite movement and animation.

So the game is supposed to be a point and click adventure. the sprite is a hunchedback man with a limp. The current code should be noting down where on the map you click, check if it's 5 pixels away, if it is, and you're not viewing a text box, then you move to where you clicked. and this movement is interruptible as a result of this. The issue I've ran into now however is that I have two animations. Since this is a 2d Point and click, the character only has two directions. left or right. However, Unless I reference specific sprites, the code wishes to turn into other sprites I don't label when trying to change back to the first frame of animation, which is the still character frame.

Current issue.

I've overrided that with my current code, which references a still sprite. But whenever the character moves 0-90 degrees on the room, the character references the last animation performed instead of the animation assigned to it.

Code:
if (mouse_check_button_released(mb_left))
{
    target_x = mouse_x;
    target_y = mouse_y;
    
    move_towards_point(mouse_x, mouse_y, 1)
}

if (point_distance(x,y,target_x,target_y) < 5)
or global.Mytextbox!=noone
{speed = 0;
sprite_index= S_MainCharacterS;    
}
This part is movement and what to do when the character is at the point where you clicked, or has opened up a textbox.

Code:
#region animation from direction

if (direction >=270 and direction <0 ) {sprite_index = SP_maincharacterwalkright;}
if (direction >=90 and direction <=180) {sprite_index = SP_maincharacterwalkleft;}
if (direction <=89 and direction >=0) {sprite_index = SP_maincharacterwalkright;}
if (direction >=181 and direction <=269) {sprite_index = SP_maincharacterwalkleft;}
#endregion end
This is the part that's having trouble. originally I only referenced two hemispheres of direction, then thought that maybe the game couldn't keep up, and made 4 hemispheres of direction. This made it to where instead of bugging out when going left. the character sprite only bugs out when you go left and down.

And yes. I tried to use
Code:
point_in_rectangle
but it wouldn't obey the boundary I set. And incase you can't tell, I'm new to programming in GML.
 

Mk.2

Member
Code:
if (direction >=270 and direction <0 ) {sprite_index = SP_maincharacterwalkright;}
It should be < 360, not < 0.
 
Code:
if (direction >=270 and direction <0 ) {sprite_index = SP_maincharacterwalkright;}
It should be < 360, not < 0.
Thanks. I really didn't catch that I kept putting 0 instead of 360. This is what I get for working on this for 18 hours yesterday.
 
Top