Exemplo n.º 1
0
Arquivo: main.c Projeto: wjwwood/agame
int agame_msg(char const * msg, ALLEGRO_FONT * font) {
  int w = al_get_display_width(display);
  int h = al_get_display_height(display);
  // Draw the bounding box
  al_draw_filled_rounded_rectangle(0, h - h/3.0, w, h,
                                   10, 10, al_map_rgb(120, 120, 120));
  al_draw_filled_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5,
                                   10, 10, al_map_rgb(230, 230, 230));
  al_draw_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5,
                            10, 10, al_map_rgb(0, 0, 0), 3);
  al_draw_justified_text(font, al_map_rgb(0, 0, 0), 10, w - 10,
                         h - h/3.0 + 10, 16, 0, msg);
  return 1;
}
Exemplo n.º 2
0
    void ProgressBar::Print()
    {
        wd_PrintBegin();

        if(value < 0)
        {
            value = 0;
        }
        else if(value >100)
        {
            value = 100;
        }

        wd_Print_Background();
        wd_Print_Frame();

        if(value > 0)
        {
             al_draw_filled_rounded_rectangle(wd_theme.added_thickness/2 + wd_theme.thickness +1,
                                              wd_theme.added_thickness/2 + wd_theme.thickness +1,
                            (wd_theme.added_thickness/2 + wd_theme.thickness +1.0f)+ ((wd_theme.added_thickness/2 + wd_width - wd_theme.thickness -1.0f)-(wd_theme.added_thickness/2 + wd_theme.thickness +1))*((float)value/100.0f),
                            wd_theme.added_thickness/2 + wd_height - wd_theme.thickness -1 ,
                            wd_theme.roundx, wd_theme.roundy, wd_theme.c_text);
        }

        wd_PrintEnd();
    }
Exemplo n.º 3
0
   static void draw(float x, float y)
   {
      float w = 300;
      float line_height = 25;
      float pad = 20;
      float h = Profiler::get_instance()->timer.size()*line_height + pad*2;
      PROFILE_TIMER_TIME_T duration = 0.0;
      int i=0;
      char time[32];

      al_draw_filled_rounded_rectangle(x, y, x+w, y+h, 8, 8, bg_color);

      //if (!font) return;

      std::vector<profile_timer_class *>::iterator it = Profiler::get_instance()->timer.begin();
      for ( ; it != get_instance()->timer.end(); ++it)
      {
         duration = (*it)->stop_time - (*it)->start_time;
         al_draw_filled_rectangle(x, y+pad+line_height*i+15, x+duration*10000, y+pad+line_height*i+20, al_color_name("orange"));
         al_draw_text(font, font_color, x+pad, y+pad+line_height*i, 0, (*it)->name);
         sprintf(time, "%f", duration*100);
         al_draw_text(font, font_color, x+pad+200, y+pad+line_height*i, 0, time);
         i++;
      }
      al_draw_line(x+ALLEGRO_BPS_TO_SECS(60)*10000, y, x+ALLEGRO_BPS_TO_SECS(60)*10000, y+h, limit_bar_color, 1.0);
      al_draw_line(x+ALLEGRO_BPS_TO_SECS(72)*10000, y, x+ALLEGRO_BPS_TO_SECS(72)*10000, y+h, limit_bar_color, 1.0);
   }
   void on_draw()
   {
      if (delete_me) return;

      al_draw_filled_rounded_rectangle(0, 0, place.size.x, place.size.y, 6, 6, color::hex("#fce566", opacity));
      al_draw_text(font, color::hex("645710", opacity), 23, 20, 0, text.c_str());
   }
Exemplo n.º 5
0
 void Widget::wd_Print_ClickingShadow()
 {
     al_draw_filled_rounded_rectangle(wd_theme.added_thickness/2+1,
                                       wd_theme.added_thickness/2+1,
                                       wd_width + wd_theme.added_thickness/2-1,
                                       wd_height + wd_theme.added_thickness/2-1,
                             wd_theme.roundx, wd_theme.roundy, wd_theme.c_clicking);
 }
Exemplo n.º 6
0
 void Widget::wd_Print_Background()
 {
      al_draw_filled_rounded_rectangle( wd_theme.added_thickness/2+1 ,
                                       wd_theme.added_thickness/2,
                                       wd_width + wd_theme.added_thickness/2 ,
                                       wd_height + wd_theme.added_thickness/2-1,
                                       wd_theme.roundx, wd_theme.roundy, wd_theme.c_background);
 }
