slifer 0.2.3 → 0.2.5
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/.npmignore +138 -0
- package/README.md +8 -6
- package/bun.lockb +0 -0
- package/index.ts +7 -10
- package/package.json +7 -4
- package/src/download.ts +23 -0
- package/src/{modules → engine}/audio.ts +5 -22
- package/src/{color.ts → engine/color.ts} +2 -3
- package/src/engine/image.ts +26 -20
- package/src/engine/rectangle.ts +8 -18
- package/src/engine/render.ts +15 -0
- package/src/engine/vector2.ts +10 -0
- package/src/engine/window.ts +23 -53
- package/src/engine.ts +0 -1
- package/src/ffi.ts +8 -0
- package/src/modules/graphics.ts +51 -121
- package/src/modules/keyboard.ts +24 -54
- package/src/modules/mouse.ts +38 -82
- package/src/slifer.test.ts +3 -3
- package/src/slifer.ts +31 -75
- package/Logo.png +0 -0
- package/libs/libSDL2.dll +0 -0
- package/libs/libSDL2.dylib +0 -0
- package/libs/libSDL2.so +0 -0
- package/libs/libSDL2_gfx.dylib +0 -0
- package/libs/libSDL2_image.dll +0 -0
- package/libs/libSDL2_image.dylib +0 -0
- package/libs/libSDL2_image.so +0 -0
- package/libs/libSDL2_mixer.dll +0 -0
- package/libs/libSDL2_mixer.dylib +0 -0
- package/libs/libSDL2_mixer.so +0 -0
- package/libs/libSDL2_ttf.dll +0 -0
- package/libs/libSDL2_ttf.dylib +0 -0
- package/libs/libSDL2_ttf.so +0 -0
- package/logo-alpha.png +0 -0
- package/src/engine/renderer.ts +0 -40
- package/src/engine/time.ts +0 -79
- package/src/engine/vector.ts +0 -47
package/src/engine/renderer.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import { type Pointer } from "bun:ffi";
|
2
|
-
import { libsdl } from "../ffi";
|
3
|
-
import Window from "./window";
|
4
|
-
|
5
|
-
class Renderer {
|
6
|
-
static #instance: Renderer;
|
7
|
-
static #pointer: Pointer;
|
8
|
-
|
9
|
-
private constructor() {}
|
10
|
-
|
11
|
-
public static get instance() {
|
12
|
-
if (!Renderer.#instance) {
|
13
|
-
Renderer.#instance = new Renderer();
|
14
|
-
}
|
15
|
-
|
16
|
-
return Renderer.#instance;
|
17
|
-
}
|
18
|
-
|
19
|
-
public static get pointer() {
|
20
|
-
return Renderer.#pointer;
|
21
|
-
}
|
22
|
-
|
23
|
-
static createRenderer() {
|
24
|
-
const vsyncHint = 0x00000004;
|
25
|
-
const _ren = libsdl.symbols.SDL_CreateRenderer(
|
26
|
-
Window.pointer,
|
27
|
-
-1,
|
28
|
-
vsyncHint
|
29
|
-
);
|
30
|
-
|
31
|
-
if (_ren == null) throw `Renderer Creation Failed`;
|
32
|
-
Renderer.#pointer = _ren;
|
33
|
-
}
|
34
|
-
|
35
|
-
static clear() {
|
36
|
-
libsdl.symbols.SDL_RenderClear(Renderer.pointer);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
export default Renderer;
|
package/src/engine/time.ts
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
import { libsdl } from "../ffi";
|
2
|
-
|
3
|
-
export class Timer {
|
4
|
-
|
5
|
-
private mStartTicks;
|
6
|
-
private mPausedTicks;
|
7
|
-
private mPaused;
|
8
|
-
private mStarted;
|
9
|
-
|
10
|
-
|
11
|
-
constructor() {
|
12
|
-
this.mStartTicks = 0;
|
13
|
-
this.mPausedTicks = 0;
|
14
|
-
this.mPaused = false;
|
15
|
-
this.mStarted = false;
|
16
|
-
}
|
17
|
-
|
18
|
-
public start() {
|
19
|
-
this.mStarted = true;
|
20
|
-
|
21
|
-
this.mPaused = false;
|
22
|
-
|
23
|
-
this.mStartTicks = libsdl.symbols.SDL_GetTicks();
|
24
|
-
this.mPausedTicks = 0;
|
25
|
-
}
|
26
|
-
|
27
|
-
public stop() {
|
28
|
-
this.mStarted = false;
|
29
|
-
this.mPaused = true;
|
30
|
-
|
31
|
-
this.mStartTicks = 0;
|
32
|
-
this.mPausedTicks = 0;
|
33
|
-
}
|
34
|
-
|
35
|
-
public pause() {
|
36
|
-
if (this.mStarted && !this.mPaused) {
|
37
|
-
this.mPaused = true;
|
38
|
-
|
39
|
-
this.mPausedTicks = libsdl.symbols.SDL_GetTicks() - this.mStartTicks;
|
40
|
-
this.mStartTicks = 0;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
public unpause() {
|
45
|
-
if (this.mStarted && this.mPaused) {
|
46
|
-
this.mPaused = false;
|
47
|
-
|
48
|
-
this.mStartTicks = libsdl.symbols.SDL_GetTicks() - this.mPausedTicks;
|
49
|
-
this.mPausedTicks = 0;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
public getTicks() {
|
54
|
-
let time = 0;
|
55
|
-
|
56
|
-
if (this.mStarted) {
|
57
|
-
if (this.mPaused) {
|
58
|
-
time = this.mPausedTicks;
|
59
|
-
} else {
|
60
|
-
time = libsdl.symbols.SDL_GetTicks() - this.mStartTicks;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
return time;
|
65
|
-
}
|
66
|
-
|
67
|
-
public isStarted() {
|
68
|
-
return this.mStarted;
|
69
|
-
}
|
70
|
-
|
71
|
-
public isPaused() {
|
72
|
-
return (this.mPaused && this.mStarted);
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
|
package/src/engine/vector.ts
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
export class Vector2 {
|
2
|
-
public x;
|
3
|
-
public y;
|
4
|
-
|
5
|
-
constructor(x: number, y: number) {
|
6
|
-
this.x = x;
|
7
|
-
this.y = y;
|
8
|
-
}
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Creates a Vector2 with the components 1,1
|
12
|
-
*/
|
13
|
-
static one() {
|
14
|
-
return new Vector2(1, 1);
|
15
|
-
}
|
16
|
-
|
17
|
-
/**
|
18
|
-
* Creates a Vector2 with the components 1,0
|
19
|
-
*/
|
20
|
-
static unitX() {
|
21
|
-
return new Vector2(1, 0);
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Creates a Vector2 with the components 0,1
|
26
|
-
*/
|
27
|
-
static unitY() {
|
28
|
-
return new Vector2(0, 1);
|
29
|
-
}
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Creates a vector2 with component 0,0
|
33
|
-
*/
|
34
|
-
static zero() {
|
35
|
-
return new Vector2(0, 0);
|
36
|
-
}
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Adds two vectors together
|
40
|
-
*
|
41
|
-
* @param vec1 Vector2 object
|
42
|
-
* @param vec2 Vector2 object
|
43
|
-
*/
|
44
|
-
static add(vec1: Vector2, vec2: Vector2) {
|
45
|
-
return new Vector2(vec1.x + vec2.x, vec1.y + vec2.y);
|
46
|
-
}
|
47
|
-
}
|