This commit is contained in:
Lendemor 2015-01-22 13:15:27 +01:00
commit 5ae8fb3f27
2 changed files with 13 additions and 5 deletions

13
main.c
View File

@ -54,6 +54,7 @@ void updateTeam(t_team team){
int i;
for(i=0; i<team.nb_dudes; i++){
current_dude = team.dudes + i;
team.dudes[i].action = team.update((void*)(team.dudes[i].custom_data), (void*)(team.dudes[i].com_data), team.dudes[i].success);
}
@ -193,10 +194,12 @@ void handleAction(t_dude* dude){
map[target_pos.x][target_pos.y].data = NULL;
putpixel(img, target_pos.x, target_pos.y, getColor(map[target_pos.x][target_pos.y]));
}
dude->success = 1;
}else
dude->success = 0;
break;
case PUT :
dude->success = 1;
if(dude->inventory != -1 && (target.type == GRASS || target.type == MARK || target.type == dude->inventory)){
if(target.type == GRASS || target.type == MARK){
map[target_pos.x][target_pos.y].type = dude->inventory;
@ -327,6 +330,7 @@ void handleAction(t_dude* dude){
dude->success = 1;
break;
default :
dude->success = 0;
break;
}
break;
@ -395,7 +399,7 @@ int MAIN
int paused = 0;
int x_offset = 0;
int y_offset = 0;
int zoom_level = 1;
int zoom_level = DEFAULT_STARTING_ZOOM;
int over = 0;
int time = 0;
int wait_time = 100;
@ -404,6 +408,8 @@ int MAIN
int fullscreen = 0;
int width = DEFAULT_GAME_WIDTH;
int height = DEFAULT_GAME_HEIGHT;
int disp_width = DEFAULT_WINDOW_WIDTH;
int disp_height = DEFAULT_WINDOW_HEIGHT;
#ifndef _WIN32
argv++;
@ -415,9 +421,11 @@ int MAIN
break;
case 'w' :
width = atoi(argv[0]+2);
disp_width = 2*width;
break;
case 'h' :
height = atoi(argv[0]+2);
disp_height = 2*height;
break;
default :
break;
@ -427,7 +435,7 @@ int MAIN
}
#endif
screen = initSDL(width, height, fullscreen);
screen = initSDL(disp_width, disp_height, fullscreen);
initWorld(width, height);
SDL_Flip(img);
@ -504,7 +512,6 @@ int MAIN
spawnDudes();
for(i=0; i<NB_TEAMS; i++)
updateTeam(teams[i]);
// resolve_fights(); // TODO : debugging
resolve_moves();
remaining_time = wait_time;

5
main.h
View File

@ -15,8 +15,9 @@
#define STACK_SIZE 5
#define DEFAULT_GAME_WIDTH 400
#define DEFAULT_GAME_HEIGHT 250
#define DEFAULT_WINDOW_WIDTH 400
#define DEFAULT_WINDOW_HEIGHT 250
#define DEFAULT_WINDOW_WIDTH 800
#define DEFAULT_WINDOW_HEIGHT 500
#define DEFAULT_STARTING_ZOOM 2
#define NB_STARTING_FOOD 5
#define SPAWN_COOLDOWN 30