Object CreateObject(Vector2 pos, float r, ALLEGRO_BITMAP* obj_bitmap, ALLEGRO_BITMAP* exp_bitmap) { Object object; object.pos = pos; object.vel = CreateVector2(0, 0); object.acc = CreateVector2(0, 0); object.r = r; object.d = 2 * r; object.first_update = true; // inicjalizujemy obiekt eksplozji (parametry na podstawie pliku graficznego): object.explosion = CreateExplosion(CreateAnimation(object.pos, 38, 1, CreateSize(128, 128), CreateSize(object.d * 4, object.d * 4), exp_bitmap)); object.entrance_animation.active = false; object.bitmap = obj_bitmap; return object; }
int main() { eosFrameBuffer fb; if(eosFrameBuffer_Open(&fb)) { return 0; } CFrameBuffer bf = CreateFrameBuffer(1366, 768); struct timeval start, end; long mtime, seconds, useconds; gettimeofday(&start, NULL); // Draw background rectangle. CRect bg_rect = CreateRect(100, 100, 200, 200); CColor bg_color = CreateColor(240, 0, 0); DrawRectangle(&bf, &bg_rect, &bg_color); // Draw rectangle contour. //CColor contour_color = CreateColor(0, 0, 0); //DrawRectangleContour(&bf, &bg_rect, &contour_color); // Draw diagonal line. //CPoint p0 = CPoint_Create(0, 499); //CPoint p1 = CPoint_Create(499, 0); //CColor p_color = CreateColor(255, 255, 0); //DrawLine(&bf, &p0, &p1, &p_color); // Draw char. CFont font = CreateFont("resources/test.myfont"); //CPoint char_pos = CPoint_Create(300, 100); //CColor char_color = CreateColor(255, 255, 255); //DrawChar(&bf, &font, 'P', &char_pos, &char_color); // Draw text. CPoint str_pos = CPoint_Create(100, 200); CColor str_color = CreateColor(180, 180, 180); DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color); // Draw text. CPoint str2_pos = CPoint_Create(100, 220); CColor str2_color = CreateColor(10, 180, 180); DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color); // Get text width. //CString mst_str = CString_Create("Monster Truck"); //printf("Monster Truck width : %d\n", GetStringXSize(&font, &mst_str)); // Draw image resize. CImage image = CreateImageFromBitmap("resources/umbrella2.bmp"); CPoint img_pos = CPoint_Create(300, 51); CSize img_size = CreateSize(500, 500); DrawImageResize(&bf, &image, &img_pos, &img_size); eosFrameBuffer_Draw(&fb); eosFrameBuffer_DrawBackBuffer(&fb, &bf); gettimeofday(&end, NULL); seconds = end.tv_sec - start.tv_sec; useconds = end.tv_usec - start.tv_usec; mtime = seconds + useconds; printf("Elapsed time: %d ms\n", mtime / 1000); gettimeofday(&start, NULL); DrawRectangle(&bf, &bg_rect, &bg_color); DrawString(&bf, &font, "Monster Truck", &str_pos, &str_color); DrawString(&bf, &font, "Monster Truck", &str2_pos, &str2_color); DrawImageResize(&bf, &image, &img_pos, &img_size); eosFrameBuffer_DrawBackBuffer(&fb, &bf); gettimeofday(&end, NULL); seconds = end.tv_sec - start.tv_sec; useconds = end.tv_usec - start.tv_usec; mtime = seconds + useconds; printf("Elapsed time: %d ms\n", mtime / 1000); eosFrameBuffer_Close(&fb); //printf("FIX:\n"); //printf("FB len : %d\n", m_FixInfo.smem_len); //printf("FB type : %d\n", m_FixInfo.type); //printf("FB type aux : %d\n", m_FixInfo.type_aux); //printf("FB visual : %d\n", m_FixInfo.visual); //printf("FB xpanstep : %d\n", m_FixInfo.xpanstep); //printf("FB ypanstep : %d\n", m_FixInfo.ypanstep); //printf("FB ywrapstep : %d\n", m_FixInfo.ywrapstep); //printf("FB line_length : %d\n", m_FixInfo.line_length); //printf("VAR:\n"); //printf("Res : %d %d\n", m_VarInfo.xres, m_VarInfo.yres); //printf("Res virtual : %d %d\n", m_VarInfo.xres_virtual, m_VarInfo.yres_virtual); //printf("Offset : %d %d\n", m_VarInfo.xoffset, m_VarInfo.yoffset); //printf("bits_per_pixel : %d\n", m_VarInfo.bits_per_pixel); //printf("grayscale : %d\n", m_VarInfo.grayscale); return 0; }