Crosshair Help

Samurai1506

Member
I am building a 2d shooter. My player moves in four directions. In my game I also have an ingame crosshair using the window_set_cursor and the cursor_sprite functions. However what I need help with is making so that if the crosshair is to the left of the player the sprite index changes to the left side of the player. Same with the other three directions (Up, Down, Right)
 

MD_Wade

Member
switch (point_direction(x,y,mouse_x,mouse_y)+45) div 90 & 3 {
case 0: use right sprite; break
case 1: use up sprite; break
case 2: use left sprite; break
case 3: use down sprite; break
}
I would even iterate on this by storing the result in a variable so you can reference this direction later for whatever else you need (instead of just checking the sprite_index or something)
 
Top