Reformat
This commit is contained in:
parent
e1a909b728
commit
dd831a0a97
@ -1,15 +1,9 @@
|
||||
class Block {
|
||||
constructor(width, height, xBox, yBox, wBox, hBox, tile) {
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
this._xBox = xBox;
|
||||
this._yBox = yBox;
|
||||
this._wBox = wBox;
|
||||
this._hBox = hBox;
|
||||
constructor(xBox, yBox, wBox, hBox, tile) {
|
||||
this._box = new Box(xBox, yBox, wBox, hBox);
|
||||
this._tile = tile;
|
||||
}
|
||||
|
||||
|
||||
draw(ctx, x, y){
|
||||
ctx.drawImage(tile, x, y);
|
||||
}
|
||||
@ -17,4 +11,15 @@ class Block {
|
||||
resolveAttack(){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Box {
|
||||
constructor(xBox, yBox, wBox, hBox) {
|
||||
this._xBox = xBox;
|
||||
this._yBox = yBox;
|
||||
this._wBox = wBox;
|
||||
this._hBox = hBox;
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@ export class Tile {
|
||||
this.height = height;
|
||||
this.id = id;
|
||||
|
||||
this.isTransperent = false;
|
||||
this.img = null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Tileset } from "./Graphics/Tileset/tileset"
|
||||
import { Map } from "./Graphics/map";
|
||||
import { PlayerTank } from "./playerTank";
|
||||
import { Tileset } from "./Tileset/tileset"
|
||||
import { Map } from "./map";
|
||||
import { PlayerTank } from "../Tanks/playerTank";
|
||||
|
||||
export class GameField {
|
||||
TILE_SIZE = 32;
|
||||
@ -1,5 +1,5 @@
|
||||
import { GameKeyAdapterInterface } from "./gameKeyAdapterInterface";
|
||||
import {DirectionEnum} from "./../directionEnum";
|
||||
import {DirectionEnum} from "../Tanks/directionEnum";
|
||||
|
||||
export class TankKeyAdapter extends GameKeyAdapterInterface{
|
||||
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import { Game } from "./game";
|
||||
|
||||
export function init() {
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (ctx) {
|
||||
const game = new Game(500, 500, ctx, canvas);
|
||||
game.start();
|
||||
}
|
||||
}
|
||||
11
src/game.js
11
src/game.js
@ -1,6 +1,15 @@
|
||||
import { GameField } from "./gameField";
|
||||
import { GameField } from "./Graphics/gameField";
|
||||
import { TankKeyAdapter } from "./KeyAdapters/tankKeyAdapter";
|
||||
|
||||
export function init() {
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (ctx) {
|
||||
const game = new Game(500, 500, ctx, canvas);
|
||||
game.start();
|
||||
}
|
||||
}
|
||||
|
||||
export class Game {
|
||||
constructor(width = 500, height = 500, ctx) {
|
||||
this.gameField = new GameField(width, height, ctx, canvas);
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
import * as canvas from "./canvas";
|
||||
import {init} from "./game";
|
||||
|
||||
addEventListener("load", () => canvas.init());
|
||||
addEventListener("load", () => init());
|
||||
Loading…
x
Reference in New Issue
Block a user