-
Notifications
You must be signed in to change notification settings - Fork 4
Main Menu Button Code
the making of a button on the main menu, its listeners, event triggers, initialization and everything that makes a main menu accessible.
- listeners:
the listeners for events that trigger specific function which in turn cause a speicif case to occus and the appropriate screen to be set accordingly.
@Override
public void create() {
entity.getEvents().addListener("start", this::onStart);
entity.getEvents().addListener("load", this::onLoad);
entity.getEvents().addListener("exit", this::onExit);
entity.getEvents().addListener("settings", this::onSettings);
entity.getEvents().addListener("gameOver", this::onGameOver);
//Team History Score board
entity.getEvents().addListener("displayPropsShop", this::onDisplayPropsShop);
entity.getEvents().addListener("displayHistoryScores", this::onDisplayHistoryScores);
entity.getEvents().addListener("achievements", this::onAchievements);
entity.getEvents().addListener("unlockedAttires", this::onUnlockedAttires);
entity.getEvents().addListener("monsterMenu", this::onDisplayMonsterMenu);
entity.getEvents().addListener("buffMenu", this::onDisplayBuffManualMenu);
entity.getEvents().addListener("GameTutorial", this::onDisplayInstructions);
}
}
/**
* Swaps to the Main Game screen.
*/
private void onStart() {
logger.info("Start game");
game.setScreen(GdxGame.ScreenType.MAIN_GAME);
}
/**
* Intended for loading a saved game state.
* Load functionality is not actually implemented.
*/
private void onLoad() {
logger.info("Load game");
}
/**
* Exits the game.
*/
private void onExit() {
logger.info("Exit game");
game.exit();
}
/**
* Swaps to the Settings screen.
*/
private void onSettings() {
logger.info("Launching settings screen");
game.setScreen(GdxGame.ScreenType.SETTINGS);
}
/**
* Swaps to the GameOver screen.
*/
private void onGameOver() {
logger.info("Launching GameOver screen");
game.setScreen(GdxGame.ScreenType.GAME_OVER);
}
private void onDisplayPropsShop() {
logger.info("Open the propsShop");
game.setScreen(GdxGame.ScreenType.PROPS_SHOP);
}
private void onDisplayHistoryScores() {
logger.info("Open the history scores board");
game.setScreen(GdxGame.ScreenType.HISTORY_SCORES);
}
private void onAchievements(){
logger.info("Launching Achievements screen");
game.setScreen(GdxGame.ScreenType.ACHIEVEMENTS);
}
private void onUnlockedAttires(){
logger.info("Launching Unlocked Attires screen");
game.setScreen(GdxGame.ScreenType.UNLOCKED_ATTIRES);
}
private void onDisplayMonsterMenu() {
//logger.info("Open the history scores board");
game.setScreen(GdxGame.ScreenType.MONSTER_MENU);
}
private void onDisplayBuffManualMenu() {
game.setScreen(GdxGame.ScreenType.BUFF_MENU);
}
private void onDisplayInstructions() {
System.out.println("check 1");
game.setScreen(GdxGame.ScreenType.INSTRUCTIONS);
}
- initializing a button :
making the button, giving it texture, adding it to the table to put it on the main menu list or in a specific position depending on the button
/** build new start button */
Button.ButtonStyle start = new Button.ButtonStyle();
start.up= new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/start1.png"))));
start.over= new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/start2.png"))));
Button startBtn = new Button(start);
/** build select unlocked attire button */
Button.ButtonStyle attires = new Button.ButtonStyle();
attires.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/select1.png"))));
attires.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/select2.png"))));
Button attiresBtn = new Button(attires);
/** build new setting button */
Button.ButtonStyle setting = new Button.ButtonStyle();
setting.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/setting1.png"))));
setting.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/setting2.png"))));
Button settingBtn = new Button(setting);
/** build new exit button */
Button.ButtonStyle exit = new Button.ButtonStyle();
exit.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/exit1.png"))));
exit.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/exit2.png"))));
Button exitBtn = new Button(exit);
/** build new prop shop button */
Button.ButtonStyle propShop = new Button.ButtonStyle();
propShop.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/shop1.png"))));
propShop.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/shop2.png"))));
Button shopBtn = new Button(propShop);
shopBtn.setPosition(820,650);
/** build new score button */
Button.ButtonStyle score = new Button.ButtonStyle();
score.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/score1.png"))));
score.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/score2.png"))));
Button scoreBtn = new Button(score);
scoreBtn.setPosition(960,685);
/** build new achievement button */
Button.ButtonStyle achievement = new Button.ButtonStyle();
achievement.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/achievement1.png"))));
achievement.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/achievement2.png"))));
Button achievementBtn = new Button(achievement);
achievementBtn.setPosition(1100,682);
/** build new monster button */
Button.ButtonStyle monster = new Button.ButtonStyle();
monster.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/monster1.png"))));
monster.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/monster2.png"))));
Button monsterBtn = new Button(monster);
monsterBtn.setPosition(1120,40);
Button.ButtonStyle buff = new Button.ButtonStyle();
buff.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/buff1.png"))));
buff.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/buff2.png"))));
Button buffBtn = new Button(buff);
buffBtn.setPosition(1120,170);
Button.ButtonStyle tutorial = new Button.ButtonStyle();
tutorial.up = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/tutorial1.png"))));
tutorial.over = new TextureRegionDrawable(new TextureRegion(
new Texture(Gdx.files.internal("button/tutorial2.png"))));
Button tutorialBtn = new Button(tutorial);
- assigning screens to each case:
depending on what button has been clicked an what event has occurred there will be an associated screen that we're taken to depending on the case that event and hence that event was associated to
private void switchScreen(GdxGame game, ScreenType screenType) {
game.setScreen(screenType);
}
public enum ScreenType {
MAIN_MENU, MAIN_GAME, SETTINGS, GAME_OVER, PROPS_SHOP, HISTORY_SCORES,
ACHIEVEMENTS,MONSTER_MENU, UNLOCKED_ATTIRES,BUFF_MENU, INSTRUCTIONS
}
@Override
public void create() {
logger.info("Creating game");
loadSettings();
// Sets background to light yellow
Gdx.gl.glClearColor(248f / 255f, 249 / 255f, 178 / 255f, 1);
setScreen(ScreenType.MAIN_MENU);
}
/**
* Loads the game's settings.
*/
private void loadSettings() {
logger.debug("Loading game settings");
UserSettings.Settings settings = UserSettings.get();
UserSettings.applySettings(settings);
}
/**
* Sets the game's screen to a new screen of the provided type.
*
* @param screenType screen type
*/
public void setScreen(ScreenType screenType) {
logger.info("Setting game screen to {}", screenType);
Screen currentScreen = getScreen();
if (currentScreen != null) {
currentScreen.dispose();
}
setScreen(newScreen(screenType));
}
@Override
public void dispose() {
logger.debug("Disposing of current screen");
getScreen().dispose();
}
/**
* Create a new screen of the provided type.
*
* @param screenType screen type
* @return new screen
*/
private Screen newScreen(ScreenType screenType) {
switch (screenType) {
case MAIN_MENU:
return new MainMenuScreen(this);
case MAIN_GAME:
return new MainGameScreen(this);
case SETTINGS:
return new SettingsScreen(this);
case GAME_OVER:
return new GameOverScreen(this);
case PROPS_SHOP:
return new PropsShopScreen(this);
case HISTORY_SCORES:
return new HistoryScoreScreen(this);
case ACHIEVEMENTS:
return new AchievementsScreen(this);
case UNLOCKED_ATTIRES:
return new UnlockedAttiresScreen(this);
case MONSTER_MENU:
return new MonsterMenuScreen(this);
case BUFF_MENU:
return new BuffManualMenuScreen(this);
case INSTRUCTIONS:
return new InstructionsScreen(this);
default:
return null;
}
}
/**
* Exit the game.
*/
public void exit() {
app.exit();
}
}
Camera Angle and The Player's Perspective
Achievements Trophies and Cards
πΎ Obstacle/Enemy
βMonster Manual
βObstacles/Enemies
ββ- Alien Plants
ββ- Variation thorns
ββ- Falling Meteorites
ββ- FaceHugger
ββ- AlienMonkey
βSpaceship & Map Entry
βParticle effect
[code for debuff animations](code for debuff animations)
Main Character Movement, Interactions and Animations - Code Guidelines
ItemBar & Recycle system
πΎ Obstacle/Enemy
βObstacle/Enemy
βMonster Manual
βSpaceship Boss
βParticle effects
βOther Related Code
βUML & Sequence diagram of enemies/obstacles
Scoring System Implementation Explanation
Buff and Debuff Implementation
Infinite generating terrains Implementation Explanation
Game Over Screen and functions explaination
Buffer timer before game start
Rocks and woods layout optimization
Magma and nails code implementation
Guide: Adding Background music for a particular screen
History Scoreboard - Score Details
Listening for important events in the Achievements ecosystem
Hunger and Thirst icon code guidelines
Hunger and Thirst User Testing
Buff and Debuff Manual User Testing
The New Button User Test in Setting Page
The Main Menu Buttons User Testing
Infinite loop game and Terrain Testing
https://github.com/UQdeco2800/2021-ext-studio-2.wiki.git
πΎ Obstacle/Enemy
βObstacle testing
ββ- Alien Plants & Variation Thorns
ββ- Falling Meteorites
βEnemy testing
ββ- Alien Monkeys & Facehugger
ββ- Spaceship Boss
βMonster Manual
βParticle-effect
βPlayer attack testing
ββ- Player Attack
Sprint 1
Sprint 2
Sprint 3
Sprint 4
Changeable background & Buffer time testing
Game over screen test sprint 4
New terrain textures on bonus map test sprint 4
Achievements System, Game Records and Unlockable Chapters
Musics Implementation Testing plan