Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into SaveManagerAttempt3
Browse files Browse the repository at this point in the history
  • Loading branch information
uoy-jb2501 committed May 2, 2022
2 parents 8fffcdd + 311290a commit f00c7fb
Show file tree
Hide file tree
Showing 11 changed files with 418 additions and 43 deletions.
5 changes: 5 additions & 0 deletions core/assets/audio/music/credits-attibution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Title: Wings Of Liberty
By: EvgenyBardyuzha
Website: https://pixabay.com/

Music was listed under Royalty Free
Binary file added core/assets/audio/music/credits.mp3
Binary file not shown.
Binary file added core/assets/mario/shard-software-logo4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions core/assets/ui/credits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-= Developers =-

-= Assessment 2 =-
-= Team 29 "Shard Software" =-
James Burnell
Hector Woods
Ben Faulkner

-= Assessment 1 =-
-= Team 28 "Mario" =-
Annabeth Singleton
Joseph Frankland
Leif Kemp
Hugo Kwok
Saj Hoque
Lucy Li


-= Website =-
www.mario.shardsoftware.tk

Jensen Bradshaw
James Burnell


-= Audio =-

Powerup SoundFX by 15.ai
Based on characters from "TF2"

Credits Music - "Wings Of Liberty"
By EvgenyBardyuzha
pixabay.com



-= Graphics =-
Original Assets By

Annabeth Singleton
Leif Kemp
James Burnell


-= Shard Software Logo =-

James Burnell


-= Software Used =-

libGDX - Java Game Engine
Blender - Shard Software Logo
Eclipse & IntelliJ - Code Development
Audacity - Audio Development







Produced For The University of York
As Part of Engineering 1






149 changes: 149 additions & 0 deletions core/src/main/java/io/github/annabeths/GameScreens/CreditScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package io.github.annabeths.GameScreens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FillViewport;

import io.github.annabeths.GeneralControl.ResourceManager;
import io.github.annabeths.GeneralControl.eng1game;

/**
* A screen to display credits for the game
*
* @since Assessment 2
* @author James Burnell
*/
public class CreditScreen implements Screen {

private eng1game game;
private String creditText;
/** How fast the credits scroll in px/sec */
private float scrollSpeed = 100;

public Stage stage;
public LabelStyle lblStyle;
public Label label;
public Image shardLogo;
public Image marioLogo;

public Music music;
/** How long the music will fade out in seconds */
public static final float MUSIC_FADE_TIME = 4f;

public CreditScreen(eng1game game) {
this.game = game;

creditText = Gdx.files.internal("ui/credits.txt").readString();

lblStyle = new LabelStyle();
lblStyle.font = ResourceManager.debugFont;
lblStyle.fontColor = Color.WHITE;

music = Gdx.audio.newMusic(Gdx.files.internal("audio/music/credits.mp3"));

label = new Label(creditText, lblStyle);
label.setAlignment(Align.center);
label.setFontScale(1f);
label.setHeight(label.getPrefHeight());
label.setPosition(0, -label.getPrefHeight() - 100);

shardLogo = new Image(ResourceManager.getTexture("mario/shard-software-logo4.png"));
shardLogo.setScale(0.5f);

marioLogo = new Image(ResourceManager.getTexture("mario/full.png"));
}

@Override
public void show() {
stage = new Stage(new FillViewport(1280, 720));

label.setWidth(stage.getWidth());
stage.addActor(label);

shardLogo.setPosition((stage.getWidth() - shardLogo.getWidth() * 0.5f) / 2,
label.getY() - shardLogo.getHeight() * 0.5f);
stage.addActor(shardLogo);

marioLogo.setPosition((stage.getWidth() - marioLogo.getWidth()) / 2,
shardLogo.getY() - marioLogo.getHeight());
stage.addActor(marioLogo);

music.play();
}

@Override
public void render(float delta) {
ScreenUtils.clear(Color.BLACK);

// skip credits
if (Gdx.input.isKeyJustPressed(Keys.ESCAPE)) {
returnToMenu();
}

// scroll text and images up
float scrollAmount = scrollSpeed * delta;
label.moveBy(0, scrollAmount);
shardLogo.moveBy(0, scrollAmount);
marioLogo.moveBy(0, scrollAmount);

// go to the menu if the credits are over
if (marioLogo.getY(Align.bottom) > stage.getHeight()) {
returnToMenu();
}

music.setVolume(MathUtils.clamp(timeLeft() / MUSIC_FADE_TIME, 0, 1));

stage.draw();
}

public void returnToMenu() {
game.gotoScreen(Screens.menuScreen);
music.stop();
music.dispose();
}

/**
* How long is left in the credits before they end
*
* @return the time left in seconds
*/
public float timeLeft() {
return (stage.getHeight() - marioLogo.getY(Align.bottom)) / scrollSpeed;
}

@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
}

