Change snake's tint based on player-id.
This commit is contained in:
@@ -99,6 +99,17 @@ uint32_t floor_texture_variant(uint32_t x, uint32_t y, uint32_t seed, uint32_t n
|
|||||||
return (wang_hash(x * 73856093u ^ y * 19349663u ^ seed)) % num_variants;
|
return (wang_hash(x * 73856093u ^ y * 19349663u ^ seed)) % num_variants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color get_tint_for_player_id(uint16_t player_id) {
|
||||||
|
switch(player_id) {
|
||||||
|
case 0: {
|
||||||
|
return (Color) { 255, 135, 102, 255 };
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return (Color) { 82, 33, 110, 255 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define SHADOW_ALPHA 64
|
#define SHADOW_ALPHA 64
|
||||||
|
|
||||||
static void state_render(Presentation_State *state) {
|
static void state_render(Presentation_State *state) {
|
||||||
@@ -151,7 +162,21 @@ static void state_render(Presentation_State *state) {
|
|||||||
|
|
||||||
switch(entity->type) {
|
switch(entity->type) {
|
||||||
case Entity_Type_Snake_Head: {
|
case Entity_Type_Snake_Head: {
|
||||||
Color tint = (Color) { 255, 135, 102, 255 }; // TODO: SS - Get tint based on player ID.
|
|
||||||
|
Color tint = (Color) { 255, 255, 255, 255 };
|
||||||
|
// Set the snake's tint based on player-index.
|
||||||
|
for(uint16_t i = 0; i < sim_world->max_players; i++) {
|
||||||
|
Simulation_Player *player = &sim_world->players[i];
|
||||||
|
if(!player->active) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player->entity_id == entity->id) {
|
||||||
|
tint = get_tint_for_player_id(i); // NOTE: SS - It's more like player-index. This needs to change if they're not sorted (but they are at the moment and I don't really plan on switching that up.)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 origin = (Vector2) { GRID_CELL_SIZE/2, GRID_CELL_SIZE/2 };
|
Vector2 origin = (Vector2) { GRID_CELL_SIZE/2, GRID_CELL_SIZE/2 };
|
||||||
|
|
||||||
Entity *e = entity;
|
Entity *e = entity;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
// TODO: SS - Maybe add an ID here.
|
Entity_ID id;
|
||||||
|
|
||||||
Entity_Type type;
|
Entity_Type type;
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ bool game_world_create_entity(Game_World *world, Entity_Type type, uint16_t x, u
|
|||||||
|
|
||||||
world->entities[id] = (Entity) {
|
world->entities[id] = (Entity) {
|
||||||
.active = true,
|
.active = true,
|
||||||
|
.id = id,
|
||||||
.type = type,
|
.type = type,
|
||||||
.child = INVALID_ENTITY_ID
|
.child = INVALID_ENTITY_ID
|
||||||
};
|
};
|
||||||
@@ -98,7 +99,7 @@ void game_world_destroy_entity(Game_World *world, Entity_ID entity_id) {
|
|||||||
entity_id
|
entity_id
|
||||||
);
|
);
|
||||||
assert(entity != NULL);
|
assert(entity != NULL);
|
||||||
entity->active = false;
|
memset(&entity, 0, sizeof(Entity));
|
||||||
|
|
||||||
Grid_Cell *cell = grid_get_cell(&world->grid, entity->x, entity->y);
|
Grid_Cell *cell = grid_get_cell(&world->grid, entity->x, entity->y);
|
||||||
assert(cell != NULL);
|
assert(cell != NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user