This commit is contained in:
Andrea Bianchi
2025-04-17 16:04:18 +09:00
commit f31906224a
11 changed files with 1892 additions and 0 deletions

30
src/App.svelte Normal file
View File

@@ -0,0 +1,30 @@
<script>
import { onMount } from 'svelte';
let id; // the div in the HTML
let sprite;
const sketch = (p5) => {
p5.setup = async () => {
p5.createCanvas(400, 300);
sprite = new p5.Sprite();
sprite.img = '/assets/monster.png';
sprite.diameter = 100;
sprite.scale = 0.5;
};
p5.draw = () => {
p5.clear();
p5.fill(100);
p5.ellipse(p5.mouseX, p5.mouseY, 20, 20);
sprite.debug = p5.mouse.pressing();
};
};
// On startup
onMount(function () {
let myp5 = new p5(sketch, id);
});
</script>
<div {id} />

8
src/main.js Normal file
View File

@@ -0,0 +1,8 @@
import App from './App.svelte';
const app = new App({
target: document.body,
props: {},
});
export default app;