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
45 changed files with 5086 additions and 38 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()],
});

View File

@@ -1,6 +1,11 @@
/*.d/*
hello
primitives
variable_bindings
/custom_types/*
/hello/*
/primitives/*
/variable_bindings/*
/types/*
!/*.d/*.rs
!/custom_types/*.rs
!/hello/*.rs
!/primitives/*.rs
!/variable_bindings/*.rs
!/types/*.rs

View File

@@ -1,4 +1,3 @@
#[allow(dead_code)]
#[derive(Debug)]
struct Person {
name: String,

View File

@@ -1,4 +1,3 @@
#[allow(dead_code)]
#[derive(Debug)]
struct Person<'a> {
name: &'a str,

View File

@@ -20,6 +20,6 @@ impl fmt::Display for List {
}
fn main() {
let v = List(vec![6, 0, 6, 8, 0, 8, 9, 1, 1, 1, 3, 1, 2]);
let v = List(vec![1, 2, 3]);
println!("{}", v);
}

View File

@@ -1,5 +1,3 @@
#[allow(unused_variables)]
#[allow(unused_assignments)]
fn main() {
let logical: bool = true;

View File

@@ -22,14 +22,5 @@ fn main() {
println!("borrow a section of the array as a slice");
analyze_slice(&ys[1..4]);
let empty_array: [u32; 0] = [];
assert_eq!(&empty_array, &[]);
assert_eq!(&empty_array, &[][..]);
for i in 0..xs.len() + 1 {
match xs.get(i) {
Some(xval) => println!("{}: {}", i, xval),
None => println!("Slow down! {} is too far!", i),
}
}
// println!("{}", xs[5]);
}

View File

@@ -3,8 +3,6 @@ fn main() {
println!("1 - 2 = {}", 1i32 - 2);
println!("1e4 is {}, -2.5e-3 is {}", 1e4, -2.5e-3);
println!("true AND false is {}", true && false);
println!("true OR false is {}", true || false);
println!("NOT true is {}", !true);

View File

@@ -1,15 +0,0 @@
type NanoSecond = u64;
type Inch = u64;
type U64 = u64;
fn main() {
let nanoseconds: NanoSecond = 5 as U64;
let inches: Inch = 2 as U64;
println!(
"{} nanoseconds + {} inches = {} unit?",
nanoseconds,
inches,
nanoseconds + inches
);
}

View File

@@ -0,0 +1,15 @@
type NanoSecond = u64;
type Inch = u64;
#[allow(non_camel_case_types)]
type u64_t = u64;
fn main() {
let nanoseconds: NanoSecond = 5 as u64_t;
let inches: Inch = 2 as u64_t;
println!("{} nanoseconds + {} inches = {} unit?",
nanoseconds,
inches,
nanoseconds + inches);
}

View File

@@ -13,3 +13,4 @@ fn main() {
let shadowed_binding = 2;
println!("shadowed in outer block: {}", shadowed_binding);
}

View File

@@ -11,5 +11,5 @@ fn main() {
let _unused_variable = 3u32;
let _noisy_unused_variable = 2u32;
let noisy_unused_variable = 2u32;
}