Example #1
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));
	}
}
/* ----------------------------------------------------------------------------
 * Draws the textbox. It's basically a rectangle with a border.
 * The border is drawn line by line. Finally, it draws the
 * text within.
 */
void textbox::draw_self() {
    al_draw_filled_rectangle(x1, y1, x2, y2, get_bg_color());
    draw_line(this, DRAW_LINE_TOP,    0, 1, 0, get_darker_bg_color());  // Top line.
    draw_line(this, DRAW_LINE_LEFT,   0, 1, 0, get_darker_bg_color());  // Left line.
    draw_line(this, DRAW_LINE_BOTTOM, 1, 0, 0, get_lighter_bg_color()); // Bottom line.
    draw_line(this, DRAW_LINE_RIGHT,  1, 0, 0, get_lighter_bg_color()); // Right line.
    
    if(style->text_font) {
        int text_start = x1 + 2 - scroll_x;
        
        if(parent->focused_widget == this) {
            al_draw_filled_rectangle(
                text_start + al_get_text_width(style->text_font, text.substr(0, min(sel_start, sel_end)).c_str()),
                y1 + 2,
                text_start + al_get_text_width(style->text_font, text.substr(0, max(sel_start, sel_end)).c_str()),
                y2 - 2,
                get_alt_color()
            );
        }
        
        al_draw_text(style->text_font, get_fg_color(), text_start, (y2 + y1) / 2  - al_get_font_line_height(style->text_font) / 2, 0, text.c_str());
        
        unsigned int cursor_x = al_get_text_width(style->text_font, text.substr(0, cursor).c_str());
        
        if(parent->focused_widget == this) {
            al_draw_line(
                x1 + cursor_x + 1.5 - scroll_x,
                y1 + 2,
                x1 + cursor_x + 1.5 - scroll_x,
                y2 - 2,
                get_alt_color(),
                1);
        }
    }
}
Example #3
0
void draw_referencing_line(const int sx, const int sy, const int cx, const int cy) {
  const int tborder_x1 = BORDER_WIDTH;
  const int tborder_x2 = TABLE_WIDTH - BORDER_WIDTH;
  const int tborder_y1 = TABLE_Y_POSITION + BORDER_WIDTH;
  const int tborder_y2 = TABLE_Y_POSITION + TABLE_HEIGHT - BORDER_WIDTH;
  const int dx = sx - cx;
  const int dy = sy - cy;
  int line_x = sx, line_y = sy;
  double delta;

  if(dx == 0 && dy == 0)
    return;

  while(1)
  {
    line_x += dx;
    line_y += dy;
    if(line_x <= tborder_x1 || line_x >= tborder_x2)
    {
      line_x = (line_x <= tborder_x1 ? tborder_x1 : tborder_x2);
      delta = 1.0 * (line_x - sx) / dx;
      line_y = sy + (int) (dy * delta);
      break;
    }
    if(line_y <= tborder_y1 || line_y >= tborder_y2)
    {
      line_y = (line_y <= tborder_y1 ? tborder_y1 : tborder_y2);
      delta = 1.0 * (line_y - sy) / dy;
      line_x = sx + (int) (dx * delta);
      break;
    }
  }

  al_draw_line(line_x, line_y, cx, cy, color_white(), RL_WIDTH);
}
Example #4
0
void particle::render(double tx, double ty){
    if(tracer){
        al_draw_line( tx-x_vel, ty-y_vel, tx, ty, color, 0 );
    }else{
        al_draw_pixel( tx, ty, color);
    }
}
static void plonk(const int x, const int y, bool blend)
{
   al_set_target_bitmap(dbuf);

   fade();
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ZERO);
   draw_clip_rect();
   red_dot(x, y);

   if (last_x == -1 && last_y == -1) {
      last_x = x;
      last_y = y;
   }
   else {
      my_set_clip_rect();
      if (blend) {
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
      }
      al_draw_line(last_x, last_y, x, y, white, 0);
      last_x = last_y = -1;
      reset_clip_rect();
   }

   flip();
}
Example #6
0
void Draw_body(b2Body* body, b2Vec2 camera)
{
	float scale = 10;
	b2Vec2 position = scale*body->GetPosition() - camera;
	float32 angle = body->GetAngle();

	al_draw_pixel(position.x, position.y, al_map_rgb_f(1, 0, 0));

	for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext())
	{
		b2Shape* shape_base = f->GetShape();
		if(shape_base->GetType() == b2Shape::e_polygon)
		{
			b2PolygonShape& shape = dynamic_cast<b2PolygonShape&>(*shape_base);
			int np = shape.GetVertexCount ();
			b2Vec2 pn = scale*shape.GetVertex(np-1);
			b2Vec2 ps, pe;
			ps.x = cos(angle)*pn.x - sin(angle)*pn.y;
			ps.y = sin(angle)*pn.x + cos(angle)*pn.y;
			for(int i=0; i<np; ++i)
			{
				pn = scale*shape.GetVertex(i);
				pe.x = cos(angle)*pn.x - sin(angle)*pn.y;
				pe.y = sin(angle)*pn.x + cos(angle)*pn.y;
				al_draw_line(position.x+ps.x, position.y+ps.y, position.x+pe.x, position.y+pe.y, al_map_rgb_f(1, 0, 0), 0);
				ps = pe;
			}
		}
		if(shape_base->GetType() == b2Shape::e_circle)
		{
			b2CircleShape& shape = dynamic_cast<b2CircleShape&>(*shape_base);
			al_draw_circle(position.x, position.y, shape.m_radius * scale, al_map_rgb_f(1, 0, 0), 0);
		}
	}
}
Example #7
0
void particle::render(){
    if(tracer){
        al_draw_line( x-x_vel, y-y_vel, x, y, color, 0 );
    }else{
        al_draw_pixel( x, y, color);
    }
}
Example #8
0
void Inputbox_view::Render(const Widget& widget) const
{
	const Inputbox& inputbox = dynamic_cast<const Inputbox&>(widget);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	ALLEGRO_COLOR text_color = al_map_rgb_f(0, 0, 0);
	ALLEGRO_COLOR bg_color = al_map_rgb_f(1, 1, 1);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5);

	al_draw_filled_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, bg_color);
	al_draw_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, edge_color, 0);

	int y = p.y + 3;
	int x = p.x + 3;
	const Ustring& text = inputbox.Get_text();
	
	if(inputbox.Has_focus())
	{
		int sel_s = inputbox.Get_selection_start();
		int sel_e = inputbox.Get_selection_end();

		int cp_s = font->Get_ustr_width(text.Substring(0, sel_s).Astring());
		int cp_e = font->Get_ustr_width(text.Substring(0, sel_e).Astring());
		int h = al_get_font_line_height(font->Afont());
		if(sel_s != sel_e)
			al_draw_filled_rectangle(x+cp_s-1, y, x+cp_e, y+h, al_map_rgb_f(0.5, 0.5, 1));
		else if(cursor_flash>0)
			al_draw_line(x+cp_e-1, y, x+cp_e, y+h, al_map_rgb_f(0, 0, 0), 0);
	}

	al_draw_ustr(font->Afont(), text_color, x, y, 0, text.Astring());
}
Example #9
0
void draw_ship(game *game) {
    ALLEGRO_TRANSFORM trans;
    al_identity_transform(&trans);
    al_rotate_transform(&trans, game->Ship->angle);
    al_translate_transform(&trans,
                           (int)game->Ship->position->x,
                           (int)game->Ship->position->y);
    al_use_transform(&trans);
    
    float w = game->Ship->time >= 0 ? 1 : 4;
    
    al_draw_line(-8, 20, 0, 0, SHIP_COLOR, w);
    al_draw_line(8, 20, 0, 0, SHIP_COLOR, w);
    al_draw_line(-6, 15, -1, 15, SHIP_COLOR, w);
    al_draw_line(6, 15, 1, 15, SHIP_COLOR, w);
}
Example #10
0
static void redraw(void)
{
    ALLEGRO_COLOR black, white;
    int w, h;

    white = al_map_rgba_f(1, 1, 1, 1);
    black = al_map_rgba_f(0, 0, 0, 1);

    al_clear_to_color(white);
    w = al_get_display_width();
    h = al_get_display_height();
    al_draw_line(0, h, w / 2, 0, black, 0);
    al_draw_line(w / 2, 0, w, h, black, 0);
    al_draw_line(w / 4, h / 2, 3 * w / 4, h / 2, black, 0);
    al_flip_display();
}
Example #11
0
bool InputField::Bitmap()
{

   // al_set_target_bitmap(bmp);
    al_set_target_bitmap(as_bitmap);
    al_clear_to_color(bckground_color);

    //float tx = (text_width <= width ? 0 : width - text_width);
    float tx = (text_width <= width ? (center == true ? (width - text_width)/2 : 0) : width - text_width);

    al_draw_text(font, text_color, tx, (height - text_height) / 2.0f, 0, text.c_str());

    if(detectingbutton->is_button_clicked() == true)
    {
        if(bling > 30)
        {
            al_draw_line(tx + text_width -2, (height - text_height) / 2.0f, tx + text_width -2, (height + text_height) / 2.0f, text_color, 2);
            if(bling > 60)
            {
                bling = 0;
            }
        }
        bling++;
    }

    /*al_set_target_bitmap(as_bitmap);
    al_clear_to_color(al_map_rgba(0,0,0,0));
    al_draw_bitmap(bmp, 0, 0, 0);*/
    al_draw_rounded_rectangle(0, 0, width, height, 5, 5, outline_color, 2);
    al_set_target_backbuffer(al_get_current_display());
    return true;
}
static void draw(void)
{
   const float sw = al_get_bitmap_width(bmp);
   const float sh = al_get_bitmap_height(bmp);
   const float dw = al_get_bitmap_width(dbuf);
   const float dh = al_get_bitmap_height(dbuf);
   const float dx = dw / 2.0;
   const float dy = dh / 2.0;
   float db_l;
   float db_r;
   float db;
   float scale;
   float disp;

   /* Whatever looks okay. */
   if (rms_l > 0.0 && rms_r > 0.0) {
      db_l = 20 * log10(rms_l / 20e-6);
      db_r = 20 * log10(rms_r / 20e-6);
      db = (db_l + db_r) / 2.0;
      scale = db / 20.0;
      disp = (rms_l + rms_r) * 200.0;
   }
   else {
      db_l = db_r = db = scale = disp = 0.0;
   }

   al_set_target_bitmap(dbuf);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
   al_draw_filled_rectangle(0, 0, al_get_bitmap_width(dbuf), al_get_bitmap_height(dbuf),
      al_map_rgba_f(0.8, 0.3, 0.1, 0.06));
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
   al_draw_tinted_scaled_rotated_bitmap(bmp,
      al_map_rgba_f(0.8, 0.3, 0.1, 0.2),
      sw/2.0, sh/2.0, dx, dy - disp, scale, scale, theta, 0);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
   al_set_target_backbuffer(display);
   al_draw_bitmap(dbuf, 0, 0, 0);

   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
   al_draw_line(10, dh - db_l, 10, dh, al_map_rgb_f(1, 0.6, 0.2), 6);
   al_draw_line(20, dh - db_r, 20, dh, al_map_rgb_f(1, 0.6, 0.2), 6);

   al_flip_display();

   theta -= (rms_l + rms_r) * 0.1;
}
Example #13
0
			void entityGUIChat::render(float oX,float oY){
			ALLEGRO_MOUSE_STATE mState; //Mouse state
			al_get_mouse_state(&mState); //Get the state of the mouse

			al_hold_bitmap_drawing(true);
			al_draw_bitmap(chatBoxCache,x,y-31-al_get_bitmap_height(chatBoxCache),0);

			if (resizingChatVertical || gameEngine::globalFunctions::pointInRegion(mState.x,mState.y,x,y-31-(drawLines*lineHeight)-7,x+chatWidth,y-31-(drawLines*lineHeight)+2)) {
				al_draw_line(x,y-31-al_get_bitmap_height(chatBoxCache),x+chatWidth,y-31-al_get_bitmap_height(chatBoxCache),al_map_rgb(255,255,255),1);
				al_draw_line(x,y-31-al_get_bitmap_height(chatBoxCache)+2,x+chatWidth,y-31-al_get_bitmap_height(chatBoxCache)+2,al_map_rgb(255,255,255),1);
			}

			al_draw_bitmap(chatTypeBG,x,y-26,0);
			textEntryBox->render(x+99,y-26,1);
			al_hold_bitmap_drawing(false);
				
			}
