Compare commits
2 Commits
cat-town
...
7f4f627769
Author | SHA1 | Date | |
---|---|---|---|
7f4f627769
|
|||
dc8045a20e
|
3
cat-town/.gitignore
vendored
3
cat-town/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
/node_modules/
|
||||
/src/*.js
|
||||
/dist/
|
4838
cat-town/package-lock.json
generated
4838
cat-town/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
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())
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
// 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';
|
Binary file not shown.
Before Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
@@ -1,30 +0,0 @@
|
||||
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')
|
||||
})
|
@@ -1,8 +0,0 @@
|
||||
import { ImageSource } from 'excalibur'
|
||||
import catImage from './images/cat.png'
|
||||
|
||||
const Resources = {
|
||||
Cat: new ImageSource(catImage)
|
||||
}
|
||||
|
||||
export { Resources }
|
@@ -1,7 +0,0 @@
|
||||
import { Engine, Scene } from 'excalibur'
|
||||
|
||||
export class Beginning extends Scene {
|
||||
public onInitialize(engine: Engine) {}
|
||||
public onActivate() {}
|
||||
public onDeactivate() {}
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
// 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;
|
||||
// };
|
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"target": "es2017",
|
||||
"module": "es6",
|
||||
"types": ["excalibur"],
|
||||
"outDir": "./dist/",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
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",
|
||||
}),
|
||||
],
|
||||
};
|
@@ -1,12 +0,0 @@
|
||||
const { merge } = require("webpack-merge");
|
||||
const common = require("./webpack.common");
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: "development",
|
||||
devtool: "inline-source-map",
|
||||
devServer: {
|
||||
static: {
|
||||
directory: "./dist",
|
||||
},
|
||||
},
|
||||
});
|
@@ -1,13 +0,0 @@
|
||||
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()],
|
||||
});
|
15
rustbyexample/.gitignore
vendored
15
rustbyexample/.gitignore
vendored
@@ -1,11 +1,6 @@
|
||||
/custom_types/*
|
||||
/hello/*
|
||||
/primitives/*
|
||||
/variable_bindings/*
|
||||
/types/*
|
||||
/*.d/*
|
||||
hello
|
||||
primitives
|
||||
variable_bindings
|
||||
|
||||
!/custom_types/*.rs
|
||||
!/hello/*.rs
|
||||
!/primitives/*.rs
|
||||
!/variable_bindings/*.rs
|
||||
!/types/*.rs
|
||||
!/*.d/*.rs
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
struct Person {
|
||||
name: String,
|
@@ -1,3 +1,4 @@
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
struct Person<'a> {
|
||||
name: &'a str,
|
@@ -20,6 +20,6 @@ impl fmt::Display for List {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let v = List(vec![1, 2, 3]);
|
||||
let v = List(vec![6, 0, 6, 8, 0, 8, 9, 1, 1, 1, 3, 1, 2]);
|
||||
println!("{}", v);
|
||||
}
|
@@ -22,5 +22,14 @@ fn main() {
|
||||
println!("borrow a section of the array as a slice");
|
||||
analyze_slice(&ys[1..4]);
|
||||
|
||||
// println!("{}", xs[5]);
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,6 +3,8 @@ 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);
|
@@ -1,3 +1,5 @@
|
||||
#[allow(unused_variables)]
|
||||
#[allow(unused_assignments)]
|
||||
fn main() {
|
||||
let logical: bool = true;
|
||||
|
15
rustbyexample/types.d/alias.rs
Normal file
15
rustbyexample/types.d/alias.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
);
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
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);
|
||||
}
|
@@ -13,4 +13,3 @@ fn main() {
|
||||
let shadowed_binding = 2;
|
||||
println!("shadowed in outer block: {}", shadowed_binding);
|
||||
}
|
||||
|
@@ -11,5 +11,5 @@ fn main() {
|
||||
|
||||
let _unused_variable = 3u32;
|
||||
|
||||
let noisy_unused_variable = 2u32;
|
||||
let _noisy_unused_variable = 2u32;
|
||||
}
|
Reference in New Issue
Block a user