This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scenes and Buttons implemented (#77)
* Implement scenes Add Scenes framework - Implement Scene class - Implement Elements - Implement SceneRenderer - Implement ElementRenderer - Implement SceneManager - Add SceneRenderer to RenderPipeline - Add ElementRenderer to RenderPipeline - Other adaptations * Scene framework changes - Remove LevelScene - Add InGame Scene * Scenes added - Implement Level Overview Scene - Implement GameOver Scene * Left and SoundButton added * Put Sound and Music Buttons to the right places --------- Co-authored-by: Kitt3120 <torben@schweren.dev>
- Loading branch information
1 parent
1244438
commit e2499e7
Showing
9 changed files
with
406 additions
and
28 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
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
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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import Texture from "../../engine/assets/texture/texture.js"; | ||
import Services from "../../engine/dependencyinjection/services.js"; | ||
import MouseClickEvent from "../../engine/event/events/mouseclickevent/mouseclickevent.js"; | ||
import LevelManager from "../../engine/level/levelmanager.js"; | ||
import Button from "../../engine/scene/elements/button.js"; | ||
import CheckBox from "../../engine/scene/elements/checkbox.js"; | ||
import Scene from "../../engine/scene/scene.js"; | ||
import SceneManager from "../../engine/scene/scenemanager.js"; | ||
|
||
class Base extends Scene { | ||
private _soundCheckBox: CheckBox; | ||
private _musicCheckBox: CheckBox; | ||
|
||
protected get soundCheckBox(): CheckBox { | ||
return this._soundCheckBox; | ||
} | ||
|
||
protected get musicCheckBox(): CheckBox { | ||
return this._musicCheckBox; | ||
} | ||
|
||
public constructor( | ||
background: string | CanvasGradient | CanvasPattern | Texture | ||
) { | ||
super(background); | ||
|
||
this._soundCheckBox = new CheckBox( | ||
375, | ||
0, | ||
50, | ||
50, | ||
"rgba(0, 0, 0, 0)", | ||
"rgba(0, 255, 0, 0.5)", | ||
"rgba(255, 255, 255, 0.25)", | ||
"rgba(0, 255, 0, 0.25)", | ||
"white", | ||
"white", | ||
"white", | ||
"white", | ||
"black", | ||
"black", | ||
"black", | ||
"black", | ||
1, | ||
"bold 20px Arial", | ||
"center", | ||
"middle", | ||
"⛔", | ||
"🔊", | ||
true, | ||
true | ||
); | ||
|
||
this._musicCheckBox = new CheckBox( | ||
450, | ||
0, | ||
50, | ||
50, | ||
"rgba(0, 0, 0, 0)", | ||
"rgba(0, 255, 0, 0.5)", | ||
"rgba(255, 255, 255, 0.25)", | ||
"rgba(0, 255, 0, 0.25)", | ||
"white", | ||
"white", | ||
"white", | ||
"white", | ||
"black", | ||
"black", | ||
"black", | ||
"black", | ||
1, | ||
"bold 20px Arial", | ||
"center", | ||
"middle", | ||
"⛔", | ||
"🎵", | ||
true, | ||
true | ||
); | ||
|
||
this._soundCheckBox.onClick = () => { | ||
this._soundCheckBox.toggle(); | ||
console.log("Sound: " + this._soundCheckBox.checked); | ||
}; | ||
|
||
this._musicCheckBox.onClick = () => { | ||
this._musicCheckBox.toggle(); | ||
console.log("Music: " + this._musicCheckBox.checked); | ||
}; | ||
|
||
this.addElement(this._soundCheckBox); | ||
this.addElement(this._musicCheckBox); | ||
} | ||
} | ||
|
||
export default Base; |
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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import AssetManager from "../../engine/assets/assetmanager.js"; | ||
import Services from "../../engine/dependencyinjection/services.js"; | ||
import MouseClickEvent from "../../engine/event/events/mouseclickevent/mouseclickevent.js"; | ||
import Game from "../../engine/game.js"; | ||
import LevelManager from "../../engine/level/levelmanager.js"; | ||
import Vector2D from "../../engine/math/vector2d.js"; | ||
import Button from "../../engine/scene/elements/button.js"; | ||
import Text from "../../engine/scene/elements/text.js"; | ||
import Scene from "../../engine/scene/scene.js"; | ||
import SceneManager from "../../engine/scene/scenemanager.js"; | ||
import Base from "./base.js"; | ||
|
||
class GameOver extends Base { | ||
private _buttonLevelOverview: any; | ||
private _backToMainMenu: Button; | ||
private _runAgain: Button; | ||
|
||
public constructor() { | ||
super( | ||
Services.resolve<AssetManager>("AssetManager").getTexture( | ||
"level1-background" | ||
) | ||
); | ||
|
||
this.musicCheckBox.location = new Vector2D(450, 500); | ||
this.soundCheckBox.location = new Vector2D(300, 500); | ||
|
||
let title = new Text( | ||
400, | ||
100, | ||
"yellow", | ||
"bolder 50px Arial", | ||
"center", | ||
"middle", | ||
"Game Finished!", | ||
true | ||
); | ||
this._runAgain = new Button( | ||
250, | ||
200, | ||
300, | ||
50, | ||
"rgba(0, 0, 0, 0.5)", | ||
"white", | ||
"white", | ||
"black", | ||
"white", | ||
"green", | ||
1, | ||
"bold 20px Arial", | ||
"center", | ||
"middle", | ||
"Run Again", | ||
true | ||
); | ||
|
||
this._runAgain.onClick = (mouseClickEvent: MouseClickEvent) => { | ||
Services.resolve<SceneManager>("SceneManager").switchScene("ingame"); | ||
Services.resolve<LevelManager>("LevelManager").start("level1"); | ||
}; | ||
|
||
this._backToMainMenu = new Button( | ||
250, | ||
300, | ||
300, | ||
50, | ||
"rgba(0, 0, 0, 0.5)", | ||
"white", | ||
"white", | ||
"black", | ||
"white", | ||
"green", | ||
1, | ||
"bold 20px Arial", | ||
"center", | ||
"middle", | ||
"Back to Main Menu", | ||
true | ||
); | ||
|
||
this._backToMainMenu.onClick = (mouseClickEvent: MouseClickEvent) => { | ||
Services.resolve<SceneManager>("SceneManager").switchScene("mainmenu"); | ||
}; | ||
|
||
this._buttonLevelOverview = new Button( | ||
250, | ||
400, | ||
300, | ||
50, | ||
"rgba(0, 0, 0, 0.5)", | ||
"white", | ||
"white", | ||
"black", | ||
"white", | ||
"green", | ||
1, | ||
"bold 20px Arial", | ||
"center", | ||
"middle", | ||
"Level Overview", | ||
true | ||
); | ||
|
||
this._buttonLevelOverview.onClick = (mouseClickEvent: MouseClickEvent) => { | ||
Services.resolve<SceneManager>("SceneManager").switchScene( | ||
"leveloverview" | ||
); | ||
}; | ||
|
||
this.addElement(title); | ||
this.addElement(this._runAgain); | ||
this.addElement(this._backToMainMenu); | ||
this.addElement(this._buttonLevelOverview); | ||
} | ||
} | ||
|
||
export default GameOver; |
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.