This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
142 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"explorer.excludeGitIgnore": false | ||
"explorer.excludeGitIgnore": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
import { worldToScreen } from "@/utils/position"; | ||
import { type OrbDTO } from "@viper-vortex/shared"; | ||
import { Food } from "./Food"; | ||
import { getOrbSizeFromPoints, type OrbDTO, type Position } from "@viper-vortex/shared"; | ||
import { Entity } from './Entity'; | ||
import { type Game } from "./Game"; | ||
|
||
export class Orb extends Food { | ||
export class Orb extends Entity{ | ||
private size: number; | ||
private points: number; | ||
private readonly color: string; | ||
private position: Position; | ||
|
||
constructor(orb: OrbDTO, game: Game) { | ||
super(orb, game); | ||
this.size = orb.size; | ||
super(orb.id, game); | ||
this.points = orb.points; | ||
this.size = getOrbSizeFromPoints(orb.points); | ||
this.color = orb.color; | ||
this.position = orb.position; | ||
} | ||
|
||
update(orb: OrbDTO) { | ||
super.update(orb); | ||
this.size = orb.size; | ||
this.position = orb.position; | ||
this.points = orb.points; | ||
this.size = getOrbSizeFromPoints(orb.points); | ||
} | ||
|
||
draw(): void { | ||
const c = this.game.c; | ||
if (!c) return; | ||
const screenFood = worldToScreen(this.position, this.game.camera); | ||
const screenPos = worldToScreen(this.position, this.game.camera); | ||
c.beginPath(); | ||
c.arc( | ||
screenFood.x, | ||
screenFood.y, | ||
screenPos.x, | ||
screenPos.y, | ||
this.size * 5 * this.game.camera.zoom, | ||
0, | ||
2 * Math.PI, | ||
); | ||
c.fillStyle = this.color; | ||
// lower opacity | ||
c.globalAlpha = 0.4; | ||
c.shadowBlur = 6; | ||
c.shadowColor = "rgba(255, 255, 255, 0.4)"; | ||
c.fill(); | ||
c.shadowBlur = 0; | ||
c.globalAlpha = 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.