like2d 2.5.0 → 2.5.1

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.
Files changed (2) hide show
  1. package/README.md +23 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -43,26 +43,28 @@ pnpm add like2d
43
43
  Ideal for small games, jams, or prototyping.
44
44
 
45
45
  ```typescript
46
- import { love, graphics, input } from 'like2d/callback';
46
+ import { createLike } from 'like2d/callback';
47
47
 
48
- love.load = () => {
49
- love.setMode({ pixelResolution: [800, 600] });
50
- input.map('jump', ['Space', 'ButtonBottom']);
48
+ const like = createLike(document.body);
49
+
50
+ like.load = () => {
51
+ like.setMode({ pixelResolution: [800, 600] });
52
+ like.input.map('jump', ['Space', 'ButtonBottom']);
51
53
  };
52
54
 
53
- love.update = (dt) => {
54
- if (input.justPressed('jump')) {
55
+ like.update = (dt) => {
56
+ if (like.input.justPressed('jump')) {
55
57
  console.log('Jump!');
56
58
  }
57
59
  };
58
60
 
59
- love.draw = () => {
60
- graphics.clear([0.1, 0.1, 0.1, 1]);
61
- graphics.circle('fill', 'dodgerblue', [400, 300], 50);
62
- graphics.print('white', 'Hello Like2D!', [20, 20]);
61
+ like.draw = () => {
62
+ like.gfx.clear([0.1, 0.1, 0.1, 1]);
63
+ like.gfx.circle('fill', 'dodgerblue', [400, 300], 50);
64
+ like.gfx.print('white', 'Hello Like2D!', [20, 20]);
63
65
  };
64
66
 
65
- love.init(document.body);
67
+ await like.start();
66
68
  ```
67
69
 
68
70
  ### Scene Pattern (Class-based)
@@ -70,19 +72,21 @@ love.init(document.body);
70
72
  Ideal for larger projects with menus, levels, and explicit state management.
71
73
 
72
74
  ```typescript
73
- import { SceneRunner, type Scene, Vec2 } from 'like2d/scene';
75
+ import { SceneRunner, type Scene } from 'like2d/scene';
76
+ import type { Like } from 'like2d';
74
77
 
75
78
  class MyScene implements Scene {
76
- load() {
79
+ load(like: Like) {
77
80
  console.log('Scene loaded!');
78
81
  }
79
82
 
80
- update(dt: number) {
83
+ update(like: Like, dt: number) {
81
84
  // update logic
82
85
  }
83
86
 
84
- draw(canvas: HTMLCanvasElement) {
85
- // draw logic
87
+ draw(like: Like) {
88
+ like.gfx.clear([0.1, 0.1, 0.1, 1]);
89
+ like.gfx.print('white', 'Hello Like2D!', [20, 20]);
86
90
  }
87
91
  }
88
92
 
@@ -95,9 +99,9 @@ await runner.start(new MyScene());
95
99
  Pick your pattern, import what you need:
96
100
 
97
101
  ```typescript
98
- import { love, graphics, input } from 'like2d/callback'; // Love2D-style
99
- import { SceneRunner, type Scene } from 'like2d/scene'; // Class-based scenes
100
- import { Vec2, Rect } from 'like2d/math'; // Pure math functions
102
+ import { createLike } from 'like2d/callback'; // Love2D-style
103
+ import { SceneRunner, type Scene } from 'like2d/scene'; // Class-based scenes
104
+ import { Vec2, Rect, type Like } from 'like2d'; // Core types and math
101
105
  ```
102
106
 
103
107
  See the [PHILOSOPHY.md](../../docs/PHILOSOPHY.md) for the principles behind the design.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "like2d",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "A web-native game framework inspired by Love2D",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",