delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/23/18:07:18

Message-Id: <199811232307.XAA25337@remus.clara.net>
From: "Arthur" <arfa AT clara DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: More help with Allegro
Date: Mon, 23 Nov 1998 23:06:11 -0000
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
In-Reply-To: <3659d77b.6628220@news.flash.net>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

> I'm using DJGPP & Allegro and am currently trying to code a puzzle
> game.  The main screen is comprised of a 9x9 sprite grid.  I have a
> way to access all of the coordinates, but I'm still wondering how to
> get the program to check when the cursor is at a border of the screen.

int OnBorder(int x_mouse, int y_mouse)
{
	if(x_mouse == 0)		return 1;	/* Left Border   */
	if(x_mouse == SCREEN_W)	return 2;	/* Right Border  */
	if(y_mouse == 0)		return 3;	/* Top Border    */
	if(y_mouse == SCREEN_H)	return 4;	/* Bottom Border */
	return 0;
}

This is one easy way of doing it. If the function returns 0, then no border
is touched by the mouse. If 1, then left border, 2 then right border etc.

This is a very simple method and there are far more elegant ways of doing
it.

James Arthur - jaa AT arfa DOT clara DOT net
http://www.arfa.clara.net/james/
ICQ#15054819


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019