Exemplo n.º 1
0
int yes_no_dialog(const char *text){
    ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
    ALLEGRO_EVENT ev;
    int noexit;
    int yes_x, yes_y, no_x, no_y;
    int dw = al_get_bitmap_width(al_get_target_bitmap());
    int dh = al_get_bitmap_height(al_get_target_bitmap());
    int ret=0;
    int bh = 120, bw = 400;
    
    al_register_event_source(queue, al_get_keyboard_event_source());
    al_register_event_source(queue, al_get_mouse_event_source());

    al_clear_to_color(NULL_COLOR);
    al_draw_filled_rectangle((dw - bw)/2, (dh-bh)/2, (dw+bw)/2, (dh+bh)/2, WINDOW_BG_COLOR);
    al_draw_rectangle((dw - bw)/2, (dh-bh)/2, (dw+bw)/2, (dh+bh)/2, WINDOW_BD_COLOR,3);
    
    al_draw_multiline_text(default_font, al_map_rgb_f(1,1,1), dw/2, (dh-bh)/2+20, 360, 18, ALLEGRO_ALIGN_CENTER, text);
    
    yes_x = (dw-bw)/2 + 64;
    yes_y = (dh+bh)/2 - 44;
    no_x = (dw+bw)/2 - 128;
    no_y = (dh+bh)/2 - 44;
    
    al_draw_rectangle(yes_x, yes_y, yes_x+64, yes_y+24, al_map_rgb_f(1,1,1), 1);
    al_draw_rectangle(no_x, no_y, no_x+64, no_y+24, al_map_rgb_f(1,1,1), 1);
    al_draw_text(default_font, al_map_rgb_f(1,1,1), yes_x+32, yes_y+4, ALLEGRO_ALIGN_CENTER, "OK");
    al_draw_text(default_font, al_map_rgb_f(1,1,1), no_x+32, no_y+4, ALLEGRO_ALIGN_CENTER, "Cancel");
    
    al_flip_display();
    
    noexit=1;
    while(noexit){
        al_wait_for_event(queue, &ev);
        if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN){
            if( (ev.mouse.x > yes_x) && (ev.mouse.x < yes_x+64) && (ev.mouse.y > yes_y) && (ev.mouse.y < yes_y+24) ){
                ret = 1;
                noexit = 0;
            } else if( (ev.mouse.x > no_x) && (ev.mouse.x < no_x+64) && (ev.mouse.y > no_y) && (ev.mouse.y < no_y+24) ){
                ret = 0; noexit = 0;
            }
        }
        if(ev.type == ALLEGRO_EVENT_KEY_CHAR)
            noexit = 0;
    }
    al_destroy_event_queue(queue);
    return ret;
}
Exemplo n.º 2
0
void my_clear_bitmap(MBITMAP *b)
{
	ALLEGRO_BITMAP *target = al_get_target_bitmap();
	m_set_target_bitmap(b);
	m_clear(al_map_rgba(0, 0, 0, 0));
	al_set_target_bitmap(target);
}
Exemplo n.º 3
0
void Menu_Screen::Screen_Lighten()
{
	//TWORZYMY BITMAPE ORAZ KOPIUJEMY OBECNY display
	Screen_Photo = al_create_bitmap( 800 , 600 ) ;
	ALLEGRO_BITMAP *Prev_Target = al_get_target_bitmap() ;

	//USTAWIAMY RYSOWANIE NA NOWEJ BITMAPIE
	al_set_target_bitmap( Screen_Photo ) ;

	al_draw_bitmap( Screen_Bitmap["Menu_Background"] , 0 , 0 , NULL ) ;
	al_draw_bitmap( Screen_Bitmap["Start"] , ScreenWidth / 2 - 100 , 200 , NULL ) ;
	al_draw_bitmap( Screen_Bitmap["Exit"] , ScreenWidth / 2 - 100 , 500 , NULL ) ;

	//USTAWIAMY STARY display (CHODZI O RYSOWANIE JAKBY WYBOR OKNA)
	al_set_target_bitmap( Prev_Target ) ;

	//PETLA RYSUJACA OBRAZ Z CORAZ MNIEJSZA PRZEZROCZYSTOSCIA
	for( float i = 0 ; i <= 1 ; i += 0.001 )
	{
		//ZMIANA KOLORU (JESLI DOBRZE ROZUMIEM) [BEZ TEGO NIE DZIALA TAK JAK TRZEBA]
		al_set_blender( ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA ) ;

		//RYSUJEMY BITMAPE Z ODPOWIEDNIM KANALEM ALPHA (PRZEZROCZYSTOSC)
		al_draw_tinted_bitmap( Screen_Photo , al_map_rgba_f( 1 , 1 , 1 , i ) , 0 , 0 , 0 ) ;

		al_flip_display() ;
		al_clear_to_color(al_map_rgb(0 , 0 , 0)) ;
		//al_rest(5.0) ;
	}
}
void _al_clear_memory(ALLEGRO_COLOR *color)
{
   ALLEGRO_BITMAP *bitmap = al_get_target_bitmap();

   _al_draw_filled_rectangle_memory_fast(0, 0, bitmap->w-1, bitmap->h-1,
      color);
}
Exemplo n.º 5
0
static void ogl_lock_region_nonbb_readwrite(
   ALLEGRO_BITMAP *bitmap, ALLEGRO_BITMAP_EXTRA_OPENGL *ogl_bitmap,
   int x, int gl_y, int w, int h, int format)
{
   ALLEGRO_BITMAP *old_target = NULL;

   /* Create an FBO if there isn't one. */
   if (!ogl_bitmap->fbo_info) {
      old_target = al_get_target_bitmap();
      bitmap->locked = false; // FIXME: hack :(
      if (al_is_bitmap_drawing_held())
         al_hold_bitmap_drawing(false);

      al_set_target_bitmap(bitmap); // This creates the fbo
      bitmap->locked = true;
   }

   if (ogl_bitmap->fbo_info) {
      ogl_lock_region_nonbb_readwrite_fbo(bitmap, ogl_bitmap,
         x, gl_y, w, h, format);
   }
   else {
      ogl_lock_region_nonbb_readwrite_nonfbo(bitmap, ogl_bitmap,
         x, gl_y, w, h, format);
   }

   if (old_target) {
      al_set_target_bitmap(old_target);
   }
}
void Player::die(void)
{
   shake();
   reset();

   lives--;
   if (lives <= 0) {
      // game over
      isDestructable = false;
      invincibleCount = 20000;
      ALLEGRO_BITMAP *old_target = al_get_target_bitmap();
      al_set_target_bitmap(highscoreBitmap);
      int w = al_get_bitmap_width(highscoreBitmap);
      int h = al_get_bitmap_height(highscoreBitmap);
      ResourceManager& rm = ResourceManager::getInstance();
      ALLEGRO_FONT *large_font = (ALLEGRO_FONT *)rm.getData(RES_LARGEFONT);
      ALLEGRO_FONT *small_font = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT);
      al_draw_textf(large_font, al_map_rgb(255, 255, 255), w/2, h/2-16, ALLEGRO_ALIGN_CENTRE, "GAME OVER");
      al_draw_textf(small_font, al_map_rgb(255, 255, 255), w/2, h/2+16, ALLEGRO_ALIGN_CENTRE, "%d Points", score);
      al_set_target_bitmap(old_target);
   }
   else {
      hp = 1;
      isDestructable = false;
      invincibleCount = 3000;
   }
}
Exemplo n.º 7
0
static void ogl_draw_pixel(ALLEGRO_DISPLAY *d, float x, float y,
   ALLEGRO_COLOR *color)
{
   ALLEGRO_BITMAP *target = al_get_target_bitmap();
   ALLEGRO_BITMAP_OGL *ogl_target;
   GLfloat vert[2];

   /* For sub-bitmaps */
   if (target->parent) {
      target = target->parent;
   }

   ogl_target = (void *)target;

   if ((!ogl_target->is_backbuffer &&
      d->ogl_extras->opengl_target != ogl_target) ||
      target->locked || !set_opengl_blending(d))  {
      _al_draw_pixel_memory(target, x, y, color);
      return;
   }

   vert[0] = x;
   vert[1] = y;

   glEnableClientState(GL_VERTEX_ARRAY);
   glEnableClientState(GL_COLOR_ARRAY);
   glVertexPointer(2, GL_FLOAT, 0, vert);
   glColorPointer(4, GL_FLOAT, 0, color);

   glDrawArrays(GL_POINTS, 0, 1);

   glDisableClientState(GL_VERTEX_ARRAY);
   glDisableClientState(GL_COLOR_ARRAY);
}
Exemplo n.º 8
0
void c_minimap::reload(void)
{
	ALLEGRO_BITMAP * backup = al_get_target_bitmap();
	if(minimap_bitmap)
		al_destroy_bitmap(minimap_bitmap);
	minimap_bitmap = al_create_bitmap(user_config.minimap_size,user_config.minimap_size);
	if(!map_list.biome_map)
		return;
	int bigsize = al_get_bitmap_width(map_list.biome_map);
	if (bigsize < al_get_bitmap_height(map_list.biome_map))
		bigsize = al_get_bitmap_height(map_list.biome_map);
	scale = (double)user_config.minimap_size / (double)bigsize;
	al_set_target_bitmap(minimap_bitmap);
	al_draw_scaled_bitmap(map_list.biome_map,
		0,
		0,
		al_get_bitmap_width(map_list.biome_map),
		al_get_bitmap_height(map_list.biome_map),
		0,
		0,
		al_get_bitmap_width(map_list.biome_map)* scale,
		al_get_bitmap_height(map_list.biome_map) * scale,
		0);
	al_set_target_bitmap(backup);
}
Exemplo n.º 9
0
/* Function: al_destroy_display
 */
