first commit
This commit is contained in:
commit
bdde7897a9
24 changed files with 14901 additions and 0 deletions
16
.editorconfig
Normal file
16
.editorconfig
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Editor configuration, see https://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.ts]
|
||||||
|
quote_type = single
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
42
.gitignore
vendored
Normal file
42
.gitignore
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
|
||||||
|
|
||||||
|
# Compiled output
|
||||||
|
/dist
|
||||||
|
/tmp
|
||||||
|
/out-tsc
|
||||||
|
/bazel-out
|
||||||
|
|
||||||
|
# Node
|
||||||
|
/node_modules
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
.idea/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.history/*
|
||||||
|
|
||||||
|
# Miscellaneous
|
||||||
|
/.angular/cache
|
||||||
|
.sass-cache/
|
||||||
|
/connect.lock
|
||||||
|
/coverage
|
||||||
|
/libpeerconnection.log
|
||||||
|
testem.log
|
||||||
|
/typings
|
||||||
|
|
||||||
|
# System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
4
.vscode/extensions.json
vendored
Normal file
4
.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||||
|
"recommendations": ["angular.ng-template"]
|
||||||
|
}
|
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "ng serve",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "npm: start",
|
||||||
|
"url": "http://localhost:4200/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ng test",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "npm: test",
|
||||||
|
"url": "http://localhost:9876/debug.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
42
.vscode/tasks.json
vendored
Normal file
42
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "start",
|
||||||
|
"isBackground": true,
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "typescript",
|
||||||
|
"pattern": "$tsc",
|
||||||
|
"background": {
|
||||||
|
"activeOnStart": true,
|
||||||
|
"beginsPattern": {
|
||||||
|
"regexp": "(.*?)"
|
||||||
|
},
|
||||||
|
"endsPattern": {
|
||||||
|
"regexp": "bundle generation complete"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "test",
|
||||||
|
"isBackground": true,
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "typescript",
|
||||||
|
"pattern": "$tsc",
|
||||||
|
"background": {
|
||||||
|
"activeOnStart": true,
|
||||||
|
"beginsPattern": {
|
||||||
|
"regexp": "(.*?)"
|
||||||
|
},
|
||||||
|
"endsPattern": {
|
||||||
|
"regexp": "bundle generation complete"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
27
README.md
Normal file
27
README.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# SillyGameFrontend
|
||||||
|
|
||||||
|
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.1.
|
||||||
|
|
||||||
|
## Development server
|
||||||
|
|
||||||
|
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
||||||
|
|
||||||
|
## Code scaffolding
|
||||||
|
|
||||||
|
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||||
|
|
||||||
|
## Running end-to-end tests
|
||||||
|
|
||||||
|
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
||||||
|
|
||||||
|
## Further help
|
||||||
|
|
||||||
|
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
127
angular.json
Normal file
127
angular.json
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
{
|
||||||
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"version": 1,
|
||||||
|
"newProjectRoot": "projects",
|
||||||
|
"projects": {
|
||||||
|
"silly-game-frontend": {
|
||||||
|
"projectType": "application",
|
||||||
|
"schematics": {
|
||||||
|
"@schematics/angular:component": {
|
||||||
|
"style": "scss",
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:class": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:directive": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:guard": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:interceptor": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:pipe": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:resolver": {
|
||||||
|
"skipTests": true
|
||||||
|
},
|
||||||
|
"@schematics/angular:service": {
|
||||||
|
"skipTests": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"prefix": "app",
|
||||||
|
"architect": {
|
||||||
|
"build": {
|
||||||
|
"builder": "@angular-devkit/build-angular:application",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist/silly-game-frontend",
|
||||||
|
"index": "src/index.html",
|
||||||
|
"browser": "src/main.ts",
|
||||||
|
"polyfills": [
|
||||||
|
"zone.js"
|
||||||
|
],
|
||||||
|
"tsConfig": "tsconfig.app.json",
|
||||||
|
"inlineStyleLanguage": "scss",
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.scss"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "500kB",
|
||||||
|
"maximumError": "1MB"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "2kB",
|
||||||
|
"maximumError": "4kB"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"optimization": false,
|
||||||
|
"extractLicenses": false,
|
||||||
|
"sourceMap": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "production"
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"buildTarget": "silly-game-frontend:build:production"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"buildTarget": "silly-game-frontend:build:development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "development"
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"polyfills": [
|
||||||
|
"zone.js",
|
||||||
|
"zone.js/testing"
|
||||||
|
],
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"inlineStyleLanguage": "scss",
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"glob": "**/*",
|
||||||
|
"input": "public"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.scss"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cli": {
|
||||||
|
"analytics": false
|
||||||
|
}
|
||||||
|
}
|
14305
package-lock.json
generated
Normal file
14305
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
38
package.json
Normal file
38
package.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"name": "silly-game-frontend",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"ng": "ng",
|
||||||
|
"start": "ng serve",
|
||||||
|
"build": "ng build",
|
||||||
|
"watch": "ng build --watch --configuration development",
|
||||||
|
"test": "ng test"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@angular/animations": "^18.2.0",
|
||||||
|
"@angular/common": "^18.2.0",
|
||||||
|
"@angular/compiler": "^18.2.0",
|
||||||
|
"@angular/core": "^18.2.0",
|
||||||
|
"@angular/forms": "^18.2.0",
|
||||||
|
"@angular/platform-browser": "^18.2.0",
|
||||||
|
"@angular/platform-browser-dynamic": "^18.2.0",
|
||||||
|
"@angular/router": "^18.2.0",
|
||||||
|
"rxjs": "~7.8.0",
|
||||||
|
"tslib": "^2.3.0",
|
||||||
|
"zone.js": "~0.14.10"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@angular-devkit/build-angular": "^18.2.1",
|
||||||
|
"@angular/cli": "^18.2.1",
|
||||||
|
"@angular/compiler-cli": "^18.2.0",
|
||||||
|
"@types/jasmine": "~5.1.0",
|
||||||
|
"jasmine-core": "~5.2.0",
|
||||||
|
"karma": "~6.4.0",
|
||||||
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
|
"karma-coverage": "~2.2.0",
|
||||||
|
"karma-jasmine": "~5.1.0",
|
||||||
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
|
"typescript": "~5.5.2"
|
||||||
|
}
|
||||||
|
}
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
3
src/app/app.component.html
Normal file
3
src/app/app.component.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<app-mario></app-mario>
|
||||||
|
|
||||||
|
<router-outlet />
|
0
src/app/app.component.scss
Normal file
0
src/app/app.component.scss
Normal file
14
src/app/app.component.ts
Normal file
14
src/app/app.component.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { RouterOutlet } from '@angular/router';
|
||||||
|
import { MarioComponent } from "./mario/mario.component";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-root',
|
||||||
|
standalone: true,
|
||||||
|
imports: [RouterOutlet, MarioComponent],
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
styleUrl: './app.component.scss'
|
||||||
|
})
|
||||||
|
export class AppComponent {
|
||||||
|
title = 'silly-game-frontend';
|
||||||
|
}
|
8
src/app/app.config.ts
Normal file
8
src/app/app.config.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
||||||
|
import { provideRouter } from '@angular/router';
|
||||||
|
|
||||||
|
import { routes } from './app.routes';
|
||||||
|
|
||||||
|
export const appConfig: ApplicationConfig = {
|
||||||
|
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
|
||||||
|
};
|
3
src/app/app.routes.ts
Normal file
3
src/app/app.routes.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
|
export const routes: Routes = [];
|
4
src/app/mario/mario.component.html
Normal file
4
src/app/mario/mario.component.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div style="width: 100%; height: 100vh; overflow-x: scroll; overflow-y: hidden;">
|
||||||
|
<canvas id="gameCanvas"></canvas>
|
||||||
|
</div>
|
||||||
|
|
10
src/app/mario/mario.component.scss
Normal file
10
src/app/mario/mario.component.scss
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
body, html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
display: block;
|
||||||
|
background-color: #c2f0c2;
|
||||||
|
}
|
154
src/app/mario/mario.component.ts
Normal file
154
src/app/mario/mario.component.ts
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-mario',
|
||||||
|
standalone: true,
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './mario.component.html',
|
||||||
|
styleUrl: './mario.component.scss'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class MarioComponent implements OnInit {
|
||||||
|
mario = {
|
||||||
|
x: 50,
|
||||||
|
y: 0,
|
||||||
|
width: 40,
|
||||||
|
height: 60,
|
||||||
|
dx: 0,
|
||||||
|
dy: 0,
|
||||||
|
speed: 4,
|
||||||
|
jumpStrength: 25,
|
||||||
|
gravity: 0.5,
|
||||||
|
onGround: false,
|
||||||
|
color: 'red'
|
||||||
|
};
|
||||||
|
|
||||||
|
private canvas!: HTMLCanvasElement;
|
||||||
|
private ctx!: CanvasRenderingContext2D;
|
||||||
|
private canvasWidth = window.innerWidth * 5;
|
||||||
|
private canvasHeight = window.innerHeight;
|
||||||
|
private platforms = [
|
||||||
|
{ x: 300, y: 500, width: 100, height: 10 },
|
||||||
|
{ x: 600, y: 400, width: 150, height: 10 },
|
||||||
|
{ x: 900, y: 350, width: 200, height: 10 },
|
||||||
|
{ x: 1300, y: 450, width: 120, height: 10 },
|
||||||
|
{ x: 1600, y: 380, width: 180, height: 10 },
|
||||||
|
{ x: 1900, y: 320, width: 120, height: 10 },
|
||||||
|
{ x: 2200, y: 300, width: 150, height: 10 },
|
||||||
|
{ x: 2500, y: 350, width: 180, height: 10 },
|
||||||
|
{ x: 2800, y: 400, width: 120, height: 10 },
|
||||||
|
{ x: 3100, y: 450, width: 150, height: 10 },
|
||||||
|
{ x: 3400, y: 390, width: 130, height: 10 },
|
||||||
|
{ x: 3700, y: 350, width: 200, height: 10 },
|
||||||
|
{ x: 4000, y: 300, width: 140, height: 10 },
|
||||||
|
{ x: 4300, y: 330, width: 180, height: 10 },
|
||||||
|
{ x: 4600, y: 380, width: 120, height: 10 },
|
||||||
|
{ x: 4900, y: 350, width: 160, height: 10 },
|
||||||
|
{ x: 5200, y: 420, width: 180, height: 10 },
|
||||||
|
{ x: 5500, y: 460, width: 120, height: 10 },
|
||||||
|
{ x: 5800, y: 500, width: 160, height: 10 },
|
||||||
|
{ x: 6100, y: 400, width: 140, height: 10 }
|
||||||
|
];
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.canvas = document.getElementById('gameCanvas') as HTMLCanvasElement;
|
||||||
|
this.ctx = this.canvas.getContext('2d')!;
|
||||||
|
this.canvas.width = this.canvasWidth;
|
||||||
|
this.canvas.height = this.canvasHeight;
|
||||||
|
this.mario.y = this.canvasHeight - 100;
|
||||||
|
this.loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:keydown', ['$event'])
|
||||||
|
handleKeyDown(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'ArrowRight') this.mario.dx = this.mario.speed;
|
||||||
|
if (event.key === 'ArrowLeft') this.mario.dx = -this.mario.speed;
|
||||||
|
if (event.key === ' ' && this.mario.onGround) {
|
||||||
|
this.mario.dy = -this.mario.jumpStrength;
|
||||||
|
this.mario.onGround = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:keyup', ['$event'])
|
||||||
|
handleKeyUp(event: KeyboardEvent) {
|
||||||
|
if (['ArrowRight', 'ArrowLeft'].includes(event.key)) this.mario.dx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private loop = () => {
|
||||||
|
this.update();
|
||||||
|
this.draw();
|
||||||
|
this.scrollToMario();
|
||||||
|
requestAnimationFrame(this.loop);
|
||||||
|
};
|
||||||
|
|
||||||
|
private update() {
|
||||||
|
this.mario.x += this.mario.dx;
|
||||||
|
this.mario.y += this.mario.dy;
|
||||||
|
|
||||||
|
// Gravity
|
||||||
|
this.mario.dy += this.mario.gravity;
|
||||||
|
|
||||||
|
this.mario.onGround = false;
|
||||||
|
const groundY = this.canvasHeight - 60;
|
||||||
|
|
||||||
|
if (this.mario.y + this.mario.height >= groundY) {
|
||||||
|
this.mario.y = groundY - this.mario.height;
|
||||||
|
this.mario.dy = 0;
|
||||||
|
this.mario.onGround = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const platform of this.platforms) {
|
||||||
|
if (
|
||||||
|
this.mario.x + this.mario.width > platform.x &&
|
||||||
|
this.mario.x < platform.x + platform.width &&
|
||||||
|
this.mario.y + this.mario.height <= platform.y &&
|
||||||
|
this.mario.y + this.mario.height + this.mario.dy >= platform.y
|
||||||
|
) {
|
||||||
|
this.mario.y = platform.y - this.mario.height;
|
||||||
|
this.mario.dy = 0;
|
||||||
|
this.mario.onGround = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Boundaries
|
||||||
|
if (this.mario.x < 0) this.mario.x = 0;
|
||||||
|
if (this.mario.x + this.mario.width > this.canvasWidth)
|
||||||
|
this.mario.x = this.canvasWidth - this.mario.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
private draw() {
|
||||||
|
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
|
||||||
|
// Ground
|
||||||
|
this.ctx.fillStyle = '#654321';
|
||||||
|
this.ctx.fillRect(0, this.canvas.height - 60, this.canvas.width, 60);
|
||||||
|
|
||||||
|
// Platforms
|
||||||
|
this.ctx.fillStyle = '#888';
|
||||||
|
for (const p of this.platforms) {
|
||||||
|
this.ctx.fillRect(p.x, p.y, p.width, p.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mario
|
||||||
|
this.ctx.fillStyle = this.mario.color;
|
||||||
|
this.ctx.fillRect(this.mario.x, this.mario.y, this.mario.width, this.mario.height);
|
||||||
|
|
||||||
|
this.ctx.fillStyle = 'white';
|
||||||
|
this.ctx.fillRect(this.mario.x + 8, this.mario.y + 15, 8, 8);
|
||||||
|
this.ctx.fillRect(this.mario.x + 24, this.mario.y + 15, 8, 8);
|
||||||
|
this.ctx.fillStyle = 'black';
|
||||||
|
this.ctx.fillRect(this.mario.x + 10, this.mario.y + 17, 4, 4);
|
||||||
|
this.ctx.fillRect(this.mario.x + 26, this.mario.y + 17, 4, 4);
|
||||||
|
|
||||||
|
this.ctx.fillStyle = 'yellow';
|
||||||
|
this.ctx.fillRect(this.canvasWidth - 60, this.canvas.height - 160, 20, 100);
|
||||||
|
this.ctx.fillStyle = 'black';
|
||||||
|
this.ctx.fillText('🏁', this.canvasWidth - 60, this.canvas.height - 170);
|
||||||
|
}
|
||||||
|
|
||||||
|
private scrollToMario() {
|
||||||
|
const scrollContainer = this.canvas.parentElement!;
|
||||||
|
const centerOffset = scrollContainer.clientWidth / 2;
|
||||||
|
scrollContainer.scrollLeft = this.mario.x - centerOffset;
|
||||||
|
}
|
||||||
|
}
|
13
src/index.html
Normal file
13
src/index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>SillyGameFrontend</title>
|
||||||
|
<base href="/">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<app-root></app-root>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
src/main.ts
Normal file
7
src/main.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { bootstrapApplication } from '@angular/platform-browser';
|
||||||
|
import { appConfig } from './app/app.config';
|
||||||
|
import { AppComponent } from './app/app.component';
|
||||||
|
import { MarioComponent } from './app/mario/mario.component';
|
||||||
|
|
||||||
|
bootstrapApplication(AppComponent, appConfig)
|
||||||
|
.catch((err) => console.error(err));
|
1
src/styles.scss
Normal file
1
src/styles.scss
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/* You can add global styles to this file, and also import other style files */
|
15
tsconfig.app.json
Normal file
15
tsconfig.app.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||||
|
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./out-tsc/app",
|
||||||
|
"types": []
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/main.ts"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"src/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
33
tsconfig.json
Normal file
33
tsconfig.json
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||||
|
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||||
|
{
|
||||||
|
"compileOnSave": false,
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/out-tsc",
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitOverride": true,
|
||||||
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"declaration": false,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"importHelpers": true,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"lib": [
|
||||||
|
"ES2022",
|
||||||
|
"dom"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"enableI18nLegacyMessageIdFormat": false,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"strictInputAccessModifiers": true,
|
||||||
|
"strictTemplates": true
|
||||||
|
}
|
||||||
|
}
|
15
tsconfig.spec.json
Normal file
15
tsconfig.spec.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||||
|
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./out-tsc/spec",
|
||||||
|
"types": [
|
||||||
|
"jasmine"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.spec.ts",
|
||||||
|
"src/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue