Add an ability to mark the main UI dirty so that it forces a render at specific times.
This commit is contained in:
parent
b8bafdcab5
commit
fa6311f10c
6 changed files with 20 additions and 8 deletions
|
@ -6,7 +6,7 @@
|
||||||
"foreground": [255, 200, 125],
|
"foreground": [255, 200, 125],
|
||||||
"background": [30, 20, 75]
|
"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": "Motion", "dx": 0, "dy": 0, "random": false},
|
||||||
{"_type": "LightSource", "strength": 50, "radius": 1.0},
|
{"_type": "LightSource", "strength": 50, "radius": 1.0},
|
||||||
{"_type": "EnemyConfig", "hearing_distance": 5},
|
{"_type": "EnemyConfig", "hearing_distance": 5},
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
"foreground": [24, 120, 189],
|
"foreground": [24, 120, 189],
|
||||||
"background": [230,120, 120]
|
"background": [230,120, 120]
|
||||||
},
|
},
|
||||||
{"_type": "Sprite", "name": "torch_horizontal_floor"}
|
{"_type": "Sprite", "name": "torch_horizontal_floor"},
|
||||||
|
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SWORD_RUSTY": {
|
"SWORD_RUSTY": {
|
||||||
|
@ -38,7 +39,8 @@
|
||||||
"background": [150, 100, 189]
|
"background": [150, 100, 189]
|
||||||
},
|
},
|
||||||
{"_type": "Loot", "amount": 10},
|
{"_type": "Loot", "amount": 10},
|
||||||
{"_type": "Sprite", "name": "barrel_small"}
|
{"_type": "Sprite", "name": "barrel_small"},
|
||||||
|
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
||||||
],
|
],
|
||||||
"inventory_count": 1
|
"inventory_count": 1
|
||||||
},
|
},
|
||||||
|
@ -53,7 +55,8 @@
|
||||||
"background": [24, 205, 210]
|
"background": [24, 205, 210]
|
||||||
},
|
},
|
||||||
{"_type": "LightSource", "strength": 60, "radius": 1.8},
|
{"_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": {
|
"POTION_HEALING_SMALL": {
|
||||||
|
@ -67,7 +70,8 @@
|
||||||
"background": [255, 205, 189]
|
"background": [255, 205, 189]
|
||||||
},
|
},
|
||||||
{"_type": "Curative", "hp": 200},
|
{"_type": "Curative", "hp": 200},
|
||||||
{"_type": "Sprite", "name": "healing_potion_small"}
|
{"_type": "Sprite", "name": "healing_potion_small"},
|
||||||
|
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"GRAVE_STONE": {
|
"GRAVE_STONE": {
|
||||||
|
@ -81,7 +85,8 @@
|
||||||
"background": [24, 205, 189]
|
"background": [24, 205, 189]
|
||||||
},
|
},
|
||||||
{"_type": "Loot", "amount": 10},
|
{"_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()) {
|
if(auto move_to = $main_ui.play_move()) {
|
||||||
System::plan_motion(*$level.world, *move_to);
|
System::plan_motion(*$level.world, *move_to);
|
||||||
run_systems();
|
run_systems();
|
||||||
|
$main_ui.dirty();
|
||||||
state(State::IDLE);
|
state(State::IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,6 +173,7 @@ namespace gui {
|
||||||
|
|
||||||
switch(ev) {
|
switch(ev) {
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
|
$main_ui.dirty();
|
||||||
$status_ui.log("You attack!");
|
$status_ui.log("You attack!");
|
||||||
state(State::ATTACKING);
|
state(State::ATTACKING);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,10 @@ namespace gui {
|
||||||
$window.setFramerateLimit(FRAME_LIMIT);
|
$window.setFramerateLimit(FRAME_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainUI::dirty() {
|
||||||
|
$needs_render = true;
|
||||||
|
}
|
||||||
|
|
||||||
void MainUI::debug() {
|
void MainUI::debug() {
|
||||||
auto& dbg = $level.world->get_the<Debug>();
|
auto& dbg = $level.world->get_the<Debug>();
|
||||||
dbg.FPS = !dbg.FPS;
|
dbg.FPS = !dbg.FPS;
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace gui {
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void draw();
|
void draw();
|
||||||
|
void dirty();
|
||||||
|
|
||||||
void generate_map();
|
void generate_map();
|
||||||
void dead_entity(DinkyECS::Entity entity);
|
void dead_entity(DinkyECS::Entity entity);
|
||||||
|
|
|
@ -273,7 +273,7 @@ void Raycaster::cast_rays() {
|
||||||
int tex_y = (int)tex_pos & (texture_height - 1);
|
int tex_y = (int)tex_pos & (texture_height - 1);
|
||||||
tex_pos += step;
|
tex_pos += step;
|
||||||
RGBA pixel = texture[texture_height * tex_y + tex_x];
|
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);
|
$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?
|
// floor_x cell_x to find the texture x/y. How?
|
||||||
int map_x = int(floor_x);
|
int map_x = int(floor_x);
|
||||||
int map_y = int(floor_y);
|
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
|
// FLOOR
|
||||||
color = $floor_texture[texture_width * ty + tx];
|
color = $floor_texture[texture_width * ty + tx];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue