EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
C++代做
您的位置: 主页 > 编程案例 > C++代做 >
代做C++/C:C++ Allegro代写 | 游戏代写 | Lightning Game - C++代做
发布时间:2021-07-25 22:55:17浏览次数:
1.语言及环境:用C语言的Allegro 5套件写一个类似雷电的2D射击小游戏(大一课设水平),须使用提供的template(后面有关于template的说明2.内容:(1)游戏主选单:StartAboutExit(2)游戏主体:外观:战机,血条(蓝条),子弹 游戏性:射击子弹,移动,击中扣血等…(3)游戏结束画面:WinGame OverRestartEnd4.以下几样选5样做就行:(1)开头+人物动画(可截取多张图片连续display(2)厉害的AI(比如子弹追踪等…(3)道具(4)商店系统(5)存档,读档(6)背景音乐-and so on对于Template中所提供code中各func的解释:game_init():初始化所有控制器game_begin():初始游戏介面game_run():游戏主体(while循环内,会持续刷新接收queue指令)game_destroy():对queue,display等的摧毁,防占用内存process_event():控制各式event(键盘 鼠标)show_err_msg(int msg):方便debug范例:#include stdio.h #include allegro5/allegro.h #include allegro5/allegro_primitives.h #include allegro5/allegro_image.h #include allegro5/allegro_audio.h #include allegro5/allegro_acodec.h #include allegro5/allegro_font.h #include allegro5/allegro_ttf.h #define GAME_TERMINATE -1// ALLEGRO VariablesALLEGRO_DISPLAY* display = NULL;ALLEGRO_EVENT_QUEUE *event_queue = NULL;ALLEGRO_BITMAP *image = NULL;ALLEGRO_BITMAP *image2 = NULL;ALLEGRO_BITMAP *image3 = NULL;ALLEGRO_BITMAP *background = NULL;ALLEGRO_KEYBOARD_STATE keyState ;ALLEGRO_TIMER *timer = NULL;ALLEGRO_TIMER *timer2 = NULL;ALLEGRO_TIMER *timer3 = NULL;ALLEGRO_SAMPLE *song=NULL;ALLEGRO_FONT *font = NULL;//Custom Definitionconst char *title = "Final Project 10xxxxxxx";const float FPS = 60;const int WIDTH = 400;const int HEIGHT = 600;typedef struct characterint x;int y;ALLEGRO_BITMAP *image_path;}Character;Character character1;Character character2;Character character3;int imageWidth = 0;int imageHeight = 0;int draw = 0;int done = 0;int window = 1;bool judge_next_window = false;bool ture = true; //true: appear, false: disappearbool next = false; //true: triggerbool dir = true; //true: left, false: rightvoid show_err_msg(int msg);void game_init();void game_begin();int process_event();int game_run();void game_destroy();int main(int argc, char *argv[]) {int msg = 0;game_init();game_begin();while (msg != GAME_TERMINATE) {msg = game_run();if (msg == GAME_TERMINATE)printf("Game Over ");game_destroy();return 0;void show_err_msg(int msg) {fprintf(stderr, "unexpected msg: %d ", msg);game_destroy();exit(9);void game_init() {if (!al_init()) {show_err_msg(-1);if(!al_install_audio()){fprintf(stderr, "failed to initialize audio! ");show_err_msg(-2);if(!al_init_acodec_addon()){fprintf(stderr, "failed to initialize audio codecs! ");show_err_msg(-3);if (!al_reserve_samples(1)){fprintf(stderr, "failed to reserve samples! ");show_err_msg(-4);// Create displaydisplay = al_create_display(WIDTH, HEIGHT);event_queue = al_create_event_queue();if (display == NULL || event_queue == NULL) {show_err_msg(-5);// Initialize Allegro settingsal_set_window_position(display, 0, 0);al_set_window_title(display, title);al_init_primitives_addon();al_install_keyboard();al_install_audio();al_init_image_addon();al_init_acodec_addon();al_init_font_addon();al_init_ttf_addon();// Register evental_register_event_source(event_queue, al_get_display_event_source(display));al_register_event_source(event_queue, al_get_keyboard_event_source());void game_begin() {// Load soundsong = al_load_sample( "hello.wav" );if (!song){printf( "Audio clip sample not loaded! " );show_err_msg(-6);// Loop the song until the display closesal_play_sample(song, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_LOOP,NULL);al_clear_to_color(al_map_rgb(100,100,100));// Load and draw textfont = al_load_ttf_font("pirulen.ttf",12,0);al_draw_text(font, al_map_rgb(255,255,255), WIDTH/2, HEIGHT/2+220 , ALLEGRO_ALIGN_CENTRE, "Press 'Enter' to start");al_draw_rectangle(WIDTH/2-150, 510, WIDTH/2+150, 550, al_map_rgb(255, 255, 255), 0);al_flip_display();int process_event(){// Request the eventALLEGRO_EVENT event;al_wait_for_event(event_queue, event);// Our setting for controlling animationif(event.timer.source == timer){if(character2.x -150) dir = false;else if(character2.x WIDTH+50) dir = true;if(dir) character2.x -= 10;else character2.x += 10;if(event.timer.source == timer2){ture = false;next = true;if(event.timer.source == timer3){if(next) next = false;else ture = true;// Keyboardif(event.type == ALLEGRO_EVENT_KEY_UP)switch(event.keyboard.keycode)// Controlcase ALLEGRO_KEY_W:character1.y -= 30;break;case ALLEGRO_KEY_S:character1.y += 30;break;case ALLEGRO_KEY_A:character1.x -= 30;break;case ALLEGRO_KEY_D:character1.x += 30;break;// For Start Menucase ALLEGRO_KEY_ENTER:judge_next_window = true;break;// Shutdown our programelse if(event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)return GAME_TERMINATE;return 0;int game_run() {int error = 0;// First window(Menu)if(window == 1){if (!al_is_event_queue_empty(event_queue)) {error = process_event();if(judge_next_window) {window = 2;// Setting Charactercharacter1.x = WIDTH / 2;character1.y = HEIGHT / 2 + 150;character2.x = WIDTH + 100;character2.y = HEIGHT / 2 - 280;character1.image_path = al_load_bitmap("tower.png");character2.image_path = al_load_bitmap("teemo_left.png");character3.image_path = al_load_bitmap("teemo_right.png");background = al_load_bitmap("stage.jpg");//Initialize Timertimer = al_create_timer(1.0/15.0);timer2 = al_create_timer(1.0);timer3 = al_create_timer(1.0/10.0);al_register_event_source(event_queue, al_get_timer_event_source(timer)) ;al_register_event_source(event_queue, al_get_timer_event_source(timer2)) ;al_register_event_source(event_queue, al_get_timer_event_source(timer3)) ;al_start_timer(timer);al_start_timer(timer2);al_start_timer(timer3);// Second window(Main Game)else if(window == 2){// Change Image for animational_draw_bitmap(background, 0,0, 0);if(ture) al_draw_bitmap(character1.image_path, character1.x, character1.y, 0);if(dir) al_draw_bitmap(character2.image_path, character2.x, character2.y, 0);else al_draw_bitmap(character3.image_path, character2.x, character2.y, 0);al_flip_display();al_clear_to_color(al_map_rgb(0,0,0));// Listening for new eventif (!al_is_event_queue_empty(event_queue)) {error = process_event();return error;void game_destroy() {// Make sure you destroy all thingsal_destroy_event_queue(event_queue);al_destroy_display(display);al_destroy_timer(timer);al_destroy_timer(timer2);al_destroy_bitmap(image);al_destroy_sample(song)

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。