handle resize
This commit is contained in:
parent
1b66d6289b
commit
4a8a9185af
1 changed files with 13 additions and 0 deletions
|
@ -142,6 +142,10 @@ class GameInstance {
|
|||
SLIDER.max = this.turn_count - 1 + '';
|
||||
}
|
||||
|
||||
on_resize() {
|
||||
this.resizer = new Resizer(CANVAS, [...f32v(this.game.get_viewbox(), 4)], true);
|
||||
}
|
||||
|
||||
_update_state() {
|
||||
const colours = f32v(this.game.get_planet_colors(), this.planet_count * 6);
|
||||
for(let i=0; i < this.planet_count; i++){
|
||||
|
@ -276,6 +280,15 @@ export async function set_instance(source: string) {
|
|||
set_loading(false);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', function() {
|
||||
CANVAS.width = CANVAS.getBoundingClientRect().width;
|
||||
CANVAS.height = CANVAS.getBoundingClientRect().height;
|
||||
|
||||
if (game_instance) {
|
||||
game_instance.on_resize();
|
||||
}
|
||||
}, { capture: false, passive: true})
|
||||
|
||||
SLIDER.oninput = function() {
|
||||
if (game_instance) {
|
||||
game_instance.updateTurn(parseInt(SLIDER.value));
|
||||
|
|
Loading…
Reference in a new issue