Beispiel #1
0
void draw(struct Game *game, ALLEGRO_BITMAP *bitmap) {
	al_set_target_bitmap(game->loading.loading_bitmap);
	al_draw_bitmap(bitmap, 0, 0, 0);
	al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), game->viewportWidth*0.0234, game->viewportHeight*0.84, ALLEGRO_ALIGN_LEFT, "Loading...");
	al_draw_filled_rectangle(0, game->viewportHeight*0.985, game->viewportWidth, game->viewportHeight, al_map_rgba(128,128,128,128));
	al_set_target_bitmap(al_get_backbuffer(game->display));
}
Beispiel #2
0
void About(struct Game *game, struct MenuResources* data) {
	ALLEGRO_TRANSFORM trans;
	al_identity_transform(&trans);
	al_use_transform(&trans);

	if (!game->_priv.font_bsod) {
		game->_priv.font_bsod = al_create_builtin_font();
	}

	al_set_target_backbuffer(game->display);
	al_clear_to_color(al_map_rgb(0,0,170));

	char *header = "TICKLE MONSTER";

	al_draw_filled_rectangle(al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header)/2 - 4, (int)(al_get_display_height(game->display) * 0.32), 4 + al_get_display_width(game->display)/2 + al_get_text_width(game->_priv.font_bsod, header)/2, (int)(al_get_display_height(game->display) * 0.32) + al_get_font_line_height(game->_priv.font_bsod), al_map_rgb(170,170,170));

	al_draw_text(game->_priv.font_bsod, al_map_rgb(0, 0, 170), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32), ALLEGRO_ALIGN_CENTRE, header);

	char *header2 = "A fatal exception 0xD3RP has occured at 0028:M00F11NZ in GST SD(01) +";

	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+2*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, header2);
	al_draw_textf(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+3*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "%p and system just doesn't know what went wrong.", (void*)game);

	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+5*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, 	"About screen not implemented!");
	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+6*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, 	"See http://dosowisko.net/ticklemonster/");
	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+7*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, 	"Made for Ludum Dare 33 by Sebastian Krzyszkowiak");

	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+9*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to terminate this error.");
	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+10*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to destroy all muffins in the world.");
	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+11*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Just kidding, please press any key anyway.");

	al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+13*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "Press any key to continue _");

	al_use_transform(&game->projection);
}
Beispiel #3
0
void menu::draw() {
	int elem_num = size;
	if (size > 5)
		elem_num = 5;
	else
		offset = 0;

	al_clear_to_color(COLOR_BLACK);
	al_draw_rectangle(MAP_SIZE / 2 - 60, 120, MAP_SIZE / 2 + 60, 240, al_map_rgb(0, 255, 00), 10);
	al_draw_filled_rectangle(MAP_SIZE / 2, 175, MAP_SIZE / 2 + 108, 185, COLOR_WHITE);
	char buffer[100];
	

	for (int i = 0; i < elem_num; ++i) {
		if (entries[i+offset].type == MENU_OPTION) {
			sprintf_s(buffer, 100, "%s: %.1f", entries[i+offset].name.c_str(), *entries[i+offset].value);
			al_draw_text(menu_font, (i+offset == active) ? al_map_rgb(255, 0, 0) : COLOR_WHITE, MAP_SIZE / 2, MAP_SIZE / 2 + 60 * i, ALLEGRO_ALIGN_CENTER, buffer);
		}
		else if (entries[i + offset].type == MENU_ENUM) {
			sprintf_s(buffer, 100, "%s: %s", entries[i + offset].name.c_str(), entries[i + offset].opt[*(entries[i + offset].set)].c_str());
			al_draw_text(menu_font, (i + offset == active) ? al_map_rgb(255, 0, 0) : COLOR_WHITE, MAP_SIZE / 2, MAP_SIZE / 2 + 60 * i, ALLEGRO_ALIGN_CENTER, buffer);
		}
		else {
			al_draw_text(menu_font, (i + offset == active) ? al_map_rgb(255, 0, 0) : COLOR_WHITE, MAP_SIZE / 2, MAP_SIZE / 2 + 60 * i, ALLEGRO_ALIGN_CENTER, this->entries[i + offset].name.c_str());
		}
	}
	al_flip_display();
}
Beispiel #4
0
void drawTracks()
{
	int n; 
	float y = ((float)SCREEN_H - (CAR_WIDTH * 1.3) * TRACKS_NUM)/2;
	
	for (n = TRACKS_BEGIN-5; n <= TRACKS_FINISH; n += 400) {
		al_draw_filled_circle(
			n + world_x, y - 60, 10,
			al_map_rgb(255,255,0));
	}
	
	al_draw_filled_rectangle(0, y,
			SCREEN_W, y + 1.3*CAR_WIDTH*TRACKS_NUM,
			al_map_rgb(20,20,20));
		
	
	for(n = 0; n <= TRACKS_NUM; n++) {
		al_draw_line(
				(float)TRACKS_BEGIN + world_x, y,
				(float)TRACKS_FINISH + world_x, y,
				al_map_rgb(200,200,200	), 1);
		y += (float)(CAR_WIDTH * 1.3);
	}
	
	for (n = TRACKS_BEGIN-5; n <= TRACKS_FINISH; n += 400) {
		al_draw_filled_circle(
			n + world_x, y + 40, 10,
			al_map_rgb(255,255,0));
	}
}
Beispiel #5
0
void mapper_help_render(void)
{
	al_hold_bitmap_drawing(false);
	al_draw_filled_rectangle(0, 0, t3f_virtual_display_width, t3f_virtual_display_height, al_map_rgba_f(0.0, 0.0, 0.0, 0.75));
	al_hold_bitmap_drawing(true);
	al_draw_textf(mapper_font, t3f_color_white, 0, 0, 0, "Global Keys");
	al_draw_textf(mapper_font, t3f_color_white, 0, 16, 0, "-------------");
	al_draw_textf(mapper_font, t3f_color_white, 0, 32, 0, "F1: Help");
	al_draw_textf(mapper_font, t3f_color_white, 0, 48, 0, "Tab: Change View");

	al_draw_textf(mapper_font, t3f_color_white, 0, 80, 0, "Tileset Keys");
	al_draw_textf(mapper_font, t3f_color_white, 0, 96, 0, "-------------");
	al_draw_textf(mapper_font, t3f_color_white, 0, 112, 0, "F2: Save tileset");
	al_draw_textf(mapper_font, t3f_color_white, 0, 128, 0, "F3: Load tileset");
	al_draw_textf(mapper_font, t3f_color_white, 0, 144, 0, "F4: Create new tileset");
	al_draw_textf(mapper_font, t3f_color_white, 0, 160, 0, "Insert: Add tile");
	al_draw_textf(mapper_font, t3f_color_white, 0, 176, 0, "Delete: Delete tile");

	al_draw_textf(mapper_font, t3f_color_white, 0, 208, 0, "Tilemap Keys");
	al_draw_textf(mapper_font, t3f_color_white, 0, 224, 0, "-------------");
	al_draw_textf(mapper_font, t3f_color_white, 0, 240, 0, "F2: Save tilemap");
	al_draw_textf(mapper_font, t3f_color_white, 0, 256, 0, "F3: Load tilemap");
	al_draw_textf(mapper_font, t3f_color_white, 0, 272, 0, "F4: Create new tilemap");
	al_draw_textf(mapper_font, t3f_color_white, 0, 288, 0, "-/=: Select tile");
	al_draw_textf(mapper_font, t3f_color_white, 0, 304, 0, "PGUP/PGDN: Select layer");
	al_draw_textf(mapper_font, t3f_color_white, 0, 320, 0, "Pad +/-: Change Z-position of current layer");
	al_draw_textf(mapper_font, t3f_color_white, 0, 336, 0, "Ctrl+*: Scale current layer so tiles appear 1:1");
	al_draw_textf(mapper_font, t3f_color_white, 0, 352, 0, "Ctrl+Shift+*: Reset layer scale");
	al_draw_textf(mapper_font, t3f_color_white, 0, 368, 0, "*: Reset layer Z-position");
	al_draw_textf(mapper_font, t3f_color_white, 0, 384, 0, "S: Toggle layer solid flag");
	al_draw_textf(mapper_font, t3f_color_white, 0, 400, 0, "Ctrl+S: Toggle layer static flag");
	al_draw_textf(mapper_font, t3f_color_white, 0, 416, 0, "Insert: Insert layer");
	al_draw_textf(mapper_font, t3f_color_white, 0, 432, 0, "Delete: Delete layer");
}
Beispiel #6
0
void
draw_filled_rectangle (ALLEGRO_BITMAP *to, float x1, float y1,
                       float x2, float y2, ALLEGRO_COLOR color)
{
  set_target_bitmap (to);
  al_draw_filled_rectangle (x1, y1, x2 + 1, y2 + 1, color);
}
void GameClass::DrawPauseMenu () const {
  ALLEGRO_COLOR fontColor = cBlack;

  al_draw_filled_rectangle(0, 0, cWindowWidth, cWindowHeight, cWhite);
  al_draw_text(hugeFont, fontColor, cWindowWidth/2, 40, ALLEGRO_ALIGN_CENTRE,
      cPause[language].c_str());

  std::stringstream aux[8];
  for (int i = 0; i < 4; i++)
    aux[i] << cPauseInformation[language][i];
  aux[4] << hero->GetLives();
  aux[5] << hero->GetJumpUpgrades();
  aux[6] << hero->GetSpeedUpgrades();
  aux[7] << hero->GetLifeUpgrades();


  float xdif = 500, ydif = 50;
  float x = cWindowWidth/2 + 10, y = 250 + 100*pauseOption,
        xf = cWindowWidth/2 + xdif, yf = y + ydif;

  al_draw_rectangle(25, 225, 600, 475, cBlack, 0);

  for (int i = 0; i < 4; i++)
    al_draw_text(bigFont, fontColor, 50, 250 + 50*i,
        ALLEGRO_ALIGN_LEFT, aux[i].str().c_str());
  for (int i = 0; i < 4; i++)
    al_draw_text(bigFont, fontColor, 550, 250 + 50*i,
        ALLEGRO_ALIGN_LEFT, aux[i+4].str().c_str());

  for (int i = 0; i < 3; i++)
    al_draw_text(bigFont, fontColor, cWindowWidth/2 + 50, 250 + 100*i,
        ALLEGRO_ALIGN_LEFT, cPauseMenuOptionsText[language][i].c_str());

  al_draw_rectangle(x, y, xf, yf, cBlack,0);
}
Beispiel #8
0
void Enemy::Render(){
	if(GetAlive()){
		//only draw it if it's in the screen
		if(x > LEVEL_LEFT_X + 8 && x < LEVEL_RIGHT_X - 8 && y > LEVEL_TOP_Y - 8 && y < LEVEL_BOT_Y + 8)
			al_draw_filled_rectangle(x, y, x+boundX, y+boundY, al_map_rgb(107, 142, 35));
	}
}
Beispiel #9
0
static void dot_create_touch_start_effect(void * data)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;
	ALLEGRO_STATE old_state;
	ALLEGRO_TRANSFORM identity;
	float sx = 512.0 / (float)t3f_virtual_display_width;
	bool held = al_is_bitmap_drawing_held();

	if(held)
	{
		al_hold_bitmap_drawing(false);
	}
	al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_TRANSFORM | ALLEGRO_STATE_BLENDER);
	al_set_target_bitmap(app->bitmap[DOT_BITMAP_SCRATCH]);
	al_identity_transform(&identity);
	al_use_transform(&identity);
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
	al_set_clipping_rectangle(0, 0, 512, 512);
	al_clear_to_color(al_map_rgba_f(0.0, 0.0, 0.0, 1.0));
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_INVERSE_ALPHA);
	al_draw_filled_rectangle(DOT_GAME_TOUCH_START_X * sx, DOT_GAME_TOUCH_START_Y, DOT_GAME_TOUCH_END_X * sx, DOT_GAME_TOUCH_END_Y, al_map_rgba_f(1.0, 1.0, 1.0, 1.0));
	al_restore_state(&old_state);
	al_hold_bitmap_drawing(held);
	t3f_set_clipping_rectangle(0, 0, 0, 0);
}
void AllegroTextBox::Draw()
{
    int bbx;
    int bby;
    int bbw;
    int bbh;

    QString display = m_value;

    if (m_passwordMode)
        display.fill('*');

    al_get_text_dimensions(m_boxFont, display.toStdString().c_str(), &bbx, &bby, &bbw, &bbh);

    int x1 = GetXPos();
    int y1 = GetYPos();
    int x2 = x1 + GetWidth();
    int y2 = y1 + GetHeight();

    al_draw_filled_rectangle(x1, y1, x2, y2, m_backgroundColor);
    al_draw_rectangle(x1, y1, x2, y2, GetFocus() ? m_focusedBorder : m_defaultBorder, 1);

    bool Overflow = (bbw > GetWidth() - m_sidePadding * 2);

    al_set_clipping_rectangle((m_xPos+m_sidePadding), m_yPos, (GetWidth()-m_sidePadding*2), GetHeight());
    al_draw_text(m_boxFont, m_textColor, Overflow ? (m_xPos+GetWidth()-m_sidePadding) : (m_xPos+m_sidePadding), (m_yPos + (GetHeight() / 2) - bbh/2), Overflow ? ALLEGRO_ALIGN_RIGHT : ALLEGRO_ALIGN_LEFT, display.toStdString().c_str());
    al_reset_clipping_rectangle();
}
Beispiel #11
0
void Player::draw() {
	if(weaponPickup != -1  && currentWeaponIndex != -1) {
		currentWeapon->draw();
	}

	int blackoutAlpha = (int)(((LOSE_TIME - loseTimer)/LOSE_TIME)*255.0f);

/*	if(blackoutAlpha > 255) {
		blackoutAlpha = 255;
	}

	if(blackoutAlpha < 0) {
		blackoutAlpha = 0;
	}
*/
    //This allows the death screen to be shown
    if (blackoutAlpha > 255 || blackoutAlpha < 0)
    {
        blackoutAlpha = 0;
    }

	al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
	al_draw_filled_rectangle(0, 0, 1280, 720, al_map_rgba(100, 0, 0, blackoutAlpha));

	hurtOverlay.setTransparency(health + sin(time*4.0f)*(1.0f-health)/2);
	hurtOverlay.draw();
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);

	if(displayHealthTimer > 0) {
		for(int i = 0; i < healthpacks; i++) {
			al_draw_bitmap(healthBitmap, 50.0 + 90*i, 580, 0);
		}
	}
}
Beispiel #12
0
void Bullet::draw(){
    if(!this->playerShot){
        al_draw_filled_rectangle(this->posX, this->posY, this->posX + this->width, this->posY + this->height, al_map_rgb(255, 50, 50));
    }else{
        al_draw_rotated_bitmap(bulletImage, this->width/2, this->height/2, this->posX+width/2, this->posY+height/2, this->angle, NULL);
    }
}
Beispiel #13
0
void DebugMapRenderer::renderCell(int x, int y, int cell_value)
{
	float x1, y1, x2, y2;
	x1 =	 x * m_scale;
	y1 =	 y * m_scale;
	x2 = (x+1) * m_scale;
	y2 = (y+1) * m_scale;
	if( cell_value == 0 )
	{
		al_draw_filled_rectangle(x1, y1, x2, y2, al_map_rgb(255, 0, 0));
	}
	else
	{
		al_draw_filled_rectangle(x1, y1, x2, y2, al_map_rgb(0, 255, 0));
	}
}
Beispiel #14
0
void Button::draw(void) {
    al_draw_filled_rectangle(m_x1, m_y1, m_x2, m_y2, m_color);
    if(m_name != NULL) {
        al_draw_text(g_font, colors.white, m_x1 + m_x_off,
                     m_y1 + m_y_off, 0, m_name);
    }
}
   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);
   }
