pxt-common-packages 9.4.11 → 9.4.14
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/built/common-sim.d.ts +44 -0
- package/built/common-sim.js +139 -0
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +8030 -7818
- package/libs/controller---none/built/debug/binary.js +8009 -7797
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-jsdoc-strings.json +19 -0
- package/libs/game/_locales/game-strings.json +2 -0
- package/libs/game/built/debug/binary.js +7922 -7710
- package/libs/game/extendableSprite.ts +80 -0
- package/libs/game/hitbox.ts +2 -2
- package/libs/game/keymap.cpp +12 -0
- package/libs/game/keymap.ts +169 -0
- package/libs/game/pxt.json +4 -1
- package/libs/game/scenes.ts +0 -1
- package/libs/game/sim/keymap.ts +167 -0
- package/libs/game/sprite.ts +68 -57
- package/libs/game/tilemap.ts +6 -5
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +9710 -9498
- package/libs/palette/built/debug/binary.js +7921 -7709
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +7921 -7709
- package/libs/storyboard/built/debug/binary.js +7921 -7709
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
namespace sprites {
|
|
2
|
+
/**
|
|
3
|
+
* A version of the Sprite class that is easier to extend.
|
|
4
|
+
*
|
|
5
|
+
* Unlike the normal Sprite class, this class will automatically add
|
|
6
|
+
* itself to the physics engine and run all sprite created handlers
|
|
7
|
+
* in the constructor
|
|
8
|
+
*/
|
|
9
|
+
export class ExtendableSprite extends Sprite {
|
|
10
|
+
protected hasCustomDimensions: boolean;
|
|
11
|
+
|
|
12
|
+
constructor(spriteImage: Image, kind?: number) {
|
|
13
|
+
super(spriteImage);
|
|
14
|
+
|
|
15
|
+
const scene = game.currentScene();
|
|
16
|
+
this.setKind(kind);
|
|
17
|
+
scene.physicsEngine.addSprite(this);
|
|
18
|
+
|
|
19
|
+
// run on created handlers
|
|
20
|
+
scene.createdHandlers
|
|
21
|
+
.filter(h => h.kind == kind)
|
|
22
|
+
.forEach(h => h.handler(this));
|
|
23
|
+
|
|
24
|
+
this.hasCustomDimensions = false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Override to change how the sprite is drawn to the screen
|
|
29
|
+
*
|
|
30
|
+
* @param drawLeft The left position to draw the sprite at (already adjusted for camera)
|
|
31
|
+
* @param drawTop The top position to draw the sprite at (already adjusted for camera)
|
|
32
|
+
*/
|
|
33
|
+
draw(drawLeft: number, drawTop: number) {
|
|
34
|
+
super.drawSprite(drawLeft, drawTop);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Override to add update logic for a sprite. This method runs once per frame
|
|
39
|
+
*
|
|
40
|
+
* @param deltaTimeMillis The time that has elapsed since the last frame in milliseconds
|
|
41
|
+
*/
|
|
42
|
+
update(deltaTimeMillis: number) {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Sets the width and height of this sprite. Once set, this will also prevent
|
|
47
|
+
* this width and height from automatically changing whenever scale or the image
|
|
48
|
+
* changes
|
|
49
|
+
*/
|
|
50
|
+
setDimensions(width: number, height: number) {
|
|
51
|
+
this._width = Fx8(width);
|
|
52
|
+
this._height = Fx8(height);
|
|
53
|
+
this.hasCustomDimensions = true;
|
|
54
|
+
this.resetHitbox();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
__update(camera: scene.Camera, dt: number) {
|
|
58
|
+
super.__update(camera, dt);
|
|
59
|
+
this.update(game.currentScene().eventContext.deltaTimeMillis)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setHitbox() {
|
|
63
|
+
if (this.hasCustomDimensions) {
|
|
64
|
+
this._hitbox = new game.Hitbox(this, this._width, this._height, Fx.zeroFx8, Fx.zeroFx8)
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
super.setHitbox();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected drawSprite(drawLeft: number, drawTop: number): void {
|
|
72
|
+
this.draw(drawLeft, drawTop);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected recalcSize() {
|
|
76
|
+
if (this.hasCustomDimensions) return;
|
|
77
|
+
super.recalcSize();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
package/libs/game/hitbox.ts
CHANGED
|
@@ -17,11 +17,11 @@ namespace game {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
get left() {
|
|
20
|
-
return Fx.add(this.ox,
|
|
20
|
+
return Fx.add(this.ox, this.parent._x);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
get top() {
|
|
24
|
-
return Fx.add(this.oy,
|
|
24
|
+
return Fx.add(this.oy, this.parent._y);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
get right() {
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
namespace keymap {
|
|
2
|
+
//% shim=keymap::_setPlayerKeys
|
|
3
|
+
declare function _setPlayerKeys(
|
|
4
|
+
player: number, // player number is 1-based
|
|
5
|
+
up: number,
|
|
6
|
+
down: number,
|
|
7
|
+
left: number,
|
|
8
|
+
right: number,
|
|
9
|
+
A: number,
|
|
10
|
+
B: number
|
|
11
|
+
): void;
|
|
12
|
+
|
|
13
|
+
//% shim=keymap::_setSystemKeys
|
|
14
|
+
declare function _setSystemKeys(screenshot: number, gif: number, menu: number, reset: number): void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Sets the keyboard input map for the given player.
|
|
18
|
+
* @param player The player number. 1 = Player1, etc.
|
|
19
|
+
* @param up The key code for 'up'.
|
|
20
|
+
* @param down The key code for 'down'
|
|
21
|
+
* @param left The key code for 'left'
|
|
22
|
+
* @param right The key code for 'right'
|
|
23
|
+
* @param A The key code for 'A'
|
|
24
|
+
* @param B The key code for 'B'
|
|
25
|
+
*/
|
|
26
|
+
export function setPlayerKeys(
|
|
27
|
+
player: number, // player number is 1-based
|
|
28
|
+
up: KeyCode,
|
|
29
|
+
down: KeyCode,
|
|
30
|
+
left: KeyCode,
|
|
31
|
+
right: KeyCode,
|
|
32
|
+
A: KeyCode,
|
|
33
|
+
B: KeyCode
|
|
34
|
+
) {
|
|
35
|
+
_setPlayerKeys(player, up, down, left, right, A, B);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sets the keyboard input map for system keys.
|
|
40
|
+
* @param screenshot The key code for 'screenshot'
|
|
41
|
+
* @param gif The key code for 'gif'
|
|
42
|
+
* @param menu The key code for 'menu'
|
|
43
|
+
* @param reset The key code for 'reset'
|
|
44
|
+
*/
|
|
45
|
+
export function setSystemKeys(screenshot: KeyCode, gif: KeyCode, menu: KeyCode, reset: KeyCode) {
|
|
46
|
+
_setSystemKeys(screenshot, gif, menu, reset);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Key codes
|
|
51
|
+
*/
|
|
52
|
+
export enum KeyCode {
|
|
53
|
+
None = 0,
|
|
54
|
+
|
|
55
|
+
Backspace = 8,
|
|
56
|
+
Tab = 9,
|
|
57
|
+
Enter = 13,
|
|
58
|
+
Shift = 16,
|
|
59
|
+
Ctrl = 17,
|
|
60
|
+
Alt = 18,
|
|
61
|
+
PauseBreak = 19,
|
|
62
|
+
CapsLock = 20,
|
|
63
|
+
Escape = 27,
|
|
64
|
+
Space = 32,
|
|
65
|
+
PageUp = 33,
|
|
66
|
+
PageDown = 34,
|
|
67
|
+
End = 35,
|
|
68
|
+
Home = 36,
|
|
69
|
+
|
|
70
|
+
LeftArrow = 37,
|
|
71
|
+
UpArrow = 38,
|
|
72
|
+
RightArrow = 39,
|
|
73
|
+
DownArrow = 40,
|
|
74
|
+
|
|
75
|
+
Insert = 45,
|
|
76
|
+
Delete = 46,
|
|
77
|
+
|
|
78
|
+
Zero = 48,
|
|
79
|
+
One = 49,
|
|
80
|
+
Two = 50,
|
|
81
|
+
Three = 51,
|
|
82
|
+
Four = 52,
|
|
83
|
+
Five = 53,
|
|
84
|
+
Six = 54,
|
|
85
|
+
Seven = 55,
|
|
86
|
+
Eight = 56,
|
|
87
|
+
Nine = 57,
|
|
88
|
+
|
|
89
|
+
A = 65,
|
|
90
|
+
B = 66,
|
|
91
|
+
C = 67,
|
|
92
|
+
D = 68,
|
|
93
|
+
E = 69,
|
|
94
|
+
F = 70,
|
|
95
|
+
G = 71,
|
|
96
|
+
H = 72,
|
|
97
|
+
I = 73,
|
|
98
|
+
J = 74,
|
|
99
|
+
K = 75,
|
|
100
|
+
L = 76,
|
|
101
|
+
M = 77,
|
|
102
|
+
N = 78,
|
|
103
|
+
O = 79,
|
|
104
|
+
P = 80,
|
|
105
|
+
Q = 81,
|
|
106
|
+
R = 82,
|
|
107
|
+
S = 83,
|
|
108
|
+
T = 84,
|
|
109
|
+
U = 85,
|
|
110
|
+
V = 86,
|
|
111
|
+
W = 87,
|
|
112
|
+
X = 88,
|
|
113
|
+
Y = 89,
|
|
114
|
+
Z = 90,
|
|
115
|
+
|
|
116
|
+
LeftWindowsKey = 91,
|
|
117
|
+
RightWindowsKey = 92,
|
|
118
|
+
|
|
119
|
+
Numpad0 = 96,
|
|
120
|
+
Numpad1 = 97,
|
|
121
|
+
Numpad2 = 98,
|
|
122
|
+
Numpad3 = 99,
|
|
123
|
+
Numpad4 = 100,
|
|
124
|
+
Numpad5 = 101,
|
|
125
|
+
Numpad6 = 102,
|
|
126
|
+
Numpad7 = 103,
|
|
127
|
+
Numpad8 = 104,
|
|
128
|
+
Numpad9 = 105,
|
|
129
|
+
|
|
130
|
+
Multiply = 106,
|
|
131
|
+
Add = 107,
|
|
132
|
+
Subtract = 109,
|
|
133
|
+
DecimalPoint = 110,
|
|
134
|
+
Divide = 111,
|
|
135
|
+
|
|
136
|
+
F1 = 112,
|
|
137
|
+
F2 = 113,
|
|
138
|
+
F3 = 114,
|
|
139
|
+
F4 = 115,
|
|
140
|
+
F5 = 116,
|
|
141
|
+
F6 = 117,
|
|
142
|
+
F7 = 118,
|
|
143
|
+
F8 = 119,
|
|
144
|
+
F9 = 120,
|
|
145
|
+
F10 = 121,
|
|
146
|
+
F11 = 122,
|
|
147
|
+
F12 = 123,
|
|
148
|
+
|
|
149
|
+
NumLock = 144,
|
|
150
|
+
ScrollLock = 145,
|
|
151
|
+
|
|
152
|
+
SemiColon = 186,
|
|
153
|
+
Equals = 187,
|
|
154
|
+
Comma = 188,
|
|
155
|
+
Dash = 189,
|
|
156
|
+
Period = 190,
|
|
157
|
+
ForwardSlash = 191,
|
|
158
|
+
Tilde = 192,
|
|
159
|
+
|
|
160
|
+
OpenBracket = 219,
|
|
161
|
+
ClosedBracket = 221,
|
|
162
|
+
SingleQuote = 222,
|
|
163
|
+
|
|
164
|
+
// Mouse
|
|
165
|
+
MouseLeftButton = -1,
|
|
166
|
+
MouseRightButton = -2,
|
|
167
|
+
MouseCenterButton = -3,
|
|
168
|
+
}
|
|
169
|
+
}
|
package/libs/game/pxt.json
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"spritesay.ts",
|
|
14
14
|
"sprites.ts",
|
|
15
15
|
"sprite.ts",
|
|
16
|
+
"extendableSprite.ts",
|
|
16
17
|
"sprite.d.ts",
|
|
17
18
|
"spritemap.ts",
|
|
18
19
|
"spriteevents.ts",
|
|
@@ -48,7 +49,9 @@
|
|
|
48
49
|
"effects.ts",
|
|
49
50
|
"texteffects.ts",
|
|
50
51
|
"assetTemplates.ts",
|
|
51
|
-
"animation.ts"
|
|
52
|
+
"animation.ts",
|
|
53
|
+
"keymap.cpp",
|
|
54
|
+
"keymap.ts"
|
|
52
55
|
],
|
|
53
56
|
"public": true,
|
|
54
57
|
"dependencies": {
|
package/libs/game/scenes.ts
CHANGED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
namespace pxsim.keymap {
|
|
2
|
+
// Keep in sync with pxt-arcade-sim/api.ts
|
|
3
|
+
export enum Key {
|
|
4
|
+
None = 0,
|
|
5
|
+
|
|
6
|
+
// Player 1
|
|
7
|
+
Left = 1,
|
|
8
|
+
Up = 2,
|
|
9
|
+
Right = 3,
|
|
10
|
+
Down = 4,
|
|
11
|
+
A = 5,
|
|
12
|
+
B = 6,
|
|
13
|
+
|
|
14
|
+
Menu = 7,
|
|
15
|
+
|
|
16
|
+
// Player 2 = Player 1 + 7
|
|
17
|
+
// Player 3 = Player 2 + 7
|
|
18
|
+
// Player 4 = Player 3 + 7
|
|
19
|
+
|
|
20
|
+
// system keys
|
|
21
|
+
Screenshot = -1,
|
|
22
|
+
Gif = -2,
|
|
23
|
+
Reset = -3,
|
|
24
|
+
TogglePause = -4
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function _setPlayerKeys(
|
|
28
|
+
player: number, // player number is 1-based
|
|
29
|
+
up: number,
|
|
30
|
+
down: number,
|
|
31
|
+
left: number,
|
|
32
|
+
right: number,
|
|
33
|
+
A: number,
|
|
34
|
+
B: number
|
|
35
|
+
) {
|
|
36
|
+
getKeymapState().setPlayerKeys(player, up, down, left, right, A, B);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function _setSystemKeys(screenshot: number, gif: number, menu: number, reset: number) {
|
|
40
|
+
getKeymapState().setSystemKeys(screenshot, gif, menu, reset);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
namespace pxsim {
|
|
45
|
+
import Key = pxsim.keymap.Key;
|
|
46
|
+
|
|
47
|
+
export interface KeymapBoard extends EventBusBoard {
|
|
48
|
+
keymapState: KeymapState;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getKeymapState() {
|
|
52
|
+
return (board() as EventBusBoard as KeymapBoard).keymapState;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const reservedKeyCodes = [
|
|
56
|
+
27, // Escape
|
|
57
|
+
9 // Tab
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export class KeymapState {
|
|
61
|
+
keymap: { [keyCode: number]: Key } = {};
|
|
62
|
+
altmap: { [keyCode: number]: Key } = {};
|
|
63
|
+
mappings: { [name: string]: number[] } = {};
|
|
64
|
+
|
|
65
|
+
constructor() {
|
|
66
|
+
// Player 1 keymap
|
|
67
|
+
this.setPlayerKeys(
|
|
68
|
+
1, // Player 1
|
|
69
|
+
87, // W - Up
|
|
70
|
+
83, // D - Down
|
|
71
|
+
65, // A - Left
|
|
72
|
+
83, // S - Right
|
|
73
|
+
32, // Space - A
|
|
74
|
+
13 // Enter - B
|
|
75
|
+
);
|
|
76
|
+
// Player 2 keymap
|
|
77
|
+
this.setPlayerKeys(
|
|
78
|
+
2, // Player 2
|
|
79
|
+
73, // I - Up
|
|
80
|
+
75, // K - Down
|
|
81
|
+
74, // J - Left
|
|
82
|
+
75, // K - Right
|
|
83
|
+
85, // U - A
|
|
84
|
+
79 // O - B
|
|
85
|
+
);
|
|
86
|
+
// Note: Player 3 and 4 have no default keyboard mapping
|
|
87
|
+
|
|
88
|
+
// System keymap
|
|
89
|
+
this.setSystemKeys(
|
|
90
|
+
80, // P - Screenshot
|
|
91
|
+
82, // R - Gif
|
|
92
|
+
0, // Menu - not mapped
|
|
93
|
+
0 // Reset - not mapped
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// Player 1 alternate mapping. This is cleared when the game sets any player keys explicitly
|
|
97
|
+
this.altmap[38] = Key.Up; // UpArrow
|
|
98
|
+
this.altmap[37] = Key.Left; // LeftArrow
|
|
99
|
+
this.altmap[40] = Key.Down; // DownArrow
|
|
100
|
+
this.altmap[39] = Key.Right; // RightArrow
|
|
101
|
+
this.altmap[81] = Key.A; // Q
|
|
102
|
+
this.altmap[90] = Key.A; // Z
|
|
103
|
+
this.altmap[88] = Key.B; // X
|
|
104
|
+
this.altmap[69] = Key.B; // E
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public setPlayerKeys(
|
|
108
|
+
player: number, // player number is 1-based
|
|
109
|
+
up: number,
|
|
110
|
+
down: number,
|
|
111
|
+
left: number,
|
|
112
|
+
right: number,
|
|
113
|
+
A: number,
|
|
114
|
+
B: number
|
|
115
|
+
) {
|
|
116
|
+
// We only support four players
|
|
117
|
+
if (player < 1 || player > 4) return;
|
|
118
|
+
const keyCodes = [up, down, left, right, A, B];
|
|
119
|
+
// Check for reserved key codes
|
|
120
|
+
// TODO: How to surface this runtime error to the user?
|
|
121
|
+
// TODO: Send message to UI: "Keyboard mapping contains a reserved key code"
|
|
122
|
+
const filtered = keyCodes.filter(keyCode => reservedKeyCodes.includes(keyCode));
|
|
123
|
+
if (filtered.length) return;
|
|
124
|
+
// Clear existing mapped keys for player
|
|
125
|
+
const mapName = `player-${player}`;
|
|
126
|
+
this.clearMap(mapName);
|
|
127
|
+
// Clear altmap When explicitly setting the player keys
|
|
128
|
+
this.altmap = {};
|
|
129
|
+
// Map the new keys
|
|
130
|
+
const offset = (player - 1) * 7; // +7 for player 2's keys
|
|
131
|
+
this.keymap[up] = Key.Up + offset;
|
|
132
|
+
this.keymap[down] = Key.Down + offset;
|
|
133
|
+
this.keymap[left] = Key.Left + offset;
|
|
134
|
+
this.keymap[right] = Key.Right + offset;
|
|
135
|
+
this.keymap[A] = Key.A + offset;
|
|
136
|
+
this.keymap[B] = Key.B + offset;
|
|
137
|
+
// Remember this mapping
|
|
138
|
+
this.saveMap(mapName, keyCodes);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public setSystemKeys(screenshot: number, gif: number, menu: number, reset: number) {
|
|
142
|
+
const mapName = "system";
|
|
143
|
+
// Clear existing mapped keys for system
|
|
144
|
+
this.clearMap(mapName);
|
|
145
|
+
this.keymap[screenshot] = Key.Screenshot;
|
|
146
|
+
this.keymap[gif] = Key.Gif;
|
|
147
|
+
this.keymap[menu] = Key.Menu;
|
|
148
|
+
this.keymap[reset] = Key.Reset;
|
|
149
|
+
// Remember this mapping
|
|
150
|
+
this.saveMap(mapName, [screenshot, gif, menu, reset]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public getKey(keyCode: number): Key {
|
|
154
|
+
return keyCode ? this.keymap[keyCode] || this.altmap[keyCode] || Key.None : Key.None;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private saveMap(name: string, keyCodes: number[]) {
|
|
158
|
+
this.mappings[name] = keyCodes;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private clearMap(name: string) {
|
|
162
|
+
const keyCodes = this.mappings[name];
|
|
163
|
+
keyCodes?.forEach(keyCode => delete this.keymap[keyCode]);
|
|
164
|
+
delete this.mappings[name];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
package/libs/game/sprite.ts
CHANGED
|
@@ -394,7 +394,7 @@ class Sprite extends sprites.BaseSprite {
|
|
|
394
394
|
return !(this.flags & SpriteFlag.Invisible);
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
|
|
397
|
+
protected recalcSize(): void {
|
|
398
398
|
this._width = Fx8(this._image.width * this.sx);
|
|
399
399
|
this._height = Fx8(this._image.height * this.sy);
|
|
400
400
|
this.resetHitbox();
|
|
@@ -645,21 +645,7 @@ class Sprite extends sprites.BaseSprite {
|
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
__drawCore(camera: scene.Camera) {
|
|
648
|
-
|
|
649
|
-
if (this.sayEndTime !== undefined) {
|
|
650
|
-
if (control.millis() < this.sayEndTime) {
|
|
651
|
-
this.sayRenderer.draw(screen, camera, this);
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
this.sayRenderer.destroy();
|
|
655
|
-
this.sayRenderer = undefined;
|
|
656
|
-
this.sayEndTime = undefined;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
this.sayRenderer.draw(screen, camera, this)
|
|
661
|
-
}
|
|
662
|
-
}
|
|
648
|
+
this.drawSay(camera);
|
|
663
649
|
|
|
664
650
|
if (this.isOutOfScreen(camera)) return;
|
|
665
651
|
|
|
@@ -669,47 +655,8 @@ class Sprite extends sprites.BaseSprite {
|
|
|
669
655
|
const l = Math.floor(this.left - ox);
|
|
670
656
|
const t = Math.floor(this.top - oy);
|
|
671
657
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
else
|
|
675
|
-
screen.blit(
|
|
676
|
-
// dst rect in screen
|
|
677
|
-
l, t,
|
|
678
|
-
this.width,
|
|
679
|
-
this.height,
|
|
680
|
-
// src rect in sprite image
|
|
681
|
-
this._image,
|
|
682
|
-
0, 0,
|
|
683
|
-
this._image.width, this._image.height,
|
|
684
|
-
true, false);
|
|
685
|
-
|
|
686
|
-
if (this.flags & SpriteFlag.ShowPhysics) {
|
|
687
|
-
const font = image.font5;
|
|
688
|
-
const margin = 2;
|
|
689
|
-
let tx = l;
|
|
690
|
-
let ty = t + this.height + margin;
|
|
691
|
-
screen.print(`${this.x >> 0},${this.y >> 0}`, tx, ty, 1, font);
|
|
692
|
-
tx -= font.charWidth;
|
|
693
|
-
if (this.vx || this.vy) {
|
|
694
|
-
ty += font.charHeight + margin;
|
|
695
|
-
screen.print(`v${this.vx >> 0},${this.vy >> 0}`, tx, ty, 1, font);
|
|
696
|
-
}
|
|
697
|
-
if (this.ax || this.ay) {
|
|
698
|
-
ty += font.charHeight + margin;
|
|
699
|
-
screen.print(`a${this.ax >> 0},${this.ay >> 0}`, tx, ty, 1, font);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// debug info
|
|
704
|
-
if (game.debug) {
|
|
705
|
-
screen.drawRect(
|
|
706
|
-
Fx.toInt(this._hitbox.left) - ox,
|
|
707
|
-
Fx.toInt(this._hitbox.top) - oy,
|
|
708
|
-
Fx.toInt(this._hitbox.width),
|
|
709
|
-
Fx.toInt(this._hitbox.height),
|
|
710
|
-
1
|
|
711
|
-
);
|
|
712
|
-
}
|
|
658
|
+
this.drawSprite(l, t);
|
|
659
|
+
this.drawDebug(l, t, ox, oy);
|
|
713
660
|
}
|
|
714
661
|
|
|
715
662
|
__update(camera: scene.Camera, dt: number) {
|
|
@@ -1170,4 +1117,68 @@ class Sprite extends sprites.BaseSprite {
|
|
|
1170
1117
|
toString() {
|
|
1171
1118
|
return `${this.id}(${this.x},${this.y})->(${this.vx},${this.vy})`;
|
|
1172
1119
|
}
|
|
1120
|
+
|
|
1121
|
+
protected drawSay(camera: scene.Camera) {
|
|
1122
|
+
if (this.sayRenderer) {
|
|
1123
|
+
if (this.sayEndTime !== undefined) {
|
|
1124
|
+
if (control.millis() < this.sayEndTime) {
|
|
1125
|
+
this.sayRenderer.draw(screen, camera, this);
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
this.sayRenderer.destroy();
|
|
1129
|
+
this.sayRenderer = undefined;
|
|
1130
|
+
this.sayEndTime = undefined;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
this.sayRenderer.draw(screen, camera, this)
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
protected drawDebug(left: number, top: number, offsetX: number, offsetY: number) {
|
|
1140
|
+
if (this.flags & SpriteFlag.ShowPhysics) {
|
|
1141
|
+
const font = image.font5;
|
|
1142
|
+
const margin = 2;
|
|
1143
|
+
let tx = left;
|
|
1144
|
+
let ty = top + this.height + margin;
|
|
1145
|
+
screen.print(`${this.x >> 0},${this.y >> 0}`, tx, ty, 1, font);
|
|
1146
|
+
tx -= font.charWidth;
|
|
1147
|
+
if (this.vx || this.vy) {
|
|
1148
|
+
ty += font.charHeight + margin;
|
|
1149
|
+
screen.print(`v${this.vx >> 0},${this.vy >> 0}`, tx, ty, 1, font);
|
|
1150
|
+
}
|
|
1151
|
+
if (this.ax || this.ay) {
|
|
1152
|
+
ty += font.charHeight + margin;
|
|
1153
|
+
screen.print(`a${this.ax >> 0},${this.ay >> 0}`, tx, ty, 1, font);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// debug info
|
|
1158
|
+
if (game.debug) {
|
|
1159
|
+
screen.drawRect(
|
|
1160
|
+
Fx.toInt(this._hitbox.left) - offsetX,
|
|
1161
|
+
Fx.toInt(this._hitbox.top) - offsetY,
|
|
1162
|
+
Fx.toInt(this._hitbox.width),
|
|
1163
|
+
Fx.toInt(this._hitbox.height),
|
|
1164
|
+
1
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
protected drawSprite(drawLeft: number, drawTop: number) {
|
|
1170
|
+
if (!this.isScaled())
|
|
1171
|
+
screen.drawTransparentImage(this._image, drawLeft, drawTop);
|
|
1172
|
+
else
|
|
1173
|
+
screen.blit(
|
|
1174
|
+
// dst rect in screen
|
|
1175
|
+
drawLeft, drawTop,
|
|
1176
|
+
this.width,
|
|
1177
|
+
this.height,
|
|
1178
|
+
// src rect in sprite image
|
|
1179
|
+
this._image,
|
|
1180
|
+
0, 0,
|
|
1181
|
+
this._image.width, this._image.height,
|
|
1182
|
+
true, false);
|
|
1183
|
+
}
|
|
1173
1184
|
}
|
package/libs/game/tilemap.ts
CHANGED
|
@@ -357,16 +357,17 @@ namespace tiles {
|
|
|
357
357
|
const previous = this._map;
|
|
358
358
|
|
|
359
359
|
if (this.handlerState && previous !== map && previous) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
eventHandler.callback(previous);
|
|
364
|
-
}
|
|
360
|
+
for (const eventHandler of this.handlerState) {
|
|
361
|
+
if (eventHandler.event === TileMapEvent.Unloaded) {
|
|
362
|
+
eventHandler.callback(previous);
|
|
365
363
|
}
|
|
366
364
|
}
|
|
367
365
|
}
|
|
368
366
|
|
|
369
367
|
this._map = map;
|
|
368
|
+
if (map) {
|
|
369
|
+
this._scale = map.scale;
|
|
370
|
+
}
|
|
370
371
|
|
|
371
372
|
if (this.handlerState && previous !== map && map) {
|
|
372
373
|
for (const eventHandler of this.handlerState) {
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P48209(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___48452 = (undefined);
|
|
70
|
+
globals._pollEventQueue___48465 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P48209.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P48209.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P48209_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P48209, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P48928_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P48209
|
|
92
92
|
})
|