www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/07/20:27:09

Xref: news2.mv.net comp.os.msdos.djgpp:3535
From: 004277a AT news DOT acadiau DOT ca (Hafiz Awang Pon)
Newsgroups: comp.os.msdos.djgpp
Subject: my allegro problems
Date: 6 May 96 19:46:59 GMT
Organization: Dalhousie University
Lines: 65
Message-ID: <318e5733.0@131.162.2.91>
NNTP-Posting-Host: iceberg.acadiau.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Thanks to everyone the helped me get allegro up and running.
I've just gotten allegro and i'm trying to work with it. 
It's seem a useful tool. I'm kinda however having a problem
with the mouse routine. I'm testing it right now to understand
here is a short program that i wrote for it.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "allegro.h"

extern volatile int mouse_x;
extern volatile int mouse_y;
extern volatile int mouse_b;

void main()
{
   int px, py;

   allegro_init();
   install_keyboard();
   install_mouse();
   install_timer();
   position_mouse(50, 50);
   px = 50; py = 50;
   printf("mouse_x %-4d\n", mouse_x);
   printf("mouse_y %-4d\n", mouse_y);
   do {
      if (mouse_b & 1) {
	 printf("left\n");
         mouse_b = 0;
         }
      if (mouse_b & 2) {
	 printf("right\n");
         mouse_b = 0;
         }
      if (mouse_x != px) {
         printf("mouse_x %-4d\n", mouse_x);
         px = mouse_x;
         }
      if (mouse_y != py) {
         printf("mouse_y %-4d\n", mouse_y);
         py = mouse_y;
         } 
      } while (!keypressed());
   clear_keybuf();
   allegro_exit();
   exit(0);
}

everyting seems to work out fine. when i click the right button,
it's says right, when i click the left button, it says left. 
when i press a key. it exits the program. But the problem that
i have is that when i move the mouse, it doesn't give the 
coordinate that i expected. it always gives either the value
0 or 8161. Don't get me wrong. I know that the variable 
mouse_x and mouse_y works. I've compiles and ran the test 
program. I suspect i'm probably leaving some declarations out.
Care to assist?

thanks in advance
004277a AT dragon DOT acadiau DOT ca
http://dragon.acadiau.ca/~004277a

- Raw text -


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