Пример #1
0
    Menu::Menu()
        : mFrameCounter(0)
    {
        setOpaque(false);
        setSize(320, 240);
        addKeyListener(this);
        setFocusable(true);

        mBackgroundBitmap = create_bitmap(320, 240);
        int y;

        int r1 = 236;
        int g1 = 94;
        int b1 = 96;
        int r2 = 20;
        int g2 = 20;
        int b2 = 10;

        for (y = 0; y < 240; y += 16)
        {
            int r = (r1 * (240 - y) + r2 * y) / 240;
            int g = (g1 * (240 - y) + g2 * y) / 240;
            int b = (b1 * (240 - y) + b2 * y) / 240;
            
            int pixel = makecol(r, g, b);

            rectfill(mBackgroundBitmap, 0, y, 320, y + 15, pixel); 
        }

        mBackgroundImage = new gcn::AllegroImage(mBackgroundBitmap, true);
        mBackgroundIcon = new gcn::Icon(mBackgroundImage);
        add(mBackgroundIcon);

        mStartContainer = new gcn::Container();
        mStartContainer->setSize(320, 240);
        mStartContainer->setOpaque(false);
        add(mStartContainer);

        mCastleImage = gcn::Image::load(ResourceHandler::getInstance()->getRealFilename("menu-background.bmp"));
        mCastleIcon = new gcn::Icon(mCastleImage);
        mStartContainer->add(mCastleIcon);
        mPressStartLabel = new gcn::Label("Press Start");
        mPressStartLabel->adjustSize();
        mStartContainer->add(mPressStartLabel, 
                             160 - mPressStartLabel->getWidth() / 2, 
                             170);
        mLogoImage = gcn::Image::load(ResourceHandler::getInstance()->getRealFilename("menu-logo.bmp"));
        mLogoIcon = new gcn::Icon(mLogoImage);
        mStartContainer->add(mLogoIcon);

        mInfoFont = new gcn::ImageFont(ResourceHandler::getInstance()->getRealFilename("gamefont-menu-info.bmp"), 
                                       32, 
                                       126);
        mFont = new gcn::ImageFont(ResourceHandler::getInstance()->getRealFilename("gamefont2.bmp"), 
                                       32, 
                                       126);
        mFont->setGlyphSpacing(-2);

        mInfoFont->setGlyphSpacing(1);
        mInfoTextBox = new gcn::TextBox("Copyright (C) Darkbits 2007");
        mInfoTextBox->setBorderSize(0);
        mInfoTextBox->setOpaque(false);
        mInfoTextBox->setFocusable(false);
        mInfoTextBox->setEditable(false);
        mInfoTextBox->setFont(mInfoFont);
        mStartContainer->add(mInfoTextBox, 
                             160 - mInfoTextBox->getWidth() / 2, 
                             240 - mInfoTextBox->getHeight() - 10);

        mGameSelectContainer = new gcn::Container();
        mGameSelectContainer->setOpaque(false);
        mGameSelectContainer->setSize(320, 240);
        mGameSelectContainer->setVisible(false);
        add(mGameSelectContainer);

        mSelectGameLabel = new gcn::Label("SELECT GAME");
        mSelectGameLabel->setFont(mFont);
        mSelectGameLabel->adjustSize();
        mGameSelectContainer->add(mSelectGameLabel, 
                                  160 - mSelectGameLabel->getWidth() / 2,
                                  30);
        mEraseGameLabel = new gcn::Label("ERASE GAME");
        mEraseGameLabel->setFont(mFont);
        mEraseGameLabel->adjustSize();
        mEraseGameLabel->setVisible(false);
        mGameSelectContainer->add(mEraseGameLabel, 
                                  160 - mEraseGameLabel->getWidth() / 2,
                                  30);
        mGameSlotOne = new GameSlot();
        mGameSelectContainer->add(mGameSlotOne, 
                                  160 - mGameSlotOne->getWidth() / 2, 
                                  40);
        mGameSlotTwo = new GameSlot();
        mGameSelectContainer->add(mGameSlotTwo, 
                                  160 - mGameSlotTwo->getWidth() / 2, 
                                  40 + mGameSlotOne->getHeight());

        mGameSlotThree = new GameSlot();
        mGameSelectContainer->add(mGameSlotThree, 
                                  160 - mGameSlotThree->getWidth() / 2, 
                                  40 + mGameSlotOne->getHeight() * 2);
        mGameSlotOne->update(0);
        mGameSlotTwo->update(1);
        mGameSlotThree->update(2);

        mEraseLabel = new gcn::Label("ERASE GAME");
        mEraseLabel->setFont(mFont);
        mEraseLabel->adjustSize();
        mGameSelectContainer->add(mEraseLabel, 
                                  160 - mGameSlotThree->getWidth() / 2,
                                  40 + mGameSlotOne->getHeight() * 3 + 5);

        mCancelLabel = new gcn::Label("CANCEL");
        mCancelLabel->setFont(mFont);
        mCancelLabel->adjustSize();
        mCancelLabel->setVisible(false);
        mGameSelectContainer->add(mCancelLabel, 
                                  160 - mGameSlotThree->getWidth() / 2,
                                  40 + mGameSlotOne->getHeight() * 3 + 5);
        mQueryEraseLabel = new gcn::Label("ARE YOU SURE YOU WANT TO ERASE GAME?");
        mQueryEraseLabel->setFont(mFont);
        mQueryEraseLabel->adjustSize();
        mQueryEraseLabel->setVisible(false);
        mGameSelectContainer->add(mQueryEraseLabel, 
                                  160 - mGameSlotThree->getWidth() / 2,
                                  40 + mGameSlotOne->getHeight() * 3 + 5);

        mNoLabel = new gcn::Label("NO");
        mNoLabel->setFont(mFont);
        mNoLabel->adjustSize();
        mNoLabel->setVisible(false);
        mGameSelectContainer->add(mNoLabel, 
                                  160 - mGameSlotThree->getWidth() / 2,
                                  40 + mGameSlotOne->getHeight() * 3 + 5 
                                  + mQueryEraseLabel->getHeight());
        mYesLabel = new gcn::Label("YES");
        mYesLabel->setFont(mFont);
        mYesLabel->adjustSize();
        mYesLabel->setVisible(false);
        mGameSelectContainer->add(mYesLabel, 
                                  160 - mGameSlotThree->getWidth() / 2,
                                  40 + mGameSlotOne->getHeight() * 3 + 5 
                                  + mQueryEraseLabel->getHeight() + mNoLabel->getHeight());

        mMainMultiSelector = new MultiSelector();
        mMainMultiSelector->setSize(320, 240);
        mMainMultiSelector->addActionListener(this);
        mMainMultiSelector->addSelection(40, 
                                     mGameSlotOne->getY() + mGameSlotOne->getHeight() / 2 
                                     - mMainMultiSelector->getSelectorHeight() / 2);
        mMainMultiSelector->addSelection(40, 
                                     mGameSlotTwo->getY() + mGameSlotTwo->getHeight() / 2 
                                     - mMainMultiSelector->getSelectorHeight() / 2);
        mMainMultiSelector->addSelection(40, 
                                     mGameSlotThree->getY() + mGameSlotThree->getHeight() / 2 
                                     - mMainMultiSelector->getSelectorHeight() / 2);
        mMainMultiSelector->addSelection(40, 
                                     mEraseLabel->getY() + mEraseLabel->getHeight() / 2 
                                     - mMainMultiSelector->getSelectorHeight() / 2);

        mGameSelectContainer->add(mMainMultiSelector);

        mQueryMultiSelector = new MultiSelector();
        mQueryMultiSelector->setSize(320, 240);
        mQueryMultiSelector->addActionListener(this);
        mQueryMultiSelector->setVisible(false);
        mQueryMultiSelector->addSelection(40,
                                          mNoLabel->getY() + mNoLabel->getHeight() / 2
                                          - mQueryMultiSelector->getSelectorHeight() / 2);
        mQueryMultiSelector->addSelection(40,
                                          mYesLabel->getY() + mYesLabel->getHeight() / 2
                                          - mQueryMultiSelector->getSelectorHeight() / 2);
        mGameSelectContainer->add(mQueryMultiSelector);
    }
