Skip to content

Commit

Permalink
feat: racer-796
Browse files Browse the repository at this point in the history
  • Loading branch information
horpia committed May 23, 2022
1 parent e957c32 commit 9a59f13
Show file tree
Hide file tree
Showing 114 changed files with 10,033 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Repo with misc stuff created by me

- [Water Waves Effect](https://horpia.github.io/demo/water-waves-effect/)
- [Smoke Effect](https://horpia.github.io/demo/smoke-effect/)
- [Smoke Effect](https://horpia.github.io/demo/smoke-effect/)
- [Game - Racer-796](https://horpia.github.io/demo/racer796/dist/)
Binary file added racer796/dist/assets/ModernDOS8x14.woff2
Binary file not shown.
Binary file added racer796/dist/assets/ModernDOS8x8.woff2
Binary file not shown.
Binary file added racer796/dist/assets/build1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build10.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build11.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build12.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build13.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build14.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build6.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build7.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build8.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/build9.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/button2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/coin.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/expl1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/finish.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/floor1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/joystick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/machine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/machine2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/ship.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/ship2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added racer796/dist/assets/space-bg.gif
Binary file added racer796/dist/assets/station-bg.gif
12 changes: 12 additions & 0 deletions racer796/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<script src="main.js?3"></script>
</head>
<body ondragstart="return false" style="margin: 0; background-color: #3a3a3a">
<div id="cont"></div>
</body>
</html>
1 change: 1 addition & 0 deletions racer796/dist/main.js

Large diffs are not rendered by default.

6,040 changes: 6,040 additions & 0 deletions racer796/package-lock.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions racer796/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "racer796",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js",
"watch": "webpack --watch",
"start": "webpack serve"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^9.2.8",
"typescript": "^4.6.3",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.8.1"
}
}
Binary file added racer796/public/assets/ModernDOS8x14.woff2
Binary file not shown.
Binary file added racer796/public/assets/ModernDOS8x8.woff2
Binary file not shown.
Binary file added racer796/public/assets/build1.gif
Binary file added racer796/public/assets/build10.gif
Binary file added racer796/public/assets/build11.gif
Binary file added racer796/public/assets/build12.gif
Binary file added racer796/public/assets/build13.gif
Binary file added racer796/public/assets/build14.gif
Binary file added racer796/public/assets/build2.gif
Binary file added racer796/public/assets/build3.gif
Binary file added racer796/public/assets/build4.gif
Binary file added racer796/public/assets/build5.gif
Binary file added racer796/public/assets/build6.gif
Binary file added racer796/public/assets/build7.gif
Binary file added racer796/public/assets/build8.gif
Binary file added racer796/public/assets/build9.gif
Binary file added racer796/public/assets/button.png
Binary file added racer796/public/assets/button2.png
Binary file added racer796/public/assets/coin.gif
Binary file added racer796/public/assets/expl1.gif
Binary file added racer796/public/assets/finish.gif
Binary file added racer796/public/assets/floor1.gif
Binary file added racer796/public/assets/joystick.png
Binary file added racer796/public/assets/machine.png
Binary file added racer796/public/assets/machine2.png
Binary file added racer796/public/assets/ship.gif
Binary file added racer796/public/assets/ship2.gif
Binary file added racer796/public/assets/space-bg.gif
Binary file added racer796/public/assets/station-bg.gif
12 changes: 12 additions & 0 deletions racer796/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<script src="main.js?3"></script>
</head>
<body ondragstart="return false" style="margin: 0; background-color: #3a3a3a">
<div id="cont"></div>
</body>
</html>
3 changes: 3 additions & 0 deletions racer796/src/assets-item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface AssetsItem {
loadAssets(): Promise<void>;
}
13 changes: 13 additions & 0 deletions racer796/src/assets-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {AssetsItem} from "game/assets-item";

export class AssetsLoader {
private items: Set<AssetsItem> = new Set<AssetsItem>();

addItem(item: AssetsItem): void {
this.items.add(item);
}

async load(): Promise<void> {
await Promise.all(Array.from(this.items).map(item => item.loadAssets()));
}
}
55 changes: 55 additions & 0 deletions racer796/src/canvas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {Renderable} from "game/renderable";
import {CANVAS_HEIGHT, CANVAS_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH} from "game/config";
import {UIElement} from "game/ui-element";

export class Canvas implements UIElement {
private readonly displayCanvas: HTMLCanvasElement;
private readonly bufferCanvas: HTMLCanvasElement;
private readonly displayCtx: CanvasRenderingContext2D;
private readonly bufferCtx: CanvasRenderingContext2D;

constructor() {
this.displayCanvas = document.createElement('canvas');
this.displayCanvas.width = CANVAS_WIDTH;
this.displayCanvas.height = CANVAS_HEIGHT;

this.displayCtx = this.displayCanvas.getContext('2d', {alpha: false});
this.displayCtx.imageSmoothingEnabled = false;
// @ts-ignore
this.displayCtx.mozImageSmoothingEnabled = false;
// @ts-ignore
this.displayCtx.webkitImageSmoothingEnabled = false;

this.bufferCanvas = document.createElement('canvas');
this.bufferCanvas.width = SCREEN_WIDTH;
this.bufferCanvas.height = SCREEN_HEIGHT;
this.bufferCanvas.style.cssText = 'font-smooth: never; -webkit-font-smoothing : none;';
this.bufferCtx = this.bufferCanvas.getContext('2d', {alpha: false});
this.bufferCtx.imageSmoothingEnabled = false;
// @ts-ignore
this.bufferCtx.mozImageSmoothingEnabled = false;
// @ts-ignore
this.bufferCtx.webkitImageSmoothingEnabled = false;
}

build(): void {
}

getElement(): HTMLElement {
return this.displayCanvas;
}

clear(): void {
this.bufferCtx.clearRect(0, 0, this.bufferCanvas.width, this.bufferCanvas.height);
}

draw(item: Renderable): void {
this.bufferCtx.save();
item.render(this.bufferCtx);
this.bufferCtx.restore();
}

finishFrame(): void {
this.displayCtx.drawImage(this.bufferCanvas, 0, 0, this.displayCanvas.width, this.displayCanvas.height);
}
}
Loading

0 comments on commit 9a59f13

Please sign in to comment.