Exemplo n.º 7
0
void MultiplayerModeStage::Render()
{
	ALLEGRO_FONT* optionFont = Framework::SystemFramework->GetFontManager()->GetFont( "resource/falsepos.ttf", Framework::SystemFramework->GetDisplayHeight() / 12, 0 );

	Framework::SystemFramework->ProgramStages->Previous( this )->Render();
	al_draw_filled_rectangle( 0, 0, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight(), al_map_rgba( 0, 0, 0, 128 ) );

	int boxW = Framework::SystemFramework->GetDisplayWidth() / 2.5;
	int boxH = Framework::SystemFramework->GetDisplayHeight() / 4;

	al_draw_filled_rounded_rectangle( (Framework::SystemFramework->GetDisplayWidth() / 2) - boxW - 3, (Framework::SystemFramework->GetDisplayHeight() / 2) - (boxH / 2), (Framework::SystemFramework->GetDisplayWidth() / 2) - 3, (Framework::SystemFramework->GetDisplayHeight() / 2) + (boxH / 2), 8, 8, (Selected == 0 ? al_map_rgb( 255, 255, 255 ) : al_map_rgb( 0, 0, 0 )) );
	al_draw_filled_rounded_rectangle( (Framework::SystemFramework->GetDisplayWidth() / 2) + 3, (Framework::SystemFramework->GetDisplayHeight() / 2) - (boxH / 2), (Framework::SystemFramework->GetDisplayWidth() / 2) + boxW + 3, (Framework::SystemFramework->GetDisplayHeight() / 2) + (boxH / 2), 8, 8, (Selected == 1 ? al_map_rgb( 255, 255, 255 ) : al_map_rgb( 0, 0, 0 )) );

	al_draw_text( optionFont, (Selected != 0 ? al_map_rgb( 255, 255, 255 ) : al_map_rgb( 0, 0, 0 )), (Framework::SystemFramework->GetDisplayWidth() / 2) - boxW, (Framework::SystemFramework->GetDisplayHeight() / 2), 0, "Last Man Standing" );
	al_draw_text( optionFont, (Selected != 1 ? al_map_rgb( 255, 255, 255 ) : al_map_rgb( 0, 0, 0 )), (Framework::SystemFramework->GetDisplayWidth() / 2) + 3, (Framework::SystemFramework->GetDisplayHeight() / 2), 0, "Team Battles" );

}
Exemplo n.º 8
0
void SpeakingAgent::draw()
{
   // store state
   placement2d::start_transform();

   // background
   al_draw_filled_rectangle(0, 0, size.x, size.y, color::hex("319cff"));

   // mouth
   ALLEGRO_BITMAP *mouth_shape = _get_phoneme_image(Speaker::get_current_phoneme());
   if (mouth_shape) al_draw_bitmap(mouth_shape, 0, 10, NULL);

   // eyes
   float eye_y = size.y/4;
   float eye_r = 2.3;
   float eye_1x = size.x/4;
   float eye_2x = size.x/4 * 3;
   if (blink_counter < 0.1)
   {
      al_draw_line(eye_1x-eye_r*2, eye_y, eye_1x+eye_r*2, eye_y, color::black, eye_r);
      al_draw_line(eye_2x-eye_r*2, eye_y, eye_2x+eye_r*2, eye_y, color::black, eye_r);
      if (blink_counter < 0.0) blink_counter = random_double(2.0, 6.0);
   }
   else
   {
      al_draw_filled_circle(eye_1x, eye_y, eye_r, color::black);
      al_draw_filled_circle(eye_2x, eye_y, eye_r, color::black);
   }
   blink_counter -= 1.0/60;

   // words
   float bx = size.x+size.x/4;
   float by = -size.y/3;
   float bw = size.x*2.5;
   float bh = size.y*0.8;
   float border_radius = 7;
   al_draw_filled_rounded_rectangle(bx, by, bx+bw, by+bh, border_radius, border_radius, color::white);
   float tx = bx+border_radius*4;
   float ty = by+bh-1;
   float ts = 20;
   al_draw_filled_triangle(tx, ty, tx+ts, ty, tx, ty+ts, color::white);
   std::string word = Speaker::get_current_word();
   ALLEGRO_FONT *font = fonts["lacuna.ttf 26"];
   if (is_paused()) word = "[PAUSED]";
   if (font) al_draw_text(font, color::black, bx+bw/2, by+bh/2-al_get_font_line_height(font)/2, ALLEGRO_ALIGN_CENTRE, word.c_str());

   // show stream #
   //al_draw_text(font, color::white, 0, 0, NULL, tostring(voice->get_current_stream()).c_str());

   // restore state
   placement2d::restore_transform();

   //draw_crosshair(x, y, color::white);
}
Exemplo n.º 9
0
void ProfileTab::Render(float Alpha)
{
	if( !MenuStage->Device->Profile.IsObject() || MenuStage->Device->Profile.HasParseError() )
	{
		al_draw_filled_rounded_rectangle( 10, (Dimensions.Y / 2) - 36, Dimensions.X - 10, (Dimensions.Y / 2) + 36, 8, 8, al_map_rgb( 128, 80, 64 ) );
		al_draw_text( Fonts->GetFont( "Resource/anonymous_pro.ttf", 64, 0 ), al_map_rgb( 255, 192, 128 ), (Dimensions.X / 2),  (Dimensions.Y / 2) - 32, ALLEGRO_ALIGN_CENTER, "No Profile Found!" );
	} else {

		ALLEGRO_BITMAP* pImg = Images->GetImage( CurrentConfiguration->ProfileImage );

		al_draw_filled_rounded_rectangle( 10, 10, Dimensions.X - 10, 163, 8, 8, al_map_rgb( 64, 80, 128 ) );
		al_draw_filled_rounded_rectangle( 15, 15, 163, 158, 8, 8, al_map_rgb( 160, 192, 220 ) );
		al_draw_filled_rounded_rectangle( 20, 20, 158, 153, 8, 8, al_map_rgb( 255, 255, 255 ) );
		al_draw_scaled_bitmap( pImg, 0, 0, al_get_bitmap_width( pImg ), al_get_bitmap_height( pImg ), 20, 20, 128, 128, 0 );

		al_draw_text( Fonts->GetFont( "Resource/anonymous_pro.ttf", 64, 0 ), al_map_rgb( 255, 192, 128 ), 170,  10, ALLEGRO_ALIGN_LEFT, MenuStage->Device->Profile["shortname"].GetString() );
		al_draw_text( Fonts->GetFont( "Resource/anonymous_pro.ttf", 64, 0 ), al_map_rgb( 255, 192, 128 ), 170,  74, ALLEGRO_ALIGN_LEFT, MenuStage->Device->Profile["longname"].GetString() );

		// TODO: Draw any scores or positions or something???
	}
}
Exemplo n.º 10
0
static duk_ret_t
js_RoundRectangle(duk_context* ctx)
{
	int x = duk_require_int(ctx, 0);
	int y = duk_require_int(ctx, 1);
	int w = duk_require_int(ctx, 2);
	int h = duk_require_int(ctx, 3);
	float radius = duk_require_number(ctx, 4);
	color_t color = duk_require_sphere_color(ctx, 5);

	if (!is_skipped_frame())
		al_draw_filled_rounded_rectangle(x, y, x + w, y + h, radius, radius, nativecolor(color));
	return 0;
}
Exemplo n.º 11
0
void MultipleControllerSelectStage::Render()
{
	GameStage* g = (GameStage*)Framework::SystemFramework->ProgramStages->Previous( this );
	g->Render();
	al_draw_filled_rectangle( 0, 0, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight(), al_map_rgba( 0, 0, 0, 128 ) );

	int boxW = Framework::SystemFramework->GetDisplayWidth() / 5;
	int boxH = Framework::SystemFramework->GetDisplayHeight() / 4;
	std::list<Plane*>* players = g->GetPlaneObjects();
	ALLEGRO_BITMAP* tileset = g->GetGameScaledImage();

	int i = 0;
	for( std::list<Plane*>::const_iterator p = players->begin(); p != players->end(); p++ )
	{
		al_draw_filled_rounded_rectangle( (boxW * (i % 5)) + 2, (boxH * (i / 5)) + 2, (boxW * (i % 5)) + boxW - 2, (boxH * ((i + 5) / 5)) - 2, 6, 6, al_map_rgba( 255, 255, 255, 128 ) );

		Plane* ply = (Plane*)*p;
		int tileX = 144 * g->graphicsMultiplier;
		int tileY = (ply->Team * 48) * g->graphicsMultiplier;
		ALLEGRO_BITMAP* tmp = al_create_sub_bitmap( tileset, tileX, tileY, 48 * g->graphicsMultiplier, 48 * g->graphicsMultiplier );
		al_draw_scaled_bitmap( tmp, 0, 0, 48 * g->graphicsMultiplier, 48 * g->graphicsMultiplier, (boxW * (i % 5)) + 4, (boxH * (i / 5)) + 4, boxW - 4, boxH - 4, 0 );
		al_destroy_bitmap( tmp );
		i++;
	}


	ALLEGRO_FONT* survivalFont = Framework::SystemFramework->GetFontManager()->GetFont( "resource/falsepos.ttf", Framework::SystemFramework->GetDisplayHeight() / 18, 0 );
	ALLEGRO_COLOR survivalBorder = al_map_rgb( 0, 0, 0 );
	ALLEGRO_COLOR survivalNormal = al_map_rgb( 255, 255, 255 );

	int Xpos = (Framework::SystemFramework->GetDisplayWidth() / 2) - (al_get_text_width( survivalFont, "Press Enter To Start" ) / 2);
	int Lsiz = al_get_font_line_height( survivalFont );

	for( int yBrd = -1; yBrd < 2; yBrd++ )
	{
		for( int xBrd = -1; xBrd < 2; xBrd++ )
		{
			al_draw_text( survivalFont, survivalBorder, Xpos + xBrd, Framework::SystemFramework->GetDisplayHeight() - Lsiz - 6 + yBrd, 0, "Press Enter To Start" );
		}
	}

	al_draw_text( survivalFont, survivalNormal, Xpos, Framework::SystemFramework->GetDisplayHeight() - Lsiz - 6, 0, "Press Enter To Start" );


}
Exemplo n.º 12
0
static void draw_square(Square *sq)
{
   ALLEGRO_TRANSFORM trans;
   float alpha;
   float size;
   ALLEGRO_COLOR tint;

   al_build_transform(&trans, sq->cx, sq->cy, 1.0, 1.0, sq->rot);
   al_use_transform(&trans);

   alpha = sin(sq->life);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ONE);
   tint = al_map_rgba_f(0.5, 0.3, 0, alpha);

   size = sq->size;
   al_draw_filled_rounded_rectangle(-size, -size, size, size, 3, 3, tint);

   size *= 1.1;
   al_draw_rounded_rectangle(-size, -size, size, size, 3, 3, tint, 2);
}
Exemplo n.º 13
0
void Slot::Draw(ALLEGRO_FONT * a_pFont)
{
     if (m_blHighLight)
    {
       al_draw_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                     m_pParent->m_ColorHighlight,2);

    }
    else
    {
        al_draw_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                    m_pParent->m_ColorOuter,2);


    }

     al_draw_filled_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                     m_pParent->m_ColorInner);

   if (a_pFont != NULL)
   {
      al_draw_text(a_pFont,
                   m_pParent->m_ColorOuter,
                   m_nX + (m_nWidth/2), m_nY + (m_nHeight/4),
                   ALLEGRO_ALIGN_CENTRE,
                   m_strCaption.c_str());

   }
}
Exemplo n.º 14
0
void S_Settings::Draw() 
{
    static Bitmap bg(BITMAP_MENU_BACKGROUND);
    bg.Draw();

    al_draw_filled_rounded_rectangle(40, 40, 800-40, 600-40, 10, 10, al_map_rgba(0, 0, 0, 175));

    al_draw_textf(Fonts::GetFont(30), al_map_rgb(255,255,255), 800-80, 80, ALLEGRO_ALIGN_RIGHT, GetStr(STR_ACTUAL_F).c_str(), Localization::Instance()->GetCurrentLanguage().c_str());

    for (std::vector<RectButton*>::const_iterator itr = _buttons.begin(); itr != _buttons.end(); ++itr)
        (*itr)->Draw();

    _buttons.back()->SetText(GetStr(STR_SOUND)); // this will be the sound button

    // triangle1 points
    int ux1 = 570;
    int uy1 = 182;
    int ux2 = ux1 + 17;
    int uy2 = uy1 + 15;
    int ux3 = ux1 - (ux2 - ux1);
    int uy3 = uy2;

    // triangle2 points
    int bx1 = ux1;
    int by1 = 261;
    int bx2 = ux1 + 17;
    int by2 = by1 - 15;
    int bx3 = bx1 - (bx2 - bx1);
    int by3 = by2;

    al_draw_filled_triangle(ux1, uy1, ux2, uy2, ux3, uy3, al_map_rgb(0, 255, 0));
    al_draw_filled_triangle(bx1, by1, bx2, by2, bx3, by3, al_map_rgb(0, 255, 0));

    

    if (BlackJack::Instance()->GetMute()) al_draw_line(0+488, 5+308, Fonts::GetFont(20)->vtable->text_length(Fonts::GetFont(20), al_ustr_new(GetStr(STR_SOUND).c_str()))+488+10, 25+308, al_map_rgb(255,255,255), 2.0);

    al_draw_text(Fonts::GetFont(25), al_map_rgb(255, 255, 255), 488, 208, 0, GetStr(STR_BET).c_str());
    al_draw_textf(Fonts::GetFont(25), al_map_rgb(255, 255, 100), 570, 208, 0, "%2.0f", S_Game::GetBet());
}
Exemplo n.º 15
0
void shal_draw_filled_rounded_rectangle(float x1,
                                        float y1,
                                        float x2,
                                        float y2,
                                        float rx,
                                        float ry,
                                        float color_r,
                                        float color_g,
                                        float color_b,
                                        float color_a)
{
    ALLEGRO_COLOR color;
    color.r = color_r;
    color.g = color_g;
    color.b = color_b;
    color.a = color_a;
    return al_draw_filled_rounded_rectangle(x1,
                                            y1,
                                            x2,
                                            y2,
                                            rx,
                                            ry,
                                            color);
}
Exemplo n.º 16
0
static void HighFilledPrimitives(int mode)
{
   if (mode == INIT) {
   
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, 1, 1, Theta);
   } else if (mode == DRAW) {
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
      
      al_use_transform(&MainTrans);
      
      al_draw_filled_triangle(-100, -100, -150, 200, 100, 200, al_map_rgb_f(0.5, 0.7, 0.3));
      al_draw_filled_rectangle(20, -50, 200, 50, al_map_rgb_f(0.3, 0.2, 0.6));
      al_draw_filled_ellipse(-250, 0, 100, 150, al_map_rgb_f(0.3, 0.3, 0.3));
      al_draw_filled_rounded_rectangle(50, -250, 350, -75, 50, 70, al_map_rgb_f(0.4, 0.2, 0));
      al_draw_filled_pieslice(200, 125, 50, ALLEGRO_PI / 4, 3 * ALLEGRO_PI / 2, al_map_rgb_f(0.3, 0.3, 0.1));
      
      al_use_transform(&Identity);
   }
}
Exemplo n.º 17
0
void bn_desenhaBloco(const BN_BLOCO* b)
{
    switch(b->tipo)
    {
        case 1: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(0, 0, .5, 1));
        break;
        
        case 2: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(0, 0, .6, 1));
        break;
        
        case 3: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(0, 0, .7, 1));
        break;
        
        case 4: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(0, 0, .8, 1));
        break;

        case 5: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(0, 0, .9, 1));
        break;

        case 6: al_draw_filled_rounded_rectangle(b->x - b->larg, b->y - b->alt,
                                                    b->x + b->larg, b->y + b->alt,
                                                    2, 2, al_map_rgba_f(1, 0, 0, 1));
        al_draw_filled_circle(b->x, b->y, b->alt - 2, al_map_rgb_f(1, .7, .1));
        break;
        default: break;
    }
}
Exemplo n.º 18
0
void outputArray (pixel **array, int altura, int largura, int indice, int player_x, int player_x2, int player_y, int player_y2, int tamPixel) {
    ALLEGRO_COLOR terra = al_map_rgb(110, 60, 40);      /* Cores */
    ALLEGRO_COLOR agua = al_map_rgb(51, 153, 255);
    ALLEGRO_COLOR ilha = al_map_rgb(6, 96, 0);
    ALLEGRO_COLOR canoa = al_map_rgb(51, 51, 51);
    
    int i, j;
    int ilha0 = 999999, ilhaf = 0;      /* Variáveis que guardam o começo de uma ilha e o final dela */
    
    
    int playerSize = tamPixel + largura*0.1;
    if(playerSize > 30) playerSize = 30;
    
    al_clear_to_color(agua);
    
    for (i = 0; i < altura; i ++) { /* Imprime uma linha de cada vez */
        
        int TMargemEsquerda = margemEsquerda(array[(i+indice)%altura]);         /* Os tamanhos das margens */
        int TMargemDireita = margemDireita(array[(i+indice)%altura], largura);
        
        /* Desenha a margem esquerda */
        al_draw_filled_rectangle(0, tamPixel*i, tamPixel*(TMargemEsquerda - 2), tamPixel*(i+1), terra);
        
        j = TMargemEsquerda - 2;
        
        
        /* Desenha o encontro da terra com a água, criando triângulos ou retângulos conforme necessário */
        if (tipo(&array[(i+indice+1)%altura][j+2]) == TERRA) {          /* Se a linha de baixo era maior */
            al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra);
            j++;
            al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*j, tamPixel*(i+1), tamPixel*(j+1), tamPixel*(i+1), terra);
        }
        else if (tipo(&array[(i+indice+1)%altura][j+1]) == TERRA) {     /* Se era igual */
            al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra);
            j++;
        }
        else {      /* Se era menor */
            al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*i, tamPixel*j, tamPixel*(i+1), terra);
            j++;
        }
        
        
        
        /* Descobre onde começa e termina a ilha */
        for (j = TMargemEsquerda; j < largura - TMargemDireita - 2; j++)
            if (tipo(&array[(i+indice)%altura][j]) == TERRA) {
                if (j < ilha0)
                    ilha0 = j;
                if (j > ilhaf)
                    ilhaf = j;
            }
        
        
        if (ilhaf != 0)         /* Se existe uma ilha, desenha primeiro as duas partes de água, depois ela em cima */
            al_draw_filled_rounded_rectangle(tamPixel*ilha0,tamPixel*i,tamPixel*(ilhaf+1),tamPixel*(i+1),3,3, ilha);
        ilha0 = 999999;         /* Reseta os valores */
        ilhaf = 0;
        
        /* Desenha o segundo encontro da água com a terra */
        if (tipo(&array[(i+indice+1)%altura][j+2]) == AGUA) {
            j++;
            al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra);
        }
        else if (tipo(&array[(i+indice+1)%altura][j+1]) == AGUA) {
            j++;
            al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra);
        }
        else {
            al_draw_filled_triangle(tamPixel*(j+1), tamPixel*(i+1), tamPixel*(j+1), tamPixel*i, tamPixel*j, tamPixel*(i+1), terra);
            j++;
            al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra);
        }
        
        
        /* Desenha a margem direita */
        al_draw_filled_rectangle(tamPixel*(largura - TMargemDireita), tamPixel*i, tamPixel*(largura), tamPixel*(i+1), terra);

    }
    
    /* Desenha o jogador na posição correta */
    /*al_draw_filled_ellipse(player_x, player_y, playerSize/3, playerSize, canoa);*/
    al_draw_line(player_x, player_y, player_x2, player_y2, canoa, 5.0);
    /* Coloca tudo o que foi desenhado na tela */
    al_flip_display();
}
Exemplo n.º 19
0
int main(int argc, char *argv[])
{
	ALLEGRO_DISPLAY *display = NULL;
	ALLEGRO_EVENT_QUEUE *evqueue = NULL;
	ALLEGRO_TIMER *timer = NULL;
	ALLEGRO_KEYBOARD_STATE keyboard_state;
    ALLEGRO_EVENT event;
    ALLEGRO_FONT *font;
    ALLEGRO_BITMAP *clock_hand, *clock_quadrant, *bow, *sword;
    float clock_ray = 0, clock_angle = 0;
    int clock_ray_alpha;
    float soul_interval = SOUL_TIME_INTERVAL;
    FuzzyPlayer *player, *cpu;
    FuzzyGame * game;

	bool running = true;
	bool redraw = true;

	int map_x = 13*16, map_y = 5*16;
	int screen_width = WINDOW_WIDTH;
	int screen_height = WINDOW_HEIGHT;
    double curtime;

	/* Initialization */
    fuzzy_iz_error(al_init(), "Failed to initialize allegro");
    fuzzy_load_addon("image", al_init_image_addon());
    fuzzy_load_addon("primitives", al_init_primitives_addon());
    fuzzy_load_addon("keyboard", al_install_keyboard());
    fuzzy_load_addon("mouse", al_install_mouse());
    al_init_font_addon();

	fuzzy_iz_error(timer = al_create_timer(1.0 / FPS), "Cannot create FPS timer");
    fuzzy_iz_error(evqueue = al_create_event_queue(), "Cannot create event queue");
	fuzzy_iz_error(display = al_create_display(screen_width, screen_height),
      "Cannot initialize display");
    al_set_window_title(display, WINDOW_TITLE);
    fuzzy_iz_error(font = al_load_font(fuzzy_res(FONT_FOLDER, "fixed_font.tga"), 0, 0), "Cannot load 'fixed_font.tga'");
    clock_hand = al_load_bitmap(fuzzy_res(PICTURE_FOLDER, "clock_hand.png"));
    fuzzy_iz_error(clock_hand, "Cannot load clock handle");
    clock_quadrant = al_load_bitmap(fuzzy_res(PICTURE_FOLDER, "clock_quadrant.png"));
    fuzzy_iz_error(clock_hand, "Cannot load clock quadrant");
    bow = al_load_bitmap(fuzzy_res(PICTURE_FOLDER, "bow.png"));
    fuzzy_iz_error(clock_hand, "Cannot load bow image");
    sword = al_load_bitmap(fuzzy_res(PICTURE_FOLDER, "sword.png"));
    fuzzy_iz_error(clock_hand, "Cannot load sword image");

	/* Queue setup */
	al_register_event_source(evqueue, al_get_display_event_source(display));
	al_register_event_source(evqueue, al_get_timer_event_source(timer));
	al_register_event_source(evqueue, al_get_keyboard_event_source());
    al_register_event_source(evqueue, al_get_mouse_event_source());

    /* Game setup */
    game = fuzzy_game_new("level000.tmx");
    player = fuzzy_player_new(game, FUZZY_PLAYER_LOCAL, "Dolly");
    cpu = fuzzy_player_new(game, FUZZY_PLAYER_CPU, "CPU_0");

    fuzzy_chess_add(game, player, FUZZY_FOO_LINK, 34, 30);
    fuzzy_chess_add(game, player, FUZZY_FOO_LINK, 33, 30);
    fuzzy_chess_add(game, cpu, FUZZY_FOO_LINK, 40, 30);
    bool showing_area = false;
    FuzzyChess *chess, *focus = NULL;

	al_clear_to_color(al_map_rgb(0, 0, 0));
    al_draw_bitmap(game->map->bitmap, -map_x, -map_y, 0);
	al_flip_display();

#if DEBUG
	ALLEGRO_BITMAP *icon;
    int fps, fps_accum;
    double fps_time;

    icon = al_load_bitmap(fuzzy_res(PICTURE_FOLDER, "icon.tga"));
    if (icon)
        al_set_display_icon(display, icon);
    fps_accum = fps_time = 0;
    fps = FPS;
#endif
    /* Server connection */
    int svsock;
    //~ FuzzyMessage * sendmsg = fuzzy_message_new();
    svsock = fuzzy_server_connect(FUZZY_DEFAULT_SERVER_ADDRESS, FUZZY_DEFAULT_SERVER_PORT);

    _aaa_menu(game, svsock);

	/* MAIN loop */
    player->soul_time = al_get_time();
    al_start_timer(timer);
	while (running) {
        /* wait until an event happens */
		al_wait_for_event(evqueue, &event);

        switch (event.type) {
        case ALLEGRO_EVENT_TIMER:
            /* check soul ticks */
            curtime = al_get_time();
            while (curtime - player->soul_time >= soul_interval) {
                //~ fuzzy_debug("Soul tick!");
                player->soul_time += soul_interval;
                player->soul_points += SOUL_POINTS_BOOST;

                clock_ray = 1;
            }
            clock_angle = (curtime - player->soul_time)/soul_interval * FUZZY_2PI;
            if (clock_ray) {
                clock_ray = (curtime - player->soul_time)/RAY_TIME_INTERVAL * 50 + 40;
                clock_ray_alpha = (curtime - player->soul_time)/RAY_TIME_INTERVAL*(55) + 200;
                if (clock_ray >= 90)
                    clock_ray = 0;
            }

            al_get_keyboard_state(&keyboard_state);
            if (al_key_down(&keyboard_state, ALLEGRO_KEY_RIGHT)) {
                map_x += 5;
                if (map_x > (game->map->tot_width - screen_width))
                    map_x = game->map->tot_width - screen_width;
            }
            else if (al_key_down(&keyboard_state, ALLEGRO_KEY_LEFT)) {
                map_x -= 5;
                if (map_x < 0)
                    map_x = 0;
            }
            else if (al_key_down(&keyboard_state, ALLEGRO_KEY_UP)) {
                map_y -= 5;
                if (map_y < 0)
                    map_y = 0;
            }
            else if (al_key_down(&keyboard_state, ALLEGRO_KEY_DOWN)) {
                map_y += 5;
                if (map_y > (game->map->tot_height - screen_height))
                    map_y = game->map->tot_height - screen_height;
            } else if (al_key_down(&keyboard_state, ALLEGRO_KEY_O)) {
                soul_interval = fuzzy_max(0.1, soul_interval - 0.05);
            } else if (al_key_down(&keyboard_state, ALLEGRO_KEY_P)) {
                soul_interval += 0.05;
            }
            redraw = true;
            break;
        case ALLEGRO_EVENT_KEY_DOWN:
            if(! focus)
                break;

            _attack_area_off();

            switch(event.keyboard.keycode) {
                case ALLEGRO_KEY_W:
                    _chess_move(game, player, focus, focus->x, focus->y-1);
                    break;
                case ALLEGRO_KEY_A:
                    _chess_move(game, player, focus, focus->x-1, focus->y);
                    break;
                case ALLEGRO_KEY_S:
                    _chess_move(game, player, focus, focus->x, focus->y+1);
                    break;
                case ALLEGRO_KEY_D:
                    _chess_move(game, player, focus, focus->x+1, focus->y);
                    break;

                case ALLEGRO_KEY_K:
                    _attack_area_on();
                    break;
                case ALLEGRO_KEY_SPACE:
                    /* switch attack type */
                    if (! focus)
                        break;
                    if (focus->atkarea == &FuzzyMeleeMan)
                        focus->atkarea = &FuzzyRangedMan;
                    else
                        focus->atkarea = &FuzzyMeleeMan;
                    break;
            }
            break;
        case ALLEGRO_EVENT_DISPLAY_CLOSE:
            running = false;
            break;
        case ALLEGRO_EVENT_KEY_UP:
            break;
        case ALLEGRO_EVENT_KEY_CHAR:
            break;
        case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
            if(event.mouse.button == RIGHT_BUTTON) {
                _attack_area_on();
            } else if(event.mouse.button == LEFT_BUTTON) {
                /* world to tile coords */
                int tx = (event.mouse.x+map_x) / game->map->tile_width;
                int ty = (event.mouse.y+map_y) / game->map->tile_height;
#ifdef DEBUG
                printf("SELECT %d %d\n", tx, ty);
#endif
                if(showing_area && fuzzy_chess_inside_target_area(game, focus, tx, ty)) {
                    /* select attack target */
                    if (fuzzy_map_spy(game->map, FUZZY_LAYER_SPRITES, tx, ty) == FUZZY_CELL_SPRITE) {
                        if (fuzzy_chess_local_attack(game, player, focus, tx, ty))
                            _attack_area_off();
                    }
                } else {
                    /* select chess */
                    chess = fuzzy_chess_at(game, player, tx, ty);
                    if (chess && focus != chess) {
                        _attack_area_off();

                        if (focus != NULL) {
                            // already has a focus effect, just move it
                            fuzzy_sprite_move(game->map, FUZZY_LAYER_BELOW, focus->x, focus->y, tx, ty);
                        } else {
                            fuzzy_sprite_create(game->map, FUZZY_LAYER_BELOW, GID_TARGET, tx, ty);
                        }
                        focus = chess;
                    } else if (! chess) {
                        if (showing_area) {
                            // just hide the attack area
                            _attack_area_off();
                        } else if(focus) {
                            // remove the focus
                            fuzzy_sprite_destroy(game->map, FUZZY_LAYER_BELOW, focus->x, focus->y);
                            focus = NULL;
                        }
                    }
                }
            }
            break;
        default:
#ifdef DEBUG
            //~ fprintf(stderr, "Unknown event received: %d\n", event.type);
#endif
            break;
        }

        if (redraw && al_is_event_queue_empty(evqueue)) {
            curtime = al_get_time();
            fuzzy_map_update(game->map, curtime);

            // Clear the screen
            al_clear_to_color(al_map_rgb(0, 0, 0));
            al_draw_bitmap(game->map->bitmap, -map_x, -map_y, 0);

#ifdef GRID_ON
            /* Draw the grid */
            int tw = game->map->tile_width;
            int ty = game->map->tile_height;
            int x, y;
            for (x=(tw-map_x)%tw; x<screen_width; x+=tw)
                al_draw_line(x, 0, x, screen_height, al_map_rgba(7,7,7,100), 1);
            for (y=(ty-map_y)%ty; y<screen_height; y+=ty)
                al_draw_line(0, y, screen_width, y, al_map_rgba(7,7,7,100), 1);
#endif
#if DEBUG
            al_draw_filled_rounded_rectangle(screen_width-100, 4, screen_width, 30,
                8, 8, al_map_rgba(0, 0, 0, 200));
            al_draw_textf(font, al_map_rgb(255, 255, 255),
                screen_width-50, 8, ALLEGRO_ALIGN_CENTRE, "FPS: %d", fps);
#endif
            /* draw SP count */
            al_draw_filled_rounded_rectangle(4, screen_height-170, 175, screen_height-4,
                8, 8, al_map_rgba(0, 0, 0, 200));
            al_draw_textf(font, al_map_rgb(255, 255, 255),
                15, screen_height-163, ALLEGRO_ALIGN_LEFT, "SP: %d", player->soul_points);

            /* draw Soul Clock */
            al_draw_scaled_bitmap(clock_quadrant, 0, 0, 301, 301, 20, screen_height-80-139/2, 139, 139, 0);
            al_draw_scaled_rotated_bitmap(clock_hand, 160, 607, 90, screen_height-80, 0.11, 0.11, clock_angle, 0);
            al_draw_circle(90, screen_height-80, clock_ray, al_map_rgb(80, clock_ray_alpha, 80), 2.0);

            /* draw weapon */
            if (focus) {
                ALLEGRO_BITMAP * weapon;

                if (focus->atkarea == &FuzzyMeleeMan)
                    weapon = sword;
                else
                    weapon = bow;
                al_draw_scaled_bitmap(weapon, 0, 0, 90, 90, 20, 20, 60, 60, 0);
            }

            al_flip_display();
#if DEBUG
            fps_accum++;
            if (curtime - fps_time >= 1) {
                fps = fps_accum;
                fps_accum = 0;
                fps_time = curtime;
            }
#endif
            redraw = false;
        }
    }

	/* Cleanup */
    //~ void * retval;
    //~ char srvkey[FUZZY_SERVERKEY_LEN];
    //~ fuzzy_protocol_server_shutdown(svsock, sendmsg, srvkey);
    //~ fuzzy_message_del(sendmsg);
    fuzzy_game_free(game);

    al_destroy_event_queue(evqueue);
	al_destroy_display(display);
    al_destroy_timer(timer);
	return 0;
}
Exemplo n.º 20
0
void DrawingClass::DrawFilledRoundedRectangle (float x0, float y0, float x1,
    float y1, float rx, float ry, int r, int g, int b) {
  ALLEGRO_COLOR color = al_map_rgb(r, g, b);
  al_draw_filled_rounded_rectangle(x0, y0, x1, y1, rx, ry, color);
}
Exemplo n.º 21
0
void al_draw_filled_rounded_rectangle_w(float x1, float y1, float x2, float y2, float rx, float ry, ALLEGRO_COLOR *color)
{
	al_draw_filled_rounded_rectangle(x1, y1, x2, y2, rx, ry, *color);
}