void al_destroy_display(ALLEGRO_DISPLAY *display)
{
   if (display) {
      /* This causes warnings and potential errors on Android because
       * it clears the context and Android needs this thread to have
       * the context bound in its destroy function and to destroy the
       * shader. Just skip this part on Android.
       */
#ifndef ALLEGRO_ANDROID
      ALLEGRO_BITMAP *bmp;

      bmp = al_get_target_bitmap();
      if (bmp && _al_get_bitmap_display(bmp) == display)
         al_set_target_bitmap(NULL);

      /* This can happen if we have a current display, but the target bitmap
       * was a memory bitmap.
       */
      if (display == al_get_current_display())
         _al_set_current_display_only(NULL);
#endif

      al_destroy_shader(display->default_shader);
      display->default_shader = NULL;

      ASSERT(display->vt);
      display->vt->destroy_display(display);
   }
}
Exemplo n.º 10
0
static void shader_texture_solid_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE

   PLANE_DETS(u, v1->u, v2->u, v3->u)
   PLANE_DETS(v, v1->v, v2->v, v3->v)

   state_texture_solid_any_2d* s = (state_texture_solid_any_2d*)state;

   s->target = al_get_target_bitmap();
   s->cur_color = v1->color;

   s->off_x = v1->x - 0.5f;
   s->off_y = v1->y + 0.5f;

   s->w = al_get_bitmap_width(s->texture);
   s->h = al_get_bitmap_height(s->texture);
   
   if (det_u == 0.0f) {
      s->du_dx = s->du_dy = s->u_const = 0.0f;
      s->dv_dx = s->dv_dy = s->v_const = 0.0f;
   }
   else {
      s->du_dx    = -u_det_x / det_u;
      s->du_dy    = -u_det_y / det_u;
      s->u_const  = u_det / det_u;

      s->dv_dx    = -v_det_x / det_u;
      s->dv_dy    = -v_det_y / det_u;
      s->v_const  = v_det / det_u;
   }
}
Exemplo n.º 11
0
bool BigBitmap::Draw_bitmap_region(float sx, float sy, float sw, float sh, float dx, float dy, int flags)
{

    int start_w = floor(sx / region_size_w);
    start_w = (start_w < 0 ? 0 : start_w);
    int start_h = floor(sy / region_size_h);
    start_h = (start_h < 0 ? 0 : start_h);
    int fin_w = ceil((sx + sw) / region_size_w);
    fin_w = ( fin_w > w_regions ? w_regions : fin_w);
    int fin_h = ceil((sy + sh) / region_size_h);
    fin_h = ( fin_h > h_regions ? h_regions : fin_h);
    int offset_w = sx - start_w*region_size_w,
    offset_h = sy - start_h*region_size_h;

    if(tmpbmp != nullptr)
        al_destroy_bitmap(tmpbmp);

    ALLEGRO_BITMAP *restoreto = al_get_target_bitmap();
    tmpbmp = al_create_bitmap(sw, sh);
    al_set_target_bitmap(tmpbmp);
    al_clear_to_color(al_map_rgb(0,0,0));

    for(int h = start_h; h < fin_h; h++)
    {
        for(int w = start_w; w < fin_w; w++)
        {
            al_draw_bitmap(bitmaps[h*w_regions + w], (w-start_w)*region_size_w - offset_w, (h-start_h)*region_size_h - offset_h, 0);

        }
    }

    al_set_target_bitmap(restoreto);
    al_draw_bitmap(tmpbmp, dx, dy, flags);
    return true;
}
Exemplo n.º 12
0
void update_timer(int t, Board *b) {
	ALLEGRO_BITMAP *bmp = al_get_target_bitmap();
	al_set_target_bitmap(*b->time_panel.b[0]->bmp);
	al_clear_to_color(b->time_panel.b[0]->bg_color);
	al_draw_textf(default_font, WHITE_COLOR,  b->time_panel.b[0]->w/2, 0, ALLEGRO_ALIGN_CENTER, "%02d:%02d:%02d", (int)t/3600, ((int)t/60) % 60 , (int)t%60);
	al_set_target_bitmap(bmp);
}
Exemplo n.º 13
0
static void _bitmap_drawer(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR tint,
   float sx, float sy, float sw, float sh, int flags)
{
   ALLEGRO_BITMAP *dest = al_get_target_bitmap();
   ALLEGRO_DISPLAY *display = _al_get_bitmap_display(dest);
   ASSERT(bitmap->parent == NULL);
   ASSERT(!(flags & (ALLEGRO_FLIP_HORIZONTAL | ALLEGRO_FLIP_VERTICAL)));
   ASSERT(bitmap != dest && bitmap != dest->parent);

   /* If destination is memory, do a memory blit */
   if (al_get_bitmap_flags(dest) & ALLEGRO_MEMORY_BITMAP ||
       _al_pixel_format_is_compressed(al_get_bitmap_format(dest))) {
      _al_draw_bitmap_region_memory(bitmap, tint, sx, sy, sw, sh, 0, 0, flags);
   }
   else {
      /* if source is memory or incompatible */
      if ((al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) ||
          (!al_is_compatible_bitmap(bitmap)))
      {
         if (display && display->vt->draw_memory_bitmap_region) {
            display->vt->draw_memory_bitmap_region(display, bitmap,
               sx, sy, sw, sh, flags);
         }
         else {
            _al_draw_bitmap_region_memory(bitmap, tint, sx, sy, sw, sh, 0, 0, flags);
         }
      }
      else {
         /* Compatible display bitmap, use full acceleration */
         bitmap->vt->draw_bitmap_region(bitmap, tint, sx, sy, sw, sh, flags);
      }
   }
}
Exemplo n.º 14
0
/* Function: al_set_clipping_rectangle
 */
