Compare commits

...

2 Commits

Author SHA1 Message Date
09ee33a751
idklol 2023-09-24 08:21:22 -04:00
ee9fb1955c
Is it cat town? perhaps 2023-04-06 15:08:43 -04:00
15 changed files with 5057 additions and 0 deletions

3
cat-town/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/node_modules/
/src/*.js
/dist/

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
View 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"
}
}

View 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
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

30
cat-town/src/index.ts Normal file
View 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')
})

View File

@ -0,0 +1,8 @@
import { ImageSource } from 'excalibur'
import catImage from './images/cat.png'
const Resources = {
Cat: new ImageSource(catImage)
}
export { Resources }

View 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
View 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
View 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
}
}

View 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",
}),
],
};

View 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",
},
},
});

View 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()],
});