Skip to content

Commit

Permalink
Reset game.Resized when changing worlds
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Jan 13, 2020
1 parent c7a751d commit fbab40e
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/components/com_camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Get, Has} from "./com_index.js";
export interface Camera {
EntityId: Entity;
Radius: number;
New: boolean;
Projection: Mat4;
Unproject: Mat4;
View: Mat4;
Expand All @@ -19,7 +18,6 @@ export function camera_ortho(Radius: number) {
game[Get.Camera][EntityId] = <Camera>{
EntityId,
Radius,
New: true,
Projection: create(),
Unproject: create(),
View: create(),
Expand Down
3 changes: 1 addition & 2 deletions src/systems/sys_camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ function update(game: Game, entity: Entity) {
let camera = game[Get.Camera][entity];
game.Camera = camera;

if (camera.New || game.Resized) {
camera.New = false;
if (game.Resized) {
let aspect = game.Canvas3.width / game.Canvas3.height;
if (aspect > 1) {
// Landscape orientation: radius = top.
Expand Down
1 change: 1 addition & 0 deletions src/worlds/wor_desert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function world_desert(game: Game) {
let entrance_length = 6;

game.Camera = undefined;
game.Resized = true;
game.World = [];
game.Grid = [];

Expand Down
1 change: 1 addition & 0 deletions src/worlds/wor_mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function world_mine(game: Game) {
set_seed(game.BountySeed);

game.Camera = undefined;
game.Resized = true;
game.World = [];
game.Grid = [];

Expand Down
1 change: 1 addition & 0 deletions src/worlds/wor_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {set_seed} from "../math/random.js";
export function world_store(game: Game) {
set_seed(game.PlayerSeed);
game.Camera = undefined;
game.Resized = true;
game.World = [];
game.GL.clearColor(0.9, 0.7, 0.3, 1);

Expand Down
1 change: 1 addition & 0 deletions src/worlds/wor_town.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function world_town(game: Game, is_intro?: boolean, bounty_collected?: nu
];

game.Camera = undefined;
game.Resized = true;
game.World = [];
game.Grid = [];

Expand Down
1 change: 1 addition & 0 deletions src/worlds/wor_wanted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {set_seed} from "../math/random.js";
export function world_wanted(game: Game) {
set_seed(game.BountySeed);
game.Camera = undefined;
game.Resized = true;
game.World = [];
game.GL.clearColor(0.9, 0.7, 0.3, 1);

Expand Down

0 comments on commit fbab40e

Please sign in to comment.