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/modules/graphics.ts
CHANGED
@@ -1,148 +1,78 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { Rectangle } from "../engine/rectangle";
|
5
|
-
import Color from "../color";
|
6
|
-
import { Vector2 } from "../engine/vector";
|
7
|
-
import Renderer from "../engine/renderer";
|
1
|
+
import Vector2 from "../engine/vector2";
|
2
|
+
import { libsdl } from "../ffi";
|
3
|
+
import { ptr } from 'bun:ffi';
|
8
4
|
|
9
|
-
|
10
|
-
|
5
|
+
import type Image from "../engine/image";
|
6
|
+
import Render from "../engine/render";
|
7
|
+
import type Color from "../engine/color";
|
8
|
+
import type Rectangle from "../engine/rectangle";
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
public static get instance() {
|
15
|
-
if (!Graphics.#instance) {
|
16
|
-
Graphics.#instance = new Graphics();
|
17
|
-
}
|
18
|
-
|
19
|
-
return Graphics.#instance;
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Slifers draw function. Used to draw everything to the screen.
|
23
|
-
*/
|
24
|
-
public render() {
|
25
|
-
libsdl.symbols.SDL_RenderPresent(Renderer.pointer);
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Create a new color. All values are from 0-255
|
30
|
-
*
|
31
|
-
* @param r red value
|
32
|
-
* @param g green value
|
33
|
-
* @param b blue value
|
34
|
-
* @param a alpha value
|
35
|
-
* @returns Color object
|
36
|
-
*/
|
37
|
-
public makeColor(r: number, g: number, b: number, a: number) {
|
38
|
-
const _color = new Color(r, g, b, a);
|
39
|
-
return _color;
|
40
|
-
}
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Sets the background of the window to a color of choice.
|
44
|
-
*
|
45
|
-
* Make sure this is put in the top level of the while loop
|
46
|
-
* as it will clear the renderer.
|
47
|
-
*
|
48
|
-
* @param color Color object. Make using Slifer.Graphics.makeColor
|
49
|
-
*/
|
50
|
-
public setBackground(color: Color) {
|
51
|
-
libsdl.symbols.SDL_SetRenderDrawColor(
|
52
|
-
Renderer.pointer,
|
53
|
-
color.r,
|
54
|
-
color.g,
|
55
|
-
color.b,
|
56
|
-
color.a
|
57
|
-
);
|
58
|
-
libsdl.symbols.SDL_RenderClear(Renderer.pointer);
|
59
|
-
}
|
10
|
+
/** @internal */
|
11
|
+
export default class Graphics {
|
60
12
|
|
61
|
-
|
62
|
-
|
63
|
-
*
|
64
|
-
* @param path string path to image
|
65
|
-
* @returns Image ready to draw
|
66
|
-
*/
|
67
|
-
public loadImage(path: string): Image {
|
68
|
-
const _path = Buffer.from(path + "\x00");
|
69
|
-
const surface = libimage.symbols.IMG_Load(_path);
|
70
|
-
if (surface == null) throw `Image failed to load`;
|
71
|
-
const texture = libsdl.symbols.SDL_CreateTextureFromSurface(
|
72
|
-
Renderer.pointer,
|
73
|
-
surface
|
74
|
-
);
|
75
|
-
if (texture == null) throw `Image failed to be created`;
|
76
|
-
return new Image(texture);
|
13
|
+
render() : void {
|
14
|
+
libsdl.symbols.SDL_RenderPresent(Render.pointer);
|
77
15
|
}
|
16
|
+
|
17
|
+
draw(image: Image, position: Vector2) : void {
|
78
18
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
* @param image Image object to draw. Made using Slifer.Graphics.loadImage
|
83
|
-
* @param position position to draw the image
|
84
|
-
*
|
85
|
-
*/
|
86
|
-
public draw(image: Image, position: Vector2) {
|
87
|
-
const dstRect = new Uint32Array(4);
|
88
|
-
dstRect[0] = position.x;
|
89
|
-
dstRect[1] = position.y;
|
90
|
-
dstRect[2] = image.size.x;
|
91
|
-
dstRect[3] = image.size.y;
|
92
|
-
|
19
|
+
(image as any).destArr[0] = position.x;
|
20
|
+
(image as any).destArr[1] = position.y;
|
21
|
+
|
93
22
|
libsdl.symbols.SDL_RenderCopy(
|
94
|
-
|
23
|
+
Render.pointer,
|
95
24
|
(image as any).pointer,
|
96
25
|
null,
|
97
|
-
|
26
|
+
ptr((image as any).destArr)
|
98
27
|
);
|
99
28
|
}
|
100
29
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
*/
|
109
|
-
public drawEx(
|
110
|
-
image: Image,
|
111
|
-
position: Vector2,
|
112
|
-
rotation?: number,
|
113
|
-
scale?: Vector2,
|
114
|
-
flipH?: boolean
|
115
|
-
) {
|
116
|
-
// Define destination rect
|
117
|
-
const dstRect = new Uint32Array(4);
|
118
|
-
dstRect[0] = position.x;
|
119
|
-
dstRect[1] = position.y;
|
120
|
-
dstRect[2] = image.size.x * (scale ? scale.x : 1);
|
121
|
-
dstRect[3] = image.size.y * (scale ? scale.y : 1);
|
30
|
+
drawEx(image: Image, position: Vector2, rotation?: number, scale?: Vector2, flipH?: boolean) {
|
31
|
+
|
32
|
+
const destArr = (image as any).destArr;
|
33
|
+
destArr[0] = position.x;
|
34
|
+
destArr[1] = position.y;
|
35
|
+
destArr[2] = image.width * (scale ? scale.x : 1);
|
36
|
+
destArr[3] = image.height * (scale ? scale.y : 1);
|
122
37
|
|
123
|
-
// Draw to screen
|
124
38
|
libsdl.symbols.SDL_RenderCopyEx(
|
125
|
-
|
126
|
-
image.pointer,
|
39
|
+
Render.pointer,
|
40
|
+
(image as any).pointer,
|
127
41
|
null,
|
128
|
-
ptr(
|
42
|
+
ptr(destArr),
|
129
43
|
rotation ? rotation : 0,
|
130
44
|
null,
|
131
|
-
|
45
|
+
Number(flipH)
|
132
46
|
);
|
47
|
+
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
setBackground(color: Color) : void {
|
52
|
+
libsdl.symbols.SDL_SetRenderDrawColor(Render.pointer,
|
53
|
+
color.r,
|
54
|
+
color.g,
|
55
|
+
color.b,
|
56
|
+
color.a
|
57
|
+
);
|
58
|
+
libsdl.symbols.SDL_RenderClear(Render.pointer);
|
133
59
|
}
|
134
60
|
|
135
61
|
public drawRect(rectangle: Rectangle, color: Color) {
|
136
62
|
libsdl.symbols.SDL_SetRenderDrawColor(
|
137
|
-
|
63
|
+
Render.pointer,
|
138
64
|
color.r,
|
139
65
|
color.g,
|
140
66
|
color.b,
|
141
67
|
color.a
|
142
68
|
);
|
143
|
-
libsdl.symbols.SDL_RenderFillRect(Renderer.pointer, rectangle.pointer);
|
144
|
-
}
|
145
|
-
}
|
146
69
|
|
147
|
-
|
148
|
-
|
70
|
+
const rect = new Uint32Array(4);
|
71
|
+
rect[0] = rectangle.position.x;
|
72
|
+
rect[1] = rectangle.position.y;
|
73
|
+
rect[2] = rectangle.size.x;
|
74
|
+
rect[3] = rectangle.size.y;
|
75
|
+
|
76
|
+
libsdl.symbols.SDL_RenderFillRect(Render.pointer, ptr(rect));
|
77
|
+
}
|
78
|
+
}
|
package/src/modules/keyboard.ts
CHANGED
@@ -1,77 +1,50 @@
|
|
1
1
|
import { libsdl } from "../ffi";
|
2
2
|
import { toArrayBuffer } from "bun:ffi";
|
3
|
-
|
4
3
|
/** @internal */
|
5
|
-
class Keyboard {
|
6
|
-
static #instance: Keyboard;
|
7
|
-
|
8
|
-
static keyState: DataView;
|
9
|
-
static pressMap = new Map<string, number>();
|
10
|
-
|
11
|
-
private constructor() {}
|
12
|
-
|
13
|
-
public static get instance() {
|
14
|
-
if (!Keyboard.#instance) {
|
15
|
-
Keyboard.#instance = new Keyboard();
|
16
|
-
}
|
4
|
+
export default class Keyboard {
|
17
5
|
|
18
|
-
|
19
|
-
}
|
6
|
+
public static keyMap = new Map<string, number>();
|
20
7
|
|
21
8
|
private static convertScancodeToKey(scancode: number): string {
|
22
9
|
const keyFromScancode = libsdl.symbols.SDL_GetKeyFromScancode(scancode);
|
23
10
|
const keyName = libsdl.symbols
|
24
11
|
.SDL_GetKeyName(keyFromScancode)
|
25
|
-
.toString()
|
12
|
+
.toString()
|
13
|
+
.toLocaleLowerCase();
|
26
14
|
|
27
15
|
return keyName;
|
28
16
|
}
|
29
17
|
|
30
|
-
static
|
31
|
-
const
|
32
|
-
if (
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
const
|
38
|
-
|
18
|
+
public static handleStates() {
|
19
|
+
const keyState = libsdl.symbols.SDL_GetKeyboardState(null);
|
20
|
+
if (keyState == null) throw `Keyboard state returned null.`;
|
21
|
+
const keyDV = new DataView(toArrayBuffer(keyState, 0, 512));
|
22
|
+
for (let kn = 0; kn < 512; kn++) {
|
23
|
+
if (keyDV.getUint8(kn) == 1) {
|
24
|
+
const keyName = this.convertScancodeToKey(kn);
|
25
|
+
const kmGet = this.keyMap.get(keyName);
|
26
|
+
|
39
27
|
if (kmGet == undefined || kmGet == 0) {
|
40
|
-
this.
|
28
|
+
this.keyMap.set(keyName, 1);
|
41
29
|
} else if (kmGet == 1) {
|
42
|
-
this.
|
30
|
+
this.keyMap.set(keyName, 2);
|
43
31
|
}
|
44
|
-
} else if (
|
45
|
-
const keyName = this.convertScancodeToKey(
|
46
|
-
this.
|
32
|
+
} else if (keyDV.getUint8(kn) == 0) {
|
33
|
+
const keyName = this.convertScancodeToKey(kn);
|
34
|
+
this.keyMap.set(keyName, 0);
|
47
35
|
}
|
48
36
|
}
|
49
37
|
}
|
50
38
|
|
51
|
-
public isPressed(key: keys) {
|
52
|
-
|
53
|
-
|
54
|
-
Buffer.from(key + "\x00")
|
55
|
-
);
|
56
|
-
const thisval = Keyboard.keyState.getUint8(scancode);
|
57
|
-
*/
|
58
|
-
|
59
|
-
const kmGet = Keyboard.pressMap.get(key);
|
60
|
-
if (kmGet == 1) {
|
61
|
-
return true;
|
62
|
-
}
|
63
|
-
|
64
|
-
|
39
|
+
public isPressed(key: keys) : boolean {
|
40
|
+
const kmGet = Keyboard.keyMap.get(key);
|
41
|
+
if (kmGet == 1) return true;
|
65
42
|
return false;
|
66
43
|
}
|
67
44
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if (kmGet == 1 || kmGet == 2) {
|
72
|
-
return true;
|
73
|
-
}
|
74
|
-
|
45
|
+
public isDown(key: keys) : boolean {
|
46
|
+
const kmGet = Keyboard.keyMap.get(key);
|
47
|
+
if (kmGet == 1 || kmGet == 2) return true;
|
75
48
|
return false;
|
76
49
|
}
|
77
50
|
}
|
@@ -120,6 +93,3 @@ type keys =
|
|
120
93
|
| "right shift"
|
121
94
|
| "left ctrl"
|
122
95
|
| "escape";
|
123
|
-
|
124
|
-
/** @internal */
|
125
|
-
export default Keyboard;
|
package/src/modules/mouse.ts
CHANGED
@@ -1,106 +1,62 @@
|
|
1
1
|
import { libsdl } from "../ffi";
|
2
2
|
import { ptr } from "bun:ffi";
|
3
|
-
import
|
3
|
+
import Vector2 from "../engine/vector2";
|
4
4
|
|
5
5
|
/** @internal */
|
6
6
|
class Mouse {
|
7
|
-
static #instance: Mouse;
|
8
7
|
|
9
|
-
static
|
10
|
-
static
|
11
|
-
static releasedKeyMap = new Map<string, boolean>();
|
8
|
+
private static x : number;
|
9
|
+
private static y : number;
|
12
10
|
|
13
|
-
private
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
return Mouse.#instance;
|
11
|
+
private static buttonMap = new Map<number, number>();
|
12
|
+
|
13
|
+
static onRelease(button: number) {
|
14
|
+
this.buttonMap.set(button, 0);
|
19
15
|
}
|
20
16
|
|
21
|
-
static
|
22
|
-
|
23
|
-
|
24
|
-
key = "left";
|
25
|
-
} else if (button == 2) {
|
26
|
-
key = "middle";
|
27
|
-
} else {
|
28
|
-
key = "right";
|
29
|
-
}
|
30
|
-
|
31
|
-
this.downKeyMap.set(key, true);
|
32
|
-
this.releasedKeyMap.set(key, false);
|
33
|
-
}
|
17
|
+
static handleState() {
|
18
|
+
const down = libsdl.symbols.SDL_GetMouseState();
|
19
|
+
const bmGet = this.buttonMap.get(down);
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
if (
|
38
|
-
|
39
|
-
} else if (button == 2) {
|
40
|
-
key = "middle";
|
41
|
-
} else {
|
42
|
-
key = "right";
|
21
|
+
if (bmGet == undefined || bmGet == 0) {
|
22
|
+
this.buttonMap.set(down, 1);
|
23
|
+
} else if (bmGet == 1) {
|
24
|
+
this.buttonMap.set(down, 2);
|
43
25
|
}
|
44
|
-
|
45
|
-
this.downKeyMap.set(key, false);
|
46
|
-
this.pressedKeyMap.set(key, false);
|
47
26
|
}
|
48
27
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
*/
|
54
|
-
isDown(button: buttons) {
|
55
|
-
const _state = Mouse.downKeyMap.get(button);
|
56
|
-
if (_state == undefined) return false;
|
57
|
-
|
58
|
-
return _state;
|
28
|
+
private static getPressMap(button: number) {
|
29
|
+
const bmGet = this.buttonMap.get(button);
|
30
|
+
if (bmGet == 1) return true;
|
31
|
+
return false;
|
59
32
|
}
|
60
33
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
* @returns if button is pressed. Returns only once
|
65
|
-
*/
|
66
|
-
isPressed(button: buttons) {
|
67
|
-
const _pressedState = Mouse.pressedKeyMap.get(button);
|
68
|
-
const _downState = Mouse.downKeyMap.get(button);
|
69
|
-
|
70
|
-
if (_downState == true) {
|
71
|
-
if (_pressedState == false || _pressedState == undefined) {
|
72
|
-
Mouse.pressedKeyMap.set(button, true);
|
73
|
-
return true;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
34
|
+
private static getDownMap(button: number) {
|
35
|
+
const bmGet = this.buttonMap.get(button);
|
36
|
+
if (bmGet == 1 || bmGet == 2) return true;
|
77
37
|
return false;
|
78
38
|
}
|
79
39
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if (_downState == false) {
|
90
|
-
if (_releasedState == false || undefined) {
|
91
|
-
Mouse.releasedKeyMap.set(button, true);
|
92
|
-
return true;
|
93
|
-
}
|
40
|
+
isPressed(button: buttons) : boolean {
|
41
|
+
switch (button) {
|
42
|
+
case 'left':
|
43
|
+
return Mouse.getPressMap(1);
|
44
|
+
case 'middle':
|
45
|
+
return Mouse.getPressMap(2);
|
46
|
+
case 'right':
|
47
|
+
return Mouse.getPressMap(3);
|
94
48
|
}
|
95
|
-
|
96
|
-
return false;
|
97
49
|
}
|
98
50
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
51
|
+
isDown(button: buttons) : boolean {
|
52
|
+
switch (button) {
|
53
|
+
case 'left':
|
54
|
+
return Mouse.getDownMap(1);
|
55
|
+
case 'middle':
|
56
|
+
return Mouse.getDownMap(2);
|
57
|
+
case 'right':
|
58
|
+
return Mouse.getDownMap(3);
|
59
|
+
}
|
104
60
|
}
|
105
61
|
}
|
106
62
|
|
package/src/slifer.test.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { describe, expect, it } from "bun:test";
|
2
2
|
import { initSDL, initSDLImage, initSDLTypeFont, initSDLMixer } from "./engine";
|
3
|
-
import Vector2 from "./engine/
|
3
|
+
import Vector2 from "./engine/vector2";
|
4
|
+
import Render from "./engine/render";
|
4
5
|
import Window from "./engine/window";
|
5
|
-
import Renderer from "./engine/renderer";
|
6
6
|
|
7
7
|
describe("Initializing SDL ", () => {
|
8
8
|
it("Should initialize without error ", () => {
|
@@ -38,6 +38,6 @@ describe("Window Creation ", () => {
|
|
38
38
|
|
39
39
|
describe("Renderer Creation ", () => {
|
40
40
|
it("Should create renderer without error", () => {
|
41
|
-
expect(() =>
|
41
|
+
expect(() => Render.createRenderer()).not.toThrow(Error);
|
42
42
|
});
|
43
43
|
});
|
package/src/slifer.ts
CHANGED
@@ -1,109 +1,65 @@
|
|
1
1
|
import { libsdl } from "./ffi";
|
2
|
-
import Graphics from "./modules/graphics";
|
3
|
-
import Keyboard from "./modules/keyboard";
|
4
|
-
import Mouse from "./modules/mouse";
|
5
|
-
import Audio from "./modules/audio";
|
6
2
|
import Window from "./engine/window";
|
7
|
-
import Renderer from "./engine/
|
8
|
-
import {
|
9
|
-
import { Timer } from "./engine/time";
|
10
|
-
import { ptr, toArrayBuffer } from "bun:ffi";
|
3
|
+
import Renderer from "./engine/render";
|
4
|
+
import { ptr } from "bun:ffi";
|
11
5
|
import { initLibraries } from "./engine";
|
12
6
|
import { version } from "../package.json";
|
7
|
+
import type Vector2 from "./engine/vector2";
|
8
|
+
import Graphics from "./modules/graphics";
|
9
|
+
import Keyboard from "./modules/keyboard";
|
10
|
+
import Mouse from "./modules/mouse";
|
11
|
+
import Render from "./engine/render";
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Graphics = Graphics.instance;
|
18
|
-
Keyboard = Keyboard.instance;
|
19
|
-
Mouse = Mouse.instance;
|
20
|
-
Audio = Audio.instance;
|
21
|
-
|
22
|
-
// Public Variables
|
23
|
-
public dt: number = 0;
|
24
|
-
public isRunning: boolean = true;
|
13
|
+
class Slifer {
|
14
|
+
|
15
|
+
public isRunning: boolean;
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
// Modules
|
18
|
+
public Graphics = new Graphics();
|
19
|
+
public Keyboard = new Keyboard();
|
20
|
+
public Mouse = new Mouse();
|
29
21
|
|
30
22
|
constructor() {
|
31
23
|
initLibraries();
|
32
|
-
this.
|
24
|
+
this.isRunning = true;
|
33
25
|
}
|
34
26
|
|
35
|
-
|
36
|
-
* @param title Title of window
|
37
|
-
* @param width Width of window
|
38
|
-
* @param height Height of window
|
39
|
-
*/
|
40
|
-
createWindow(title: string, size: Vector2): Window {
|
41
|
-
// Create the window
|
42
|
-
const window = Window.instance;
|
27
|
+
public createWindow(title: string, size: Vector2) : Window {
|
43
28
|
Window.createWindow(title, size);
|
44
|
-
|
45
|
-
// Create the renderer
|
46
29
|
Renderer.createRenderer();
|
47
30
|
|
48
|
-
|
49
|
-
return window;
|
31
|
+
return new Window();
|
50
32
|
}
|
51
33
|
|
52
|
-
|
53
|
-
* @returns if the window should close
|
54
|
-
*/
|
55
|
-
shouldClose(): boolean {
|
56
|
-
this.capTimer.start();
|
34
|
+
public shouldClose() : boolean {
|
57
35
|
|
58
|
-
|
59
|
-
Renderer.clear();
|
36
|
+
libsdl.symbols.SDL_RenderClear(Render.pointer);
|
60
37
|
|
61
|
-
// Calculate delta time
|
62
|
-
// this.dt = Time.instance.calcDelta();
|
63
|
-
|
64
|
-
// Poll Events
|
65
38
|
const eventArray = new Uint16Array(32);
|
66
|
-
const
|
67
|
-
|
68
|
-
if (isEvent) {
|
39
|
+
const event = libsdl.symbols.SDL_PollEvent(ptr(eventArray));
|
40
|
+
if (event) {
|
69
41
|
switch (eventArray[0]) {
|
70
|
-
// Quit event
|
71
42
|
case 256:
|
72
43
|
this.isRunning = false;
|
73
44
|
break;
|
74
|
-
// Mouse down event
|
75
|
-
case 1025:
|
76
|
-
const _dbtn = eventArray[8] - 256;
|
77
|
-
Mouse.setButtonDown(_dbtn);
|
78
|
-
break;
|
79
|
-
// Mouse up event
|
80
45
|
case 1026:
|
81
|
-
|
82
|
-
Mouse.setButtonUp(_ubtn);
|
46
|
+
Mouse.onRelease(eventArray[8]);
|
83
47
|
break;
|
84
48
|
}
|
85
49
|
}
|
86
50
|
|
87
|
-
Keyboard.
|
88
|
-
|
89
|
-
const frameTicks = this.capTimer.getTicks();
|
90
|
-
if (frameTicks < this.ticksPerFrame) {
|
91
|
-
libsdl.symbols.SDL_Delay(this.ticksPerFrame - frameTicks);
|
92
|
-
}
|
51
|
+
Keyboard.handleStates();
|
93
52
|
|
53
|
+
Mouse.handleState();
|
54
|
+
|
55
|
+
|
94
56
|
return !this.isRunning;
|
95
57
|
}
|
96
58
|
|
97
|
-
|
98
|
-
|
99
|
-
*/
|
100
|
-
quit() {
|
101
|
-
libsdl.symbols.SDL_DestroyRenderer(Renderer.pointer);
|
102
|
-
libsdl.symbols.SDL_DestroyWindow(Window.pointer);
|
103
|
-
libsdl.symbols.SDL_Quit();
|
104
|
-
}
|
105
|
-
|
106
|
-
getVersion() {
|
107
|
-
return version;
|
59
|
+
public getVersion() : string {
|
60
|
+
return 'v' + version;
|
108
61
|
}
|
109
62
|
}
|
63
|
+
|
64
|
+
|
65
|
+
export default Slifer;
|
package/Logo.png
DELETED
Binary file
|
package/libs/libSDL2.dll
DELETED
Binary file
|
package/libs/libSDL2.dylib
DELETED
Binary file
|
package/libs/libSDL2.so
DELETED
Binary file
|
package/libs/libSDL2_gfx.dylib
DELETED
Binary file
|
package/libs/libSDL2_image.dll
DELETED
Binary file
|
package/libs/libSDL2_image.dylib
DELETED
Binary file
|
package/libs/libSDL2_image.so
DELETED
Binary file
|
package/libs/libSDL2_mixer.dll
DELETED
Binary file
|
package/libs/libSDL2_mixer.dylib
DELETED
Binary file
|
package/libs/libSDL2_mixer.so
DELETED
Binary file
|
package/libs/libSDL2_ttf.dll
DELETED
Binary file
|
package/libs/libSDL2_ttf.dylib
DELETED
Binary file
|
package/libs/libSDL2_ttf.so
DELETED
Binary file
|
package/logo-alpha.png
DELETED
Binary file
|