void al_set_clipping_rectangle(int x, int y, int width, int height)
{
   ALLEGRO_BITMAP *bitmap = al_get_target_bitmap();

   ASSERT(bitmap);

   if (x < 0) {
      width += x;
      x = 0;
   }
   if (y < 0) {
      height += y;
      y = 0;
   }
   if (x + width > bitmap->w) {
      width = bitmap->w - x;
   }
   if (y + height > bitmap->h) {
      height = bitmap->h - y;
   }

   bitmap->cl = x;
   bitmap->ct = y;
   bitmap->cr_excl = x + width;
   bitmap->cb_excl = y + height;

   if (bitmap->vt && bitmap->vt->update_clipping_rectangle) {
      bitmap->vt->update_clipping_rectangle(bitmap);
   }
}
Exemplo n.º 15
0
/* Function: al_use_transform
 */
void al_use_transform(const ALLEGRO_TRANSFORM *trans)
{
    ALLEGRO_BITMAP *target = al_get_target_bitmap();
    ALLEGRO_DISPLAY *display;

    if (!target)
        return;

    /* Changes to a back buffer should affect the front buffer, and vice versa.
     * Currently we rely on the fact that in the OpenGL drivers the back buffer
     * and front buffer bitmaps are exactly the same, and the DirectX driver
     * doesn't support front buffer bitmaps.
     */

    if (trans != &target->transform) al_copy_transform(&target->transform, trans);

    /*
     * When the drawing is held, we apply the transformations in software,
     * so the hardware transformation has to be kept at identity.
     */
    if (!al_is_bitmap_drawing_held()) {
        display = target->display;
        if (display) {
            display->vt->update_transformation(display, target);
        }
    }
}
Exemplo n.º 16
0
int make_clue_bitmaps(Game *g, Board *b){
    int i;
    ALLEGRO_BITMAP *dispbuf = al_get_target_bitmap();
    al_set_target_bitmap(NULL);
    
    for(i=0;i<g->clue_n; i++){
        b->clue_bmp[i] = al_create_bitmap(b->clue_tiledblock[i]->w, b->clue_tiledblock[i]->h);
        if(!b->clue_bmp[i]){
            fprintf(stderr, "Error creating clue bitmap.\n");
            return -1;
        }
        al_set_target_bitmap(b->clue_bmp[i]);
        al_clear_to_color(b->clue_tiledblock[i]->bg_color);
        switch(g->clue[i].rel){
            case NEXT_TO:
            case CONSECUTIVE:
            case NOT_NEXT_TO:
            case NOT_MIDDLE:
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[0]][g->clue[i].k[0]], 0, 0, 0);
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[1]][g->clue[i].k[1]], b->clue_unit_size + b->clue_unit_space, 0, 0);
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[2]][g->clue[i].k[2]], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
                if(g->clue[i].rel == NOT_NEXT_TO){
                    al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 0, 0, 0);
                    al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
                } else if(g->clue[i].rel == NOT_MIDDLE){
                    al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], b->clue_unit_size + b->clue_unit_space, 0, 0);
                }
                
                if((g->clue[i].rel == NOT_MIDDLE) || (g->clue[i].rel == CONSECUTIVE))
                    al_draw_bitmap(b->symbol_bmp[SYM_SWAPPABLE], 0,0,0);
                
                break;
            case ONE_SIDE:
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[0]][g->clue[i].k[0]], 0, 0, 0);
                al_draw_bitmap(b->symbol_bmp[SYM_ONE_SIDE], b->clue_unit_size + b->clue_unit_space, 0, 0);
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[1]][g->clue[i].k[1]], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
                break;
            case TOGETHER_3:
            case TOGETHER_NOT_MIDDLE:
            case TOGETHER_FIRST_WITH_ONLY_ONE:
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[2]][g->clue[i].k[2]], 0, 2*(b->clue_unit_size + b->clue_unit_space), 0);
            case TOGETHER_2:
            case NOT_TOGETHER:
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[0]][g->clue[i].k[0]], 0, 0, 0);
                al_draw_bitmap(b->clue_unit_bmp[g->clue[i].j[1]][g->clue[i].k[1]], 0, b->clue_unit_size + b->clue_unit_space, 0);
                if((g->clue[i].rel==NOT_TOGETHER) || (g->clue[i].rel==TOGETHER_NOT_MIDDLE))
                    al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 0, b->clue_unit_size + b->clue_unit_space, 0);
                else if(g->clue[i].rel==TOGETHER_FIRST_WITH_ONLY_ONE)
                    al_draw_bitmap(b->symbol_bmp[SYM_ONLY_ONE], 0, 0, 0); //xxx todo: temporary  -- add ONLY_ONE symbol
                break;
            
            default:
                break;
        }        
    }
  
    al_set_target_bitmap(dispbuf);
    return 0;
}
Exemplo n.º 17
0
void m_draw_scaled_target(MBITMAP *src, int sx, int sy, int sw, int sh,
	int dx, int dy, int dw, int dh, MBITMAP *dst)
{
	ALLEGRO_BITMAP *old_target = al_get_target_bitmap();
	m_set_target_bitmap(dst);
	al_draw_scaled_bitmap(src->bitmap, sx, sy, sw, sh, dx, dy, dw, dh, 0);
	al_set_target_bitmap(old_target);
}
Exemplo n.º 18
0
static int allua_Bitmap_get_target(lua_State * L)
{
   ALLUA_bitmap bitmap = al_get_target_bitmap();
   if (bitmap)
      allua_pushBitmap(L, bitmap, false);
   else
      lua_pushnil(L);
   return 1;
}
Exemplo n.º 19
0
	void Canvas::drawRect(Rectangle* rect, byte r, byte g, byte b, float thickness)
	{
		if(al_get_target_bitmap() != this->buffer)
			al_set_target_bitmap(this->buffer);

		al_draw_rectangle(rect->x, rect->y, rect->x + rect->width, rect->y + rect->height, al_map_rgb(r,g,b), thickness);

		TF::engine->resetRenderingBuffer();
	}
