int main() { allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT,640,480,0,0); ball=load_bitmap("ball.bmp",NULL); buffer=create_bitmap(SCREEN_W,SCREEN_H); ball_x=SCREEN_W/2; ball_y=SCREEN_H/2; srand(time(NULL)); direction= rand()%4; while(!key[KEY_ESC]) { moveball(); clear_to_color(screen,makecol(256,256,256)); blit(ball,buffer,0,0,ball_x,ball_y,ball->w,ball->h); blit(buffer,screen,0,0,0,0,buffer->w,buffer->h); clear_bitmap(buffer); } destroy_bitmap(ball); destroy_bitmap(buffer); return(0); }
void play(void) // Our Budding Game Engine { uint16_t i; i = 100; enSet(0, 500, 1, 1, enNONCIRC, enU16, &i); while(1){ // Check wether key press is Q if so exit loop moveball(); physics(); enGet(); //EN delay_ms(i); // Reduce game speed to human playable level } }
void bubblesTask(void *pvParameters){ uint16_t old_val_encoder = enGeReg(); uiGraphicsColor = black; uiTextColor = RGB; lcd_Clear(); initialize(); while(1){ moveball(); physics(); //======== обработка кнопок ========// if(BtScan() || (old_val_encoder != enGeReg())){ // BeepTime(100); xTaskCreate(baseTSK, "baseTSK", BASE_TSK_SZ_STACK, NULL, 2, NULL); vTaskDelete(NULL); //”дал¤ем текущую задачу } vTaskDelay(60); } }
void drawgame() { if(mxhwnd.KeyCheck(DIK_UP)) { if(bar_y > 0) { bar_y = bar_y - 6; } else { bar_y = 0; } } if(mxhwnd.KeyCheck(DIK_DOWN)) { if(bar_y < 480-80) { bar_y = bar_y + 6; } else { bar_y = 480-80; } } moveball(); // drawing the wall mxhwnd.paint.mxdrawrect(640-10,0,640,480,RGB(255,255,255),RGB(255,255,255)); // ddrawing th ebar mxhwnd.paint.mxdrawrect(bar_x,bar_y,bar_x+10,bar_y+80,RGB(255,255,255),RGB(255,255,255)); // drawing the ball //mxhwnd.paint.mxdrawellipse(ball_x,ball_y,ball_x + 10,ball_y + 10,RGB(255,255,255),RGB(255,255,255)); ball.DisplayGraphic(ball_x,ball_y); drawscore(); }