Mail Archives: djgpp/1999/12/16/17:05:19
From: | "Icehot" <max133 AT chalktv DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Allegro mouse routines... Code probs
|
Lines: | 85
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2615.200
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200
|
Message-ID: | <cPb64.12704$uj2.348729@newscontent-01.sprint.ca>
|
Date: | Thu, 16 Dec 1999 15:19:46 -0800
|
NNTP-Posting-Host: | 149.99.123.90
|
X-Complaints-To: | abuse AT sprint DOT ca
|
X-Trace: | newscontent-01.sprint.ca 945375560 149.99.123.90 (Thu, 16 Dec 1999 15:19:20 EST)
|
NNTP-Posting-Date: | Thu, 16 Dec 1999 15:19:20 EST
|
Organization: | Sprint Canada Inc.
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hey, guys, please help... I have a bmp of a menu graphic and it's loaded in
a .dat file using the grabber. I didn't post it, it wouldn't help the code.
x1, y1, x2, y2 are the coords for the "New Game" button. When the user
clicks inside x1,y1,x2,y2, the prog should execute newgame(). I can't get
it to work, though.
<begin code>
//Menu.c -- mouse-driven menu functions
#include <stdlib.h>
#include <stdio.h>
#include <allegro.h>
#include "resource.h"
int newgame();
void mice();
int main()
{
DATAFILE *data;
allegro_init();
install_keyboard();
install_mouse();
install_timer();
data=load_datafile("resource.dat");
set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
set_palette(data[MAIN_PAL].dat);
draw_sprite(screen, data[MENU_BMP].dat, 0, 0);
mice();
clear(screen);
clear_keybuf();
allegro_exit();
}
void mice()
{
int pressed=0;
int mx, my;
char msg[80];
do{
show_mouse(screen);
sprintf(msg, "mouse_x = %-5d", mouse_x);
textout(screen, font, msg, 16, 16, 9);
sprintf(msg, "mouse_y = %-5d", mouse_y);
textout(screen, font, msg, 16, 32, 9);
for (mx==x1; mx<x2; mx++)
{
for (my==y1; my<y2; my++)
{
if ((mouse_x==mx) && (mouse_y==my) )&& (mouse_b & 1))
{
newgame();
}
}
}
vsync();
}while (!keypressed());
show_mouse(NULL);
}
int newgame()
{
clear(screen);
exit(1);
}
<end code>
Please help. maxiv AT sprint DOT ca
--
Max AKA Icehot
http://move.to/gametek -- A Great C/C++ Programming Resource
---------------------------------------------------
"Don't try to be like Jackie. There is only one Jackie... Study computers
instead."
- Jackie Chan
- Raw text -