Add an ability to mark the main UI dirty so that it forces a render at specific times.

master
Zed A. Shaw 2 weeks ago
parent b8bafdcab5
commit fa6311f10c
  1. 2
      assets/enemies.json
  2. 15
      assets/items.json
  3. 2
      gui_fsm.cpp
  4. 4
      main_ui.cpp
  5. 1
      main_ui.hpp
  6. 4
      raycaster.cpp

@ -6,7 +6,7 @@
"foreground": [255, 200, 125],
"background": [30, 20, 75]
},
{"_type": "Combat", "hp": 200, "max_hp": 200, "damage": 15, "dead": false},
{"_type": "Combat", "hp": 200, "max_hp": 200, "damage": 50, "dead": false},
{"_type": "Motion", "dx": 0, "dy": 0, "random": false},
{"_type": "LightSource", "strength": 50, "radius": 1.0},
{"_type": "EnemyConfig", "hearing_distance": 5},

@ -10,7 +10,8 @@
"foreground": [24, 120, 189],
"background": [230,120, 120]
},
{"_type": "Sprite", "name": "torch_horizontal_floor"}
{"_type": "Sprite", "name": "torch_horizontal_floor"},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
]
},
"SWORD_RUSTY": {
@ -38,7 +39,8 @@
"background": [150, 100, 189]
},
{"_type": "Loot", "amount": 10},
{"_type": "Sprite", "name": "barrel_small"}
{"_type": "Sprite", "name": "barrel_small"},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
],
"inventory_count": 1
},
@ -53,7 +55,8 @@
"background": [24, 205, 210]
},
{"_type": "LightSource", "strength": 60, "radius": 1.8},
{"_type": "Sprite", "name": "torch_pillar"}
{"_type": "Sprite", "name": "torch_pillar"},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
]
},
"POTION_HEALING_SMALL": {
@ -67,7 +70,8 @@
"background": [255, 205, 189]
},
{"_type": "Curative", "hp": 200},
{"_type": "Sprite", "name": "healing_potion_small"}
{"_type": "Sprite", "name": "healing_potion_small"},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
]
},
"GRAVE_STONE": {
@ -81,7 +85,8 @@
"background": [24, 205, 189]
},
{"_type": "Loot", "amount": 10},
{"_type": "Sprite", "name": "grave_stone"}
{"_type": "Sprite", "name": "grave_stone"},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
]
}
}

@ -79,6 +79,7 @@ namespace gui {
if(auto move_to = $main_ui.play_move()) {
System::plan_motion(*$level.world, *move_to);
run_systems();
$main_ui.dirty();
state(State::IDLE);
}
}
@ -172,6 +173,7 @@ namespace gui {
switch(ev) {
case ATTACK:
$main_ui.dirty();
$status_ui.log("You attack!");
state(State::ATTACKING);
break;

@ -14,6 +14,10 @@ namespace gui {
$window.setFramerateLimit(FRAME_LIMIT);
}
void MainUI::dirty() {
$needs_render = true;
}
void MainUI::debug() {
auto& dbg = $level.world->get_the<Debug>();
dbg.FPS = !dbg.FPS;

@ -35,6 +35,7 @@ namespace gui {
void init();
void draw();
void dirty();
void generate_map();
void dead_entity(DinkyECS::Entity entity);

@ -273,7 +273,7 @@ void Raycaster::cast_rays() {
int tex_y = (int)tex_pos & (texture_height - 1);
tex_pos += step;
RGBA pixel = texture[texture_height * tex_y + tex_x];
float light_level = lights[map_y][map_x];
int light_level = lights[map_y][map_x];
$pixels[pixcoord(x, y)] = new_lighting(pixel, light_level);
}
@ -338,7 +338,7 @@ void Raycaster::draw_ceiling_floor() {
// floor_x cell_x to find the texture x/y. How?
int map_x = int(floor_x);
int map_y = int(floor_y);
float light_level = matrix::inbounds(lights, map_x, map_y) ? lights[map_y][map_x] : 30;
int light_level = matrix::inbounds(lights, map_x, map_y) ? lights[map_y][map_x] : 30;
// FLOOR
color = $floor_texture[texture_width * ty + tx];

Loading…
Cancel
Save