This commit is contained in:
2026-03-12 17:09:25 -03:00
parent 244f0eb741
commit d18942196b
21 changed files with 422 additions and 581 deletions
+18 -21
View File
@@ -1,20 +1,17 @@
import { Component } from "$/common/ecs/mod.ts";
export class Camera extends Component {
active = true;
x: number;
y: number;
zoom: number;
rotation = 0;
offset_x = 0;
offset_y = 0;
x = 0;
y = 0;
z = 3;
constructor(x = 0, y = 0, zoom = 1) {
super();
this.x = x;
this.y = y;
this.zoom = zoom;
}
pitch = 0;
yaw = 0;
roll = 0;
fov = Math.PI / 3;
near = 0.1;
far = 1000;
}
export function screen_to_world(
@@ -24,10 +21,10 @@ export function screen_to_world(
screen_width: number,
screen_height: number,
) {
return {
x: (screen_x - screen_width / 2) / camera.zoom + camera.x,
y: (screen_y - screen_height / 2) / camera.zoom + camera.y,
};
// return {
// x: (screen_x - screen_width / 2) / camera.zoom + camera.x,
// y: (screen_y - screen_height / 2) / camera.zoom + camera.y,
// };
}
export function world_to_screen(
@@ -37,8 +34,8 @@ export function world_to_screen(
screen_width: number,
screen_height: number,
) {
return {
x: (world_x - camera.x) / camera.zoom + screen_width / 2,
y: (world_y - camera.y) / camera.zoom + screen_height / 2,
};
// return {
// x: (world_x - camera.x) / camera.zoom + screen_width / 2,
// y: (world_y - camera.y) / camera.zoom + screen_height / 2,
// };
}
+1
View File
@@ -7,6 +7,7 @@ import { Texture } from "../renderer/mod.ts";
export interface Tile<T = unknown> {
x: number;
y: number;
z: number;
id: string;
data?: T;
tickable?: boolean;
+3 -3
View File
@@ -2,11 +2,11 @@ import { Component } from "$/common/ecs/mod.ts";
import { KeyCode } from "$/client/input_manager.ts";
export class PlayerControls extends Component {
move_speed: number = 100;
move_speed: number = 5;
// Keys
move_up: KeyCode = "KeyW";
move_down: KeyCode = "KeyS";
move_forward: KeyCode = "KeyW";
move_backwards: KeyCode = "KeyS";
move_left: KeyCode = "KeyA";
move_right: KeyCode = "KeyD";