Пример #2
0
int Simulator()
{

  set_config_file("IR.config");  /* Read configuration file */
  Delay= (get_config_float("content", "Delay", 0));  

  fd = open("/dev/parport0", O_RDWR );

  Screen3= load_bitmap("images/Simulator/Base.pcx", pal);
  blit(Screen3, screen, 0, 0, 0, 0, 1024, 768);  
  /* Boxes to show numerical values */
  rectfill(screen, 895, 270, 945, 303, WHITE);   
  rect(screen, 895, 270, 945, 303, 1);	// x1, y1, x2, y2
  
  textprintf_ex(screen, font, 320, 0, BLACK, -1, "Simulacion de la Planta");  


  while (!key[KEY_LEFT])	/* Only pressing KEY_LEFT will return */
    {
      /* This line reads data from the interfase which is
	 the process variable(measured variable) of the system */
      ioctl(fd, PPRDATA, &PVi);
      //PV= PVi;

      if(PVi<=48)
      {
	PVi= 51;
        system("festival --tts Messages/Disconnected &");
      }

//      if(PV<=48)
//        PVi= 51;

      PV= 1.367647*(PVi-51);//      279= X 204


      if(key[KEY_PGUP])
	SP= SP+45;

      if(key[KEY_PGDN])
	SP= SP-45;
      
      if(key[KEY_UP])
	SP= SP+5;

      if(key[KEY_DOWN])
	{
	  if(SP>=1)
	    SP= SP-5;
	}

      if(PVi>=253)
	{
	  textprintf_ex(screen, font, 320, 50, BLACK, RED, "Nivel Critico, revise el controlador");  
	  system("/usr/bin/mpg123 Sounds/Alarm.wav &");
	}

//      PV= (200/298)*100;

//	504  381  544  381
//	504  83   544  381
//      rectfill(screen, 832, 513-(SP/300), 883, 513, LIGHT_BLUE);
//      rectfill(screen, 832, 213, 883, 513-(SP/300), GRAY);

      /* Fill the tank with clear water */
      rectfill(screen, 687, 386-(SP/300), 710, 381, LIGHT_BLUE);
      rectfill(screen, 687, 83, 710, 386-(SP/300), GRAY);

      float K, BIAS;   K=-2; BIAS=184;
      K=(K/368)*100;

      /* (P) Proportional only control mode */
      OP= ((((SP/298)-(PV/298))*100)*K)+(OP/298);

	
      /* PV bar */
      rectfill(screen, 440, 381-(PV/298), 480, 381, RED);
      rectfill(screen, 440, 83, 480, 381-(PV/298), GRAY);

      /* SP bar */
      if (SP>=88734)	SP=88734;      
      if (SP<=1)	SP=1;
      rectfill(screen, 504, 381-(SP/298), 544, 381, GREEN);
      rectfill(screen, 504, 83, 544, 381-(SP/298), GRAY);

      /* OP bar */
      if (OP>=88734)	OP=88734;      
      if (OP<=1)	OP=1;
      rectfill(screen, 569, 381-(OP/298), 609, 381, BLUE);
      rectfill(screen, 569, 83, 609, 381-(OP/298), GRAY);


      textprintf_ex(screen, font, 900, 264, BLACK, WHITE, "%3.1fOP", (OP/88734)*100);
//      textprintf_ex(screen, font, 900, 364, BLACK, WHITE, "%3.1fOP", (OP/298)*100);      
      textprintf_ex(screen, font, 900, 364, BLACK, WHITE, "%3.1fSP", (SP/88734)*100);

      rest(Delay);
    }
  Automatic();      
  return 1;
}
Пример #3
0
void	palla()
{
int	i, col, dcol=0;	/* indice del task  */
int	x, y;		/* coordinate grafiche pallina  */
int	ox, oy;		/* vecchia posizione pallina    */
int	x0;		/* posizione iniziale X pallina */
float	vx, vy;		/* velocità della pallina   */
float	t, tx;		/* variabile temporale      */
//float	z, z0;		/* posizione della pallina  */
float	dt;		/* incremento temporale     */
double	a;		/* variabile di appoggio    */
//long	j, k;

        i = ptask_get_index();
	col = 2 + i%14;
	y = oy = (TOP-L);
	x = ox = x0 = XMIN;

	a = 2. * G * (float)(TOP-L);
	vy = sqrt(a);
	vx = VELX;
	tx = 0.0;
	t = vy / G;
	dt = ptask_get_period(i, MILLI) / 100.;

	// removed, unless a specific activation from the main is done
	// wait_for_activation();

	while (1) {
        	x = x0 + vx * tx;
	        y = BASE + vy*t - .5*G*t*t;
	        if (y < BASE) {
			t = 0.0;
			pthread_mutex_lock(&mxv);
			v0[i] = .9 * v0[i];
			vy = v0[i];
			pthread_mutex_unlock(&mxv);
			y = BASE + vy*t - .5*G*t*t;
		}
		if (x > XMAX) {
			tx = 0.0;
			x0 = XMAX;
			vx = -vx;
			x = x0 + vx * tx;
		}
		if (x < XMIN) {
			tx = 0.0;
			x0 = XMIN;
			vx = -vx;
			x = x0 + vx * tx;
		}

		pthread_mutex_lock(&mxa);
		draw_ball(ox, YWIN-oy, BGC);
		draw_ball(x, YWIN-y, col);
		pthread_mutex_unlock(&mxa);

		oy = y; ox = x;
		t += dt;
		tx += dt;

		/* check for deadline miss */
		if (ptask_deadline_miss()) {
			dcol = dcol%15 + 1;
			pthread_mutex_lock(&mxa);
			rectfill(screen, 400, 50, 450, 70, dcol);
			pthread_mutex_unlock(&mxa);
		}
		ptask_wait_for_period();
	}
}
Пример #4
0
int d_aphoton_list_proc(int msg, DIALOG *d, int c)
{
    if (msg == MSG_DRAW) {
	int height, listsize, i, len, bar, x, y, w, char_height;
	int fg, bg;
	char *sel = (char *)d->dp2;
	char s[1024];
	int rtm;

	(*(getfuncptr)d->dp)(-1, &listsize);
	char_height = text_height(font);
	height = (d->h-4) / char_height;
	bar = (listsize > height);
	w = (bar ? d->w-14 : d->w-3);

	/* draw box contents */
	for (i=0; i<height; i++) {
	    if (d->d2+i < listsize) {
		if (d->d2+i == d->d1) {
		    fg = list_white;
		    bg = list_green;
		}
		else if ((sel) && (sel[d->d2+i])) {
		    fg = list_white;
		    bg = list_green;
		}
		else {
		    fg = black;
		    bg = list_white;
		}
		
		ustrzcpy(s, sizeof(s), (*(getfuncptr)d->dp)(i+d->d2, NULL));
		
		x = d->x + 2;
		y = d->y + 2 + i*char_height;
		
		rtm = text_mode(bg);
		rectfill(screen, x, y, x+7, y+char_height-1, bg);
		x += 8;
		
		len = ustrlen(s);
		while (text_length(font, s) >= MAX(d->w - 1 - (bar ? 22 : 10), 1)) {
		    len--;
		    usetat(s, len, 0);
		}
		
		textout(screen, font, s, x, y, fg);
		text_mode(rtm);
		
		x += text_length(font, s);
		if (x <= d->x+w)
		    rectfill(screen, x, y, d->x+w, y+char_height-1, bg);
	    }
	    else {
		rectfill(screen, d->x+2,  d->y+2+i*char_height,
			 d->x+w, d->y+1+(i+1)*char_height, list_white);
	    }
	}

	if (d->y+2+i*char_height <= d->y+d->h-3)
	    rectfill(screen, d->x+2, d->y+2+i*char_height,
		     d->x+w, d->y+d->h-3, list_white);

	/* draw frame, maybe with scrollbar */
	photon_draw_scrollable_frame(d, listsize, d->d2, height);

	return D_O_K;
    }

    return d_list_proc(msg, d, c);
}
Пример #5
0
void street()
{
     int main_row[MAX_MAIN_ROW];
     int main_col[MAX_MAIN_COL];
     int startx, starty, endx, endy;
     int r, c, tor, toc;
     int line_size;
     int start, way;
     int i;


     clear_invert_map();

     /*
     * TODO: its possible only have 1 main and thats bad...
     * 2x3 is best... tho' it may not matter much.
     * What about basing the numbers off map.num_row/col??
     * yeah I like that better than macros.
     * maybe MMR = #rows % 4 + 1..
     */

     /* pick the main rows/cols to branch from */
     for( i = 0; i < MAX_MAIN_ROW; i++ )
          main_row[i] = rand()%map.num_row;
     for( i = 0; i < MAX_MAIN_COL; i++ )
          main_col[i] = rand()%map.num_col;


     line_size = (map.sec_width > map.sec_height ? map.sec_width : map.sec_height)/4.0;
     line_size = (line_size == 0 ? 1 : line_size);


     /* branch off rows */
     for( i = 0; i < MAX_MAIN_ROW; i++ )
     {
          r = main_row[i];

          /* draw main row */
          section_center(&startx, &starty, r, 0);
          section_center(&endx, &endy, r, map.num_col-1);
          rectfill(map.map, startx, starty-line_size, endx, endy+line_size, 255);


          /* do the branches */
          start = rand()%2;
          for( c = start; c < map.num_col; c += 2 )
          {
               section_center(&startx, &starty, r, c);

               way = rand()%3;

               /* draw up */
               if( r != 0 && (way == 0 || way == 2) )
               {
                    tor = rand()%r;
                    section_center(&endx, &endy, tor, c);
                    rectfill(map.map, startx-line_size, starty, endx+line_size, endy, 255);
               }

               /* draw down */
               if( r != map.num_row-1 && (way == 1 || way == 2) )
               {

                    tor = rand_num(r, map.num_row-r);
                    /* tor = rand()%(map.num_row-r-1)+r+1; */
                    section_center(&endx, &endy, tor, c);
                    rectfill(map.map, startx-line_size, starty, endx+line_size, endy, 255);
               }               
          }
     }


     /* branch off cols */
     for( i = 0; i < MAX_MAIN_COL; i++ )
     {
          c = main_col[i];

          /* draw main col */
          section_center(&startx, &starty, 0, c);
          section_center(&endx, &endy, map.num_row-1, c);
          rectfill(map.map, startx-line_size, starty, endx+line_size, endy, 255);


          /* do the branches */
          start = rand()%2;
          for( r = start; r < map.num_row; r += 2 )
          {
               section_center(&startx, &starty, r, c);

               way = rand()%3;

               /* draw left */
               if( c != 0 && (way == 0 || way == 2) )
               {
                    toc = rand()%c;
                    section_center(&endx, &endy, r, toc);
                    rectfill(map.map, startx, starty-line_size, endx, endy+line_size, 255);
               }

               /* draw right */
               if( c != map.num_col-1 && (way == 1 || way == 2) )
               {
                    toc = rand_num(c, map.num_col-c);
                    /* toc = rand()%(map.num_col-c-1)+c+1; */
                    section_center(&endx, &endy, r, toc);
                    rectfill(map.map, startx-line_size, starty-line_size, endx, endy+line_size, 255);
               }               
          }
     }

return;
}
Пример #6
0
/*****************************************************************************

    Function: edit_ram

    Description: view or edit the RAM
    Parameters: none
    Return: nothing

*****************************************************************************/
void
edit_ram()
{

#ifdef ALLEGRO

	BITMAP *bg;
	uchar line, col;
	char *tmp_buf = (char *) alloca(100);
	unsigned short dum;

	bg = create_bitmap(vheight, vwidth);
	blit(screen, bg, 0, 0, 0, 0, vheight, vwidth);

	selected_byte = 0;
	out = 0;
	frame_up = 0;
	frame_down = frame_up + NB_LINE * NB_BYTE_LINE;

	while (!out) {
		clear(screen);
		for (line = 0; line < NB_LINE; line++) {
			sprintf(tmp_buf, "%04X", frame_up + line * NB_BYTE_LINE);
			textoutshadow(screen, font, tmp_buf, blit_x,
						  blit_y + 10 * line, -15, 2, 1, 1);
			for (col = 0; col < NB_BYTE_LINE / 2; col++) {
				if ((dum = frame_up + line * NB_BYTE_LINE + col) ==
					selected_byte)
					rectfill(screen, blit_x + (6 + col * 3) * 8,
							 blit_y + 10 * line - 1,
							 blit_x + (8 + col * 3) * 8,
							 blit_y + 10 * (line + 1) - 2, -15);
				sprintf(tmp_buf, "%02X", RAM[dum]);
				textoutshadow(screen, font, tmp_buf,
							  blit_x + (6 + col * 3) * 8,
							  blit_y + 10 * line, -1, 2, 1, 1);
			}
			for (; col < NB_BYTE_LINE; col++) {
				if ((dum = frame_up + line * NB_BYTE_LINE + col) ==
					selected_byte)
					rectfill(screen, blit_x + (8 + col * 3) * 8,
							 blit_y + 10 * line - 1,
							 blit_x + (10 + col * 3) * 8,
							 blit_y + 10 * (line + 1) - 2, -15);
				sprintf(tmp_buf, "%02X",
						RAM[frame_up + line * NB_BYTE_LINE + col]);
				textoutshadow(screen, font, tmp_buf,
							  blit_x + (8 + col * 3) * 8,
							  blit_y + 10 * line, -1, 2, 1, 1);
			}

		}

		ram_key();
		vsync();
	}

	blit(bg, screen, 0, 0, 0, 0, vheight, vwidth);
	destroy_bitmap(bg);
	return;

#endif

}
Пример #7
0
static INLINE void rectfillwh(BITMAP *bmp, int x, int y, int w, int h, int color)
{
    rectfill(bmp, x, y, x+w-1, y+h-1, color);
}
Пример #8
0
void Graphics::FillRect(const Rect &rc)
{
	rectfill(_alBitmap, rc.Left, rc.Top, rc.Right, rc.Bottom, _drawColor);
}
Пример #9
0
void Graphics::FillRect(const Rect &rc, color_t color)
{
	rectfill(_alBitmap, rc.Left, rc.Top, rc.Right, rc.Bottom, color);
}
Пример #10
0
void GameOver::update()
{
    if(counter<254)
    {
        if(counter<=32)
            link.setHitTimer(32-counter);
        
        if(counter>=62 && counter<138)
        {
            switch((counter-62)%20)
            {
            case 0:
                link.dir=right;
                break;
                
            case 5:
                link.dir=up;
                break;
                
            case 10:
                link.dir=left;
                break;
                
            case 15:
                link.dir=down;
                break;
            }
            
            link.linkstep();
        }
        
        if(counter>=194 && counter<208)
        {
            if(counter==194)
                link.setAction(dying);
                
            link.extend = 0;
            link.cs = wpnsbuf[iwDeath].csets&15;
            link.tile = wpnsbuf[iwDeath].tile;
            
            if(BSZ)
                link.tile+=(counter-194)/3;
            else if(counter>=204)
                link.tile++;
        }
        
        if(counter==208)
            link.setDontDraw(true);
            
        if(get_bit(quest_rules,qr_FADE))
        {
            if(counter < 170)
            {
                if(counter<60)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                }
                
                if(counter==60)
                {
                    red_shift();
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                }
                
                if(counter>=60 && counter<=169)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                    red_shift();
                    
                }
                
                if(counter>=139 && counter<=169)//fade from red to black
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal, (counter-138)<<1, 224, 255);
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                    
                    refreshpal=true;
                }
            }
            else //counter>=170
            {
                if(counter==170)//make Link grayish
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
                    
                    for(int i=CSET(6); i < CSET(7); i++)
                    {
                        int g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
                        RAMpal[i] = _RGB(g,g,g);
                    }
                    
                    refreshpal = true;
                }
                
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
        else //!qr_FADE
        {
            if(counter==58)
            {
                for(int i = 0; i < 96; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<96; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==59)
            {
                for(int i = 96; i < 176; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=96; i<176; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==60)
            {
                for(int i=0; i<176; i++)
                {
                    tmpscr->cset[i] = 2;
                }
                
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<176; i++)
                            tmpscr2[j].cset[i] = 2;
                            
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(2)+i]   = NESpal(0x17);
                    RAMpal[CSET(2)+i+1] = NESpal(0x16);
                    RAMpal[CSET(2)+i+2] = NESpal(0x26);
                }
                
                refreshpal=true;
            }
            
            if(counter==139)
                slide_in_color(0x06);
                
            if(counter==149)
                slide_in_color(0x07);
                
            if(counter==159)
                slide_in_color(0x0F);
                
            if(counter==169)
            {
                slide_in_color(0x0F);
                slide_in_color(0x0F);
            }
            
            if(counter==170)
            {
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(6)+i]   = NESpal(0x10);
                    RAMpal[CSET(6)+i+1] = NESpal(0x30);
                    RAMpal[CSET(6)+i+2] = NESpal(0x00);
                    refreshpal = true;
                }
            }
            
            if(counter < 169)
            {
                draw_screen(tmpscr);
                //reuse our static subscreen
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
            else
            {
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
    }
    else if(counter<350)//draw 'GAME OVER' text
    {
        clear_bitmap(framebuf);
        blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
        textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,1,-1);
    }
    else
    {
        clear_bitmap(framebuf);
    }
    
    //SFX... put them all here
    switch(counter)
    {
    case   0:
        sfx(WAV_OUCH,pan(int(link.x)));
        break;
        
    case  60:
        sfx(WAV_SPIRAL);
        break;
        
    case 194:
        sfx(WAV_MSG);
        break;
    }
    
    //advanceframe(true);
    counter++;
    if(counter<353)
        return;
    
    finish();
    destroy_bitmap(subscrbmp);
    link.setAction(none);
    link.setDontDraw(false);
}
Пример #11
0
void ending()
{
    /*
      *************************
      * WIN THE GAME SEQUENCE *
      *************************
      0    LINK at ZELDA's side
      288  begin WIPE (8px per side per step, each 5 frames)
      363  WIPE complete, DOT out, A/B items out
      QMisc.colors.link_dot = 255;
      show_subscreen_items = false;
      365  first MESSAGE character in
      371  next character in
      407  last character in
      668  LINK out, ZELDA out
      669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
      733  BLUE flash bg
      734  RED
      735  GREEN
      736  BLACK
      ...
      860  BLACK, LINK out, ZELDA out
      861  LINK in, ZELDA in
      927  first MSG character in
      935  next character in
      1335 last character in
      1461 LINK out, ZELDA out
      1493 begin SCROLL
      */
    
    //get rid off all sprites but Link and Zelda
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    decorations.clear();
    
    music_stop();
    kill_sfx();
    sfx(WAV_ZELDA);
    Quit=0;
    
    game->set_cheat(game->get_cheat() | (cheat>1)?1:0);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    draw_screen_clip_rect_y1=0;
    draw_screen_clip_rect_y2=223;
    //draw_screen_clip_rect_show_link=true;
    //draw_screen_clip_rect_show_guys=false;
    
    for(int f=0; f<365; f++)
    {
        if(f==363)
        {
            //363  WIPE complete, DOT out, A/B items out
            QMisc.colors.link_dot = 255;
            show_subscreen_items = false;
            
            for(int i = guys.Count() - 1; i >= 0; i--)
            {
                if(guys.spr(i)->id > gDUMMY9)
                {
                    guys.del(i);
                }
            }
            
            guys.draw(framebuf,true);
            Link.draw(framebuf);
        }
        
        if(f>=288 && ((f-288)%5 == 0))
        {
            //288  begin WIPE (8px per side per step, each 5 frames)
            //TODO::
            draw_screen_clip_rect_x1+=8;
            draw_screen_clip_rect_x2-=8;
            //draw_screen_clip_rect_show_guys=true;
        }
        
        draw_screen(tmpscr);
        advanceframe(true);
        
        if(Quit) return;
    }
    
    clear_bitmap(msgdisplaybuf);
    draw_screen(tmpscr);
    advanceframe(true);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    //draw_screen_clip_rect_show_guys=false;
    
    char tmpmsg[6][25];
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    strncpy(tmpmsg[x], MsgStrings[QMisc.endstring].s+(24*x), 24);
    }
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x+3], "%.24s", MsgStrings[QMisc.endstring+1].s+(24*x));
        //    strncpy(tmpmsg[x+3], MsgStrings[QMisc.endstring+1].s+(24*x), 24);
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("THANKS LINK,YOU'RE",32,96,6,noproc);
        putendmsg("THE HERO OF HYRULE.",32,112,6,noproc);
    }
    else
    {
        putendmsg(tmpmsg[0],32,80,6,noproc);
        putendmsg(tmpmsg[1],32,96,6,noproc);
        putendmsg(tmpmsg[2],32,112,6,noproc);
    }
    
    for(int f=408; f<927; f++)
    {
        /*
          668  LINK out, ZELDA out
          669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
          733  BLUE flash bg
          734  RED
          735  GREEN
          736  BLACK
          ...
          860  BLACK, LINK out, ZELDA out
          861  LINK in, ZELDA in
          */
        if(f==668)
        {
            rectfill(framebuf,120,129,152,145,0);
            blit(framebuf, tmp_bmp, 120,113, 0,0, 32,32);
        }
        
        if(f==860)
        {
            blit(tmp_bmp, framebuf, 0,0, 120,113, 32,32);
        }
        
        if(f==669 || f==861)
        {
            overtile16(framebuf,36,120,129,6,0);//draw Zelda two-handed overhead
            overtile16(framebuf,BSZ?32:29,136,129,6,0);//draw Link two-handed overhead
        }
        
        if(f==733)
        {
            blit(framebuf,scrollbuf,0,playing_field_offset!=0?168:0,0,0,256,passive_subscreen_height);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(!(framebuf->line[y][x]&15))
                    {
                        framebuf->line[y][x]=16;
                    }
                }
            }
        }
        
        if(f>=733 && f<861)
        {
            static byte flash[4] = {0x12,0x16,0x2A,0x0F};
            RAMpal[16] = NESpal(flash[(f-733)&3]);
            refreshpal=true;
        }
        
        if(f==861)
        {
            blit(scrollbuf,framebuf,0,0,0,playing_field_offset!=0?168:0,256,passive_subscreen_height);
            try_zcmusic((char*)"zelda.nsf", 1, ZC_MIDI_ENDING);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(framebuf->line[y][x]==16)
                    {
                        framebuf->line[y][x]=0;
                    }
                }
            }
        }
        
        if(f>668 && f!=860)
        {
            put_triforce();
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("FINALLY,",96,160,8,put_triforce);
        putendmsg("PEACE RETURNS TO HYRULE.",32,176,8,put_triforce);
        putendmsg("THIS ENDS THE STORY.",48,200,8,put_triforce);
    }
    else
    {
        putendmsg(tmpmsg[3],32,160,6,noproc);
        putendmsg(tmpmsg[4],32,176,6,noproc);
        putendmsg(tmpmsg[5],32,200,6,noproc);
    }
    
    for(int f=1336; f<1492; f++)
    {
        if(f<1461)
        {
            put_triforce();
        }
        
        if(f==1461)
        {
            blit(tmp_bmp,framebuf,0,0,120,113,32,32);
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    clear_bitmap(scrollbuf);
    blit(framebuf,scrollbuf,0,0,0,0,256,224);
    endingpal();
    // draw the brick
    puttile16(scrollbuf,3,256,0,csBOSS,0);
    
    int len=600*2;
    
    if(game->get_quest()>1)
    {
        len=720*2;
    }
    
    int creditsLine=0;
    int endTextLine=0;
    
    const EndingTextLine* endText;
    int numEndTextLines=0;
    int deathsYPos=-1;
    int timeYPos=-1;
    
    switch(game->get_quest())
    {
    case 1:
        endText=quest1End;
        numEndTextLines=numQuest1EndLines;
        break;
        
    case 2:
        endText=quest2End;
        numEndTextLines=numQuest2EndLines;
        deathsYPos=792;
        break;
        
    case 3:
    case 4:
        endText=quest34End;
        numEndTextLines=numQuest34EndLines;
        deathsYPos=792;
        break;
        
    default:
        endText=customQuestEnd;
        numEndTextLines=numCustomQuestEndLines;
        deathsYPos=784;
        timeYPos=800;
        break;
    }
    
    for(int f=0; f<len; f++)
    {
        if(!(f&15))
        {
            int y=(f>>1)+224;
            
            if(y>240 && y<584)
            {
                brick(24,224);
                brick(224,224);
            }
            
            if(y==240 || y==584)
            {
                for(int x=24; x<=224; x+=8)
                {
                    brick(x,224);
                }
            }
            
            if(creditsLine<numCreditsLines)
            {
                if(y==credits[creditsLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               credits[creditsLine].text,
                               credits[creditsLine].xPos,
                               224,
                               credits[creditsLine].color,
                               0);
                    creditsLine++;
                }
            }
            else
            {
                if(endTextLine<numEndTextLines &&
                   y==endText[endTextLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               endText[endTextLine].text,
                               endText[endTextLine].xPos,
                               224,
                               endText[endTextLine].color,
                               0);
                    endTextLine++;
                }
                else if(y==deathsYPos)
                    textprintf_ex(scrollbuf, zfont, 72, 224, red, 0,
                                  "%-8s -%3d", game->get_name(), game->get_deaths());
                else if(y==timeYPos)
                {
                    if(game->get_timevalid() && !game->get_cheat())
                        textout_centre_ex(scrollbuf, zfont, time_str_med(game->get_time()), 128, 224, blue, 0);
                }
            }
        }
        
        if(f==112)                                              // after subscreen has scrolled away
        {
            init_NES_mode();
            loadpalset(9,pSprite(spPILE));
            endingpal();
        }
        
        if(f&1)
        {
            blit(scrollbuf,scrollbuf,0,1,0,0,256,232);
        }
        
        blit(scrollbuf,framebuf,0,0,0,0,256,224);
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
        
        load_control_state();
        rSbtn();
    }
Пример #12
0
void FillRectangle(int x1, int y1, int x2, int y2)
{
	int color = makecol(0, 0, 0);
	rectfill(buffer, x1, y1, x2, y2, color);
}
Пример #13
0
// this function
void renderDDRHoldNoteBody(int column, int x, int topy, int bot, int color )
{
	static int columnSource[10] = { 0, 2, 3, 5, 0, 2, 3, 5, 1, 4 };

	int frame = 0;
	int source = 6;
	int rectcolor = makeacol(arrowColors[5][0], arrowColors[5][1], arrowColors[5][2], 255);
	if ( color == HOLD_BRIGHT )
	{
		frame = 3;
		rectcolor = 0xFFDDFFDD;
	}
	if ( color == HOLD_MELT )
	{
		source = 8;
		rectcolor = 0xFF505050;
	}

	// down arrows render differently than holds in other columns
	if ( column == 2 || column == 7 )
	{
		rectfill(rm.m_backbuf, x+1, topy+32, x+62, bot+26, rectcolor);
		int y = bot + 16;

		while ( y > topy + 16 )
		{
			masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 16, x, y, 64, 48);
			y -= 16;
		}

		// the top of the hold is where the adjustment is made, if the length isn't % 16
		int fractionalArrowHeight = (y - topy) % 16;
		masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, fractionalArrowHeight);

		renderDDRArrow(0, column, source == 8 ? 8 : 5, 0, getColumnOffsetX_DDR(column), topy);
	}
	else
	{
		// solo arrows are technically a little narrower than other arrows
		if ( column == 1 || column == 4 )
		{
			rectfill(rm.m_backbuf, x+9, topy+16, x+55, bot+0, rectcolor);
		}
		else
		{
			rectfill(rm.m_backbuf, x+1, topy+32, x+62, bot+31, rectcolor);
		}
		int y = topy;

		// the top of the hold is where the adjustment is made, if the length isn't % 16
		int fractionalArrowHeight = (bot - y) % 16;
		masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, fractionalArrowHeight);
		y += fractionalArrowHeight;

		while ( y < bot )
		{
			masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, 48);
			y += 16;
		}
		masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, bot, 64, 64);
		renderDDRArrow(0, column, source == 8 ? 8 : 5, 0, getColumnOffsetX_DDR(column), topy);
	}
}
int main( int argc, char *argv[] ) 
{
	int screenMode = GFX_AUTODETECT_WINDOWED;
	BITMAP *backbuf;
	
	TitleScreen *mode_titlescreen;
	CityMode *mode_city;

	bool showConsole = false;

	//args
	for (int i=1; i < argc; i++) {
		if (!strcmp(argv[i],"-fullscreen") ) {
			screenMode = GFX_AUTODETECT_FULLSCREEN;
		}
	}

	// Init alleg
	allegro_init();
	install_keyboard();
	install_mouse();
	set_color_depth( 16 );
	
	
	

	// Turn on the screeny goodness
	if (set_gfx_mode(screenMode, 640,480, 0, 0) != 0) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Unable to set 640x480 graphic mode\n%s\n", allegro_error);
      return 1;
   }

	alfont_init();

	//set_color_conversion(COLORCONV_TOTAL);
	//drawing_mode(DRAW_MODE_TRANS, NULL,0,0);


	// fonts
	font_console = alfont_load_font("Graphics/fonts/ProFontWindows.ttf");
	alfont_set_font_size(font_console, 12);

	font_title = alfont_load_font("Graphics/fonts/AbductionIII.ttf");
	alfont_set_font_size( font_title, 24 );

	font_game = alfont_load_font("Graphics/fonts/archtura.ttf" );
	alfont_set_font_size( font_game, 24 );


	// screen 
	backbuf = create_bitmap( 640, 480 );
	rectfill( backbuf, 0,0, 640, 480, 0x0 );	
	
	SpriteGraphic *testgfx = new SpriteGraphic( "testship" );
	Sprite *test = new Sprite( testgfx );
	test->m_x = 10;
	test->m_y = 70;

	// game mode
	mode_titlescreen = new TitleScreen();
	mode_city = new CityMode();
	g_mode = mode_titlescreen;

	// init scripts
	script_init( font_console );

	// The main loop
	while (1) {

		if (g_mode) {
			g_mode->update();
		}

		g_mode->draw( backbuf );

#if 0
		// draw the game
		if (Map::g_activeMap) {
			Map::g_activeMap->draw( backbuf );
			
			// DBG: Map scrolling
			Map::g_activeMap->m_scroll = ((float)mouse_y / 480.0) * ((Map::g_activeMap->m_maphite-15)*32);

		} else {
			rectfill( backbuf, 0,0, 640, 480, 0x0 );
			alfont_textout_centre( backbuf, font_game, "Infection",  320, 200, makecol(200, 0, 0) );
		}

		// draw the sprites
		test->draw( backbuf );

		char buff[200];
		sprintf( buff, "testy %d m2s %d scroll %d", test->m_y, Map::mapYtoScreenY( test->m_y ), Map::getScroll() );
		alfont_textout( backbuf, font_console, buff,  320, 200, makecol(255,255,255) );
#endif

		// draw the console
		if (showConsole) {
			draw_console( backbuf );
		}

		// event handler
		if (keypressed()) {			

			int k = readkey();
			int kk = k >>8;

			// mode specific keypress
			g_mode->key_pressed( k );
			
			// global keypress
			if (kk==KEY_TILDE) {
				showConsole = !showConsole;
			} else if (showConsole) {
				// send key to console
				console_key( k );

			} else {
				switch(k>>8) {			
				
				case KEY_DOWN:
					test->m_y += 10;
					break;
				case KEY_UP:
					test->m_y -= 10;
					break;
				}

			}
		}

		

		if (key[KEY_ESC]) {
			//exit(0);
			break;
		}

		// Blit the screen
		vsync();
		acquire_screen();
		blit( backbuf, screen, 0, 0, 0, 0, 640, 480 );
		release_screen();

		yield_timeslice();
	}
	

	return 0;
}
void cMapDrawer::drawTerrain() {
	// draw only what is visible

	// Scrolling:
	// - is X,Y position of map, not smoothed!
	// - all we need is the end of the 'to be drawn area' , which is:
	//   WIDTH OF SCREEN / 32

	int iDrawX=0;
	int iDrawY=42;

	int iCell=-1;

	int iPl = player->getId();

//	char msg[255];
//	sprintf(msg, "Drawing from %d, %d to %d, %d", camera->getX(), camera->getY(), camera->getEndX(), camera->getEndY());
//	logbook(msg);

	// draw vertical rows..
	for (int iStartX = camera->getX(); iStartX < camera->getEndX(); iStartX++) {
		iDrawY=42;

		// new row
		for (int iStartY=camera->getY(); iStartY < camera->getEndY(); iStartY++) {
			iCell = iCellMake(iStartX, iStartY);

			if (mapUtils->isCellVisibleForPlayerId(iPl, iCell) == false) {
				iDrawY+=TILESIZE_HEIGHT_PIXELS;
				continue; // do not draw this one
			}

			blit((BITMAP *)gfxdata[map->cell[iCell].type].dat, bmp_screen, map->cell[iCell].tile * 32, 0, iDrawX, iDrawY, 32, 32);

			// draw smudge if nescesary
			if (map->cell[iCell].smudgetype > -1 && map->cell[iCell].smudgetile > -1) {
				masked_blit((BITMAP *)gfxdata[SMUDGE].dat, bmp_screen,
						map->cell[iCell].smudgetile * 32, map->cell[iCell].smudgetype * 32, iDrawX, iDrawY, 32, 32);

			}

			if (DEBUGGING)
			{
				if (player->getGameControlsContext()->getMouseCell() > -1)
				{
					int mc = player->getGameControlsContext()->getMouseCell();
					if (cellCalculator->getX(mc) == iStartX && cellCalculator->getY(mc) == iStartY)
						rectfill(bmp_screen, iDrawX, iDrawY, iDrawX+32, iDrawY+32, makecol(64,64,64));

				}

				rect(bmp_screen, iDrawX, iDrawY, iDrawX+32, iDrawY+32, makecol(128,128,128));
			}

			if (key[KEY_D] && key[KEY_TAB])
			{
				int iClr=makecol(255,0,0);

				bool bDraw=false;

				if (map->cell[iCell].passable == false)
					bDraw=true;

				if (map->cell[iCell].id[MAPID_STRUCTURES] > -1)
				{
					iClr=makecol(0,255,0);
					bDraw=true;
				}

				if (map->cell[iCell].id[MAPID_UNITS] > -1)
				{
					iClr=makecol(0,0,255);
					bDraw=true;
				}

				if (bDraw)
				{
					rectfill(bmp_screen, iDrawX, iDrawY, iDrawX+32, iDrawY+32, iClr);
				}

			}

			iDrawY+=TILESIZE_HEIGHT_PIXELS;
		}
		iDrawX+=TILESIZE_WIDTH_PIXELS;
	}
}
Пример #16
0
void select_stage( int matrix[][50]) // if wall mode is off
{
    int k = 0, i,j,s=0;
    char button;
    char address[13] = "sceneryx.txt";  // the generic address to some scenery
    BITMAP *buffer2 = create_bitmap(600,272);
    BITMAP *mb = load_bitmap("Image/Miniblock.bmp",NULL);// load the miniblock
    FILE *scenery; // pointer of file
    while(s != 1)
    {
        clear_to_color(buffer2,0x6F6F6F);
        rect(buffer2,173,71,425,198,0x000000);// boot the rectangle
        rect(buffer2,172,70,426,199,0x000000);// boot the rectangle
        rectfill(buffer2,174,72,424,197,0xFFFFFF);// boot the rectangle
        address[7] = intchar(k);
        scenery = fopen(address,"r");
        if(scenery==NULL) {
            zeroing(matrix);
        }
        else
        {
            for(i=0; i<25; i++)
            {
                for(j=0; j<=50; j++)
                {
                    if(j==50) {
                        getc(scenery);
                    }
                    else matrix[i][j] = charint(getc(scenery));
                }
            }
            fclose(scenery);
        }
        for(i=0; i<25; i++)
        {
            for(j=0; j<50; j++)
            {
                if(matrix[i][j]==8) {
                    blit(mb,buffer2,0,0,(177+j*5)-2,(75+i*5)-2,5,5);
                }
            }
        }
        blit(buffer2,screen,0,0,0,0,600,272);
        outnumber(240,210,k);
        textout_ex(screen,font,"Field ",185,210,0xFFFFFF,0x6F6F6F);
        button = readkey();
        rest(20);
        if((button==enter)&&(scenery!=NULL)&&(k!=0)) {
            clear_to_color(screen,0xFFFFFF);
            build_scenery(matrix,address);
            s = 1;
            scenery_number = k;
        }
        else if((button==enter)&&(scenery==NULL)) {
            build_scenery(matrix,"scenery_.txt");
            s = 1;
            scenery_number = 0;
        }
        else if((button==l)||(button==d)) {
            if(k>0) {
                k--;
            }
        }
        else {
            if(k<9) {
                k++;
            }
        }
    }
}
void cMapDrawer::drawShroud() {
	set_trans_blender(0,0,0,128);

	BITMAP *temp = create_bitmap(32,32);

	int iDrawX=0;
	int iDrawY=42;

	int cll=-1;
	int tile=-1;

	int iPl = player->getId();

	for (int iStartX = camera->getX(); iStartX < camera->getEndX(); iStartX++) {
		iDrawY=42;
		tile=-1;

		// new row
		for (int iStartY=camera->getY(); iStartY < camera->getEndY(); iStartY++) {
			cll = iCellMake(iStartX, iStartY);

			if (DEBUGGING) {
				if (mapUtils->isCellVisibleForPlayerId(iPl, cll)) {
					// do nothing
				} else {
					rectfill(bmp_screen, iDrawX, iDrawY, iDrawX+32, iDrawY+32, makecol(0,0,0));
				}

			} else {
				if (mapUtils->isCellVisibleForPlayerId(iPl, cll)) {
					// Visible stuff, now check for not visible stuff. When found, assign the proper border
					// of shroud to it.
					int above = CELL_ABOVE(cll);
					int under = CELL_UNDER(cll);
					int left  = CELL_LEFT(cll);
					int right = CELL_RIGHT(cll);

					bool a, u, l, r;
					a=u=l=r=true;

					if (above > -1)	{
						if (mapUtils->isCellVisibleForPlayerId(iPl, above)) {
							a = false;  // visible
						}
					} else {
						a = false;
					}

					if (under > -1) {
						if (mapUtils->isCellVisibleForPlayerId(iPl, under)) {
							u = false;  // visible
						}
					} else {
						u = false;
					}

					if (left > -1) {
						if (mapUtils->isCellVisibleForPlayerId(iPl, left)) {
							l = false;  // visible
						}
					} else {
						l = false;
					}

					if (right > -1) {
						if (mapUtils->isCellVisibleForPlayerId(iPl, right)) {
							r = false;  // visible
						}
					} else {
						r = false;
					}

					int t=-1;	// tile id to draw... (x axis)

					// when above is not visible then change this border tile
					if (a == true && u == false && l == false && r == false)
						t = 3;

					if (a == false && u == true && l == false && r == false)
						t = 7;

					if (a == false && u == false && l == true && r == false)
						t = 9;

					if (a == false && u == false && l == false && r == true)
						t = 5;
							// corners

					if (a == true && u == false && l == true && r == false)
						t = 2;

					if (a == true && u == false && l == false && r == true)
						t = 4;

					if (a == false && u == true && l == true && r == false)
						t = 8;

					if (a == false && u == true && l == false && r == true)
						t = 6;

					// 3 connections
					if (a == true && u == true && l == true && r == false)
						t = 10;

					if (a == true && u == true && l == false && r == true)
						t = 12;

					if (a == true && u == false && l == true && r == true)
						t = 11;

					if (a == false && u == true && l == true && r == true)
						t = 13;

					if (a == true && u == true && l == true && r == true)
						t=1;

					tile = t - 1;

					if (tile > -1)
					{

						// Draw cell
						masked_blit((BITMAP *)gfxdata[SHROUD].dat, bmp_screen, tile * 32, 0, iDrawX, iDrawY, 32, 32);

						 clear_to_color(temp, makecol(255,0,255));

							masked_blit((BITMAP *)gfxdata[SHROUD_SHADOW].dat, temp, tile * 32, 0, 0, 0, 32, 32);
							draw_trans_sprite(bmp_screen, temp, iDrawX, iDrawY);


					//	alfont_textprintf(bmp_screen, game_font, iDrawX,iDrawY, makecol(255,255,255), "%d", tile);
				   }

				  }
				  else
				  {
					  // NOT VISIBLE, DO NOT DRAW A THING THEN!
					//	alfont_textprintf(bmp_screen, game_font, iDrawX,iDrawY, makecol(255,255,255), "%d", tile);

					  // Except when there is a building here, that should not be visible ;)
					  // if (map.cell[cll].id[1] > -1 || map.cell[cll].id[0] > -1 || map.cell[cll].id[2] > -1 || map.cell[cll].id[3] > -1)
						  masked_blit((BITMAP *)gfxdata[SHROUD].dat, bmp_screen, 0, 0, iDrawX, iDrawY, 32, 32);
				  }

			  }
			iDrawY+=32;
		}
		iDrawX+=32;
	}

	destroy_bitmap(temp);
}
Пример #18
0
int main() {
	init();
	
	show_os_cursor(MOUSE_CURSOR_ARROW);//esibe o cursor do 'OPERACIONAL' sobre a tela 
	
	BITMAP *Buffer = create_bitmap(SCREEN_WIDTH ,SCREEN_HEIGHT);
	
	BITMAP *Tile_Set0 = load_bitmap("t_map.bmp", NULL);
    BITMAP *till_0[256];//imagens do tileset_0
    
    BITMAP *Tile_Set00 = load_bitmap("bgs.bmp", NULL);
    BITMAP *till_00[320];//imagens do tileset_0
    
    Mapa d;
    
    P_Map(0,0);//posicao inicial do mapa na tela quando e desenhado
	T_Tile();//tamanho do tile padrao(16x16)  
    
    d.C_Tiles(till_0,Tile_Set0,16,16);//carega o tile_set
    d.C_Tiles(till_00,Tile_Set00,16,20);//carega o tile_set


int g=10,dc=10;
int xc=20*Tx_Tile,yc=15*Ty_Tile;

int r=0;


	while (!key[KEY_ESC]) 
    {clear_to_color(Buffer, makecol(30,30,100));//altera a cor de fundo do Buffer
     Longit_Lat();//latitude e longitude do mapa em relacao ao ponto 0x0 da tela

		  
		//---criar uma funcao chamada fase'x' com o modelo que esta representado abaixo---  
		  d.Fill_Map(till_00,320,map_pf1,200,60,Buffer,0.8,1);//plano de fundo do senario 1
		  d.Fill_Map(till_00,320,map_pf2,200,60,Buffer,0.8,0.7);//plano de fundo do senario 2
          d.Fill_Map(till_0,256,map_1,200,60,Buffer,1,1);//mapa dos objetos atras dos pesonagens 1
          d.Fill_Map(till_0,256,map_1f,200,60,Buffer);//mapa dos objetos atras dos pesonagens 2
		  //-----os pesonagens devem ser postos aqui-----
          //d.Fill_Map(till_0,256,0,0,200,60,Buffer,map_1q,X_MAP,Y_MAP);//mapa dos objetos afente dos pesonagem 
	      r=d.c(64,64,xc,yc,map_1,200,60,Buffer);//--teste de colisoes
	
		  d.Scoll_MapD(200,60,10,Buffer); //tacha de movimento do mapa   
		  

		 // obijeto de test-----------
		  set_trans_blender(0, 0, 0, 100);    
          drawing_mode(DRAW_MODE_TRANS,  0,0, 0);
		  rect(Buffer, xc,yc, xc+64, yc+64, makecol(0, 0, 100));
		  rectfill(Buffer, xc,yc, xc+64, yc+64, makecol(0, 0, 255));
		  drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); 
		  
		if(mouse_b & 1)
		  xc=mouse_x-8,yc=mouse_y-8;
		  //d.c(16,16,xc,yc,map_1,200,60,Buffer,4);
		  cout<<xc<<" "<<yc<<"\n";
  
  
  		 
		 if(key[KEY_UP])//controle do objeto
		        {//yc+=g;
                 yc-=12;
                 }       
		   if(key[KEY_DOWN] )
           	   {yc+=0;
                 // yc+=g;
                  }
          else	   
              yc+=g;
		     if(key[KEY_LEFT]) 
		        {xc-=8;}
	         if(key[KEY_RIGHT] ) 
                {xc+=8;}

  
        if(key[KEY_G])
		  yc+=g;//gravidade
		else
          yc+=0;

		  
		  if(yc>60*Ty_Tile)
		     yc=100;
		     
		   if(key[KEY_Z] && r==1)//r=colisao
              yc-=48;  
           if(key[KEY_X] && r==1)
              yc-=64;    
		  
		  
		  if(key[KEY_T])//testa o tile_set caregado
             d.Tile_test(till_0,16,16,Buffer);
  
		  
	  vsync();//aguarda a sincronizacao vertical
	  rest(80);//espera 'x' milisegundos	  
	  blit(Buffer,screen,0,0,0,0,SCREEN_WIDTH,SCREEN_HEIGHT);//fixa o Buffer no screen	  
	  clear(Buffer);//limpa o Buffer
	}

    //distruindo bitmaps--------------------------------------------------------
    destroy_bitmap(Tile_Set0);
    for(int i=0;i<256;i++)
	     destroy_bitmap(till_0[i]);
   
    destroy_bitmap(Buffer);//destroi o Biffer da memoria --obrigatorio--
    //--------------------------------------------------------------------------
    
	deinit();
	return 0;
}
Пример #19
0
void AWgtFrame::draw()
{
	int tmpFrameCaptionHeight;

	if (!captionBar) {
		tmpFrameCaptionHeight = frameCaptionHeight;
		frameCaptionHeight = frameThickness;
	}

	int x1 = x + (frameThickness*3);
	int x2 = x + width - 1 - (frameThickness*3);
	int bgHeight = height - (frameThickness*5) - frameCaptionHeight - 1;
	int bgStartY = y + (frameThickness*2) + frameCaptionHeight + 1;

	int i;

	if (alpha < 255) {
		drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);
		set_trans_blender(0, 0, 0, alpha);
	}

	for (i = 0; i < bgHeight; i++) {
		float ratio;
		if (smoothBg) {
			ratio = (float)i / (float)bgHeight;
		}
		else {
			int section = (i * 100) / bgHeight *
				frameBgSections / 100;
			ratio = (float)section / frameBgSections;
		}
		int color = aWgtInterpolateColor(ratio, top_color, bottom_color);
		int ly = bgStartY+i;
		line(tguiBitmap, x1, ly, x2, ly, color);
	}

	if (alpha < 255)
		drawing_mode(DRAW_MODE_SOLID, 0, 0, 0);

	rect(tguiBitmap, x1+1, bgStartY+1, x2-1, bgStartY+bgHeight-2, bottom_color);

	int endX = x + width - 1;
	int endY = y + height - 1;

	// outer border

	rect(tguiBitmap, x, y, endX, endY,
			aWgtDarken(aWgtDarken(border_color)));

	for (i = 1; i < frameThickness; i++)
		rect(tguiBitmap, x+i, y+i, endX-i, endY-i,
				aWgtDarken(border_color));

	// middle border
	
	int startX = x + frameThickness;
	int startY = y + frameThickness;
	endX = x + width - 1 - frameThickness;
	endY = y + height - 1 - frameThickness;

	for (i = 0; i < frameThickness; i++)
		rect(tguiBitmap, startX+i, startY+i, endX-i, endY-i,
				border_color);

	// caption rect

	startX += frameThickness;
	startY += frameThickness;
	endX -= frameThickness;
	endY = y + frameCaptionHeight + frameThickness;

	rectfill(tguiBitmap, startX, startY, endX, endY, border_color);

	// top inner border

	startY += frameCaptionHeight - frameThickness + 1;
	endY += frameThickness + 1;

	rectfill(tguiBitmap, startX, startY, endX, endY,
			aWgtDarken(border_color));

	// right inner border

	startX = endX - frameThickness;
	startY += frameThickness;
	endY += bgHeight + frameThickness - 1;

	rectfill(tguiBitmap, startX, startY, endX, endY,
			aWgtDarken(border_color));

	// left inner border

	startX = x1 - frameThickness;
	endX = startX + frameThickness;
	startY++;

	rectfill(tguiBitmap, startX, startY, endX, endY,
			aWgtHighlight(border_color));

	// bottom inner border

	startX += frameThickness;
	endX = x2-1;
	startY = endY - frameThickness;
	
	rectfill(tguiBitmap, startX, startY, endX, endY,
			aWgtHighlight(border_color));

	// top left triangle
	
	int tx1 = x + (frameThickness * 2);
	int ty1 = y + frameThickness + frameCaptionHeight + 2;
	int tx2 = tx1;
	int ty2 = ty1 + frameThickness;
	int tx3 = tx1 + frameThickness;
	int ty3 = ty2;

	triangle(tguiBitmap, tx1, ty1, tx2, ty2, tx3, ty3,
			aWgtHighlight(border_color));

	tx1 = x + width - 1 - (frameThickness * 3);
	ty1 = y + height - 1 - (frameThickness * 3) + 1;
	tx2 = tx1;
	ty2 = ty1 + frameThickness;
	tx3 = tx1 + frameThickness;
	ty3 = ty2;
	
	triangle(tguiBitmap, tx1, ty1, tx2, ty2, tx3, ty3,
			aWgtHighlight(border_color));

	aWgtTextout(tguiBitmap, aWgtFont, caption,
			x + (width / 2) -
			(text_length(aWgtFont, caption) / 2),
			y + frameThickness + (frameCaptionHeight / 2) -
			(text_height(aWgtFont) / 2),
			caption_color, captionBorderColor, captionShadowType);

	int color = aWgtDarken(aWgtDarken(border_color));

	x1 = x;
	x2 = x + frameThickness - 1;
	int y1 = y;
	int y2 = y + frameThickness - 1;

	line(tguiBitmap, x1, y1, x2, y2, color);

	x1 = x + width - 1;
	x2 = x1 - frameThickness + 1;

	line(tguiBitmap, x1, y1, x2, y2, color);

	x1 = x;
	x2 = x + frameThickness - 1;
	y1 = y + height - 2;
	y2 = y1 - frameThickness + 2;

	line(tguiBitmap, x1, y1, x2, y2, color);

	x1 = x + width - 1;
	x2 = x1 - frameThickness + 1;

	line(tguiBitmap, x1, y1, x2, y2, color);

	x1 = x + width - 1 - (frameThickness * 2);
	x2 = x1 - frameThickness;
	y1 = y + frameThickness + frameCaptionHeight + 1;
	y2 = y1 + frameThickness;
	
	line(tguiBitmap, x1, y1, x2, y2, color);

	color = aWgtHighlight(aWgtHighlight(border_color));

	x1 = x + (frameThickness * 2);
	x2 = x1 + frameThickness;
	y1 = y + height - 1 - (frameThickness * 2);
	y2 = y1 - frameThickness;

	line(tguiBitmap, x1, y1, x2, y2, color);

	if (closeable) {
		if (aWgtFrameCloseBmp) {
			x1 = x + width - frameThickness - 1 - aWgtFrameCloseBmp->w;
			y1 = y + frameThickness;
			draw_sprite(tguiBitmap, aWgtFrameCloseBmp, x1, y1);
		}
		else {
			x1 = x + width - frameThickness - 1 - frameCaptionHeight;
			y1 = y + frameThickness;
			x2 = x1 + frameCaptionHeight;
			y2 = y1 + frameCaptionHeight;
			line(tguiBitmap, x1, y1, x2, y2, 0);
			line(tguiBitmap, x1, y2, x2, y1, 0);
		}
	}

	if (!captionBar)
		frameCaptionHeight = tmpFrameCaptionHeight;
}
Пример #20
0
void main(void) {
    
    int xy,i,c,x,y,front,back,n,minc,maxc;
    float dzdx,dzdy,a,b,dot,norm,tmp;
    long p,q;
    RGB rgb;

//    srand(456789);
        srand((int)time(NULL));
        //printf("%d\n",(int)time(NULL));


    mytime=10;
    maxc=0; minc=255;


    // Set up ripples
    numripples=5;
    for (i=0; i<numripples; i++) {
        newripple(i);
    }


  allegro_init ();
  install_keyboard ();
  install_timer ();
  set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0);
  set_pallete (desktop_palette);
  buffer = create_bitmap (scrwid, scrhei);
      clear (buffer);

    // Set up grayscale colours
    for (c=0;c<=255;c++) {
        i=0;
        rgb.r=c*63/255;
        rgb.g=0;
        rgb.b=0;
        set_color(c,&rgb);
//        colors[c]=GrAllocColor(c,i,i);
    }
    

