initial commit

This commit is contained in:
2026-05-15 18:12:55 +02:00
commit 0e06d5eefa
11 changed files with 1271 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
{
"permissions": {
"allow": [
"Bash(curl -sI https://cdn.jsdelivr.net/npm/melonjs@17.4.0/dist/melonjs.mjs)",
"Bash(curl -s https://data.jsdelivr.com/v1/package/npm/melonjs@17.4.0/flat)",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); [print\\(f['name']\\) for f in d['files'] if 'dist' in f['name']]\")",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); [print\\(f['name']\\) for f in d['files'] if 'index' in f['name'].lower\\(\\) or f['name'].count\\('/'\\) <= 2]\")",
"WebFetch(domain:melonjs.github.io)",
"WebFetch(domain:github.com)",
"Bash(gh api *)",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); [print\\(f['name'], f['type']\\) for f in d]\")",
"Bash(gh auth *)",
"Bash(python3 -c \"import sys, json; [print\\(f['name']\\) for f in json.load\\(sys.stdin\\)]\")",
"Bash(python3 -c \"import sys, json, base64; print\\(base64.b64decode\\(json.load\\(sys.stdin\\)['content']\\).decode\\(\\)\\)\")",
"Bash(curl -sI \"https://cdn.jsdelivr.net/npm/melonjs@17.4.0/dist/melonjs.module.js\")",
"Bash(curl -s \"https://cdn.jsdelivr.net/npm/melonjs@17.4.0/dist/melonjs.module.js\")",
"Bash(curl *)",
"Bash(python3 -c \"import sys, json; [print\\(t['name']\\) for t in json.load\\(sys.stdin\\)]\")",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); [print\\(f['name']\\) for f in d['files'] if 'dist' in f['name'] and f['name'].count\\('/'\\) <= 3]\")",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); print\\(json.dumps\\(d, indent=2\\)[:1000]\\)\")",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); [print\\(f['name']\\) for f in d['files'] if f['name'].endswith\\('.js'\\) and f['name'].count\\('/'\\) <= 3]\")",
"Bash(python3 -c \"import sys, json; d=json.load\\(sys.stdin\\); print\\('main:', d.get\\('main'\\)\\); print\\('module:', d.get\\('module'\\)\\); print\\('exports:', json.dumps\\(d.get\\('exports'\\), indent=2\\)[:500]\\)\")",
"Bash(python3 *)"
]
}
}

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
dist
.DS_Store
*.local
.claude

26
index.html Normal file
View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pixel Path Clone</title>
<style>
body {
margin: 0;
padding: 0;
background: #000;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
#screen canvas {
display: block;
}
</style>
</head>
<body>
<div id="screen"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

1020
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "pixel-path-clone",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"phaser": "^3.80.1"
},
"devDependencies": {
"typescript": "^5.4.0",
"vite": "^5.2.0"
}
}

15
src/entities/Exit.ts Normal file
View File

@@ -0,0 +1,15 @@
import Phaser from "phaser";
export class Exit extends Phaser.GameObjects.Rectangle {
static readonly WIDTH = 40;
static readonly HEIGHT = 80;
static readonly COLOR = 0xffd700;
declare body: Phaser.Physics.Arcade.StaticBody;
constructor(scene: Phaser.Scene, x: number, groundY: number) {
super(scene, x, groundY - Exit.HEIGHT / 2, Exit.WIDTH, Exit.HEIGHT, Exit.COLOR);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}
}

13
src/entities/Platform.ts Normal file
View File

@@ -0,0 +1,13 @@
import Phaser from "phaser";
export class Platform extends Phaser.GameObjects.Rectangle {
static readonly COLOR = 0x4a7c3a;
declare body: Phaser.Physics.Arcade.StaticBody;
constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number) {
super(scene, x, y, width, height, Platform.COLOR);
scene.add.existing(this);
scene.physics.add.existing(this, true);
}
}

56
src/entities/Player.ts Normal file
View File

