aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities/johnsStore.c
blob: 41217ed9d5e081bb1a3d9f29d583088f39b9c50b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "johnsStore.h"

void initJohnsStore(Entity* entity)
{
  int width = 6;
  int height = 6;
  
  Color colors[] = {
    WHITE, WHITE, WHITE, WHITE, WHITE, WHITE,
    WHITE, BLACK, BLACK, BLACK, BLACK, WHITE,
    WHITE, BLACK, BLACK, BLACK, BLACK, WHITE,
    WHITE, BLACK, BLACK, BLACK, BLACK, WHITE,
    WHITE, BLACK, BLACK, BLACK, BLACK, WHITE,
    WHITE, WHITE, BLACK, BLACK, WHITE, WHITE
  };
    
  entity->data = (void*)createEntityBuilding(
    colorsToImage(colors, width, height));
  EntityBuilding* building = (EntityBuilding*)entity->data;
  entity->box = GetModelBoundingBox(building->model);
}

void updateJohnsStore(Entity* entity, Game* game)
{
  EntityBuilding* building = (EntityBuilding*)entity->data;

  building->model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture =
    game->assets.textures[JOHNS_SHOP_TEXTURE];
  DrawModel(building->model, entity->position, 1.0, WHITE);
  drawBuildingRoof(building, entity->position, BROWN);
}

void closeJohnsStore(Entity* entity)
{
  if (entity->data != NULL)
  {
    freeEntityBuilding((EntityBuilding*)entity->data);
  }
}