//      circlefill (buffer, x, y, 3, 255);
      textout_centre (buffer, font, "Press SPACE!", 60, 220, 4);

      blit (buffer, screen, 0, 0, 0, 0, 320, 240);

    while(!key[KEY_ESC]) {
        for (x=0; x<scrwid; x=x+res) {
        for (y=0; y<scrhei; y=y+res) {
            dzdx=0;
            dzdy=0;
            for (i=0;i<numripples;i++) {
                ripples[i].front=ripples[i].v*(mytime-ripples[i].st);
                ripples[i].back=ripples[i].v*(mytime-ripples[i].st)-ripples[i].w;
                if (ripples[i].back>scrwid)
                        newripple(i);
            }
            for (i=0;i<numripples;i++) {
                xy=(sqrt((x-ripples[i].x)*(x-ripples[i].x)+(y-ripples[i].y)*(y-ripples[i].y)));
                //printf("xy%i",xy);
                //printf("x%i",x);
                //printf("y%i",y);
                //printf("rx%i",ripples[i].x);
                //printf("ry%i",ripples[i].y);
                //printf("f%i\n",front);
                //printf("b%i\n",back);
                if ((xy>2)&&(xy<ripples[i].front)&&(xy>ripples[i].back)) {
                    //printf("*********");
                    a=pi/ripples[i].w*sin(2*pi*ripples[i].n/ripples[i].w*(xy-ripples[i].v*(mytime-ripples[i].st)));
                    //printf("a%f",a);
                    b=(float)1/xy;
                    //printf("b%f",b);
                    norm=1500/(mysquare(xy))*(exp(3*(xy-(ripples[i].v)*((mytime-ripples[i].st)))/ripples[i].w));
                    //printf("n%f",norm);
                    dzdx=dzdx+a*b*(x-ripples[i].x)*ripples[i].w*norm;
                    dzdy=dzdy+a*b*(y-ripples[i].y)*ripples[i].w*norm;
                }
            }
            //dot=dzdx*lx+dzdy*ly;
            //dot=dot*(dzdx*0.8+dzdy*0.6);
            //dot=dzdx*0.8+dzdy*0.6;
            dot=dzdx * 1 * 0.8 + dzdy * 1 * 0.6;
            c=128+dot*128*scale;
            if (c<minc)
                minc=c;
            if (c>maxc)
                maxc=c;
            if (c<0)
                c=0;
            if (c>255)
                c=255;
            /*GrPlot(x,y,colors[c]);
            GrPlot(x+1,y,colors[c]);
            GrPlot(x,y+1,colors[c]);
            GrPlot(x+1,y+1,colors[c]);*/

rectfill(buffer, x, y, x+res-1, y+res-1, c);

//            GrFilledBox(x,y,x+res-1,y+res-1,colors[c]);
        }
        }
    /*for (i=0;i<numripples;i++) {
        mycircle(ripples[i].x,ripples[i].y,ripples[i].front,colors[0]);
        mycircle(ripples[i].x,ripples[i].y,ripples[i].back,colors[0]);
    }*/
      blit (buffer, screen, 0, 0, 0, 0, 320, 240);
    mytime=mytime+2;
    }
