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

Crosshair Help

S

Samurai1506

Guest
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)
 
S

Samurai1506

Guest
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
}
Where would i put this. The crosshair obj, or the player obj.
 
Top