This commit is contained in:
Lendemor 2015-01-13 00:19:52 +01:00
commit 4b3f5e659a

64
main.c
View File

@ -132,16 +132,37 @@ void handleAction(t_action action, t_dude dude){
addFight(dude, *((t_dude*)(target.data))); addFight(dude, *((t_dude*)(target.data)));
break; break;
case PICK : case PICK :
// if target is resource :
// TODO // put target in inventory
// put grass on target
break; break;
case PUT : case PUT :
// if target is grass or road or corpse
// target = inventory
// inventory = NULL
// else if target is spawn and inventory is food
// spawn.food ++
break; break;
case WORK : case WORK :
// switch target
// case rock -> stone
// case berries -> food
// case tree -> wood
// case grass -> road
// case road -> grass
// case stone -> wall
// case wood -> sign
// case sign -> wood
// case iron_ore -> iron
// case iron -> sword
// case corpse -> grass
break; break;
case WAIT : case WAIT :
// ...
break; break;
case COMMUNICATE : case COMMUNICATE :
// if target is sign -> set sign message
// if target is dude -> sent message to dude
break; break;
} }
} }
@ -149,32 +170,41 @@ void handleAction(t_action action, t_dude dude){
void generateImg(){ void generateImg(){
int i, j; int i, j;
Uint32 color; Uint32 color;
t_dude* dudeData;
int* spawnData;
for(i=0; i<WIDTH; i++){ for(i=0; i<WIDTH; i++){
for(j=0; j<HEIGHT; j++){ for(j=0; j<HEIGHT; j++){
switch(map[i][j].type){ switch(map[i][j].type){
case BEDROCK : color = 0x101020; break; case BEDROCK : color = 0x101020; break;
case GRASS : color = 0x004400; break; case GRASS : color = 0x004400; break;
case ROCK : color = 0x444444; break; case ROCK : color = 0x8C8C8C; break;
case IRON_ORE : color = 0x402020; break; case IRON_ORE : color = 0x917B61; break;
case TREE : color = 0x000F0F; break; case TREE : color = 0x000F0F; break;
case BERRIES : color = 0x005F00; break; case BERRIES : color = 0x6B87C7; break;
case FOOD : color = 0x000000; break; case FOOD : color = 0xFF7A7A; break;
case WOOD : color = 0x000000; break; case WOOD : color = 0x634A22; break;
case STONE : color = 0x000000; break; case STONE : color = 0x999999; break;
case IRON : color = 0x000000; break; case IRON : color = 0x555555; break;
case CORPSE : color = 0x000000; break; case CORPSE : color = 0xFF0000; break;
case DUDE : color = 0x000000; break;
case SPAWN : color = 0xFFFFFF; break; case DUDE :
case WALL : color = 0x000000; break; dudeData = map[i][j].data;
case ROAD : color = 0x000000; break; color = dudeData->team == ORANGE ? 0xFF8000 : 0x9900FF;
case SWORD : color = 0x000000; break; break;
case SIGN : color = 0x000000; break; case SPAWN :
spawnData = (int*)map[i][j].data;
color = *spawnData == ORANGE ? 0xFFC080 : 0xD596FF;
break;
case WALL : color = 0xE6B2A1; break;
case ROAD : color = 0xEDB287; break;
case SWORD : color = 0xEBEBEB; break;
case SIGN : color = 0xA37A50; break;
default : color = 0x0000FF; break; // bleu absolu = bug default : color = 0x0000FF; break; // bleu absolu = bug
} }
putpixel(img, i, j, color); putpixel(img, i, j, color);
//img->pixels[j * WIDTH + i] = color; //img->pixels[j * WIDTH + i] = color;
} }
printf("\n");
} }
} }