destroy_bitmap(buffer);
exit(0);
    getch();

//    GrSetMode(GR_default_text);
    printf("max col %d\n",maxc);
    printf("min col %d\n",minc);
  
}
Пример #21
0
static void photon_box(BITMAP *bmp, int x, int y, int w, int h, int color)
{
    photon_container(bmp, x, y ,w ,h);
    rectfill(bmp, x+2, y+2, x+w-3, y+h-3, color);
}
Пример #22
0
//main function
void main()
{
    //setup allegro
    allegro_init();
    install_mouse();
    install_timer();
    set_color_depth(COLOR_DEPTH);
    set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);

    //setup the timer
    install_int(update_timer, 1);

    //seed random number
    srand(time(NULL));

    //set up the close button
    set_close_button_callback(quit);

    //initialize the buffer
    buffer = create_bitmap(WIDTH, HEIGHT);

    //main loop
    while (!end_game)
    {
        //log the start time
        start_time = timer;

        F_PLUS = (loop_num/50);
        if (F_PLUS > 120) F_PLUS = 120;

        mx = (mouse_x+mx*7)/8;
        my = (mouse_y+my*7)/8;

        if (mouse_b & 2) {nshots = 0; score = 0; ray_t = 50; game_over = false;}

        //fire a new shot
        if (loop_num % 10-F_PLUS/30 == 0)
        {
                if (rand()%2)
                {
                        shot[nshots].x = rand()%2*WIDTH;
                        shot[nshots].y = rand()%HEIGHT;
                        shot[nshots].vy = 0;
                        shot[nshots].vx = (WIDTH/2-shot[nshots].x)/(WIDTH/2);
                        nshots++;
                }
                else
                {
                        shot[nshots].y = rand()%2*HEIGHT;
                        shot[nshots].x = rand()%WIDTH;
                        shot[nshots].vx = 0;
                        shot[nshots].vy = (HEIGHT/2-shot[nshots].y)/(HEIGHT/2);
                        nshots++;
                }
        }
        //rays
        if ((loop_num % 300-F_PLUS == 0)&&(loop_num > 300))
        {
                ray_x = mx+rand()%11-5;
                ray_y = my+rand()%11-5;
                ray_t = -40;
        }

        if (loop_num % 2) ray_t++;

        //bullet move
        for (int i = 0; i < nshots; i++)
        {
                shot[i].x += shot[i].vx;
                shot[i].y += shot[i].vy;
                if ((shot[i].x > WIDTH)||(shot[i].y > HEIGHT)||(shot[i].x < 0)||(shot[i].y < 0)){nshots--; shot[i] = shot[nshots];}
                if (hit(mx, my, shot[i].x, shot[i].y, 5)){game_over = true;}
        }

        //death
        if ((abs(ray_t) < 20)&&(((mx < ray_x+(20-abs(ray_t)))&&(mx > ray_x-(20-abs(ray_t))))
        ||((my < ray_y+(20-abs(ray_t)))&&(my > ray_y-(20-abs(ray_t)))))){game_over = true;}

        ////drawing////

        //player
        if (!game_over)
        circle(buffer, mx, my, 5, WHITE);
        else
        circle(buffer, mx, my, 5, makecol(255, 0, 0));

        //bullets
        for (int i = 0; i < nshots; i++)
        {
                circlefill(buffer, shot[i].x, shot[i].y, 2, WHITE);
        }

        //beams
        if (ray_t <= -20)
        {
                hline(buffer, 0, ray_y, WIDTH, WHITE);
                vline(buffer, ray_x, 0, HEIGHT, WHITE);
        }
        if (abs(ray_t) < 20)
        {
                rectfill(buffer, 0, ray_y-(20-abs(ray_t)), WIDTH, ray_y+(20-abs(ray_t)), WHITE);
                rectfill(buffer, ray_x-(20-abs(ray_t)), 0, ray_x+(20-abs(ray_t)), HEIGHT, WHITE);
                rectfill(buffer, 0, ray_y-(20-abs(ray_t))/2, WIDTH, ray_y+(20-abs(ray_t))/2, SILVER);
                rectfill(buffer, ray_x-(20-abs(ray_t))/2, 0, ray_x+(20-abs(ray_t))/2, HEIGHT, SILVER);
        }

        //text
        if (!game_over)
        textprintf_centre_ex(buffer, font, WIDTH/2, 10, WHITE, BLACK, "%i", score*LOOP_TIME/1000);
        else
        {
        textprintf_centre_ex(buffer, font, WIDTH/2, 10, makecol(255, 0, 0), BLACK, "%i", score*LOOP_TIME/1000);
        textprintf_centre_ex(buffer, font, WIDTH/2, HEIGHT/2-5, WHITE, BLACK, "Game Over");
        textprintf_centre_ex(buffer, font, WIDTH/2, HEIGHT/2+10, WHITE, BLACK, "Right-Click to restart");
        }

        //draw to the screen
        blit(buffer, screen, 0, 0, 0, 0, WIDTH, HEIGHT);

        //clear the buffer
        clear_to_color(buffer, BLACK);

        //wait
        while (timer < start_time + LOOP_TIME)
        {rest(1);}
        loop_num++;
        if (game_over == false) score++;
    }
    remove_int(update_timer);
    destroy_bitmap(buffer);
    return;
}
Пример #23
0
static void photon_draw_menu_item(MENU *m, int x, int y, int w, int h, int bar, int sel)
{
    int i, j, height;
    char buf[256], *tok;
    int rtm;

    if (!menu_done) {
	photon_do_draw_menu(last_x, last_y, last_w, last_h, bar);
	menu_done = TRUE;
    }

    if (ugetc(m->text)) {
	if (bar) {
	    if (sel) {
		rect(screen, x+6, y, x+w-4, y+h, container_black);
		hline(screen, x+7, y+1, x+w-5, white);
		vline(screen, x+7, y+1, y+h-2, white);
		hline(screen, x+7, y+h-1, x+w-5, check_gray1);
		vline(screen, x+w-5, y, y+h-1, check_gray1);
		rectgouraud(screen, x+8, y+2, x+w-6, y+h-2, &scrollbar_gray_range, FALSE);
	    }
	    else {
		hline(screen, x+6, y, x+w-4, white);
		hline(screen, x+6, y+h-1, x+w-4, check_gray1);
		rectgouraud(screen, x+6, y+1, x+w-4, y+h-2, &menu_gray_range, FALSE);
	    }
	}
	else {
	    if (!(m->flags & D_DISABLED)) {
		if (sel)
		    rectfill(screen, x+3, y+1, x+w-5, y+h-4, highlight);
		else
		    rectfill(screen, x+3, y+1, x+w-5, y+h-4, menu_gray_to);
	    }
	}

	rtm = text_mode(-1);

	i = 0;
	j = ugetc(m->text);

	while ((j) && (j != '\t')) {
	    i += usetc(buf+i, j);
	    j = ugetc(m->text+i);
	}

	usetc(buf+i, 0);

	if (bar)
	    photon_textout(screen, buf, x+9, y+1, m->flags, FALSE);
	else
	    photon_textout(screen, buf, x+4, y+1, m->flags, FALSE);

	if (j == '\t') {
	    tok = m->text+i + uwidth(m->text+i);
	    photon_textout(screen, tok, x+w-gui_strlen(tok)-15, y+1, m->flags, FALSE);
	}

	text_mode(rtm);

	if ((m->child) && (!bar))
	    draw_sprite(screen, menu_arrow_bmp, x+w-12, y+(h-menu_arrow_bmp->h-1)/2);
    }
    else {
	height = text_height(font);
	hline(screen, x, y+height/2-1, x+w-1, check_gray1);
	hline(screen, x, y+height/2, x+w-1, container_black);
	hline(screen, x, y+height/2+1, x+w-1, white);
    }

    if (m->flags & D_SELECTED) {
	height = text_height(font);
	line(screen, x+w-10, y+height/2, x+w-8, y+height, checked_gray);
	line(screen, x+w-8, y+height, x+w-5, y+1, checked_gray);
    }
}
Пример #24
0
void Faster_clearing(short x, short y, unsigned short w, unsigned short h)
{
	rectfill(screen, x, y, x+w, x+y, 0);
}
Пример #25
0
void main()
{
    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();
    set_color_depth(32);
    set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
    srand(time(NULL)+clock());
    text_mode(-1);

    buffer = create_bitmap(WIDTH, HEIGHT);

    textprintf_centre(screen, font, 320, 200, WHITE, "-Endless Tower-");

    textprintf_centre(screen, font, 320, 240, WHITE, "press enter to start");

    while (!key[KEY_ENTER])
    {}

    for(int i = 0; i < 13; i++)
    {
        land[i].y = rand() % HEIGHT;
        land[i].x = ((rand()%300)*2) + 20;
        land[i].w = (rand()%20) + 20;
    }
    land[13].y = y + 10;
    land[13].x = x;
    land[13].w = 45;

    rest(50);

    while (!key[KEY_ESC])
    {
        start_time = clock();

        /*game goes here*/
        //move left
        if (key[KEY_LEFT])
            x -= 10;

        //move right
        if (key[KEY_RIGHT])
            x += 10;

        //jump
        if ((!jump)&&(key[KEY_SPACE]))
        {
            jump = true;
            jumpforce = 60;
        }

        if ((jump)&&(key[KEY_SPACE]))
        {
            jumpforce += 1;
        }

        //speed up!
        speed = 3 + (game_time/20000);

        //fall
        if (jump)
        {
            jumpforce -= 3;
        }
        if (!jump)
            jumpforce = -12;
        y -= jumpforce/4;

        //drop platforms down
        add_platform();
        for (int i = 0; i < 14; i++)
        {
            land[i].y += speed;
        }

        //collision
        on_land = 0;
        for (int i = 0; i < 14; i++)
        {
            if ((y > land[i].y - 20)&&(y < land[i].y))
            {
                if ((x < land[i].x + land[i].w)&&(x > land[i].x - land[i].w))
                {
                    if (jumpforce < 5)
                    {
                        jump = false;
                    }
                    jumpforce = -speed*3;
                    on_land += 1;
                }
            }
        }
        if (on_land == 0)
            jump = true;
        //warp
        if (x < 0)
            x = 0;
        if (x > WIDTH)
            x = WIDTH;

        //die
        if (y > HEIGHT)
            return;

        /*drawing goes here*/
        rectfill(buffer, 0, 0, WIDTH, HEIGHT, BLACK);
        circlefill(buffer, x, y, 10, WHITE);
        textprintf(buffer, font, 320, 20, WHITE, "%i'%i", game_time/60000, (game_time/1000)%60);

        for (int i = 0; i < 14; i++)
        {
            hline(buffer, land[i].x - land[i].w, land[i].y, land[i].x + land[i].w, WHITE);
        }

        blit(buffer, screen, 0, 0, 0, 0, WIDTH, HEIGHT);

        game_time += 20;
        while (clock() < start_time + 20)
        {}
    }
    destroy_bitmap(buffer);
    return;
}
Пример #26
0
void Draw_Pixel(unsigned short x, unsigned short y, unsigned char R, unsigned char G, unsigned char B)
{
	int color = makecol(R,G,B);
	rectfill(screen, x, y, x+1, x+1, color);
}
void SnakeLink::drawLink(BITMAP* buffer)
{
    rectfill(buffer, x, y, x + 32, y + 32, makecol(0, 255, 0));
}
Пример #28
0
int main(void) {
    int cig;

    printf("Quantos cigarros poderam ser feitos?\n"); 
    scanf("%d", &cig);

    pthread_t t_agentea, t_agenteb, t_agentec, t_fumantea, t_fumanteb, 
t_fumantec, t_pushera, t_pusherb, t_pusherc;
    
    pthread_mutex_init(&mutex, NULL);
    pthread_mutex_init(&global, NULL);
    
    sem_init(&agente, 0, 1);
    sem_init(&fosforo, 0, 0);
    sem_init(&papel, 0, 0);
    sem_init(&tabaco, 0, 0);
    sem_init(&fosforo_sem, 0, 0);
    sem_init(&papel_sem, 0, 0);
    sem_init(&tabaco_sem, 0, 0);
    sem_init(&anima_sem, 0, 0);

    int count;

    if (cig > 0) {
        for (count = 0; count < cig; ++count) sem_post(&anima_sem);
    } else sem_post(&anima_sem);

    isTobacco = isPaper = isMatch = 0;
    
    pthread_create(&t_agentea, NULL, agente_a, NULL);
    pthread_create(&t_agenteb, NULL, agente_b, NULL);
    pthread_create(&t_agentec, NULL, agente_c, NULL);
    pthread_create(&t_fumantea, NULL, fumante_a, NULL);
    pthread_create(&t_fumanteb, NULL, fumante_b, NULL);
    pthread_create(&t_fumantec, NULL, fumante_c, NULL);
    pthread_create(&t_pushera, NULL, pusher_a, NULL);
    pthread_create(&t_pusherb, NULL, pusher_b, NULL);
    pthread_create(&t_pusherc, NULL, pusher_c, NULL);
    
    allegro_init();
    
    install_timer();
    install_keyboard();
    
    allegro_fim = 0;
    
    set_color_depth(32);
    
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) != 0) {
        //abort_on_error("Couldn't set a 32 bit color resolution");
    }
    
    set_window_title("Problema dos Fumantes - Pressione ESC para sair");
    
    int x = 0, y = 0, timestamp = 0;
    
    BITMAP *agente_b, *smoking, *smoking_not, *matches, 
