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.
- package/README.md +23 -19
- 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 {
|
|
46
|
+
import { createLike } from 'like2d/callback';
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
85
|
-
|
|
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 {
|
|
99
|
-
import { SceneRunner, type Scene } from 'like2d/scene';
|
|
100
|
-
import { Vec2, Rect } from 'like2d
|
|
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.
|