@@ -0,0 +1,56 @@
import Phaser from "phaser";
export class Player extends Phaser.GameObjects.Rectangle {
static readonly SIZE = 32;
static readonly COLOR = 0xff4444;
static readonly MOVE_SPEED = 250;
static readonly JUMP_VELOCITY = 600;
declare body: Phaser.Physics.Arcade.Body;
private cursors: Phaser.Types.Input.Keyboard.CursorKeys;
private keyA: Phaser.Input.Keyboard.Key;
private keyD: Phaser.Input.Keyboard.Key;
private keyW: Phaser.Input.Keyboard.Key;
private keySpace: Phaser.Input.Keyboard.Key;
constructor(scene: Phaser.Scene, x: number, y: number) {
super(scene, x, y, Player.SIZE, Player.SIZE, Player.COLOR);
scene.add.existing(this);
scene.physics.add.existing(this);
this.body.setCollideWorldBounds(true);
const kb = scene.input.keyboard!;
this.cursors = kb.createCursorKeys();
this.keyA = kb.addKey("A");
this.keyD = kb.addKey("D");
this.keyW = kb.addKey("W");
this.keySpace = kb.addKey("SPACE");
}
override update(): void {
const left = this.cursors.left.isDown || this.keyA.isDown;
const right = this.cursors.right.isDown || this.keyD.isDown;
const jumpPressed =
Phaser.Input.Keyboard.JustDown(this.cursors.up) ||
Phaser.Input.Keyboard.JustDown(this.keyW) ||
Phaser.Input.Keyboard.JustDown(this.keySpace);
if (left) {
this.body.setVelocityX(-Player.MOVE_SPEED);
} else if (right) {
this.body.setVelocityX(Player.MOVE_SPEED);
} else {
this.body.setVelocityX(0);
}
if (jumpPressed && this.body.touching.down) {
this.body.setVelocityY(-Player.JUMP_VELOCITY);
}
}
freeze(): void {
this.body.setVelocity(0, 0);
this.body.moves = false;
}
}

22
src/main.ts Normal file
View File

@@ -0,0 +1,22 @@
import Phaser from "phaser";
import { GameScene } from "./scenes/GameScene";
const GAME_WIDTH = 800;
const GAME_HEIGHT = 600;
const GRAVITY = 1500;
new Phaser.Game({
type: Phaser.AUTO,
width: GAME_WIDTH,
height: GAME_HEIGHT,
backgroundColor: "#1a1a2e",
parent: "screen",
physics: {
default: "arcade",
arcade: {
gravity: { x: 0, y: GRAVITY },
debug: false,
},
},
scene: [GameScene],
});

55
src/scenes/GameScene.ts Normal file
View File

@@ -0,0 +1,55 @@
import Phaser from "phaser";
import { Player } from "../entities/Player";
import { Exit } from "../entities/Exit";
import { Platform } from "../entities/Platform";
export class GameScene extends Phaser.Scene {
private static readonly FLOOR_TOP = 500;
private static readonly FLOOR_HEIGHT = 100;
private player!: Player;
private exit!: Exit;
private platform!: Platform;
private levelCompleteText!: Phaser.GameObjects.Text;
private levelCompleted = false;
constructor() {
super({ key: "GameScene" });
}
create(): void {
const width = this.scale.width;
const height = this.scale.height;
const floorTop = GameScene.FLOOR_TOP;
const floorH = GameScene.FLOOR_HEIGHT;
this.platform = new Platform(this, width / 2, floorTop + floorH / 2, width, floorH);
this.exit = new Exit(this, 60, floorTop);
this.player = new Player(this, width - Player.SIZE - 40, floorTop - Player.SIZE / 2);
this.physics.add.collider(this.player, this.platform);
this.physics.add.overlap(this.player, this.exit, () => this.completeLevel());
this.levelCompleteText = this.add
.text(width / 2, height / 2, "LEVEL COMPLETED!", {
fontFamily: "Arial",
fontSize: "48px",
color: "#ffffff",
fontStyle: "bold",
})
.setOrigin(0.5)
.setVisible(false);
}
override update(): void {
if (this.levelCompleted) return;
this.player.update();
}
private completeLevel(): void {
if (this.levelCompleted) return;
this.levelCompleted = true;
this.player.freeze();
this.levelCompleteText.setVisible(true);
}
}

15
tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"]
},
"include": ["src"]
}