Exemplo n.º 20
0
	void Canvas::drawTextureRegion(Texture* texture, Rectangle* srcRect, float x, float y, bool flipped)
	{
		if(al_get_target_bitmap() != this->buffer)
			al_set_target_bitmap(this->buffer);

		Graphics::DrawRegion(texture, srcRect->x, srcRect->y, srcRect->width, srcRect->height, x, y, alpha, flipped);

		TF::engine->resetRenderingBuffer();
	}
Exemplo n.º 21
0
static void shader_solid_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   state_solid_any_2d* s = (state_solid_any_2d*)state;
   s->target = al_get_target_bitmap();
   s->cur_color = v1->color;

   (void)v2;
   (void)v3;
}
Exemplo n.º 22
0
/* Function: al_get_current_transform
 */
const ALLEGRO_TRANSFORM *al_get_current_transform(void)
{
    ALLEGRO_BITMAP *target = al_get_target_bitmap();

    if (!target)
        return NULL;

    return &target->transform;
}
Exemplo n.º 23
0
	void Canvas::fill(Rectangle* rect, byte r, byte g, byte b)
	{
		if(al_get_target_bitmap() != this->buffer)
			al_set_target_bitmap(this->buffer);

		al_draw_filled_rectangle(rect->x, rect->y, rect->x + rect->width, rect->y + rect->height, al_map_rgb(r,g,b) );

		TF::engine->resetRenderingBuffer();
	}