Example #14
0
void particle_circ::render(double tx, double ty){
    if(tracer){
        al_draw_line( tx-x_vel/2, ty-y_vel/2, tx, ty, color, 2*rad );
        al_draw_filled_circle( tx-x_vel/2, ty-y_vel/2, rad, color);
        al_draw_filled_circle( tx, ty, rad, color);
    }else{
        al_draw_filled_circle( tx, ty, rad, color);
    }
}
Example #15
0
		void ShapeRenderer::drawLine(float x1, float y1, float x2, float y2, float lineW, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
		{
			ALLEGRO_COLOR color;
			if (a != UINT8_MAX)
				color = al_map_rgba(r, g, b, a);
			else
				color = al_map_rgb(r, g, b);
			al_draw_line((x1 + xOff) * xScale, (y1 + yOff) * yScale, (x2 + xOff) * xScale, (y2 + yOff) * yScale, color, lineW);
		}
Example #16
0
/* ----------------------------------------------------------------------------
 * Draws the checkbox box. It's just a square with a fancy border.
 * The latter is drawn line by line. It also draws the checkmark,
 * if the box is ticked.
 */
void checkbox_box::draw_self() {
    al_draw_filled_rectangle(x1, y1, x2, y2, get_bg_color());
    //Top line.
    draw_line(this, DRAW_LINE_TOP,    0, 1, 0, get_darker_bg_color());
    //Left line.
    draw_line(this, DRAW_LINE_LEFT,   0, 1, 0, get_darker_bg_color());
    //Bottom line.
    draw_line(this, DRAW_LINE_BOTTOM, 1, 0, 0, get_lighter_bg_color());
    //Right line.
    draw_line(this, DRAW_LINE_RIGHT,  1, 0, 0, get_lighter_bg_color());
    
    if(checked) {
        //Southeast-going line.
        al_draw_line(x1 + 2.5, y1 + 6.5, x1 + 5.5, y1 + 9.5, get_fg_color(), 3);
        //Northeast-going line.
        al_draw_line(x1 + 3.5, y1 + 9.5, x1 + 10,  y1 + 3,   get_fg_color(), 3);
    }
}
void t3f_draw_morphed_vector_object(T3F_VECTOR_OBJECT * vp, float x, float y, float z, float sx, float sy, float sz, float tscale)
{
	int i;
	
	for(i = 0; i < vp->segments; i++)
	{
		al_draw_line(t3f_3d_project_x(x + vp->segment[i]->point[0].x * sx, vp->segment[i]->point[0].z * sz + z) + 0.5, t3f_3d_project_y(y + vp->segment[i]->point[0].y * sy, vp->segment[i]->point[0].z * sz + z) + 0.5, t3f_3d_project_x(x + vp->segment[i]->point[1].x * sx, vp->segment[i]->point[1].z * sz + z) + 0.5, t3f_3d_project_y(y + vp->segment[i]->point[1].y * sy, vp->segment[i]->point[1].z * sz + z) + 0.5, vp->segment[i]->color, vp->segment[i]->thickness * tscale);
	}
}
Example #18
0
void particle_circ::render(){
    if(tracer){
        al_draw_line( x-x_vel/2, y-y_vel/2, x, y, color, 2*rad );
        al_draw_filled_circle( x-x_vel/2, y-y_vel/2, rad, color);
        al_draw_filled_circle( x, y, rad, color);
    }else{
        al_draw_filled_circle( x, y, rad, color);
    }
}
void t3f_draw_tinted_morphed_vector_object_extrusion(T3F_VECTOR_OBJECT * vp, float x, float y, float z, float sx, float sy, float sz, float lz, float tscale, ALLEGRO_COLOR color)
{
	int i;
	
	for(i = 0; i < vp->segments; i++)
	{
		al_draw_line(t3f_3d_project_x(x + vp->segment[i]->point[0].x * sx, vp->segment[i]->point[0].z * sz + z) + 0.5, t3f_3d_project_y(y + vp->segment[i]->point[0].y * sy, vp->segment[i]->point[0].z * sz + z) + 0.5, t3f_3d_project_x(x + vp->segment[i]->point[0].x * sx, vp->segment[i]->point[0].z * sz + z + lz) + 0.5, t3f_3d_project_y(y + vp->segment[i]->point[0].y * sy, vp->segment[i]->point[0].z * sz + z + lz) + 0.5, color, vp->segment[i]->thickness * tscale);
	}
}
 void Function::draw_in_another_target()
 {
     if(_V_init_function<=_V_final_function)
     {
         Type_pos i=_V_init_function;
         Type_pos j=_V_init_function+_V_step_function;
         while(j<_V_final_function)
         {
             al_draw_line((i)+_V_cam_pos_x,(_P_Function_fx(i))+_V_cam_pos_y,
                          (j)+_V_cam_pos_x,(_P_Function_fx(j))+_V_cam_pos_y,
                          _V_color,_V_thickness);
             i+=_V_step_function;
             j+=_V_step_function;
         }
         al_draw_line((i)+_V_cam_pos_x,(_P_Function_fx(i))+_V_cam_pos_y,
                      (_V_final_function)+_V_cam_pos_x,(_P_Function_fx(_V_final_function))+_V_cam_pos_y,
                      _V_color,_V_thickness);
     }
 }
Example #21
0
void drawGradient(Area area, const Color& from, const Color& to, bool withFrame)
{
    for (float i = area.y1(); i < area.y2(); ++i) {
        al_draw_line(area.x1(), i, area.x2(), i, Color(from * ((area.y2()-i)/area.h()) + to * ((i-area.y1())/area.h())), 1.5);
    }

    if (withFrame) {
        al_draw_rectangle(AREA, Color::black(), 1.5);
    }
}
Example #22
0
bool GameState::render() { 
    //simplog.writeLog( LOG_VERBOSE, "render" );

    // Clear screen to black
    al_clear_to_color( al_map_rgb( 0, 0, 0 ) );

    double xPix = 300 / 10;
    double yPix = 600 / 20;

    // Draw the X gridlines
    for( int i = 250; i <= 551; i+=xPix) {
        al_draw_line( i, 0, i, 800, al_map_rgb( 255, 255, 255 ), 1);
    }

    // Draw the Y gridlines
    for( int i = 0; i <= 600; i+=yPix) {
        al_draw_line(250, i, 550, i, al_map_rgb( 255, 255, 255 ), 1);
    }

    //simplog.writeLog( LOG_VERBOSE, "about to draw" );
    // Draw the grid
    for( int i = 0; i < 10; i++ ) {
        for( int j = 0; j < 20; j++ ) {
            //simplog.writeLog( LOG_VERBOSE, "checking if exists" );
            if( grid->get( j, i )->doesExist() ) {
                al_draw_tinted_bitmap( grid->get( j, i )->getBlock(), grid->get( j, i)->getColor(), 250 + i * 30, 1 + j * 30, 0 );
            }
        }
    }

    // Do not draw piece if it currently does not exists
    if( currentPiece != nullptr ) {
        //simplog.writeLog( LOG_VERBOSE, "drawing" );
        currentPiece->draw();    
    }

    if( nextPiece != nullptr ) {
        nextPiece->draw();
    }
    
   return true;
}
Example #23
0
void draw_horizontal_arrow(float x0, float y0, float x1, float y1, ALLEGRO_COLOR color, float thickness)
{
    float aw = 4;
    float ah = 2;
    
    if(x1<x0) aw *= -1;
    
    al_draw_line(x0, y0, x1-aw*thickness, y1, color, thickness);
    al_draw_filled_triangle(x1, y1, x1-aw*thickness, y0+ah*thickness, x1-aw*thickness, y0-ah*thickness, color);
    al_draw_filled_triangle(x1, y1, x1-aw*thickness, y0+ah*thickness, x1-aw*thickness, y0-ah*thickness, color);
}
Example #24
0
void Textbox::draw()
{
    al_draw_filled_rectangle(AREA, al_map_rgba(255,255,255,1));

    [=]{ // Lambda rysująca text
        int length = (text == "" ? default_text : text).size();
        float x = area.x() + font_size;
        const float y = area.y() + font_size;
        for (int i = 0; i < text.size(); ++i) {
            if (x + al_get_text_width(font(font_size), (text == "" ? default_text : text).substr(0, i+1).c_str()) >= area.x2()) {
                length = i;
                break;
            }
        }
        string text_to_draw = (text == "" ? default_text : text).substr(0, length);
        if (text == "") {
            al_draw_text(font(font_size), Color(200,200,200), x, y, ALLEGRO_ALIGN_LEFT, text_to_draw.c_str());
            return;
        }
        pair<int,int> s;
        s.first = range(selection.first, 0, length);
        s.second = range(selection.second, 0, length);
        string t = text_to_draw.substr(0, s.first);
        al_draw_text(font(font_size), Color::black(), x, y, ALLEGRO_ALIGN_LEFT, t.c_str());
        x += al_get_text_width(font(font_size), t.c_str());
        t = text_to_draw.substr(s.first, s.second - s.first);
        al_draw_filled_rectangle(x, y, x+al_get_text_width(font(font_size), t.c_str()), y+font_size, color);
        al_draw_text(font(font_size), color.ifDark() ? Color::white() : Color::black(), x, y, ALLEGRO_ALIGN_LEFT, t.c_str());
        x += al_get_text_width(font(font_size), t.c_str());
        t = text_to_draw.substr(s.second);
        al_draw_text(font(font_size), Color::black(), x, y, ALLEGRO_ALIGN_LEFT, t.c_str());
    }();

    //al_draw_rectangle(area.x1()+font_size/2, area.y1()+font_size/2, area.x2()-font_size/2, area.y2()-font_size/2, Color::white(), font_size);
    al_draw_filled_rectangle(area.x2()-font_size, area.y1(), area.x2(), area.y2(), Color::white());

    al_draw_rectangle(AREA, Color::black(), 1);

    if (cs.getInvaded() || cs.getIsPressed() || active) {

        int x = 7;
        for (float i = 0; i < x; ++i) {
            al_draw_rectangle(area.x1()+i, area.y1()+i, area.x2()-i, area.y2()-i, Color(0, 0, 0, 255-255*((i*2)/x)), 1);
        }

        if (active) {

            al_draw_rectangle(AREA, color, 3);
            if (show_cursor) {
                al_draw_line(cursor_x(), area.y() + font_size, cursor_x(), area.y() + font_size*2, Color::black(), font_size/10);
            }
        }
    }
}
Example #25
0
static void redraw(ALLEGRO_BITMAP *picture)
{
   ALLEGRO_COLOR color;
   ALLEGRO_BITMAP *target = al_get_target_bitmap();
   int w = al_get_bitmap_width(target);
   int h = al_get_bitmap_height(target);

   color = al_map_rgb(
       128 + rand() % 128,
       128 + rand() % 128,
       128 + rand() % 128);
   al_clear_to_color(color);

   color = al_map_rgb(255, 0, 0);
   al_draw_line(0, 0, w, h, color, 0);
   al_draw_line(0, h, w, 0, color, 0);

   al_draw_bitmap(picture, 0, 0, 0);
   al_flip_display();
}
void t3f_3d_draw_line(float x, float y, float z, float x2, float y2, float z2, ALLEGRO_COLOR color)
{
	float obx, oby, oex, oey;
	
	obx = t3f_3d_project_x(x, z);
	oex = t3f_3d_project_x(x2, z2);
	oby = t3f_3d_project_y(y, z);
	oey = t3f_3d_project_y(y2, z2);
	
	al_draw_line(obx, oby, oex, oey, color, 1.0);
}
 void Function::draw()
 {
     if(_V_init_function<=_V_final_function)
     {
         Type_pos i=_V_init_function;
         Type_pos j=_V_init_function+_V_step_function;
         while(j<_V_final_function)
         {
             al_draw_line((i*bitmap_scale_x)+_V_cam_pos_x,(_P_Function_fx(i)*bitmap_scale_y)+_V_cam_pos_y,
                          (j*bitmap_scale_x)+_V_cam_pos_x,(_P_Function_fx(j)*bitmap_scale_y)+_V_cam_pos_y,
                          _V_color,_V_thickness*primitives_scale);
             i+=_V_step_function;
             j+=_V_step_function;
         }
         al_draw_line((i*bitmap_scale_x)+_V_cam_pos_x,
                      (_P_Function_fx(i)*bitmap_scale_y)+_V_cam_pos_y,
                      (_V_final_function*bitmap_scale_x)+_V_cam_pos_x,
                      (_P_Function_fx(_V_final_function)*bitmap_scale_y)+_V_cam_pos_y,
                      _V_color,_V_thickness*primitives_scale);
     }
 }
void GameClass::DrawFloor (float x, float y, float xf, float yf) const {
  al_draw_filled_rectangle(x, y, xf, yf, cWhite);
  for (int i = 0; i < 5; i++) {
    float z = y + 2*i;
    al_draw_line(x, z, xf, z, cBlack, 0);
  }
  for (size_t i = 0; i < 20; i++) {
    float difX = 10 + (cTileSize-10)*(rand()%1001)/1000.0;
    float difY = 10 + (cTileSize-10)*(rand()%1001)/1000.0;
    al_draw_pixel(x + difX, y + difY, cBlack);
  }
}
bool printDefaultLifeBar(
    long int          lifeactual,
    long int          lifemax,
    long int          bar_x,
    long int          bar_y,
    long int          WIDTH,
    long int          HEIGHT,
    ALLEGRO_COLOR     col,
    int               thickness)
{
    volatile long     x = bar_x,
                      y = bar_y,
                      cont_bars = 0;
    float
    /*Porcentagem referente à [lifeactual] e [lifemax]*/
    percent   = (lifeactual*100) / lifemax;
    unsigned long
    /*Espacamento entre as barras menores*/
    spacement = thickness,

    /*Total de barras que preenche completamente o retangulo*/
    max_bars  = (WIDTH / (spacement + thickness)),

    /*Numero de barras que preenche o retangulo ate [percent]*/
    actual_max_bars = (percent * max_bars) / 100;

    if(lifeactual < 0 || WIDTH <= 0 || HEIGHT <= 0 ||
            lifeactual > lifemax || thickness <= 0)
        return (false);

    if(!USING_PRIMITIVES_ADDON)
    {
        al_init_primitives_addon();
        USING_PRIMITIVES_ADDON = true;
    }

    al_draw_rectangle(
        bar_x, bar_y,
        bar_x + WIDTH, bar_y + HEIGHT,
        col, thickness);

    for(cont_bars = 0; cont_bars < actual_max_bars; cont_bars++)
    {
        al_draw_line(
            x, y,
            x, y + HEIGHT,
            col, thickness);
        x += thickness + spacement;
    }

    return (true);
}
Example #30
0
void TripleAntenna::renderFeedback(Object *object, Environment *environment) {
    if (object == environment->getPlayer() && nearestObject) {
        if (nearestObject->isVisible()) {
            Vector2D windowPos = environment->getWindowPos(object->getPosition());        
            Vector2D objectWindowPos = environment->getWindowPos(nearestObjectPosition);
            al_draw_line(windowPos.getX(),
                         windowPos.getY(),
                         objectWindowPos.getX(),
                         objectWindowPos.getY(),
                         al_map_rgb(196, 196, 196), 2.0);
        }
    }
}