Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
import { type KEventController, KEventHandler } from "../events/events";
import { canvasToViewport } from "../gfx/viewport";
import { map, vec2 } from "../math/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import { _k } from "../shared";
import { deprecateMsg } from "../utils/log";
import { overload2 } from "../utils/overload";
Expand Down
4 changes: 2 additions & 2 deletions src/assets/shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
} from "../constants/general";
import { type GfxCtx, Texture } from "../gfx/gfx";
import { Color } from "../math/color";
import { Mat4 } from "../math/Mat4";
import { Mat4 } from "../math/mat4";
import { Mat23 } from "../math/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import { _k } from "../shared";
import type { RenderProps } from "../types";
import { arrayIsColor, arrayIsNumber, arrayIsVec2 } from "../utils/asserts";
Expand Down
4 changes: 2 additions & 2 deletions src/constants/math.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mat4 } from "../math/Mat4";
import { Vec2 } from "../math/Vec2";
import { Mat4 } from "../math/mat4";
import { Vec2 } from "../math/vec2";

export const IDENTITY_MATRIX = new Mat4();
export const TOP_LEFT = new Vec2(-1, -1);
Expand Down
7 changes: 5 additions & 2 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ import { easings } from "../math/easings";
import { gjkShapeIntersection, gjkShapeIntersects } from "../math/gjk";
import { lerp } from "../math/lerp";
import { lerpAngle } from "../math/lerpAngle";
import { Mat4 } from "../math/Mat4";
import { Mat4 } from "../math/mat4";
import {
bezier,
cardinal,
Expand Down Expand Up @@ -221,6 +221,7 @@ import {
testRectRect,
triangulate,
vec2,
vec3,
wave,
} from "../math/math";
import { buildConnectivityMap, floodFill } from "../math/navigation";
Expand All @@ -234,7 +235,8 @@ import {
import { chance, rand, randi, randSeed, RNG, setRNG } from "../math/random";
import { insertionSort } from "../math/sort";
import { makeQuadtree, Quadtree } from "../math/spatial/quadtree";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import { Vec3 } from "../math/vec3";
import { BlendMode, type KAPLAYPlugin } from "../types";
import {
download,
Expand Down Expand Up @@ -512,6 +514,7 @@ export const createContext = (
Polygon,
Collision,
Vec2,
Vec3,
Color,
Mat2,
Mat4,
Expand Down
13 changes: 11 additions & 2 deletions src/core/contextType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ import type { Color, CSSColorKeywords } from "../math/color";
import type { EaseFunc, EaseFuncs } from "../math/easings";
import type { GjkCollisionResult } from "../math/gjk";
import type { LerpValue } from "../math/lerp";
import type { Mat4 } from "../math/Mat4";
import type { Mat4 } from "../math/mat4";
import type {
Circle,
Ellipse,
Expand All @@ -166,7 +166,8 @@ import type { NavGrid } from "../math/navigationgrid";
import type { NavMesh } from "../math/navigationmesh";
import type { RandomGenerator, RNG, RNGConfig, RNGSeed } from "../math/random";
import type { Quadtree, ResizingQuadtree } from "../math/spatial/quadtree";
import type { Vec2 } from "../math/Vec2";
import type { Vec2 } from "../math/vec2";
import type { Vec3 } from "../math/vec3";
import {
type Anchor,
type BlendMode,
Expand Down Expand Up @@ -6528,6 +6529,14 @@ export interface KAPLAYCtx {
Vec2: typeof Vec2;
/**
* A color.
*
* @since v2000.0
* @group Math
* @subgroup Vectors
*/
Vec3: typeof Vec3;
/**
* A 3D vector.
*
* @since v2000.0
* @group Math
Expand Down
2 changes: 1 addition & 1 deletion src/core/frameRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { drawUVQuad } from "../gfx/draw/drawUVQuad";
import type { AppGfxCtx } from "../gfx/gfxApp";
import { flush, height, width } from "../gfx/stack";
import { Quad } from "../math/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";

/**
* A frame renderer.
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/circle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getRenderProps } from "../../../game/utils";
import { drawCircle } from "../../../gfx/draw/drawCircle";
import { Circle, Rect } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import { nextRenderAreaVersion } from "../physics/area";
import type { AnchorComp } from "../transform/anchor";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/ellipse.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getRenderProps } from "../../../game/utils";
import { drawEllipse } from "../../../gfx/draw/drawEllipse";
import { Ellipse } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import { nextRenderAreaVersion } from "../physics/area";
import type { AnchorComp } from "../transform/anchor";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/particles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Color } from "../../../math/color";
import { lerp } from "../../../math/lerp";
import { deg2rad, map, Quad, type ShapeType, vec2 } from "../../../math/math";
import { rand } from "../../../math/random";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp } from "../../../types";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import type { Texture } from "../../../gfx/gfx";
import type { Color } from "../../../math/color";
import { Polygon } from "../../../math/math";
import { type Vec2 } from "../../../math/Vec2";
import { type Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import { nextRenderAreaVersion } from "../physics/area";
import type { FillComp } from "./fill";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/raycast.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RaycastResult } from "../../../math/math";
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";

// this is not a component lol
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/draw/sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { anchorPt } from "../../../gfx/anchor";
import { drawTexture } from "../../../gfx/draw/drawTexture";
import type { Texture } from "../../../gfx/gfx";
import { Quad, quad, Rect, vec2 } from "../../../math/math";
import { type Vec2 } from "../../../math/Vec2";
import { type Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj, SpriteAnimPlayOpt } from "../../../types";
import { warn } from "../../../utils/log";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/agent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { KEventController } from "../../../events/events";
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import type { PosComp } from "../transform/pos";
import type { TileComp } from "./tile";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type Vec2Args,
} from "../../../math/math";
import { calcTransform } from "../../../math/various";
import { type Vec2 } from "../../../math/Vec2";
import { type Vec2 } from "../../../math/vec2";
import {
type Comp,
type CompList,
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/pathfinder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Graph } from "../../../math/navigation";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import type { PosComp } from "../transform/pos";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/patrol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { KEventController } from "../../../events/events";
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import type { PosComp } from "../transform/pos";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { KEventController } from "../../../events/events";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj, QueryOpt } from "../../../types";
import { raycast } from "../draw/raycast";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/level/tile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2 } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { type Comp, type Edge, EdgeMask, type GameObj } from "../../../types";
import type { LevelComp } from "./level";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/misc/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Color } from "../../../math/color";
import { type EaseFunc, easings } from "../../../math/easings";
import { lerp, type LerpValue } from "../../../math/lerp";
import { catmullRom, hermiteFirstDerivative, vec2 } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";
import type { NamedComp } from "./named";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/misc/fakeMouse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";
import type { PosComp } from "../transform/pos";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/misc/timer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { KEvent } from "../../../events/events";
import { easings } from "../../../math/easings";
import { lerp, type LerpValue } from "../../../math/lerp";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/physics/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { drawRect } from "../../../gfx/draw/drawRect";
import { multTranslate, popTransform, pushTransform } from "../../../gfx/stack";
import { rgb } from "../../../math/color";
import { Circle, Polygon, Rect, shapeFactory, vec2 } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type {
Comp,
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/physics/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getGravityDirection } from "../../../game/gravity";
import { lerp } from "../../../math/lerp";
import { vec2 } from "../../../math/math";
import { calcTransform } from "../../../math/various";
import { type Vec2 } from "../../../math/Vec2";
import { type Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";
import { exists } from "../../entity/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/physics/effectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Polygon, vec2 } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import type { PosComp } from "../transform/pos";
import type { AreaComp } from "./area";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/anchor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { anchorPt } from "../../../gfx/anchor";
import { vec2 } from "../../../math/math";
import { type SerializedVec2, Vec2 } from "../../../math/Vec2";
import { type SerializedVec2, Vec2 } from "../../../math/vec2";
import type { Anchor, Comp } from "../../../types";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
updateChildrenTransformRecursive,
updateTransformRecursive,
} from "../../../math/various";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";
import { system, SystemPhase } from "../../systems/systems";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/follow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2 } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import type { Comp, GameObj } from "../../../types";
import { exists } from "../../entity/utils";
import type { PosComp } from "./pos";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/move.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type SerializedVec2, Vec2 } from "../../../math/Vec2";
import { type SerializedVec2, Vec2 } from "../../../math/vec2";
import type { Comp, EmptyComp, GameObj } from "../../../types";
import type { PosComp } from "./pos";

Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { toScreen, toWorld } from "../../../game/camera";
import { drawCircle } from "../../../gfx/draw/drawCircle";
import { rgb } from "../../../math/color";
import { vec2, type Vec2Args } from "../../../math/math";
import { Vec2 } from "../../../math/Vec2";
import { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { Comp, GameObj } from "../../../types";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/scale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2, type Vec2Args } from "../../../math/math";
import { type SerializedVec2, Vec2 } from "../../../math/Vec2";
import { type SerializedVec2, Vec2 } from "../../../math/vec2";
import type { Comp } from "../../../types";
import {
type InternalGameObjRaw,
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/components/transform/skew.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2, type Vec2Args } from "../../../math/math";
import { type SerializedVec2, Vec2 } from "../../../math/Vec2";
import { type SerializedVec2, Vec2 } from "../../../math/vec2";
import type { Comp } from "../../../types";
import {
type InternalGameObjRaw,
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/entity/premade/addKaboom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { CompList, GameObj } from "../../../types";
import { sprite } from "../../components/draw/sprite";
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/entity/premade/addLevel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2 } from "../../../math/math";
import type { Vec2 } from "../../../math/Vec2";
import type { Vec2 } from "../../../math/vec2";
import { _k } from "../../../shared";
import type { GameObj } from "../../../types";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/ecs/systems/Collision.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vec2 } from "../../math/math";
import type { Vec2 } from "../../math/Vec2";
import type { Vec2 } from "../../math/vec2";
import { _k } from "../../shared";
import type { GameObj } from "../../types";

Expand Down
2 changes: 1 addition & 1 deletion src/events/eventMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { type doubleJump } from "../ecs/components/physics/doubleJump";
import { type offscreen } from "../ecs/components/transform/offscreen";
import { type addLevel } from "../ecs/entity/premade/addLevel";
import type { Collision } from "../ecs/systems/Collision";
import type { Vec2 } from "../math/Vec2";
import type { Vec2 } from "../math/vec2";
import type {
GameObj,
Key,
Expand Down
2 changes: 1 addition & 1 deletion src/game/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { destroy } from "../ecs/entity/utils";
import { center, height, width } from "../gfx/stack";
import { type Color, rgb } from "../math/color";
import { type Mat23, vec2, type Vec2Args } from "../math/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import { _k } from "../shared";
import { deprecateMsg } from "../utils/log";

Expand Down
2 changes: 1 addition & 1 deletion src/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { GameEventMap, GameObjEventMap } from "../events/eventMap";
import { type KEventController, KEventHandler } from "../events/events";
import { Mat23, Rect } from "../math/math";
import { RNG, type RNGConfig } from "../math/random";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import type { GameObj } from "../types";
import type { SceneDef, SceneState } from "./scenes";

Expand Down
2 changes: 1 addition & 1 deletion src/game/gravity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Gravity manipulation

import { vec2 } from "../math/math";
import { type Vec2 } from "../math/Vec2";
import { type Vec2 } from "../math/vec2";
import { _k } from "../shared";

export function setGravity(g: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/TexPacker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { drawImageSourceAt } from "../assets/utils";
import { Quad, Rect, testRectRect } from "../math/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import type { ImageSource, TexFilter } from "../types";
import { type GfxCtx, Texture } from "./gfx";

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/anchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TOP_LEFT,
TOP_RIGHT,
} from "../constants/math";
import { Vec2 } from "../math/Vec2";
import { Vec2 } from "../math/vec2";
import { type Anchor } from "../types";
import type { TextAlign } from "./draw/drawText";

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/draw/drawBezier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { evaluateBezier } from "../../math/math";
import { type Vec2 } from "../../math/Vec2";
import { type Vec2 } from "../../math/vec2";
import { drawCurve, type DrawCurveOpt } from "./drawCurve";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/gfx/draw/drawCircle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Color } from "../../math/color";
import type { Vec2 } from "../../math/Vec2";
import type { Vec2 } from "../../math/vec2";
import type { Anchor, RenderProps } from "../../types";
import { drawEllipse } from "./drawEllipse";

Expand Down
2 changes: 1 addition & 1 deletion src/gfx/draw/drawCurve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Vec2 } from "../../math/Vec2";
import type { Vec2 } from "../../math/vec2";
import type { RenderProps } from "../../types";
import { drawLines } from "./drawLine";

Expand Down
Loading