Exemplo n.º 24
0
// width_factor is the preferred width (portion of the screen width), but if text won't fit
// it will increase width until it fits
void draw_center_text_box(ALLEGRO_FONT *font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR bg_color, ALLEGRO_COLOR bd_color, float width_factor, const char *text){
    int dw = al_get_bitmap_width(al_get_target_bitmap());
    int dh = al_get_bitmap_height(al_get_target_bitmap());
    float factor=width_factor;
    int w,h;
    
    if(!font) return;
    
    do{
        w=dw*factor;
        h = get_multiline_text_lines(font,  w-40, text) * al_get_font_line_height(font) + 30;
        factor += 0.05;
    }while( (h > dh*0.9) && (factor < 1) );
    
    al_draw_filled_rectangle((dw-w)/2, (dh-h)/2, (dw+w)/2, (dh+h)/2, bg_color);
    al_draw_rectangle((dw-w)/2, (dh-h)/2, (dw+w)/2, (dh+h)/2, bd_color, 3);
    al_draw_multiline_text(font, text_color, (dw-w+40)/2, (dh-h+30)/2, w-30, al_get_font_line_height(font), ALLEGRO_ALIGN_LEFT, text);
}
Exemplo n.º 25
0
Arquivo: gui.c Projeto: mnstrmnch/meka
DrawCursor::DrawCursor(v2i _pos, int font_id)
{
	this->pos = _pos;
	this->x_base = this->pos.x;
	this->y_spacing = Font_Height((t_font_id)font_id)+2;

	ALLEGRO_BITMAP* bitmap = al_get_target_bitmap();
	this->viewport_min.Set(0,0);
	this->viewport_max.Set(al_get_bitmap_width(bitmap),al_get_bitmap_height(bitmap));
}
Exemplo n.º 26
0
/* Function: al_reset_clipping_rectangle
 */
