Reformat
This commit is contained in:
parent
e1a909b728
commit
dd831a0a97
@ -1,15 +1,9 @@
|
|||||||
class Block {
|
class Block {
|
||||||
constructor(width, height, xBox, yBox, wBox, hBox, tile) {
|
constructor(xBox, yBox, wBox, hBox, tile) {
|
||||||
this._width = width;
|
this._box = new Box(xBox, yBox, wBox, hBox);
|
||||||
this._height = height;
|
|
||||||
this._xBox = xBox;
|
|
||||||
this._yBox = yBox;
|
|
||||||
this._wBox = wBox;
|
|
||||||
this._hBox = hBox;
|
|
||||||
this._tile = tile;
|
this._tile = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
draw(ctx, x, y){
|
draw(ctx, x, y){
|
||||||
ctx.drawImage(tile, x, y);
|
ctx.drawImage(tile, x, y);
|
||||||
}
|
}
|
||||||
@ -17,4 +11,15 @@ class Block {
|
|||||||
resolveAttack(){
|
resolveAttack(){
|
||||||
return;
|
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.height = height;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
this.isTransperent = false;
|
|
||||||
this.img = null;
|
this.img = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Tileset } from "./Graphics/Tileset/tileset"
|
import { Tileset } from "./Tileset/tileset"
|
||||||
import { Map } from "./Graphics/map";
|
import { Map } from "./map";
|
||||||
import { PlayerTank } from "./playerTank";
|
import { PlayerTank } from "../Tanks/playerTank";
|
||||||
|
|
||||||
export class GameField {
|
export class GameField {
|
||||||
TILE_SIZE = 32;
|
TILE_SIZE = 32;
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { GameKeyAdapterInterface } from "./gameKeyAdapterInterface";
|
import { GameKeyAdapterInterface } from "./gameKeyAdapterInterface";
|
||||||
import {DirectionEnum} from "./../directionEnum";
|
import {DirectionEnum} from "../Tanks/directionEnum";
|
||||||
|
|
||||||
export class TankKeyAdapter extends GameKeyAdapterInterface{
|
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";
|
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 {
|
export class Game {
|
||||||
constructor(width = 500, height = 500, ctx) {
|
constructor(width = 500, height = 500, ctx) {
|
||||||
this.gameField = new GameField(width, height, ctx, canvas);
|
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