Beispiel #16
0
void Vertical_paned_view::Render(const Widget& widget) const
{
	const Vertical_paned& vertical_paned = dynamic_cast<const Vertical_paned&>(widget);
	Widget* top = vertical_paned.Get_top();
	Widget* bottom = vertical_paned.Get_bottom();
	Widget_view* view;
	int clip_x, clip_y, clip_w, clip_h;
	al_get_clipping_rectangle(&clip_x, &clip_y, &clip_w, &clip_h);
	if(top)
	{
		Vector2 p = top->Get_position();
		Vector2 s = top->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		top->Render();
	}
	if(bottom)
	{
		Vector2 p = bottom->Get_position();
		Vector2 s = bottom->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		bottom->Render();
	}
	al_set_clipping_rectangle(clip_x, clip_y, clip_w, clip_h);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	float pane = p.y+vertical_paned.Get_pane_position()+1;
	ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);
	al_draw_filled_rectangle(p.x, pane, p.x+s.x-1, pane+6, bg_color);
	al_draw_rectangle(p.x, pane, p.x+s.x-1, pane+6, edge_color, 0);
	al_draw_line(p.x+s.x/2-10, pane+2, p.x+s.x/2+10, pane+2, edge_color, 0);
	al_draw_line(p.x+s.x/2-10, pane+4, p.x+s.x/2+10, pane+4, edge_color, 0);
}
void Affection_box::debug_draw_frame()
{
	if(exists)	
	al_draw_filled_rectangle(PosX_left,PosY_top,PosX_left+width,PosY_top+height,al_map_rgb(68,23,99));
	

}
Beispiel #18
0
void Card::Draw(float angle /*= 0.0*/, bool mouseHovered /*= false*/, bool drawBack/*=false*/) // angle must be in radians
{
    float sx = _rank * _frameSize.X;
    float sy = _suit * _frameSize.Y;

    if (drawBack)
    {
        static Bitmap backTemp(BITMAP_GAME_CARDS_BACK_SPRITE, Vector2D(GetPosition().X + 1, GetPosition().Y + 1),Vector2D(1,1),Vector2D(_frameSize.X - 1, _frameSize.Y - 1),Vector2D(0,0),Vector2D(1.0 + mouseHovered*0.3, 1.0 + mouseHovered*0.3),al_map_rgb(255,255,255),angle);
        backTemp.Draw();

        backTemp.SetDestinationCoordinates(GetPosition()).SetTint(al_map_rgb(_backColorRGB, _backColorRGB, _backColorRGB)).Draw();

        backTemp.SetDestinationCoordinates(Vector2D(GetPosition().X + 1, GetPosition().Y + 1)).SetTint(al_map_rgb(255,255,255)).Draw();
    }
    else
    {
        if (mouseHovered) // score top left
        {
            _bitmap.SetScale(Vector2D(1.3,1.3)).Draw();
            _bitmap.SetScale(Vector2D(1,1));
            al_draw_filled_rectangle(GetPosition().X + _frameSize.X*1.3 -25, GetPosition().Y + 4, GetPosition().X+_frameSize.X*1.3 - 4, GetPosition().Y + 25, al_map_rgb(255,255,255));
            al_draw_textf(Fonts::GetFont(20), al_map_rgb(0,0,0), GetPosition().X+_frameSize.X*1.3 - 4 , GetPosition().Y, ALLEGRO_ALIGN_RIGHT, "%i", _score);
        }
        else
            _bitmap.Draw();
    }
}
Beispiel #19
0
void Hero::draw(void) {
   // this will hold the frame that the animation is to hold
   int state;

   // increments frameCount and updates currentFrame if necessary
   ++frameCount;

   if (frameCount == animationDelay) {
      frameCount = 0;
      ++currentFrame;
      // overflows currentFrame
      if (currentFrame == 4) 
         currentFrame = 0;
   }

   switch(currentFrame) {
      case 0:
         state = STANDING; break;
      case 1:
         state = RIGHT_STEP; break;
      case 2:
         state = STANDING; break;
      case 3:
         state = LEFT_STEP; break;
   }

   // `still' doesn't require animation
   if (movement == STILL) {
      // erases old image
      al_draw_filled_rectangle(x, y, x + 16, y + 16, al_map_rgb(0,0,0));

      // draws still guy
      drawState(dir, STANDING);
   }

   // animated movement
   else {
      // erases the old image
      al_draw_filled_rectangle(x, y, x + 16, y + 16, al_map_rgb(0,0,0));

      // moves the character
      move(movement);

      // draws the moved character
      drawState(movement, state);
   }
}
Beispiel #20
0
/* Renders the next frame in a GIF animation to the given position.
 * You need to call this in order on the same destination for frames
 * [0..gif->frames_count - 1] to properly render all the frames in the GIF.
 * The current target bitmap should have the same height as the animation,
 * and blending should be set to fully copy RGBA.
 */