@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void hide() {

}

@Override
public void dispose() {

}

}
35 changes: 27 additions & 8 deletions core/src/main/java/io/github/annabeths/GameScreens/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ public Menu(eng1game g) {
*/
@Override
public void show() {
batch = new SpriteBatch();
// layouts can be used to manage text to allow it to be centered
menuTextLayout = new GlyphLayout();
menuTextLayout.setText(font,
"press ENTER to PLAY\npress I to toggle INSTRUCTIONS\npress ESCAPE to QUIT");
"press ENTER to PLAY\n"
+ "press I to toggle INSTRUCTIONS\n"
+ "press F for fullscreen\n"
+ "press C for credits\n"
+ "press ESCAPE to QUIT");
instructions = ResourceManager.getTexture("ui/instructions.png");
// create example HUD
hud = new HUD(GameController.getMockForHUD());
hud.Update(1f);
reset();
}

/**
Expand All @@ -75,8 +76,18 @@ public void render(float delta) {
} else {
toggleInstructions();
}
} else if (Gdx.input.isKeyJustPressed(Keys.ESCAPE)) {
Gdx.app.exit();
}
if (Gdx.input.isKeyJustPressed(Keys.ESCAPE)) {
if (showInstructions)
showInstructions = false;
else
Gdx.app.exit();
}
if (Gdx.input.isKeyJustPressed(Keys.C)) {
game.gotoScreen(Screens.credits);
}
if (Gdx.input.isKeyJustPressed(Keys.F)) {
game.setFullscreen();
}

// do draws
Expand All @@ -102,13 +113,22 @@ public void toggleInstructions() {
instructionsBeenShown = true;
}

/** Resets the menu graphics objects. Used for changing resolutions */
public void reset() {
batch = new SpriteBatch();
// create example HUD
hud = new HUD(GameController.getMockForHUD());
hud.Update(1f);
}

/**
* resize the window
* @param width new width
* @param height new height
*/
@Override
public void resize(int width, int height) {
reset();
}

@Override
Expand All @@ -125,7 +145,6 @@ public void hide() {

@Override
public void dispose() {

}

}
10 changes: 9 additions & 1 deletion core/src/main/java/io/github/annabeths/GameScreens/Screens.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@

/** Enum that represents all the screens the game can switch to */
public enum Screens {
splashScreen, menuScreen, gameScreen, gameOverScreen, gameWinScreen, gameDifScreen, saveLoadScreen, loadedGameScreen
splashScreen,
menuScreen,
gameScreen,
gameOverScreen,
gameWinScreen,
gameDifScreen,
saveLoadScreen,
loadedGameScreen,
credits
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public static void init(AssetManager assetMan) {
for (PowerupType p : PowerupType.values()) {
loadTexture(p.getTexture());
}
/* Other Textures */
loadTexture("mario/shard-software-logo4.png");
loadTexture("mario/full.png");

assets.finishLoading();
});
Expand Down
Loading

0 comments on commit f00c7fb

Please sign in to comment.