Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ages into imageCache
tballmsft committed Dec 5, 2024
2 parents 3a65e62 + 7deed7d commit b01875a
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 0 additions & 1 deletion libs/base/sim/control.ts
Original file line number Diff line number Diff line change
@@ -48,7 +48,6 @@ namespace pxsim.control {
type: "simulator",
command: "single"
})
const cb = getResume();
}
export function waitMicros(micros: number) {
thread.pause(micros / 1000); // it prempts not much we can do here.
31 changes: 19 additions & 12 deletions libs/multiplayer/player.ts
Original file line number Diff line number Diff line change
@@ -49,12 +49,17 @@ namespace mp {
}
}

class StateEntry {
constructor(public key: number, public value: number) {
}
}

/**
* A player in the game
*/
export class Player {
_sprite: Sprite;
_state: number[];
_state: StateEntry[];
_index: number;
_data: any;
_mwb: boolean;
@@ -153,20 +158,11 @@ namespace mp {
}

_setState(key: number, val: number) {
this._ensureState(key);
if (this._state.length > key)
this._state[key] = val;
this._lookupOrCreateState(key).value = val;
}

_getState(key: number): number {
this._ensureState(key);
return (this._state.length > key) ? this._state[key] : 0;
}

_ensureState(key: number) {
if (!this._state) this._state = [];
if (key < 0 || key > 255) return;
while (this._state.length < key) this._state.push(0);
return this._lookupOrCreateState(key).value;
}

_getInfo(): info.PlayerInfo {
@@ -188,6 +184,17 @@ namespace mp {
}
return undefined;
}

_lookupOrCreateState(key: number) {
if (!this._state) this._state = [];
for (const entry of this._state) {
if (entry.key === key) return entry;
}

const newEntry = new StateEntry(key, 0);
this._state.push(newEntry);
return newEntry;
}
}

class MPState {
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pxt-common-packages",
"version": "12.1.1",
"version": "12.2.1",
"description": "Microsoft MakeCode (PXT) common packages",
"keywords": [
"MakeCode",
@@ -24,7 +24,7 @@
"libs/**/*"
],
"dependencies": {
"pxt-core": "10.2.3"
"pxt-core": "11.2.24"
},
"devDependencies": {
"typescript": "^4.2.3"

0 comments on commit b01875a

Please sign in to comment.