示例#1
0
//changes the mouse cursor to the tile when you click on a tile
//also changes the actual mouse xy position to the center of the tile
void CGame::DrawCursor() {
	
	CObject *object;
	CTile *tile;

	if (players[currplayer].cursor == NULL) {
		set_mouse_sprite(NULL);
		set_mouse_sprite_focus(0,0);
	}
	else{
		object = players[currplayer].cursor;
		tile = (CTile*) object;
		set_mouse_sprite((WINDOWS_BITMAP *)data[tile->GetIndex()].dat);
		set_mouse_sprite_focus(18,18);
	}
}
示例#2
0
int savecity()
{
     buffer = create_bitmap(640,480);
     
     samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\savecity.wav");
     samExplosion1 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion1.wav");

     textout(buffer,font,"Save City (ESC to quit)",0,1,WHITE);

     updatescore();

//     rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);

     city = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\city.bmp", NULL);
     for (n = 0; n < 5; n++)
         masked_blit(city, buffer, 0, 0, 20+n*120, SCREEN_H-city->h-2, city->w, city->h);

     crosshair = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\crosshair.bmp", NULL); 
     set_mouse_sprite(crosshair);
     set_mouse_sprite_focus(15,15);
     show_mouse(buffer); 
     
     play_sample(samSong, 128, 128, 1000, 1);
     
     while (!key[KEY_ESC])
     {
           //above the red was border get destroyed
           rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED);
           
           mx = mouse_x;
           my = mouse_y;
           mb = (mouse_b & 1);
     
           if (destroyed)
                firenewmissile();
     
           if (mb)
           {
                explosion1(screen,mx,my,GREEN);
                play_sample(samExplosion1, 40, 128, 1000, 0);
           }
           
           movemissile();
           
           blit(buffer,screen,0,0,0,0,640,480);
           
           if(key[KEY_BACKSPACE])
           {    
                 score=-1;        
                 firenewmissile();
                 stop_sample(samSong);

                 openscreen();        
           }
              
           if(key[KEY_ESC])
           {
                           exit(1);
           }
           
                         
           if(score>=0 && score <5)
                 rest(10);
           else if(score>=5 && score<10)
                 rest(9);            
           else if(score>=10 && score<15)
                 rest(8);            
           else if(score>=15 && score<20)
                 rest(7);            
           else if(score>=20 && score<25)
                 rest(6);            
           else if(score>=25 && score<30)
                 rest(5);            
           else if(score>=30 && score<35)
                 rest(4);            
           else if(score>=35 && score<40)
                 rest(3);
           else if(score>=40 && score<45)
                 rest(2);
           else if(score>=45)
                 rest(1);            
                                   
     }
     
     set_mouse_sprite(NULL);
     destroy_bitmap(city);
     destroy_bitmap(crosshair);
    // openscreen();
     return 0;
}
示例#3
0
文件: main.cpp 项目: lastab/BagChal
int main()
{
    //initialize allegro
    allegro_init();
    install_keyboard();
    install_mouse();      
    //initialize video mode to 640x480
    set_color_depth(32);
    int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    install_sound(DIGI_AUTODETECT, MIDI_NONE, "") ;

    pointer = load_bitmap("pointer.bmp", NULL);
    board=load_bitmap("bord.bmp",NULL);
    tiger=load_bitmap("tiger.bmp",NULL);
    goat=load_bitmap("goat.bmp",NULL);
    target=load_bitmap("target.bmp",NULL);
    buffer = create_bitmap(640,480);
    // mouse
    set_mouse_sprite(pointer);
    set_mouse_sprite_focus(15,15);
    show_mouse(screen);
    //top
    top:;
    
    count_dead_goat = 0;
    count_steps = 0;
    
    reset_bord_player();
    textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
    show_bord_player();
    turn=2;  
//background sound
        background=load_sample("background.wav");
        play_sample(background, volume, panning, pitch, TRUE);

//wait
int tempx,tempy,temp_player ;    
while (!key[KEY_ESC])
{
//grab the current mouse values
mx = mouse_x;
my = mouse_y;
mb = (mouse_b & 1);

    

 temp_player= check_location_available(getx(mx),getx(my));
if (temp_player!=3 && mb==1)
{
    if (turn==1 && temp_player==1)
    {
             textout_ex(buffer, font, "TIGER'S TURN", 480, 1, 1, -1);
              textout_ex(buffer, font, "FIND TIGER PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);
                turn=11;
    }
    else if(turn==11 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
        remove_player(tempx,tempy);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         }
         else if(check_jump_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
        add_tiger_player(getx(mx),gety(my));
        remove_player(tempx,tempy);
//sound
        sound=load_sample("tiger.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

        remove_player((tempx+getx(mx))/2,(tempy+gety(my))/2);
        turn=2;
         textout_ex(buffer, font, "FIND TIGER PLACE", 480, 1, 1, -1);
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
         count_dead_goat++;
         }

         
    }
    else if(turn==2  && temp_player==2 && count_steps>=20)
    {
         turn=22;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , white, -1);
                  tempx=getx(mx);
                  tempy=gety(my);

    }
    else if(turn==22 && temp_player==0)
    {
         if(check_movement_ok(tempx,tempy,getx(mx),gety(my))==1)
         {
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

             add_goat_player(getx(mx),gety(my));
              remove_player(tempx,tempy);
    turn=1;
         textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);
         }
    }
    else if(turn==2 && temp_player==0 && count_steps<20)
    {
         count_steps++;
    add_goat_player(getx(mx),gety(my));
//sound
        sound=load_sample("goat.wav");
        play_sample(sound, volume, panning, pitch, FALSE);

    turn=1;
         textout_ex(buffer, font, "GOAT'S TURN",480, 1 , 1, -1);
         textout_ex(buffer, font, "TIGER'S TURN", 480, 1, white, -1);

    }
    if ( check_game_over()==1)
    {
         textout_ex(buffer, font, "GOAT WINS", 480, 30, white, -1);
         goto end;
         }
    else if ( check_game_over()==2)
    {
         textout_ex(buffer, font, "TIGER WINS", 480, 30, white, -1);
         goto end;
         }
    

    show_bord_player();
}
       if (turn==11)
    {     

          jump=check_possible_jump_movement(tempx,tempy);     
          move=check_possible_movement(tempx,tempy);
          show_possible_jump_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);
          if( jump==0 && move==0 )
          {
          turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
          }
    }
       if (turn==22)
    {
          move=check_possible_movement(tempx,tempy);
          show_possible_movement(tempx,tempy);          
          if (move==0)
          {
          turn=2;
          textout_ex(buffer, font, "FIND GOAT PLACE",480, 1 , 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN", 480, 1, white, -1);
          show_bord_player();
          }

     
    }
    

/* uncheck tiget or goat to move
     if(turn==11 && mb==2)
     {  turn=1;
          textout_ex(buffer, font,"FIND TIGER PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "TIGER'S TURN",480, 1 , white, -1);
          show_bord_player();          
        }
     if(turn==22 && mb==2)
     {  turn=2;
          textout_ex(buffer, font,"FIND GOAT PLACE" , 480, 1, 1, -1);
          textout_ex(buffer, font, "GOAT'S TURN",480, 1 , white, -1);
            show_bord_player();
     }
*/


     
//pause
rest(10);
}
end:;