void al_reset_clipping_rectangle(void)
{
   ALLEGRO_BITMAP *bitmap = al_get_target_bitmap();

   if (bitmap) {
      int w = al_get_bitmap_width(bitmap);
      int h = al_get_bitmap_height(bitmap);
      al_set_clipping_rectangle(0, 0, w, h);
   }
}
Exemplo n.º 27
0
void PhysicsBody::setBmp()
{
	this->bitmapW = w * B2D_SCALE;
	this->bitmapH = h * B2D_SCALE;
	bodyBitMap = al_create_bitmap(w * B2D_SCALE, h * B2D_SCALE);
	ALLEGRO_BITMAP* previousBitmap = al_get_target_bitmap();
	al_set_target_bitmap(bodyBitMap);
	al_clear_to_color(al_map_rgba(255, 0, 0, 255));
	al_set_target_bitmap(previousBitmap);
}
Exemplo n.º 28
0
// debug
ALLEGRO_BITMAP *get_clue_bitmap(Board *b, Clue *clue){
    int w,h;
    int size = b->clue_unit_size;
    if(is_vclue(clue->rel)){ w = size; h = 3*size; } else {w = 3*size; h = size; }
    ALLEGRO_BITMAP *dispbuf = al_get_target_bitmap();
    
    ALLEGRO_BITMAP *clue_bmp = al_create_bitmap(w, h);
    al_set_target_bitmap(clue_bmp);
    al_clear_to_color(NULL_COLOR);
    
    switch(clue->rel){
        case NEXT_TO:
        case CONSECUTIVE:
        case NOT_NEXT_TO:
        case NOT_MIDDLE:
            al_draw_bitmap(b->clue_unit_bmp[clue->j[0]][clue->k[0]], 0, 0, 0);
            al_draw_bitmap(b->clue_unit_bmp[clue->j[1]][clue->k[1]], b->clue_unit_size + b->clue_unit_space, 0, 0);
            al_draw_bitmap(b->clue_unit_bmp[clue->j[2]][clue->k[2]], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
            if(clue->rel == NOT_NEXT_TO){
                al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 0, 0, 0);
                al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
            } else if(clue->rel == NOT_MIDDLE){
                al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], b->clue_unit_size + b->clue_unit_space, 0, 0);
            }
            
            if((clue->rel == NOT_MIDDLE) || (clue->rel == CONSECUTIVE))
                al_draw_bitmap(b->symbol_bmp[SYM_SWAPPABLE], 0,0,0);
            
            break;
        case ONE_SIDE:
            al_draw_bitmap(b->clue_unit_bmp[clue->j[0]][clue->k[0]], 0, 0, 0);
            al_draw_bitmap(b->symbol_bmp[SYM_ONE_SIDE], b->clue_unit_size + b->clue_unit_space, 0, 0);
            al_draw_bitmap(b->clue_unit_bmp[clue->j[1]][clue->k[1]], 2*(b->clue_unit_size + b->clue_unit_space), 0, 0);
            break;
        case TOGETHER_3:
        case TOGETHER_NOT_MIDDLE:
            al_draw_bitmap(b->clue_unit_bmp[clue->j[2]][clue->k[2]], 0, 2*(b->clue_unit_size + b->clue_unit_space), 0);
        case TOGETHER_2:
        case NOT_TOGETHER:
            al_draw_bitmap(b->clue_unit_bmp[clue->j[0]][clue->k[0]], 0, 0, 0);
            al_draw_bitmap(b->clue_unit_bmp[clue->j[1]][clue->k[1]], 0, b->clue_unit_size + b->clue_unit_space, 0);
            if((clue->rel==NOT_TOGETHER) || (clue->rel==TOGETHER_NOT_MIDDLE))
                al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 0, b->clue_unit_size + b->clue_unit_space, 0);
            break;
            
        case TOGETHER_FIRST_WITH_ONLY_ONE: // temporary debug bmp, shouldn't show up
            al_draw_bitmap(b->symbol_bmp[SYM_FORBIDDEN], 0, b->clue_unit_size + b->clue_unit_space, 0);
            break;
        default:
            break;
    }
    
    al_set_target_bitmap(dispbuf);
    return clue_bmp;
}
Exemplo n.º 29
0
static void shader_texture_grad_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE

   ALLEGRO_COLOR v1c = v1->color;
   ALLEGRO_COLOR v2c = v2->color;
   ALLEGRO_COLOR v3c = v3->color;

   PLANE_DETS(r, v1c.r, v2c.r, v3c.r)
   PLANE_DETS(g, v1c.g, v2c.g, v3c.g)
   PLANE_DETS(b, v1c.b, v2c.b, v3c.b)
   PLANE_DETS(a, v1c.a, v2c.a, v3c.a)
   PLANE_DETS(u, v1->u, v2->u, v3->u)
   PLANE_DETS(v, v1->v, v2->v, v3->v)

   state_texture_grad_any_2d* s = (state_texture_grad_any_2d*)state;
   
   s->solid.target = al_get_target_bitmap();
   s->solid.w = al_get_bitmap_width(s->solid.texture);
   s->solid.h = al_get_bitmap_height(s->solid.texture);

   s->solid.off_x = v1->x - 0.5f;
   s->solid.off_y = v1->y + 0.5f;

   if (det_u == 0.0) {
      s->solid.du_dx = s->solid.du_dy = s->solid.u_const = 0.0;
      s->solid.dv_dx = s->solid.dv_dy = s->solid.v_const = 0.0;
      s->color_dx = s->color_dy = s->color_const = al_map_rgba_f(0, 0, 0, 0);
   }
   else {
      s->solid.du_dx    = -u_det_x / det_u;
      s->solid.du_dy    = -u_det_y / det_u;
      s->solid.u_const  = u_det / det_u;

      s->solid.dv_dx    = -v_det_x / det_u;
      s->solid.dv_dy    = -v_det_y / det_u;
      s->solid.v_const  = v_det / det_u;

      s->color_dx.r    = -r_det_x / det_u;
      s->color_dy.r    = -r_det_y / det_u;
      s->color_const.r = r_det / det_u;

      s->color_dx.g    = -g_det_x / det_u;
      s->color_dy.g    = -g_det_y / det_u;
      s->color_const.g = g_det / det_u;

      s->color_dx.b    = -b_det_x / det_u;
      s->color_dy.b    = -b_det_y / det_u;
      s->color_const.b = b_det / det_u;

      s->color_dx.a    = -a_det_x / det_u;
      s->color_dy.a    = -a_det_y / det_u;
      s->color_const.a = a_det / det_u;
   }
}
Exemplo n.º 30
0
void Bill::Sprite::paint() {
	if (!bitmap)
		this->bitmap = al_create_bitmap(width, height);

	ALLEGRO_BITMAP *current = al_get_target_bitmap();

	al_set_target_bitmap(this->bitmap);
	al_clear_to_color(this->color);
	
	al_set_target_bitmap(current);
}