mouse_on_screen(3alleg4)

✨ mouse_on_screen ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's about mouse_on_screen, and it's from the Allegro game programming library. yes, that Allegro. the game programming one. iykyk πŸŽ€


SYNOPSIS 🌸

#include <allegro.h>

int mouse_on_screen();

that's it. one lil function. no args. no drama. she just tells you a thing πŸ’…


DESCRIPTION πŸ¦‹

so here's the vibe: mouse_on_screen() tells you whether the mouse pointer is currently on screen. that's the whole job. she's not complicated, she's just honest 🫢

and lowkey she's so useful for the windowed mode girlies. like, if you're running your program in windowed mode and you're drawing the mouse pointer yourself, you do not want two mouse pointers chilling on screen at the same time. that's giving double-vision, not giving slay 😭 so you use this function to prevent that. iconic behaviour honestly.

other possible uses, because she's versatile like that:

  • pausing your game when the mouse goes off of the window ✨
  • only scrolling the view when the pointer is near the edge of the window, but not while off of the window 🌈

Example :

if (mouse_on_screen()) {draw_sprite(buffer , mouse_sprite , mouse_x , mouse_y);}

see how that works? mouse on screen β†’ draw the sprite. mouse off screen β†’ don't. the way that she's literally just doing her little job and eating every single time πŸ‘‘


RETURN VALUE ⭐

  • Returns 0 if the mouse pointer is off of the screen πŸ’€
  • Returns non-zero otherwise 🌸

so basically: truthy = mouse is home 🏠, falsy = mouse has left the building 🧚


no cap, that's the entire page. short, sweet, and she ate πŸ’–

mwah, love u, bye πŸ’œ this lil page is from Allegro, version 4.4.3, and she's filed under mouse_on_screen(3alleg4). go draw some sprites, bestie πŸŽ€βœ¨