allegro_message("game over");    
//sound        
        sound=load_sample("clapping.wav");
        play_sample(sound, volume, panning, pitch, FALSE);
          textout_ex(screen, font, "PLAY AGAIN?(Y/N)",480, 10 , white, -1);        
while (!key[KEY_N])
{
 if(key[KEY_Y])
    goto top;
}
    set_mouse_sprite(NULL);
    destroy_sample(sound);        
    destroy_sample(background);    
    destroy_bitmap(pointer);
    destroy_bitmap(board);
    destroy_bitmap(tiger);
    destroy_bitmap(goat);
    destroy_bitmap(buffer);
    destroy_bitmap(target);
    allegro_exit();    
    return 0;
}
示例#4
0
文件: MOUSE.C 项目: kashopi/KMid
int main()
{
   int mickeyx = 0;
   int mickeyy = 0;
   BITMAP *custom_cursor;
   char msg[80];
   int c = 0;

   allegro_init();
   install_keyboard(); 
   install_mouse();
   install_timer();
   set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
   set_pallete(desktop_pallete);

   do {
      /* the mouse position is stored in the variables mouse_x and mouse_y */
      sprintf(msg, "mouse_x = %-5d", mouse_x);
      textout(screen, font, msg, 16, 16, 255);

      sprintf(msg, "mouse_y = %-5d", mouse_y);
      textout(screen, font, msg, 16, 32, 255);

      /* or you can use this function to measure the speed of movement.
       * Note that we only call it every fourth time round the loop: 
       * there's no need for that other than to slow the numbers down 
       * a bit so that you will have time to read them...
       */
      c++;
      if ((c & 3) == 0)
	 get_mouse_mickeys(&mickeyx, &mickeyy);

      sprintf(msg, "mickey_x = %-7d", mickeyx);
      textout(screen, font, msg, 16, 64, 255);

      sprintf(msg, "mickey_y = %-7d", mickeyy);
      textout(screen, font, msg, 16, 80, 255);

      /* the mouse button state is stored in the variable mouse_b */
      if (mouse_b & 1)
	 textout(screen, font, "left button is pressed ", 16, 112, 255);
      else
	 textout(screen, font, "left button not pressed", 16, 112, 255);

      if (mouse_b & 2)
	 textout(screen, font, "right button is pressed ", 16, 128, 255);
      else
	 textout(screen, font, "right button not pressed", 16, 128, 255);

      if (mouse_b & 4)
	 textout(screen, font, "middle button is pressed ", 16, 144, 255);
      else
	 textout(screen, font, "middle button not pressed", 16, 144, 255);

      vsync();

   } while (!keypressed());

   clear_keybuf();

   /*  To display a mouse pointer, call show_mouse(). There are several 
    *  things you should be aware of before you do this, though. For one,
    *  it won't work unless you call install_timer() first. For another,
    *  you must never draw anything onto the screen while the mouse
    *  pointer is visible. So before you draw anything, be sure to turn 
    *  the mouse off with show_mouse(NULL), and turn it back on again when
    *  you are done.
    */
   clear(screen);
   textout_centre(screen, font, "Press a key to change cursor", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   /* create a custom mouse cursor bitmap... */
   custom_cursor = create_bitmap(32, 32);
   clear(custom_cursor); 
   for (c=0; c<8; c++)
      circle(custom_cursor, 16, 16, c*2, c);

   /* select the custom cursor and set the focus point to the middle of it */
   set_mouse_sprite(custom_cursor);
   set_mouse_sprite_focus(16, 16);

   clear(screen);
   textout_centre(screen, font, "Press a key to quit", SCREEN_W/2, SCREEN_H/2, 255);
   show_mouse(screen);
   readkey();
   show_mouse(NULL);

   destroy_bitmap(custom_cursor);

   return 0;
}
示例#5
0
文件: editmode.c 项目: neiderm/turaco
void create_cursors(BITMAP * curs, BITMAP * busy, BITMAP * flood, BITMAP * eye)
{
    if (curs != NULL)
    {
	// this is actually the default cursor for AmigaDos 2.x
	// it's a cool cursor, so i'm stealing it. ;}
	clear(curs);

	line(curs, 0, 0, 4,  9, MOUSE_COLOR_DARK);
	line(curs, 6, 7, 9, 10, MOUSE_COLOR_DARK);

	line(curs, 0, 0, 9,  4, MOUSE_COLOR_LIGHT);
	line(curs, 7, 6, 10, 9, MOUSE_COLOR_LIGHT);

	rect(curs, 2, 2, 3, 3, MOUSE_COLOR_MID);
	rect(curs, 3, 3, 5, 5, MOUSE_COLOR_MID);
	rect(curs, 6, 4, 7, 5, MOUSE_COLOR_MID);
	rect(curs, 4, 6, 5, 7, MOUSE_COLOR_MID);
	line(curs, 8, 5, 9, 5, MOUSE_COLOR_MID);
	line(curs, 5, 8, 5, 9, MOUSE_COLOR_MID);
	line(curs, 0, 0, 9, 9, MOUSE_COLOR_MID);

	// now install the new cursor, and set the hot-spot
	set_mouse_sprite(curs);
    }

    if (busy != NULL)
    {
	// make a simple busy pointer, as i can't muster the
	// thought to come up with anything better.
	clear(busy);
	text_mode (-1);
	rectfill(busy, 0, 0, 34, 11, MOUSE_COLOR_LIGHT);
	rect(busy, 0, 0, 34, 11, 1);
	textout(busy, font, "Wait", 3,3, MOUSE_COLOR_DARK);
	textout(busy, font, "Wait", 2,2, MOUSE_COLOR_MID);
    }

    if (flood != NULL)
    {
	clear(flood);

	// the spilling paint... 
	// perhaps change MOUSE_COLOR_DARK to be the color to fill with?
	line (flood, 0,5,  0,14, MOUSE_COLOR_DARK);
	line (flood, 1,4,  1,15, MOUSE_COLOR_DARK);
	line (flood, 1,4,  3,4,  MOUSE_COLOR_DARK);

	// paint can outline
	line (flood, 3,3,  6,0,  MOUSE_COLOR_MID);
	line (flood, 7,0,  13,6, MOUSE_COLOR_MID);
	line (flood, 13,7, 9,11, MOUSE_COLOR_MID);
	line (flood, 8,11, 2,5,  MOUSE_COLOR_MID);

	// paint can body
	floodfill(flood, 8,6, MOUSE_COLOR_LIGHT);

	// paint can top
	line (flood, 3,5,  7,1,  MOUSE_COLOR_MID);

	/*
	// the paint can handle
	line (flood, 7,5,  11,1, MOUSE_COLOR_DARK);
	line (flood, 7,6,  12,1, MOUSE_COLOR_DARK);
	line (flood, 8,6,  12,2, MOUSE_COLOR_DARK);
	*/

	// the hot spot -- make it brighter
	putpixel(flood, 1, 15, MOUSE_COLOR_MID);
    }

    if (eye != NULL)
    {
	clear(eye);
	// the dropper
	line(eye, 1,0,  3,0,  MOUSE_COLOR_DARK);
	line(eye, 0,1,  0,6,  MOUSE_COLOR_DARK);
	line(eye, 4,1,  4,6,  MOUSE_COLOR_DARK);
	line(eye, 0,6,  4,6,  MOUSE_COLOR_DARK);
	floodfill(eye, 2,2,   MOUSE_COLOR_DARK);
	// the vial
	line(eye, 1,7,  1,12, MOUSE_COLOR_MID);
	line(eye, 3,7,  3,12, MOUSE_COLOR_MID);
	line(eye, 2,13, 2,14, MOUSE_COLOR_MID);
	floodfill(eye, 2,8,   MOUSE_COLOR_LIGHT);
    }

    set_mouse_sprite_focus(0,0);
}