Skip to content

Commit

Permalink
緊急修復 蛇死光的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
e8035669 committed Jan 15, 2017
1 parent eeee834 commit 22ef9c5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Final_Project_Slither_lite_allegro.depend
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
1483943908 source:d:\codeblocks_hw\final_project_slither_lite_allegro\src\lightspot.c
"Lightspot.h"

1484448990 source:d:\codeblocks_hw\final_project_slither_lite_allegro\src\main.c
1484489021 source:d:\codeblocks_hw\final_project_slither_lite_allegro\src\main.c
<stdio.h>
<stdlib.h>
<time.h>
Expand Down
28 changes: 14 additions & 14 deletions Final_Project_Slither_lite_allegro.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="src\main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\OtherFunctions.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20542" topLine="614" />
<Cursor1 position="377" topLine="0" />
</Cursor>
</File>
<File name="src\LevelSelect.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\OtherFunctions.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="68" topLine="0" />
<Cursor1 position="496" topLine="15" />
</Cursor>
</File>
<File name="src\Structures.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="281" topLine="0" />
<Cursor1 position="11703" topLine="380" />
</Cursor>
</File>
<File name="src\OtherFunctions.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\LevelSelect.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="496" topLine="15" />
<Cursor1 position="159" topLine="0" />
</Cursor>
</File>
<File name="src\AiFunction.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="926" topLine="18" />
</Cursor>
</File>
<File name="src\OtherFunctions.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\Init.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="377" topLine="0" />
<Cursor1 position="451" topLine="0" />
</Cursor>
</File>
<File name="src\Init.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\LevelSelect.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="451" topLine="0" />
<Cursor1 position="68" topLine="0" />
</Cursor>
</File>
<File name="src\Init.c" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="703" topLine="12" />
</Cursor>
</File>
<File name="src\LevelSelect.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\Structures.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="159" topLine="0" />
<Cursor1 position="281" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
2 changes: 1 addition & 1 deletion Setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DefaultDirName={userdesktop}\Slither_Lite
DisableProgramGroupPage=yes
InfoBeforeFile=D:\CodeBlocks_HW\Final_Project_Slither_lite_allegro\CopyRight.md
LicenseFile=D:\CodeBlocks_HW\Final_Project_Slither_lite_allegro\同意條款.txt
OutputBaseFilename=setup
OutputBaseFilename=貪吃蛇的危機_Setup
SetupIconFile=D:\CodeBlocks_HW\Final_Project_Slither_lite_allegro\assets\icon.ico
SolidCompression=yes
Uninstallable=yes
Expand Down
Binary file removed assets/data.bin
Binary file not shown.
20 changes: 14 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ int mainGameLoop(char* name,int Ainumbers,int lightspot,void (*aiExec)(Snake** s
/**< 殺蛇幾隻 一隻加1000分 */
int killCount = 0;

int remainSnakes = 0;

al_flush_event_queue(Res.eventQueue);


Expand Down Expand Up @@ -381,15 +383,21 @@ int mainGameLoop(char* name,int Ainumbers,int lightspot,void (*aiExec)(Snake** s
oldFPS = FPS;
FPS = 0;
mapUpdateLightSpotData(map);
int k;
remainSnakes = 0;
for(k=1; k<Ainumbers; k++) {
if(!(snakes[k]->isDead))remainSnakes++;
}
}

if(al_is_event_queue_empty(Res.eventQueue)&&FPS>59) {
if(al_is_event_queue_empty(Res.eventQueue)&&oldFPS>59) {
//*< 死掉會復活 */
if(event.timer.count%6==0) {
int k=50;
while(k--){
Snake_rebirth(snakes,Ainumbers);
}
//*< 有機率增加亮點 */
if(rand()%100 < 10) {
if(rand()%100 < 30) {
Put_LightSpot(map,Create_LightSpot(map->size));
}
}
Expand Down Expand Up @@ -476,8 +484,8 @@ int mainGameLoop(char* name,int Ainumbers,int lightspot,void (*aiExec)(Snake** s
Draw_Snake(snakes[i],Res.snake_body,Res.snake_head,Res.display,snakes[keyIn_int]->head->current_position);
}
al_draw_textf(Res.builtinFont,al_map_rgb(255,0,0),0,al_get_display_height(Res.display)-8,0,
"FPS:%d Pos(%.0f,%.0f) Length:%d Lsp:%d LspSize:%d",
oldFPS,snake->head->current_position.x,snake->head->current_position.y,snake->length,map->totalLightSpotLength,map->totalLightSpotSize);
"FPS:%d Pos(%.0f,%.0f) Length:%d Lsp:%d LspSize:%d remainSnake:%d",
oldFPS,snake->head->current_position.x,snake->head->current_position.y,snake->length,map->totalLightSpotLength,map->totalLightSpotSize,remainSnakes);
al_draw_textf(Res.builtinFont,al_map_rgb(255,0,0),al_get_display_width(Res.display)-80,al_get_display_height(Res.display)-8,0,
"snakes:%d",keyIn_int);
if(userControl) {
Expand Down Expand Up @@ -675,7 +683,7 @@ int selectLevel(int levelNum) {
button[i].startY=frameH*((i/maxLevelRow)+1.0/4);
}
screenNeedRefresh=1;
}else if(event.keyboard.keycode==ALLEGRO_KEY_F12) {
} else if(event.keyboard.keycode==ALLEGRO_KEY_F12) {
/**< Screen shot */
ALLEGRO_BITMAP* screenshot = al_create_bitmap(al_get_display_width(Res.display),al_get_display_height(Res.display));
al_set_target_bitmap(screenshot);
Expand Down

0 comments on commit 22ef9c5

Please sign in to comment.