*paper, *tabaco_b, *gear;

    agente_b = load_bmp("bitmaps/agent_b.bmp", NULL);
    smoking = load_bmp("bitmaps/smoking.bmp", NULL);
    smoking_not = load_bmp("bitmaps/smoking_not.bmp", NULL);
    matches = load_bmp("bitmaps/matches.bmp", NULL);
    paper = load_bmp("bitmaps/paper.bmp", NULL);
    tabaco_b = load_bmp("bitmaps/tobacco.bmp", NULL);
    gear = load_bmp("bitmaps/gear.bmp", NULL);
    
    int passos, passos_total = 27;
    
    while (!key[KEY_ESC]) {
        BITMAP *buffer = create_bitmap(SCREEN_W, SCREEN_H);
        
        pthread_mutex_lock(&global);

	rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, makecol(255, 255, 255));
        
        draw_sprite(buffer, tabaco_b, 490, 90);
        draw_sprite(buffer, paper, 490, 230);
        draw_sprite(buffer, matches, 490, 390);

	//textprintf_ex(buffer, font, 10, 10, makecol(255, 100, 200),
	//	    -1, "Tempo: %d", timestamp/20);
		

	
        
        //printf("ALLEGRO\n");
        //imprime_estado_global();  
        
        int offsets[3];
        
        offsets[0] = 10;
        offsets[1] = 180;
        offsets[2] = 330;
        
        for (x = 0; x < 3; ++x) {
            if (estado_global[x] == Esperando) {
                draw_sprite(buffer, smoking_not, 550, offsets[x]);
            } else if (estado_global[x] == Fumando) {
                draw_sprite(buffer, smoking, 550, offsets[x]);
            }       
        }

        
        /* Desenha o Agente*/
        draw_sprite(buffer, agente_b, 0, 135);
        
        /* Desenha os ingredientes disponiveis */
        if (disponivel[Tabaco] == 1) {
            draw_sprite(buffer, tabaco_b, 150, 175+0);
        }
        
        if (disponivel[Fosforo] == 1) {
            draw_sprite(buffer, matches, 150, 175+35);
        }
        
        if (disponivel[Papel] == 1) {
            draw_sprite(buffer, paper, 150, 175+90);
        }
        
        	/* Anima os fumantes */
        desenha_fumante(buffer, smoking, smoking_not, gear, Tabaco, passos, passos_total, 10);
        desenha_fumante(buffer, smoking, smoking_not, gear, Papel, passos, passos_total, 180);
        desenha_fumante(buffer, smoking, smoking_not, gear, Fosforo, passos, passos_total, 330);
        
        /* Fim dos desenhos */
        
        pthread_mutex_unlock(&global);
        
        blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h);
        
        ++timestamp;
        
        timestamp = timestamp % 32000;
        
        rest_callback(50, callback);
    }
    
    allegro_fim = 1;
    
    pthread_join(t_fumantea, NULL);
    pthread_join(t_fumanteb, NULL);
    pthread_join(t_fumantec, NULL);
    
    pthread_mutex_destroy(&mutex);
    pthread_mutex_destroy(&global);
    
    sem_destroy(&agente);
    sem_destroy(&fosforo);
    sem_destroy(&papel);
    sem_destroy(&tabaco);
    sem_destroy(&fosforo_sem);
    sem_destroy(&papel_sem);
    sem_destroy(&tabaco_sem);
    
    return 0;
}
Пример #29
0
/**
 * Draw inventory-grid for belt, backpack, armory etc.
 */
