Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
09ee33a751 | |||
ee9fb1955c |
3
cat-town/.gitignore
vendored
Normal file
3
cat-town/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/node_modules/
|
||||||
|
/src/*.js
|
||||||
|
/dist/
|
4838
cat-town/package-lock.json
generated
Normal file
4838
cat-town/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
cat-town/package.json
Normal file
30
cat-town/package.json
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"name": "cat-town",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"webpack": "webpack",
|
||||||
|
"dev": "webpack serve --config webpack.development.js",
|
||||||
|
"start": "npm run dev",
|
||||||
|
"build:dev": "webpack --config webpack.development.js",
|
||||||
|
"build:prod": "webpack --config webpack.production.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@excaliburjs/testing": "^0.25.1",
|
||||||
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
|
"compression-webpack-plugin": "^7.1.2",
|
||||||
|
"html-webpack-plugin": "^5.5.0",
|
||||||
|
"source-map-loader": "^2.0.2",
|
||||||
|
"terser-webpack-plugin": "^5.3.6",
|
||||||
|
"ts-loader": "^9.4.2",
|
||||||
|
"typescript": "^4.9.4",
|
||||||
|
"webpack": "^5.75.0",
|
||||||
|
"webpack-cli": "^4.10.0",
|
||||||
|
"webpack-dev-server": "^4.11.1",
|
||||||
|
"webpack-merge": "^5.8.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"excalibur": "^0.27.0"
|
||||||
|
}
|
||||||
|
}
|
17
cat-town/src/actors/player.ts
Normal file
17
cat-town/src/actors/player.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { Actor, Color, vec } from 'excalibur'
|
||||||
|
import { Resources } from '../resources'
|
||||||
|
|
||||||
|
export class Player extends Actor {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
pos: vec(150, 150),
|
||||||
|
width: 25,
|
||||||
|
height: 25,
|
||||||
|
color: new Color(255, 100, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onInitialize() {
|
||||||
|
this.graphics.use(Resources.Cat.toSprite())
|
||||||
|
}
|
||||||
|
}
|
16
cat-town/src/cat.ts
Normal file
16
cat-town/src/cat.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// type Cat = {
|
||||||
|
// name string;
|
||||||
|
// years int;
|
||||||
|
// centimeters int;
|
||||||
|
// kilograms int;
|
||||||
|
// coloring Coloring;
|
||||||
|
// pattern Pattern;
|
||||||
|
// mood Mood;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// type Coloring = 'orange' | 'black' | 'brown' | 'blue';
|
||||||
|
//
|
||||||
|
// type Pattern = 'plain' | 'striped' | 'spotted';
|
||||||
|
//
|
||||||
|
// type Mood = 'happy' | 'sad' | 'purring' |
|
||||||
|
// 'screaming' | 'mad' | 'scratchy' | 'curious' | 'concerned';
|
BIN
cat-town/src/images/cat.png
Normal file
BIN
cat-town/src/images/cat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
BIN
cat-town/src/images/cat.png-autosave.kra
Normal file
BIN
cat-town/src/images/cat.png-autosave.kra
Normal file
Binary file not shown.
30
cat-town/src/index.ts
Normal file
30
cat-town/src/index.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { Engine, Loader, DisplayMode } from 'excalibur'
|
||||||
|
import { Beginning } from './scenes/beginning'
|
||||||
|
import { Player } from './actors/player'
|
||||||
|
import { Resources } from './resources'
|
||||||
|
|
||||||
|
class Game extends Engine {
|
||||||
|
private player: Player
|
||||||
|
private beginning: Beginning
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super({ displayMode: DisplayMode.FitScreen })
|
||||||
|
}
|
||||||
|
|
||||||
|
public start() {
|
||||||
|
this.beginning = new Beginning()
|
||||||
|
this.player = new Player()
|
||||||
|
this.beginning.add(this.player)
|
||||||
|
|
||||||
|
game.add('beginning', this.beginning)
|
||||||
|
|
||||||
|
const loader = new Loader(Object.values(Resources))
|
||||||
|
|
||||||
|
return super.start(loader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const game = new Game()
|
||||||
|
game.start().then(() => {
|
||||||
|
game.goToScene('beginning')
|
||||||
|
})
|
8
cat-town/src/resources.ts
Normal file
8
cat-town/src/resources.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { ImageSource } from 'excalibur'
|
||||||
|
import catImage from './images/cat.png'
|
||||||
|
|
||||||
|
const Resources = {
|
||||||
|
Cat: new ImageSource(catImage)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Resources }
|
7
cat-town/src/scenes/beginning.ts
Normal file
7
cat-town/src/scenes/beginning.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Engine, Scene } from 'excalibur'
|
||||||
|
|
||||||
|
export class Beginning extends Scene {
|
||||||
|
public onInitialize(engine: Engine) {}
|
||||||
|
public onActivate() {}
|
||||||
|
public onDeactivate() {}
|
||||||
|
}
|
22
cat-town/src/town.ts
Normal file
22
cat-town/src/town.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// type Town = {
|
||||||
|
// grid Grid;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// type Grid = {
|
||||||
|
// squares Map<Coords, Square>;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// type Coords = {
|
||||||
|
// x int;
|
||||||
|
// y int;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// type Square = {
|
||||||
|
// description string;
|
||||||
|
// things Map<string, Thing>;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// type Thing = {
|
||||||
|
// name string;
|
||||||
|
// description string;
|
||||||
|
// };
|
14
cat-town/tsconfig.json
Normal file
14
cat-town/tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"target": "es2017",
|
||||||
|
"module": "es6",
|
||||||
|
"types": ["excalibur"],
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
}
|
||||||
|
}
|
47
cat-town/webpack.common.js
Normal file
47
cat-town/webpack.common.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||||
|
const HtmlWebPackPlugin = require("html-webpack-plugin");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: "./src/index.ts",
|
||||||
|
target: "web",
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
sourceMapFilename: "[file].map",
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
},
|
||||||
|
devtool: "source-map",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
||||||
|
type: "asset/resource"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
use: ["source-map-loader"],
|
||||||
|
exclude: [path.resolve(__dirname, "node_modules/excalibur")],
|
||||||
|
enforce: "pre",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: "ts-loader",
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [".tsx", ".ts", ".js"],
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
chunks: "all",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CleanWebpackPlugin(),
|
||||||
|
new HtmlWebPackPlugin({
|
||||||
|
title: "Cat Town",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
12
cat-town/webpack.development.js
Normal file
12
cat-town/webpack.development.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const { merge } = require("webpack-merge");
|
||||||
|
const common = require("./webpack.common");
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: "development",
|
||||||
|
devtool: "inline-source-map",
|
||||||
|
devServer: {
|
||||||
|
static: {
|
||||||
|
directory: "./dist",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
13
cat-town/webpack.production.js
Normal file
13
cat-town/webpack.production.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const { merge } = require("webpack-merge");
|
||||||
|
const CompressionWebpackPlugin = require("compression-webpack-plugin");
|
||||||
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
|
const common = require("./webpack.common");
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: "production",
|
||||||
|
optimization: {
|
||||||
|
minimize: true,
|
||||||
|
minimizer: [new TerserPlugin()],
|
||||||
|
},
|
||||||
|
plugins: [new CompressionWebpackPlugin()],
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user