slifer 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Mohammed Salim
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mohammed Salim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,70 +1,70 @@
1
- # Slifer : Native Typescript Game Framework
2
-
3
- <p align="center">
4
- <img width="80%" src="https://ucarecdn.com/288f053f-61e0-42e6-804a-8c1d48a41aac/-/preview/1000x562/">
5
- </p>
6
-
7
- > [!CAUTION]
8
- > Slifer is currently in alpha. Use at your own risk.
9
-
10
- > [!NOTE]
11
- > Not all basic features have been implemented. Many are missing such as
12
- > window customization. As such, I recommend waiting for a beta release of
13
- > Slifer before using it for a long term project.
14
-
15
- For up to date docs, please head over to the [Slifer Webpage](https://slifer.hazyvt.com).
16
-
17
- ## Introduction
18
-
19
- Slifer is a game framework made to allow users to code games in typescript. The
20
- framework uses bun and SDL2 under the hood to allow your game to render and
21
- build natively to desktop.
22
-
23
- ## Contents
24
-
25
- - [Goals](#goals)
26
- - [Current Features](#current-features)
27
- - [Future Features](#future-features)
28
- - [Example](#example)
29
-
30
- ## Goals
31
-
32
- - Contain all basic game framework implementations. Such as drawing images,
33
- drawing text and making animations from a sprite sheet.
34
- - Provide an easy transition from web development to game development.
35
- - Create an easy to use framework. Slifer should handle the bulk of the work
36
- - Keep updates consistent.
37
-
38
- ## Current Features
39
-
40
- - Create a native desktop window with custom title and size.
41
- - Handle both keyboard and mouse inputs
42
- - Load and draw images onto the window
43
- - Play Audio
44
-
45
- ## Future Features
46
-
47
- - Animation library
48
- - Save file library
49
-
50
- ## Example
51
-
52
- ```ts
53
- import Slifer, { Vector2 } from "slifer";
54
-
55
- Slifer.createWindow("Example Window", new Vector2(640, 480));
56
-
57
- const bg = Slifer.Graphics.makeColor(36, 36, 36, 255);
58
-
59
- while (!Slifer.shouldClose()) {
60
- Slifer.Graphics.setBackground(bg);
61
-
62
- if (Slifer.Keyboard.isPressed("escape")) {
63
- Slifer.isRunning = false;
64
- }
65
-
66
- Slifer.Graphics.render();
67
- }
68
-
69
- Slifer.quit();
70
- ```
1
+ # Slifer : Native Typescript Game Framework
2
+
3
+ <p align="center">
4
+ <img width="80%" src="https://ucarecdn.com/288f053f-61e0-42e6-804a-8c1d48a41aac/-/preview/1000x562/">
5
+ </p>
6
+
7
+ > [!CAUTION]
8
+ > Slifer is currently in alpha. Use at your own risk.
9
+
10
+ > [!NOTE]
11
+ > Not all basic features have been implemented. Many are missing such as
12
+ > window customization. As such, I recommend waiting for a beta release of
13
+ > Slifer before using it for a long term project.
14
+
15
+ For up to date docs, please head over to the [Slifer Webpage](https://slifer.hazyvt.com).
16
+
17
+ ## Introduction
18
+
19
+ Slifer is a game framework made to allow users to code games in typescript. The
20
+ framework uses bun and SDL2 under the hood to allow your game to render and
21
+ build natively to desktop.
22
+
23
+ ## Contents
24
+
25
+ - [Goals](#goals)
26
+ - [Current Features](#current-features)
27
+ - [Future Features](#future-features)
28
+ - [Example](#example)
29
+
30
+ ## Goals
31
+
32
+ - Contain all basic game framework implementations. Such as drawing images,
33
+ drawing text and making animations from a sprite sheet.
34
+ - Provide an easy transition from web development to game development.
35
+ - Create an easy to use framework. Slifer should handle the bulk of the work
36
+ - Keep updates consistent.
37
+
38
+ ## Current Features
39
+
40
+ - Create a native desktop window with custom title and size.
41
+ - Handle both keyboard and mouse inputs
42
+ - Load and draw images onto the window
43
+ - Play Audio
44
+
45
+ ## Future Features
46
+
47
+ - Animation library
48
+ - Save file library
49
+
50
+ ## Example
51
+
52
+ ```ts
53
+ import Slifer, { Vector2 } from "slifer";
54
+
55
+ Slifer.createWindow("Example Window", new Vector2(640, 480));
56
+
57
+ const bg = Slifer.Graphics.makeColor(36, 36, 36, 255);
58
+
59
+ while (!Slifer.shouldClose()) {
60
+ Slifer.Graphics.setBackground(bg);
61
+
62
+ if (Slifer.Keyboard.isPressed("escape")) {
63
+ Slifer.isRunning = false;
64
+ }
65
+
66
+ Slifer.Graphics.render();
67
+ }
68
+
69
+ Slifer.quit();
70
+ ```
package/index.ts CHANGED
@@ -1,11 +1,13 @@
1
- import Slifer from "./src/slifer";
2
- import Image from "./src/engine/image";
3
- import Vector2 from "./src/engine/vector2";
4
- import Color from "./src/engine/color";
5
- import Audio from "./src/engine/audio";
6
- import Rectangle from "./src/engine/rectangle";
7
- import Font from "./src/engine/font";
8
- import Canvas from './src/engine/canvas';
9
-
10
- const slf = new Slifer();
11
- export { Vector2, Color, Image, Audio, Rectangle, Font, Canvas, slf as Slifer };
1
+ import Slifer from "./src/slifer";
2
+ import Image from "./src/engine/image";
3
+ import Vector2 from "./src/engine/vector2";
4
+ import Color from "./src/engine/color";
5
+ import Audio from "./src/engine/audio";
6
+ import Rectangle from "./src/engine/rectangle";
7
+ import Font from "./src/engine/font";
8
+ import Cursor from './src/engine/cursor';
9
+
10
+ import { type keys } from './src/modules/keyboard';
11
+
12
+ const slf = new Slifer();
13
+ export { Vector2, Color, Image, Audio, Rectangle, Font, Cursor, slf as Slifer, type keys };
package/main.exe ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slifer",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "description": "A game framework made for bun and typescript",
5
5
  "module": "index.ts",
6
6
  "devDependencies": {
package/single.png ADDED
Binary file
package/src/download.ts CHANGED
@@ -1,27 +1,48 @@
1
- import * as path from 'path';
2
-
3
- const libDir = path.join(__dirname, '../libs/');
4
-
5
- async function downloadLibrary(url: string, filename: string) {
6
- const response = await fetch(url);
7
- await Bun.write(libDir + filename, response);
8
-
9
-
10
- }
11
-
12
- if (process.platform == "darwin") {
13
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2.dylib", "libSDL2.dylib");
14
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_image.dylib", "libSDL2_image.dylib");
15
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_mixer.dylib", "libSDL2_mixer.dylib");
16
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_ttf.dylib", "libSDL2_ttf.dylib");
17
- } else if (process.platform == "win32") {
18
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2.dll", "SDL2.dll");
19
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_image.dll", "SDL2_image.dll");
20
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_mixer.dll", "SDL2_mixer.dll");
21
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_ttf.dll", "SDL2_ttf.dll");
22
- } else if (process.platform == "linux") {
23
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2.so", "libSDL2.so");
24
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_image.so", "libSDL2_image.so");
25
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_mixer.so", "libSDL2_mixer.so");
26
- downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_ttf.so", "libSDL2_ttf.so");
27
- }
1
+ import * as path from 'path';
2
+ import { parseArgs } from 'util';
3
+
4
+ const libDir = path.join(__dirname, '../libs/');
5
+
6
+ async function downloadLibrary(url: string, filename: string) {
7
+ const response = await fetch(url);
8
+ await Bun.write(libDir + filename, response);
9
+ }
10
+
11
+ function downloadFiles(check: string) {
12
+ if (check == "darwin") {
13
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2.dylib", "libSDL2.dylib");
14
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_image.dylib", "libSDL2_image.dylib");
15
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_mixer.dylib", "libSDL2_mixer.dylib");
16
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_ttf.dylib", "libSDL2_ttf.dylib");
17
+ } else if (check == "win32") {
18
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2.dll", "SDL2.dll");
19
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_image.dll", "SDL2_image.dll");
20
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_mixer.dll", "SDL2_mixer.dll");
21
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/SDL2_ttf.dll", "SDL2_ttf.dll");
22
+ } else if (check == "linux") {
23
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2.so", "libSDL2.so");
24
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_image.so", "libSDL2_image.so");
25
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_mixer.so", "libSDL2_mixer.so");
26
+ downloadLibrary("https://github.com/HazyVT/Slifer/releases/download/Libraries/libSDL2_ttf.so", "libSDL2_ttf.so");
27
+ }
28
+ }
29
+
30
+ const { values } = parseArgs({
31
+ args: Bun.argv,
32
+ options: {
33
+ mode: {
34
+ type: 'string'
35
+ }
36
+ },
37
+ strict: true,
38
+ allowPositionals: true
39
+ })
40
+
41
+ if (values.mode == undefined) {
42
+ downloadFiles(process.platform);
43
+ } else {
44
+ downloadFiles(values.mode);
45
+ }
46
+
47
+
48
+
@@ -1,24 +1,24 @@
1
- import { libmixer } from "../ffi";
2
-
3
- /** @internal */
4
- export default class Audio {
5
- private readonly pointer;
6
-
7
- constructor(path: string) {
8
- const audiomix = libmixer.symbols.Mix_LoadWAV(
9
- //@ts-expect-error Buffer error
10
- Buffer.from(path + "\x00")
11
- );
12
-
13
- if (audiomix == null) throw `Failed to open wav file`;
14
- this.pointer = audiomix;
15
- }
16
-
17
- public play() {
18
- libmixer.symbols.Mix_PlayChannel(-1, this.pointer, 0);
19
- }
20
-
21
- public destroy() {
22
- libmixer.symbols.Mix_FreeChunk(this.pointer);
23
- }
1
+ import { libmixer } from "../ffi";
2
+
3
+ /** @internal */
4
+ export default class Audio {
5
+ private readonly pointer;
6
+
7
+ constructor(path: string) {
8
+ const audiomix = libmixer.symbols.Mix_LoadWAV(
9
+ //@ts-expect-error Buffer error
10
+ Buffer.from(path + "\x00")
11
+ );
12
+
13
+ if (audiomix == null) throw `Failed to open wav file`;
14
+ this.pointer = audiomix;
15
+ }
16
+
17
+ public play() {
18
+ libmixer.symbols.Mix_PlayChannel(-1, this.pointer, 0);
19
+ }
20
+
21
+ public destroy() {
22
+ libmixer.symbols.Mix_FreeChunk(this.pointer);
23
+ }
24
24
  }
@@ -1,14 +1,14 @@
1
- /** @internal */
2
- export default class Color {
3
- readonly r;
4
- readonly g;
5
- readonly b;
6
- readonly a;
7
-
8
- constructor(r: number, g: number, b: number, a: number) {
9
- this.r = r;
10
- this.g = g;
11
- this.b = b;
12
- this.a = a;
13
- }
14
- }
1
+ /** @internal */
2
+ export default class Color {
3
+ readonly r;
4
+ readonly g;
5
+ readonly b;
6
+ readonly a;
7
+
8
+ constructor(r: number, g: number, b: number, a: number) {
9
+ this.r = r;
10
+ this.g = g;
11
+ this.b = b;
12
+ this.a = a;
13
+ }
14
+ }
@@ -0,0 +1,17 @@
1
+ import { type Pointer } from 'bun:ffi';
2
+ import { libsdl, libimage } from '../ffi';
3
+
4
+ class Cursor {
5
+ pointer : Pointer;
6
+
7
+ constructor(path: string) {
8
+ //@ts-expect-error
9
+ const surf = libimage.symbols.IMG_Load(Buffer.from(path+"\x00"));
10
+ if (surf == null) throw `Cursor surface ${path} failed`;
11
+ const cursor = libsdl.symbols.SDL_CreateColorCursor(surf, 0, 0);
12
+ if (cursor == null) throw `Cursor ${path} failed`;
13
+ this.pointer = cursor;
14
+ }
15
+ }
16
+
17
+ export default Cursor;
@@ -1,16 +1,16 @@
1
- import { type Pointer } from 'bun:ffi';
2
- import { libttf } from '../ffi';
3
-
4
- export default class Font {
5
- private pointer : Pointer;
6
-
7
- constructor(path: string, size: number) {
8
- const fp = libttf.symbols.TTF_OpenFont(Buffer.from(path+"\x00"), size);
9
- if (fp == null) throw `Font failed to be opened`;
10
- this.pointer = fp;
11
- }
12
-
13
- public destroy() {
14
- libttf.symbols.TTF_CloseFont(this.pointer);
15
- }
16
- }
1
+ import { type Pointer } from 'bun:ffi';
2
+ import { libttf } from '../ffi';
3
+
4
+ export default class Font {
5
+ private pointer : Pointer;
6
+
7
+ constructor(path: string, size: number) {
8
+ const fp = libttf.symbols.TTF_OpenFont(Buffer.from(path+"\x00"), size);
9
+ if (fp == null) throw `Font failed to be opened`;
10
+ this.pointer = fp;
11
+ }
12
+
13
+ public destroy() {
14
+ libttf.symbols.TTF_CloseFont(this.pointer);
15
+ }
16
+ }
@@ -1,23 +1,42 @@
1
- import { libimage, libsdl } from "../ffi";
2
- import { type Pointer, ptr, toArrayBuffer } from 'bun:ffi';
3
- import Render from "./render";
4
-
5
- /** @internal */
6
- export default class Image {
7
-
8
- private pointer: Pointer;
9
-
10
- public readonly width: number;
11
- public readonly height: number;
12
-
13
- constructor(path: string) {
14
- const cs = Buffer.from(path+'\x00');
15
- //@ts-expect-error
16
- const surface = libimage.symbols.IMG_Load(cs);
17
- if (surface == null) throw `Loading ${path} failed`;
18
- this.pointer = surface;
19
- const dv = new DataView(toArrayBuffer(this.pointer, 0, 21));
20
- this.width = dv.getUint8(16);
21
- this.height = dv.getUint8(20);
22
- }
23
- }
1
+ import { libimage, libsdl } from "../ffi";
2
+ import { type Pointer, ptr } from 'bun:ffi';
3
+ import Render from "./render";
4
+
5
+ /** @internal */
6
+ export default class Image {
7
+
8
+ private pointer: Pointer;
9
+ private destArray: Uint32Array;
10
+
11
+ public readonly width: number;
12
+ public readonly height: number;
13
+
14
+ constructor(path: string) {
15
+ const cs = Buffer.from(path+'\x00');
16
+
17
+ //@ts-expect-error
18
+ const surface = libimage.symbols.IMG_Load(cs);
19
+ if (surface == null) throw `Surface load failed on image ${cs}`;
20
+
21
+ const texture = libsdl.symbols.SDL_CreateTextureFromSurface(Render.pointer, surface);
22
+ if (texture == null) throw `Texture load failed on image ${cs}`;
23
+ this.pointer = texture;
24
+
25
+ const wArr = new Uint32Array(1);
26
+ const hArr = new Uint32Array(1);
27
+ libsdl.symbols.SDL_QueryTexture(
28
+ texture,
29
+ null,
30
+ null,
31
+ ptr(wArr),
32
+ ptr(hArr)
33
+ )
34
+
35
+ this.width = wArr[0];
36
+ this.height = hArr[0];
37
+
38
+ this.destArray = new Uint32Array(4);
39
+ this.destArray[2] = this.width;
40
+ this.destArray[3] = this.height;
41
+ }
42
+ }
@@ -1,31 +1,31 @@
1
- import Vector2 from "./vector2";
2
- import { ptr, type Pointer } from 'bun:ffi';
3
-
4
- /** @internal */
5
- export default class Rectangle {
6
-
7
- public readonly position;
8
- public readonly size;
9
-
10
- constructor(position: Vector2, size: Vector2) {
11
- this.position = position;
12
- this.size = size;
13
- }
14
-
15
- static empty() : Rectangle {
16
- return new Rectangle(new Vector2(0, 0), new Vector2(0, 0));
17
- }
18
-
19
- public isColliding(rectangle: Rectangle) : boolean {
20
- if (
21
- this.position.x < rectangle.position.x + rectangle.size.x &&
22
- this.position.x + this.size.x > rectangle.position.x &&
23
- this.position.y < rectangle.position.y + rectangle.size.y &&
24
- this.position.y + this.size.y > rectangle.position.y
25
- ) {
26
- return true;
27
- }
28
-
29
- return false;
30
- }
31
- }
1
+ import Vector2 from "./vector2";
2
+ import { ptr, type Pointer } from 'bun:ffi';
3
+
4
+ /** @internal */
5
+ export default class Rectangle {
6
+
7
+ public position;
8
+ public size;
9
+
10
+ constructor(position: Vector2, size: Vector2) {
11
+ this.position = position;
12
+ this.size = size;
13
+ }
14
+
15
+ static empty() : Rectangle {
16
+ return new Rectangle(new Vector2(0, 0), new Vector2(0, 0));
17
+ }
18
+
19
+ public isColliding(rectangle: Rectangle) : boolean {
20
+ if (
21
+ this.position.x < rectangle.position.x + rectangle.size.x &&
22
+ this.position.x + this.size.x > rectangle.position.x &&
23
+ this.position.y < rectangle.position.y + rectangle.size.y &&
24
+ this.position.y + this.size.y > rectangle.position.y
25
+ ) {
26
+ return true;
27
+ }
28
+
29
+ return false;
30
+ }
31
+ }
@@ -1,19 +1,15 @@
1
- import { type Pointer } from 'bun:ffi';
2
- import { libsdl } from "../ffi";
3
- import Window from "./window";
4
-
5
- /** @internal */
6
- export default class Render {
7
-
8
- public static pointer : Pointer;
9
- public static surface: Pointer;
10
-
11
- public static createRenderer(width: number, height: number) {
12
- const renPointer = libsdl.symbols.SDL_CreateRenderer(Window.pointer, -1, 0);
13
- if (renPointer == null) throw `Renderer creation failed.`;
14
- this.pointer = renPointer;
15
- const surPointer = libsdl.symbols.SDL_CreateRGBSurface(0, width, height, 32, 0, 0, 0, 0)
16
- if (surPointer == null) throw `Surface creation failed`;
17
- this.surface = surPointer;
18
- }
19
- }
1
+ import { type Pointer } from 'bun:ffi';
2
+ import { libsdl } from "../ffi";
3
+ import Window from "./window";
4
+
5
+ /** @internal */
6
+ export default class Render {
7
+
8
+ public static pointer : Pointer;
9
+
10
+ public static createRenderer(width: number, height: number) {
11
+ const renPointer = libsdl.symbols.SDL_CreateRenderer(Window.pointer, -1, 0x00000004 + 0x00000002);
12
+ if (renPointer == null) throw `Renderer creation failed.`;
13
+ this.pointer = renPointer;
14
+ }
15
+ }
@@ -1,26 +1,26 @@
1
- /** @internal */
2
- export default class Vector2 {
3
- public x;
4
- public y;
5
-
6
- constructor(x: number, y: number) {
7
- this.x = x;
8
- this.y = y;
9
- }
10
-
11
- static one() : Vector2 {
12
- return new Vector2(1, 1);
13
- }
14
-
15
- static unitX() : Vector2 {
16
- return new Vector2(1, 0);
17
- }
18
-
19
- static unitY() : Vector2 {
20
- return new Vector2(0, 1);
21
- }
22
-
23
- static zero() : Vector2 {
24
- return new Vector2(0, 0);
25
- }
1
+ /** @internal */
2
+ export default class Vector2 {
3
+ public x;
4
+ public y;
5
+
6
+ constructor(x: number, y: number) {
7
+ this.x = x;
8
+ this.y = y;
9
+ }
10
+
11
+ static one() : Vector2 {
12
+ return new Vector2(1, 1);
13
+ }
14
+
15
+ static unitX() : Vector2 {
16
+ return new Vector2(1, 0);
17
+ }
18
+
19
+ static unitY() : Vector2 {
20
+ return new Vector2(0, 1);
21
+ }
22
+
23
+ static zero() : Vector2 {
24
+ return new Vector2(0, 0);
25
+ }
26
26
  }