-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.html
More file actions
55 lines (50 loc) · 1.49 KB
/
Example.html
File metadata and controls
55 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Choppy2D v2.0 + OpenFL Demo</title>
<!-- 1. OpenFL Library via CDN -->
<script src="https://cdn.jsdelivr.net/npm/openfl@9.5.0/dist/openfl.min.js"></script>
<!-- 2. Your Engine (choppy.js) -->
<script src="choppy.js"></script>
<style>
body { margin: 0; overflow: hidden; background: #111; }
canvas { display: block; margin: 0 auto; }
</style>
</head>
<body>
<script>
// --- OPENFL SETUP ---
const stage = new openfl.display.Stage(800, 600, 0xFFFFFF);
document.body.appendChild(stage.element);
// --- CHOPPY 2.0 LOGIC ---
const engine = new Choppy();
// Player Layer
engine.addLayer(
function(self) {
if (this.sprite.x > 800) {
this.sprite.x = -50;
} else {
this.sprite.x += 200 * deltaTime;
}
this.sprite.rotation += 2;
},
"Player",
function(self) {
this.sprite = new openfl.display.Sprite();
this.sprite.graphics.beginFill(0x22AABB);
this.sprite.graphics.drawRect(-25, -25, 50, 50);
this.sprite.x = 100;
this.sprite.y = 300;
stage.addChild(this.sprite);
},
function(self) {
stage.removeChild(this.sprite);
}
);
// Run Engine
engine.play();
</script>
</body>
</html>