void algif_render_frame(ALGIF_ANIMATION *gif, int frame, int xpos, int ypos) {
    int x, y, w, h;
    ALGIF_FRAME *f = &gif->frames[frame];
    ALGIF_PALETTE *pal;
    if (frame == 0) {
        al_draw_filled_rectangle(xpos, ypos, xpos + gif->width,
              ypos + gif->height, al_map_rgba_f(0, 0, 0, 0));
    }
    else {
        ALGIF_FRAME *p = &gif->frames[frame - 1];
        if (p->disposal_method == 2) {
            al_draw_filled_rectangle(xpos + p->xoff, ypos + p->yoff,
                xpos + p->xoff + p->bitmap_8_bit->w,
                ypos + p->yoff + p->bitmap_8_bit->h,
                al_map_rgba_f(0, 0, 0, 0));
        }
        else if (p->disposal_method == 3 && gif->store) {
            al_draw_bitmap_region(gif->store, xpos + p->xoff, ypos + p->yoff,
                p->bitmap_8_bit->w,
                p->bitmap_8_bit->h,
                xpos + p->xoff, ypos + p->yoff, 0);
            al_destroy_bitmap(gif->store);
            gif->store = NULL;
        }
    }
    w = f->bitmap_8_bit->w;
    h = f->bitmap_8_bit->h;
    if (f->disposal_method == 3) {
        if (gif->store)
            al_destroy_bitmap(gif->store);
        gif->store = al_clone_bitmap(al_get_target_bitmap());
    }
    pal = &gif->frames[frame].palette;
    if (pal->colors_count == 0)
        pal = &gif->palette;

    for (y = 0; y < h; y++) {
        for (x = 0; x < w; x++) {
            int c = f->bitmap_8_bit->data[x + y * f->bitmap_8_bit->w];
            if (c != f->transparent_index) {
                al_draw_pixel(xpos + f->xoff + x, ypos + f->yoff + y,
                    al_map_rgb(pal->colors[c].r, pal->colors[c].g,
                        pal->colors[c].b));
            }
        }
    }
}
Beispiel #21
0
void Plansza::rysuj_plansze() {
    for (int i = 0; i < 17; i++) {
        for (int j = 0; j < 13; j++) {
            if (tablica[i][j] == 1)
                al_draw_filled_rectangle(61 + 30 * j, 45 + 30 * i, 91 + 30 * j, 74 + 30 * i,al_map_rgb(0,0,0));
        }
    }
}
 void Rectangle::draw()
 {
     if(get_filled_status())
         al_draw_filled_rectangle(_V_pos_x,_V_pos_y,_V_pos_x+(_V_size_x*bitmap_scale_x),
                                  _V_pos_y+(_V_size_y*bitmap_scale_y),_V_color);
     al_draw_rectangle(_V_pos_x,_V_pos_y,_V_pos_x+(_V_size_x*bitmap_scale_x),_V_pos_y+(_V_size_y*bitmap_scale_y),
                       _V_color,_V_thickness*primitives_scale);
 }
