-
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
1 parent
2526684
commit 1a9f395
Showing
12 changed files
with
154 additions
and
23 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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,81 @@ | ||
package com.boomchess.game.frontend.actor; | ||
|
||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.g2d.Batch; | ||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | ||
import com.badlogic.gdx.math.Vector2; | ||
import com.badlogic.gdx.scenes.scene2d.Actor; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Stack; | ||
import com.boomchess.game.BoomChess; | ||
import com.boomchess.game.backend.Board; | ||
import com.boomchess.game.backend.Coordinates; | ||
import com.boomchess.game.backend.Soldier; | ||
import com.boomchess.game.frontend.interfaces.makeASoundInterface; | ||
import com.boomchess.game.frontend.stage.MenuStage; | ||
|
||
import static com.boomchess.game.BoomChess.*; | ||
|
||
public class Bubble extends Actor { | ||
/* | ||
This class holds functions to create objects that hold the speech bubbles, it self destructs after 2 seconds | ||
*/ | ||
|
||
// px coords | ||
private float X; | ||
private float Y; | ||
// elapsed time since addition to stage | ||
private float elapsed = 0; | ||
// this is the maximum duration that the bubble will be on the screen | ||
private static final float MAX_DURATION = 2f; | ||
// this is the stack of the bubble | ||
private Stack stack; | ||
|
||
public Bubble(Stack stack, float X, float Y){ | ||
/* | ||
This function creates a Stack object that holds the speech bubble that says "Attack in Progress!" | ||
*/ | ||
this.stack = stack; | ||
this.X = X; | ||
this.Y = Y; | ||
} | ||
|
||
@Override | ||
public void act(float delta) { | ||
/* | ||
* this method is called every frame to update the Bubbles Object and overrides the standard act method | ||
* so that the Bubble will be removed after a certain amount of time | ||
*/ | ||
|
||
// this ensures that if the player has gone back to the menu, the sequence will not continue | ||
if (BoomChess.currentStage instanceof MenuStage){ | ||
remove(); // This will remove the actor from the stage | ||
return; | ||
} | ||
|
||
super.act(delta); | ||
elapsed += delta; | ||
if (elapsed > MAX_DURATION) { | ||
remove(); // This will remove the actor from the stage | ||
} | ||
} | ||
|
||
// Override the draw method to add the stack at the correct position | ||
@Override | ||
public void draw(Batch batch, float parentAlpha) { | ||
/* | ||
This method is called every frame to draw the bubble | ||
*/ | ||
super.draw(batch, parentAlpha); | ||
stack.setPosition(X, Y); | ||
stack.draw(batch, parentAlpha); | ||
} | ||
|
||
public void makeSound(){ | ||
// plays some cool sounds | ||
|
||
speechSounds.play(soundVolume); | ||
|
||
// TODO add some more sounds | ||
} | ||
|
||
} |
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