-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
4,575 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "dungeon-generator", | ||
"type": "module", | ||
"scripts": { | ||
"start": "parcel serve ./src/index.html", | ||
"build": "parcel build ./src/index.html --dist-dir ./publish --public-url ./" | ||
}, | ||
"author": "tenpaMk2", | ||
"license": "MIT", | ||
"dependencies": { | ||
"excalibur": "^0.27.0" | ||
}, | ||
"devDependencies": { | ||
"parcel": "^2.6.2", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const gameWidth = 1080 / 2; | ||
const gameHeight = 1920 / 2; | ||
|
||
export default { | ||
gameWidth: gameWidth, | ||
gameHeight: gameHeight, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "*.png"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<script defer type="module" src="./index.ts"></script> | ||
<title>Example</title> | ||
</head> | ||
<body> | ||
<canvas id="game"></canvas> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DisplayMode, Engine, Loader } from "excalibur"; | ||
import config from "./config"; | ||
import { Resources } from "./resource"; | ||
import { GameScene } from "./scenes/game-scene"; | ||
|
||
const engine = new Engine({ | ||
width: config.gameWidth, | ||
height: config.gameHeight, | ||
canvasElementId: "game", | ||
displayMode: DisplayMode.FitScreen, | ||
}); | ||
|
||
engine.showDebug(false); | ||
|
||
engine.add("game-scene", new GameScene()); | ||
engine.goToScene("game-scene"); | ||
|
||
const loader = new Loader(); | ||
for (const resource of Object.values(Resources)) { | ||
loader.addResource(resource); | ||
} | ||
|
||
loader.suppressPlayButton = true; | ||
|
||
engine.start(loader); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ImageSource } from "excalibur"; | ||
|
||
import heart from "./assets/heart.png"; | ||
|
||
export const Resources = { | ||
heart: new ImageSource(heart), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Color, Engine, Scene, Text, TileMap, Vector } from "excalibur"; | ||
import { PointerEvent } from "excalibur/build/dist/Input/PointerEvent"; | ||
|
||
export class GameScene extends Scene { | ||
private tilemap!: TileMap; | ||
|
||
onInitialize(engine: Engine): void { | ||
this.tilemap = new TileMap({ | ||
pos: Vector.Zero, | ||
rows: 24, | ||
columns: 16, | ||
tileWidth: 32, | ||
tileHeight: 32, | ||
}); | ||
engine.add(this.tilemap); | ||
|
||
this.tilemap.tiles.forEach((tile) => { | ||
tile.data.set("id", 0); | ||
}); | ||
|
||
engine.input.pointers.primary.on("down", (event: PointerEvent): void => { | ||
this.tilemap.tiles.forEach((tile) => { | ||
const id = tile.data.get("id")!; | ||
tile.data.set("id", id + 1); | ||
}); | ||
|
||
this.updateTilemap(); | ||
}); | ||
} | ||
|
||
updateTilemap(): void { | ||
this.tilemap.tiles.forEach((tile) => { | ||
const id = tile.data.get("id")!; | ||
|
||
const text = new Text({ | ||
text: `${id}`, | ||
color: Color.White, | ||
}); | ||
tile.clearGraphics(); | ||
tile.addGraphic(text); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
canvas { | ||
-webkit-touch-callout: none !important; | ||
-webkit-user-select: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"module": "ES6", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true | ||
} | ||
} |