Beispiel #23
0
/**< Função Desenha um retangulo preenchido na Janela */
void Des_Retangulo_preenchido(int desenha_retangulo, ALLEGRO_FONT *fonte, int x1, int y1, int x2, int y2)
{
    if (desenha_retangulo == 1)
    {
        al_draw_text(fonte, al_map_rgb(255, 255, 255), 320, 70, ALLEGRO_ALIGN_CENTRE, "Precione em 2 pontos:");
        al_draw_filled_rectangle( x1, y1, x2, y2, al_map_rgb(255, 255,255));
    }
}
Beispiel #24
0
void Tela::retangulo(Retangulo r) {
    /* preenche o retangulo r com a cor padrao */
    al_draw_filled_rectangle(
        /* canto superior esquerdo */
        XU2X(r.pos.x), YU2X(r.pos.y),
        /* canto inferior direito */
        XU2X(r.pos.x + r.tam.larg), YU2X(r.pos.y + r.tam.alt), ac_cor);
}
Beispiel #25
0
void TextEntry::draw()
{
   const Theme & theme = dialog->get_theme();
   SaveState state;
   ALLEGRO_COLOR bg = theme.bg;

   if (is_disabled()) {
      bg = al_map_rgb(64, 64, 64);
   }

   al_draw_filled_rectangle(x1, y1, x2, y2, bg);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);

   if (!focused) {
      al_draw_ustr(theme.font, theme.fg, x1, y1, 0, UString(text, left_pos));
   }
   else {
      int x = x1;

      if (cursor_pos > 0) {
         UString sub(text, left_pos, cursor_pos);
         al_draw_ustr(theme.font, theme.fg, x1, y1, 0, sub);
         x += al_get_ustr_width(theme.font, sub);
      }

      if ((unsigned) cursor_pos == al_ustr_size(text)) {
         al_draw_filled_rectangle(x, y1, x + CURSOR_WIDTH,
            y1 + al_get_font_line_height(theme.font), theme.fg);
      }
      else {
         int post_cursor = cursor_pos;
         al_ustr_next(text, &post_cursor);

         UString sub(text, cursor_pos, post_cursor);
         int subw = al_get_ustr_width(theme.font, sub);
         al_draw_filled_rectangle(x, y1, x + subw,
            y1 + al_get_font_line_height(theme.font), theme.fg);
         al_draw_ustr(theme.font, theme.bg, x, y1, 0, sub);
         x += subw;

         al_draw_ustr(theme.font, theme.fg, x, y1, 0,
            UString(text, post_cursor));
      }
   }
}
void GameClass::DrawBlock (float x, float y, float xf, float yf) const {
  al_draw_filled_rectangle(x, y, xf, yf, cWhite);
  for (size_t i = 0; i < 20; i++) {
    float difX = cTileSize*(rand()%1001)/1000.0;
    float difY = cTileSize*(rand()%1001)/1000.0;
    al_draw_pixel(x + difX, y + difY, cBlack);
  }
}
			void framerate::renderFPS() { //Renders the FPS
				al_draw_filled_rectangle(0,0,32,16,al_map_rgba_f(0,0,0,0.5));
				al_draw_rectangle(1,1,31,15,al_map_rgba_f(1,1,1,0.7),1);
				al_draw_ustr(FPSRenderFont,al_map_rgb(255,255,255),6,2,0,FPSText);
				ALLEGRO_USTR* nS = al_ustr_newf("%i",networking::gameServer::getLatency());
				al_draw_ustr(FPSRenderFont,al_map_rgb(255,255,255),6,16,0,nS);
				al_ustr_free(nS);
			}
