@thewhateverapp/tile-sdk 0.14.4 → 0.14.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.
@@ -1 +1 @@
1
- {"version":3,"file":"SceneRenderer.d.ts","sourceRoot":"","sources":["../../src/scene/SceneRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAU,MAAM,2BAA2B,CAAC;AAmDrE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EAAE,SAAS,EACf,OAAO,EACP,MAAc,EACd,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,WAAW,EACnB,KAAa,GACd,EAAE,kBAAkB,qBA0CpB;AAuOD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"SceneRenderer.d.ts","sourceRoot":"","sources":["../../src/scene/SceneRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAE,WAAW,EAAU,MAAM,2BAA2B,CAAC;AAqDrE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EAAE,SAAS,EACf,OAAO,EACP,MAAc,EACd,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,WAAW,EACnB,KAAa,GACd,EAAE,kBAAkB,qBA0CpB;AAiPD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React, { useEffect, useRef, useCallback, useMemo, useState } from 'react';
3
+ import Matter from 'matter-js';
3
4
  import { compileScene } from '@thewhateverapp/scene-sdk';
4
5
  import { PixiGame, useGameLoop, Container } from '../pixi/index.js';
5
6
  import { SceneContext, createEntityState, createPlayerState, createCameraState, createInputState, createTimelineState, } from './SceneContext.js';
@@ -10,6 +11,7 @@ import { useComponentRunner } from './components/ComponentRunner.js';
10
11
  import { useTimelineExecutor } from './timeline/TimelineExecutor.js';
11
12
  import { useCameraController } from './camera/CameraController.js';
12
13
  import { TILE_WIDTH, TILE_HEIGHT } from '../react/PixiGame.js';
14
+ const { Body } = Matter;
13
15
  /**
14
16
  * Hook to track container size using ResizeObserver
15
17
  */
@@ -132,16 +134,24 @@ function SceneContent({ spec, onEvent, paused, width, height, debug, }) {
132
134
  // Find player entity and reset position
133
135
  for (const [, state] of entitiesRef.current) {
134
136
  if (state.entity.tags?.includes('player')) {
135
- state.x = player.checkpointX || 128;
136
- state.y = player.checkpointY || (height - 100);
137
+ const respawnX = player.checkpointX ?? state.entity.transform.x;
138
+ const respawnY = player.checkpointY ?? state.entity.transform.y;
139
+ state.x = respawnX;
140
+ state.y = respawnY;
137
141
  state.velocityX = 0;
138
142
  state.velocityY = 0;
139
143
  state.rotation = 0;
144
+ // Update physics body if it exists
145
+ if (state.body) {
146
+ Body.setPosition(state.body, { x: respawnX, y: respawnY });
147
+ Body.setVelocity(state.body, { x: 0, y: 0 });
148
+ Body.setAngle(state.body, 0);
149
+ }
140
150
  break;
141
151
  }
142
152
  }
143
153
  emitEvent('player.respawn', { x: player.checkpointX, y: player.checkpointY });
144
- }, [height, emitEvent]);
154
+ }, [emitEvent]);
145
155
  // Build context value
146
156
  const contextValue = useMemo(() => ({
147
157
  spec,
@@ -137,8 +137,8 @@ export function usePhysicsEngine(context, width, height) {
137
137
  // Simple ground check - if velocity.y is very small and we're not in the air
138
138
  playerState.grounded = Math.abs(body.velocity.y) < 0.5;
139
139
  }
140
- // Check for death (fell off screen)
141
- if (playerEntity && playerEntity.y > height + 100) {
140
+ // Check for death (fell off screen) - only if height is valid
141
+ if (playerEntity && height > 0 && playerEntity.y > height + 200) {
142
142
  if (!playerState.dead) {
143
143
  playerState.dead = true;
144
144
  playerState.deaths++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thewhateverapp/tile-sdk",
3
- "version": "0.14.4",
3
+ "version": "0.14.5",
4
4
  "description": "SDK for building interactive tiles on The Whatever App platform",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",