void Place::drawgrid(BITMAP *dest, int PLACE_NUM)
{
    ASSERT((PLACE_NUM >= 0) && (PLACE_NUM <= NUMBER_OF_PLACES));

    if (PLACE_NUM == P_ARMOURY) {
        const char *eqname = get_current_equipment_name();
        if (!eqname) eqname = _("(none, remote player doesn't have any of your weaposets)");
        textprintf(dest, g_small_font, gx, gy + 1 - text_height(g_small_font), COLOR_WHITE,
            _("Weapon set: %s"), eqname);
    } else {
        textout(dest, g_small_font, place_name[PLACE_NUM], gx, gy + 1 - text_height(g_small_font), COLOR_LT_OLIVE);
    }

    if (!ishand()) {
        int dx = 0, dy = 0;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (!outside_belt(j, i))
                    rect(dest, gx + dx, gy + dy, gx + dx + 16, gy + dy + 15, COLOR_GRAY08);      //square
                dx += 16;
                if (j == 19) break;      // for map cell!!!!!!!!!!!!!!!!!!!
            }
            dx = 0;
            dy += 15;
        }
    } else {
        rect(dest, gx, gy, gx + width * 16, gy + height * 15, COLOR_GRAY08);
    }

    // Draw items in grid:
    Item *t = m_item;
    while (t != NULL) {
        if ((t->m_x >= viscol - 1) && (t->m_x < viscol + 20)) {

            if (!is_item_allowed(t->itemtype())) {
                int x = gx + (t->m_x - viscol) * 16;
                int y = gy + t->m_y * 15;
                int sx = t->obdata_width() * 16;
                int sy = t->obdata_height() * 15;
                if (ishand()) {
                    x = gx;
                    y = gy;
                    sx = width * 16;
                    sy = height * 15;
                }
                rectfill(dest, x + 1, y + 1, x + sx - 1, y + sy - 1, COLOR_RED06);
            }

            int x = gx + (t->m_x - viscol) * 16;
            int y = gy + t->m_y * 15 + 5;

            if (ishand()) {
                int it_width = t->obdata_width();
                int it_height = t->obdata_height();
                x = gx + (width - it_width) * 16 / 2;
                y = gy + (height - it_height) * 15 / 2 + 5;
            }

            PCK::showpck(dest, t->obdata_pInv(), x, y);  // Picture of item

            if (ishand()) { // Inventory-view: display ammo-rounds & grenade-delay
                if (t->clip() != NULL) {   // see also: Soldier::drawinfo()
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_WHITE, t->roundsremain() );
                    textout(dest, g_small_font, t->get_damage_name(), gx + 3, gy + 36, COLOR_GREEN);
                }
                if (t->obdata_isAmmo() ) {   // Test
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_WHITE, t->m_rounds );
                }
                if (t->is_grenade() ) {  // see also: icon.h : DrawPrimed
                    if (t->delay_time() > 0)
                    printsmall_x(dest, gx + 23, gy + 39, COLOR_RED, t->delay_time() - 1);
                    else if (t->is_proximity_grenade() && t->delay_time() < 0)
                    textout(dest, g_small_font, "*", gx + 23, gy + 36, COLOR_RED);
                }
            }

            if (key[KEY_LCONTROL]) {
                t->draw_health(dest, 1, x + 1, y - 4);
            }
            if (key[KEY_ALT]) {
                t->draw_health(dest, 0, x + 1, y - 4);
            }
        }
        t = t->m_next;
    }
}
Пример #30
0
Файл: sgame.c Проект: rj76/kq
/*! \brief Display saved game statistics
 *
 * This is the routine that displays the information about
 * each saved game for the save/load screen.
 *
 * \param   saving 0 if loading, 1 if saving.
 */