Beispiel #28
0
void Hand::Draw()
{
    if (_cards.size() == 0)
        return;

    if (!IsPositionSet())
        return;

    // Draw cards (including "zoomed" ones (when mouse hovered))
    int indexMHCard = -1;

    float angle = 0.0;

    for (int i = _cards.size() - 1; i >= 0; --i)
    {
        float x = _cards[i]->GetPosition().X;
        float y = _cards[i]->GetPosition().Y;
        if ((BlackJack::GetMousePosition().X <= x + CARD_SIZE.X) && (BlackJack::GetMousePosition().X >= x) &&
            (BlackJack::GetMousePosition().Y <= y + CARD_SIZE.Y) && (BlackJack::GetMousePosition().Y >= y))
        {
            indexMHCard = i; 
            break;
        }
    }

    for (uint i = 0; i < _cards.size(); ++i)
        _cards[i]->Draw(angle, (uint)_cardJustAdded <= i, _drawSecondCardBack && i == 1);

    // Effect when dealing cards
    if (_cardJustAdded > -1)
    {
        static int timer = 0;

        if (timer == 10)
            _cardJustAdded--;
        else
            timer++;
    }

    if (indexMHCard != -1)
    {
        float x = _cards[indexMHCard]->GetPosition().X;
        float y = _cards[indexMHCard]->GetPosition().Y;

        if (_drawSecondCardBack && indexMHCard == 1)
            _cards[indexMHCard]->Draw(angle, false, true);
        else
            _cards[indexMHCard]->Draw(angle, true);
    }

    // Draw score of hand if no card is hidden and if score is not zero
    if ((!_dealerHand && _score > 0 && _cards.size() >= 2) || (_dealerHand && _cards.size() > 0 && _cards[0]->GetScore() >= 10) || !_drawSecondCardBack)
    {
        ShowSecondCard();
        al_draw_filled_rectangle(_position.X - 21, _position.Y - 21, _position.X + 1, _position.Y + 1, al_map_rgb(255, 255, 255));
        al_draw_textf(Fonts::GetFont(19), al_map_rgb(0, 0, 0), _position.X - 20, _position.Y - 20, 0, "%2.0i", _score);
    }
}
Beispiel #29
0
void CaveGame::Render(){
	al_draw_bitmap(caveBackground,0,0,0);
	al_draw_bitmap(koala, koalaX, koalaY, 0);
	for(int i=0; i<10;i++)
		for(int k=0;k<8;k++)
			if(isObj[i][k]){
				int numImage = (int)(intoxication/300) % 3;
				al_draw_bitmap_region(objImage[i][numImage], objW[i][numImage] * ((t/2) % objFrames[i][numImage]), 0, objW[i][numImage], objH[i][numImage], objX[i][k], objY[i][k], 0);
			}
	al_draw_rectangle(1,1,600,49,al_map_rgb(10,200,10),2);
	al_draw_filled_rectangle(2,2,health-2, 50, al_map_rgb(0,220,0));
	if(intoxication <= 300){
		al_draw_rectangle(1,53,299,99,al_map_rgb(180,70,180),2);
		al_draw_filled_rectangle(2,54, intoxication, 98, al_map_rgb(200,50,200));
	}else if(intoxication <= 600){
		al_draw_rectangle(1,53,299,69,al_map_rgb(180,70,180),2);
		al_draw_rectangle(1,73,299,109,al_map_rgb(180,70,180),2);
		al_draw_filled_rectangle(2,54, 298, 68, al_map_rgb(200,50,200));
		al_draw_filled_rectangle(2,74, intoxication-302, 108, al_map_rgb(200,50,200));
		al_draw_textf(font36, al_map_rgb(0,100,200), width, 40, ALLEGRO_ALIGN_RIGHT, "Score per second: %i", timeAtIntox*6);
	}else{
		al_draw_rectangle(1,53,299,69,al_map_rgb(180,70,180),2);
		al_draw_rectangle(1,73,299,89,al_map_rgb(180,70,180),2);
		al_draw_rectangle(1,93,299,129,al_map_rgb(180,70,180),2);
		al_draw_filled_rectangle(2,54, 298, 68, al_map_rgb(200,50,200));
		al_draw_filled_rectangle(2,74, 298, 88, al_map_rgb(200,50,200));
		al_draw_filled_rectangle(2,94, intoxication-602, 128, al_map_rgb(200,50,200));
		al_draw_textf(font36, al_map_rgb(0,100,200), width, 40, ALLEGRO_ALIGN_RIGHT, "Score per second: %i", timeAtIntox*6);
	}
	al_draw_text(font36, al_map_rgb(10,200,10),5,5,0,"Health");
	al_draw_textf(font36, al_map_rgb(0,100,200), width, 0, ALLEGRO_ALIGN_RIGHT, "Score: %i", score);
}
Beispiel #30
0
void HSlider::draw()
{
   const Theme & theme = dialog->get_theme();
   const int cy = (y1 + y2) / 2;
   SaveState state;
   ALLEGRO_COLOR bg = theme.bg;

   if (is_disabled()) {
      bg = al_map_rgb(64, 64, 64);
   }

   al_draw_filled_rectangle(x1, y1, x2, y2, bg);
   al_draw_line(x1, cy, x2, cy, theme.fg, 0);

   double ratio = (double) this->cur_value / (double) this->max_value;
   int xpos = x1 + (int) (ratio * (width() - 2));
   al_draw_filled_rectangle(xpos - 2, y1, xpos + 2, y2, theme.fg);
}