Skip to content

Commit a65f67f

Browse files
get rid of cp hack file since there's only kaplay game on the page
1 parent 140992c commit a65f67f

File tree

5 files changed

+152
-131
lines changed

5 files changed

+152
-131
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
build: clean
44
./build.py
55
cp blogtheme.css docs/blogtheme.css
6-
cp kdemo.html docs/2024/boy-have-i-been/kdemo.html
76
# that was a KLUDGE!! why
87

98
clean:

docs/2024/boy-have-i-been/index.html

Lines changed: 76 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2024/boy-have-i-been/kdemo.html

Lines changed: 0 additions & 64 deletions
This file was deleted.

kdemo.html

Lines changed: 0 additions & 64 deletions
This file was deleted.

markdown/0059_boy_have_i_been.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ I quickly decided it was going to (a) be a platformer game and (b) be playable i
2424
Digging through old git commit history, here's the very first test I ever made using KAPLAY. It is date-stamped July 19.
2525

2626
%%% figure
27-
<iframe src="kdemo.html" height="125" width="450" style="margin-left:auto;margin-right:auto"></iframe>
27+
<canvas id="a" height="125" width="450" style="margin-left:auto;margin-right:auto"></canvas>
2828

2929
%: You can click on the canvas and use the <kbd>&larr;</kbd> and <kbd>&rarr;</kbd> arrow keys to move the red rectangle (the player) and the <kbd>&uarr;</kbd> key to jump. There's not much to do, but hey... it works!
3030

@@ -63,3 +63,78 @@ I turned him down, mostly because I knew that I should be prioritizing my studie
6363
I'd say it's been a productive 3 months.
6464

6565
<!-- cSpell: ignore kaplay -->
66+
<!-- markdownlint-disable no-reversed-links -->
67+
68+
<script async type="module">
69+
import kaboom from "https://unpkg.com/kaplay@3001.0.0-alpha.18/dist/kaboom.mjs";
70+
const canvas = document.getElementById("a");
71+
// Hack to make focus() not get called, since the focus
72+
// option doesn't seem to work.
73+
Object.defineProperty(canvas, "focus", {
74+
value() {
75+
console.log("skipping focusing canvas:", this);
76+
}
77+
});
78+
const k = kaboom({
79+
crisp: true,
80+
background: "#000000",
81+
focus: false,
82+
canvas,
83+
global: false
84+
});
85+
k.setGravity(300);
86+
const level = k.addLevel([
87+
"==========================",
88+
"= =",
89+
"= =",
90+
"= ===== =",
91+
"= @ =",
92+
"= ^^ ============",
93+
"=============== "
94+
], {
95+
tileWidth: 16,
96+
tileHeight: 16,
97+
pos: k.vec2(20, 20),
98+
tiles: {
99+
"@": () => [
100+
k.rect(15, 31),
101+
k.area(),
102+
k.body({ jumpForce: 150, maxVelocity: 400 }),
103+
k.anchor("bot"),
104+
k.color("#ff0000"),
105+
k.z(Infinity),
106+
"player"
107+
],
108+
"^": () => [
109+
k.rect(16, 16),
110+
k.area(),
111+
k.anchor("bot"),
112+
k.color("#ffff00"),
113+
"coin"
114+
],
115+
"=": () => [
116+
k.rect(16, 16),
117+
k.area(),
118+
k.body({ isStatic: true }),
119+
k.anchor("bot"),
120+
k.color("#0000ff"),
121+
"ground"
122+
],
123+
}
124+
});
125+
const player = level.get("player")[0];
126+
// ?!? hacky ?!?
127+
player.vel = k.vec2(0, -100);
128+
k.onKeyDown("up", () => {
129+
if (player.isGrounded()) {
130+
player.jump();
131+
}
132+
});
133+
const SPEED = 64;
134+
k.onKeyDown("left", () => {
135+
player.move(-SPEED, 0);
136+
});
137+
k.onKeyDown("right", () => {
138+
player.move(SPEED, 0);
139+
});
140+
</script>

0 commit comments

Comments
 (0)