static void show_sgstats (int saving)
{
   int a, sg, hx, hy, b;
   int pointer_offset;

   /* TT UPDATE:
    * More than 5 save states!  Hooray!
    *
    * Details of changes:
    *
    * If we want to have, say, 10 save games instead of 5, we can only show
    * 5 on the screen at any given time.  Therefore, we will need to print the
    * menuboxes 0..4 and have an up/down arrow indicator to show there are
    * more selections to choose from.
    *
    * To draw the menuboxes, we need to keep track of the TOP visible savegame
    * (0..5), and alter the rest accordingly.
    *
    * When the 5th on-screen box is selected and DOWN is pressed, move down by
    * one menubox (shift all savegames up one) so 1..5 are showing (vs 0..4).
    * When the 5th on-screen box is SG9 (10th savegame), loop up to the top of
    * the savegames (save_ptr=0, top_pointer=0).
    */

   pointer_offset = (save_ptr - top_pointer) * 48;
   if (saving == 0) {
      menubox (double_buffer, 0, pointer_offset + 12, 7, 1, BLUE);
      print_font (double_buffer, 8, pointer_offset + 20, _("Loading"), FGOLD);
   } else if (saving == 1) {
      menubox (double_buffer, 8, pointer_offset + 12, 6, 1, BLUE);
      print_font (double_buffer, 16, pointer_offset + 20, _("Saving"), FGOLD);
   } else if (saving == 2 || saving == 3) {
      menubox (double_buffer, 8, pointer_offset + 12, 6, 1, BLUE);
      print_font (double_buffer, 16, pointer_offset + 20, _("Delete"), FRED);
   }

   if (top_pointer > 0)
      draw_sprite (double_buffer, upptr, 32, 0);
   if (top_pointer < NUMSG - max_onscreen)
      draw_sprite (double_buffer, dnptr, 32, 240 - 8);

   for (sg = top_pointer; sg < top_pointer + max_onscreen; sg++) {
      pointer_offset = (sg - top_pointer) * 48;
      if (sg == save_ptr)
         menubox (double_buffer, 72, pointer_offset, 29, 4, DARKBLUE);
      else
         menubox (double_buffer, 72, pointer_offset, 29, 4, BLUE);

      if (snc[sg] == -1)
         print_font (double_buffer, 136, pointer_offset + 20, _("Wrong version"),
                     FNORMAL);
      else {
         if (snc[sg] == 0)
            print_font (double_buffer, 168, pointer_offset + 20, _("Empty"),
                        FNORMAL);
         else {
            for (a = 0; a < snc[sg]; a++) {
               hx = a * 72 + 84;
               hy = pointer_offset + 12;
               draw_sprite (double_buffer, frames[sid[sg][a]][1], hx, hy + 4);
               sprintf (strbuf, _("L: %02d"), slv[sg][a]);
               print_font (double_buffer, hx + 16, hy, strbuf, FNORMAL);
               print_font (double_buffer, hx + 16, hy + 8, _("H:"), FNORMAL);
               print_font (double_buffer, hx + 16, hy + 16, _("M:"), FNORMAL);
               rectfill (double_buffer, hx + 33, hy + 9, hx + 65, hy + 15, 2);
               rectfill (double_buffer, hx + 32, hy + 8, hx + 64, hy + 14, 35);
               rectfill (double_buffer, hx + 33, hy + 17, hx + 65, hy + 23, 2);
               rectfill (double_buffer, hx + 32, hy + 16, hx + 64, hy + 22, 19);
               b = shp[sg][a] * 32 / 100;
               rectfill (double_buffer, hx + 32, hy + 9, hx + 32 + b, hy + 13, 41);
               b = smp[sg][a] * 32 / 100;
               rectfill (double_buffer, hx + 32, hy + 17, hx + 32 + b, hy + 21, 25);
            }
            sprintf (strbuf, _("T %d:%02d"), shr[sg], smin[sg]);
            print_font (double_buffer, 236, pointer_offset + 12, strbuf,
                        FNORMAL);
            sprintf (strbuf, _("G %d"), sgp[sg]);
            print_font (double_buffer, 236, pointer_offset + 28, strbuf,
                        FNORMAL);
         }
      }
   }
}