📄 init.cpp
字号:
OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, G1, G2, G3, G4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, TT, TT, OO, OO, OO, OO, G5, G6, G7, G8, OO, OO, OO, OO, TT, TT, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, TT, TT, OO, OO, OO, OO, G9, Ga, Gb, Gc, OO, OO, OO, OO, TT, TT, OO, OO, OO, OO, OO, OO, OO, OO, OO }; int bore_pos[][2] = { {0, 1}, {15, 1}, {32, 1}, {0, 6}, {32, 6} }; for (i = 0; i < PLANE_H; i++) for (j = 0; j < PLANE_W; j++) bg[i][j] = tmpbg[i][j]; for (i = 0; i < 5; i++) for (j = 0; j < 2; j++) ge->enemy_pos[i][j] = bore_pos[i][j]; } else if (ge->level == 3) { tiles = IMG_Load ("pics/tiles2.png"); SDL_BlitSurface (tiles, NULL, ge->tiles, NULL); SDL_FreeSurface (tiles); tmp = IMG_Load ("pics/map04.png"); ge->bore_enemy = 12; ge->enemy_left = 12 + 2; // ge->player_left = 3; ge->max_enemys = 4; int tmpbg[][34] = { OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, RV, OO, OO, B1, B2, A3, A4, A3, A4, A1, A3, A4, B1, B2, A3, A4, B1, B2, A3, A4, A3, A4, B1, B2, A3, A4, A3, A4, B1, B2, A3, A4, B3, OO, OO, OO, OO, B4, B5, A5, A6, A5, A6, B3, A5, A6, B4, B5, A5, A6, B4, B5, A5, A6, A5, A6, B4, B5, A5, A6, A5, A6, B4, B5, A5, A6, B3, OO, OO, OO, OO, A3, A4, OO, OO, A3, A4, B1, B2, B1, B2, B3, OO, OO, A3, A4, B1, B2, OO, OO, B3, A3, A4, B1, B2, A3, A4, OO, OO, B1, B2, OO, OO, OO, OO, A5, A6, OO, OO, A5, A6, B4, B5, B4, B5, A1, OO, OO, A5, A6, B4, B5, OO, OO, A1, A5, A6, B4, B5, A5, A6, OO, OO, B4, B5, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, B1, B2, B3, OO, OO, A3, A4, B1, B2, OO, OO, B3, B1, B2, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, B4, B5, B3, OO, OO, A5, A6, B4, B5, OO, OO, B3, B4, B5, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A3, A4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A3, A4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A5, A6, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A5, A6, OO, OO, OO, OO, OO, OO, HH, A1, B3, B3, OO, OO, B3, A1, OO, OO, A1, B3, B1, B2, A1, B3, B1, B2, A1, B3, B1, B2, A3, A4, OO, OO, A1, B3, OO, OO, B3, B3, A1, HH, A3, A4, B1, B2, OO, OO, OO, OO, OO, OO, A3, A4, B4, B5, A3, A4, B4, B5, A3, A4, B4, B5, A5, A6, OO, OO, OO, OO, OO, OO, B1, B2, A3, A4, A5, A6, B4, B5, OO, OO, OO, OO, OO, OO, A5, A6, B3, B3, A5, A6, A1, B3, A5, A6, B3, B3, A1, B3, OO, OO, OO, OO, OO, OO, B4, B5, A5, A6, B1, B2, A3, A4, B1, B2, A3, A4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A3, A4, B1, B2, A3, A4, B1, B2, B4, B5, A5, A6, B4, B5, A5, A6, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A5, A6, B4, B5, A5, A6, B4, B5, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, G1, G2, G3, G4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A3, A4, B3, OO, OO, G5, G6, G7, G8, OO, OO, B3, A3, A4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO, A5, A6, B3, OO, OO, G9, Ga, Gb, Gc, OO, OO, B3, A3, A4, OO, OO, OO, OO, OO, OO, OO, OO, OO, OO }; int bore_pos[][2] = { {0, 11}, {32, 11}, {0, 13}, {32, 13}, {32, 15} }; for (i = 0; i < PLANE_H; i++) for (j = 0; j < PLANE_W; j++) bg[i][j] = tmpbg[i][j]; for (i = 0; i < 5; i++) for (j = 0; j < 2; j++) ge->enemy_pos[i][j] = bore_pos[i][j]; ge->bigtank = IMG_Load ("pics/bigtanks.png"); SDL_SetColorKey (ge->bigtank, SDL_SRCCOLORKEY, SDL_MapRGB (ge->bigtank->format, 255, 0, 255)); ge->bigtank = SDL_DisplayFormat (ge->bigtank); } SDL_BlitSurface (tmp, NULL, ge->bg1, NULL); SDL_FreeSurface (tmp); /* Draw background */ SDL_BlitSurface (ge->bg1, NULL, ge->screen, NULL); res_rect.w = res_rect.h = 16; des_rect.w = res_rect.h = 16; for (i = 0; i < PLANE_H; i++) { for (j = 0; j < PLANE_W; j++) { if (bg[i][j] == OO || bg[i][j] == RV) continue; des_rect.x = j * 16; des_rect.y = i * 16; res_rect.x = ((bg[i][j] - 1) % 9) * 16; res_rect.y = ((bg[i][j] - 1) / 9) * 16; SDL_BlitSurface (ge->tiles, &res_rect, ge->screen, &des_rect); } } SDL_BlitSurface (ge->screen, NULL, ge->bg2, NULL); SDL_UpdateRect (ge->screen, 0, 0, 0, 0); srand (time (NULL)); /* Init key state */ key_state.Up[0] = 0; key_state.Up[1] = 0; key_state.Down[0] = 0; key_state.Down[1] = 0; key_state.Left[0] = 0; key_state.Left[1] = 0; key_state.Right[0] = 0; key_state.Right[1] = 0; key_state.Fire[0] = 0; key_state.Fire[1] = 0; key_state.Move[0] = 0; key_state.Move[1] = 0; key_state.F4 = 0; key_state.Quit = 0; key_state.AnyKey = 0; key_state.Debug = 0; for (i = 0; i < 2; i++) player[i].active = 0; for (i = 0; i < MAX_ENEMYS; i++) enemy[i].active = 0; for (i = 0; i < MAX_ENEMYS + 4; i++) bullet[i].active = 0; for (i = 0; i < 4; i++) explode[i].active = 0; if (ge->level == 3) BoreBigTank (ge, 11);}/* ----------------------------------- */voidGame_Menu (){ //SDL_Event event; SDL_Surface *tmp,*tmp2; SDL_Rect des_rect,rect1,rect2; tmp = IMG_Load ("pics/menu.png"); tmp2=IMG_Load("pics/bullets.png"); //SDL_SetColorKey(tmp,SDL_SRCCOLORKEY,SDL_MapRGB(tmp->format,0,0,0)); tmp = SDL_DisplayFormat (tmp); des_rect.w = 576; des_rect.h = 448; des_rect.x = 32; des_rect.y = 16; rect1.w=rect2.w=rect1.h=rect2.h=15; rect1.x=230; rect1.y=395; //点的坐标 rect2.x=230;rect2.y=430; SDL_BlitSurface (tmp, NULL, game_engine.screen, &des_rect); SDL_BlitSurface(tmp2,NULL,game_engine.screen,&rect1); SDL_UpdateRect (game_engine.screen, 0, 0, 0, 0); SDL_FreeSurface (tmp); //sleep(3); while (game_state == GAME_MENU) { while(SDL_PollEvent (&game_engine.event)) { switch(game_engine.event.type) { case SDL_KEYDOWN: switch(game_engine.event.key.keysym.sym) { case SDLK_UP: printf("one player\n"); if(players!=0) { players=0; //clear dot 2 SDL_BlitSurface(game_engine.screen,&rect1,game_engine.screen, &rect2); SDL_BlitSurface(tmp2,NULL,game_engine.screen, &rect1); SDL_UpdateRect (game_engine.screen, 0, 0, 0, 0); } break; case SDLK_DOWN: printf("two player\n"); if(players!=1) { players=1; //clear dot 1 SDL_BlitSurface(game_engine.screen,&rect2,game_engine.screen, &rect1); SDL_BlitSurface(tmp2,NULL,game_engine.screen, &rect2); SDL_UpdateRect (game_engine.screen, 0, 0, 0, 0); } break; case SDLK_RETURN: game_state=GAME_RUNNING; printf("begin \n"); break; case SDLK_F4: Video_Reset (&game_engine); break; case SDLK_ESCAPE: SDL_Quit(); exit(0); break; } break; } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -