diff --git a/imports/import.js b/imports/import.js index 5104c62..a0fb66c 100644 --- a/imports/import.js +++ b/imports/import.js @@ -20,6 +20,7 @@ import { Held } from "../system/map-player/player/heldItems/holdManager.js" import { Bazooka } from "../system/map-player/player/heldItems/Bazooka.js" import { Shotgun } from "../system/map-player/player/heldItems/Shotgun.js" import { Dash } from "../system/map-player/player/heldItems/dash.js" +import { UiUtills } from "../system/variousParts/UIUtills.js" export class Game{ // System @@ -28,7 +29,7 @@ export class Game{ enemy; // fields - + uitills = new UiUtills(this) shotgun = new Shotgun(this) dash = new Dash(this) keyManager = new KeyManager(this); diff --git a/system/map-player/player/heldItems/Shotgun.js b/system/map-player/player/heldItems/Shotgun.js index 212d779..0397034 100644 --- a/system/map-player/player/heldItems/Shotgun.js +++ b/system/map-player/player/heldItems/Shotgun.js @@ -9,6 +9,8 @@ export class Shotgun{ particles = [] steps = 50 length = 0 + frame = 0 + colideTime = 1 constructor(game){ this.game = game } @@ -31,6 +33,7 @@ export class Shotgun{ this.particles[this.length].velX = (this.trajectory.x*30 + (Math.random() - .5) * 5) this.particles[this.length].velY = (this.trajectory.y*30 + (Math.random() - .5) * 5) this.particles[this.length].alpha = 2 + this.particles[this.length].frame = 2 this.length++ if(this.length > 50){ this.length = 0 @@ -74,16 +77,24 @@ export class Shotgun{ this.reloading = false } } - for(let i = 0; i < this.particles.length; i++){ - for(let h = 0; h < this.steps; h++){ - this.particles[i].x -= (this.particles[i].velX * this.velMultiplyer) / this.steps - this.particles[i].y -= (this.particles[i].velY * this.velMultiplyer) / this.steps - if(this.particles[i].alpha > 0){ - this.colideAll(this.game.map.ground, i) - } - this.particles[i].alpha -= 0.0001 + + + for(let i = 0; i < this.particles.length; i++){ + this.particles[i].frame++ + //for(let h = 0; h < this.steps; h++){ + this.particles[i].x -= (this.particles[i].velX * this.velMultiplyer) // this.steps + this.particles[i].y -= (this.particles[i].velY * this.velMultiplyer) // this.steps + //if(this.particles[i].alpha > 0 && this.particles[i].frame > 15){ + this.colideAll(this.game.map.ground, i) + this.particles[i].frame = 0 + //} + this.particles[i].alpha -= 0.0001 + + + //} } - } + + if(this.velMultiplyer > 0){ this.velMultiplyer /= 1 + (this.velMultiplyer/15) } diff --git a/system/variousParts/GameDisplayer.js b/system/variousParts/GameDisplayer.js index 40d6516..72148d5 100644 --- a/system/variousParts/GameDisplayer.js +++ b/system/variousParts/GameDisplayer.js @@ -76,6 +76,7 @@ export class GameDisplayer { this.resizeCanvasForWindowSize(ballEffect, bctx); this.resizeCanvasForWindowSize(postEffect, ppctx); + this.bgFade(this.targetR, this.targetG, this.targetB) this.r += this.rC this.g += this.gC @@ -92,6 +93,8 @@ export class GameDisplayer { ctx.drawImage(this.grid, 0, 0, this.originalWidth,625 * (this.originalWidth / 1000)) } + //this.game.uitills.draw() + for(let i = 0; i < this.game.shotgun.particles.length; i++) { ctx.globalAlpha = Math.max(0, Math.min(1,this.game.shotgun.particles[i].alpha)) console.log(this.game.shotgun.particles[i].alpha) diff --git a/system/variousParts/UIUtills.js b/system/variousParts/UIUtills.js new file mode 100644 index 0000000..a0af51e --- /dev/null +++ b/system/variousParts/UIUtills.js @@ -0,0 +1,19 @@ +const canvas = document.getElementById("UI") +const ctx = canvas.getContext("2d") + +import { DrawUtils } from "../../utils/DrawUtils.js" + +export class UiUtills { + tText = "" + tTime = 0 + tY = 500 + draw = new DrawUtils() + + draw(){ + //this.draw.Rect(500, 500, 500, 100, "#000000") + } + + toast(text, time){ + + } +}