Skip to content

Commit

Permalink
Added assetmanager usage, loading and splash screens, waiting time du…
Browse files Browse the repository at this point in the history
…ring introduction and before kickoff
  • Loading branch information
ssenegas committed May 23, 2020
1 parent c09b758 commit c7e4838
Show file tree
Hide file tree
Showing 26 changed files with 326 additions and 103 deletions.
Binary file added android/assets/sounds/bounce.ogg
Binary file not shown.
Binary file added android/assets/sounds/dribble.ogg
Binary file not shown.
Binary file added android/assets/sounds/foul.ogg
Binary file not shown.
Binary file added android/assets/sounds/foulcrowd.ogg
Binary file not shown.
Binary file added android/assets/sounds/passe.ogg
Binary file not shown.
Binary file added android/assets/sounds/penalty.ogg
Binary file not shown.
Binary file added android/assets/sounds/shot.ogg
Binary file not shown.
Binary file added android/assets/sounds/woodwork.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion core/src/com/senegas/kickoff/KickOff.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class KickOff extends Game {

public static String TITLE = "Open Kick Off";
public static String VERSION = "0.3.7";
public static String VERSION = "0.4";
public static int APP_DESKTOP_WIDTH = 1280;
public static int APP_DESKTOP_HEIGHT = 800;

Expand Down
16 changes: 12 additions & 4 deletions core/src/com/senegas/kickoff/entities/Ball.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.senegas.kickoff.entities;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector3;
import com.senegas.kickoff.KickOff;

/**
* Ball entity class
Expand Down Expand Up @@ -60,16 +61,20 @@ public class Ball extends Entity {
private float speed = 0;
private Player owner = null;
private Vector3 lastPosition;
private Sound bounce;

/**
* Constructor
*
* @param app
* @param position position of the ball
*/
public Ball(Vector3 position) {
super(new Texture("entities/ball.png"), position);
public Ball(KickOff app, Vector3 position) {
super(app.assets.get("entities/ball.png"), position);
this.frames = TextureRegion.split(this.texture, SPRITE_WIDTH, SPRITE_HEIGHT);
this.lastPosition = new Vector3(getPosition());

this.bounce = app.assets.get("sounds/bounce.ogg");
}

/**
Expand Down Expand Up @@ -155,6 +160,10 @@ public void update(float deltaTime) {
this.velocity.z = -this.velocity.z;
this.position.z += this.velocity.z;

if (this.velocity.z > 0.9f) {
this.bounce.play(0.2f);
}

this.velocity.z -= this.velocity.z / 4;
this.velocity.x -= this.velocity.x / 32;
this.velocity.y -= this.velocity.y / 32;
Expand Down Expand Up @@ -196,7 +205,6 @@ public void trap(Player player) { //!Reimp move to player class
}

public void dispose() {
this.texture.dispose();
}
}

9 changes: 4 additions & 5 deletions core/src/com/senegas/kickoff/entities/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
import com.senegas.kickoff.entities.Player.Direction;
import com.senegas.kickoff.screens.Match;
import com.senegas.kickoff.screens.MatchScreen;
import com.senegas.kickoff.tactics.Tactic;
import com.senegas.kickoff.tactics.Tactic424;

Expand All @@ -22,7 +22,7 @@
*/
public class Team implements Disposable {
private Tactic tactic;
private Match match;
private MatchScreen match;
private String name;
private Direction direction;
private Color mainColor;
Expand All @@ -36,13 +36,13 @@ public class Team implements Disposable {
* @param name the team name
* @param direction the team's direction
*/
public Team(Match match, String name, Direction direction) {
public Team(MatchScreen match, String name, Direction direction) {
this.tactic = new Tactic424(this);
this.match = match;
this.name = name;
this.direction = direction;
this.mainColor = (direction == Direction.NORTH ? new Color(Color.RED) : new Color(Color.BLUE));
this.texture = (direction == Direction.NORTH ? new Texture("entities/style1a.png") : new Texture("entities/style1b.png"));
this.texture = (direction == Direction.NORTH ? this.match.getApp().assets.get("entities/style1a.png") : this.match.getApp().assets.get("entities/style1b.png"));

createPlayers();
setupIntroduction();
Expand Down Expand Up @@ -183,7 +183,6 @@ public void dispose() {
for (Player player : this.players) {
player.dispose();
}
this.texture.dispose();
this.tactic.dispose();
}
}
18 changes: 12 additions & 6 deletions core/src/com/senegas/kickoff/managers/GameScreenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.senegas.kickoff.KickOff;
import com.senegas.kickoff.screens.AbstractScreen;
import com.senegas.kickoff.screens.MainMenu;
import com.senegas.kickoff.screens.Match;
import com.senegas.kickoff.screens.LoadingScreen;
import com.senegas.kickoff.screens.MainMenuScreen;
import com.senegas.kickoff.screens.MatchScreen;
import com.senegas.kickoff.screens.SplashScreen;

import java.util.HashMap;

Expand All @@ -16,20 +18,24 @@ public class GameScreenManager {
public enum STATE {
MAIN_MENU,
PLAY,
LOADING,
SPLASH,
SETTINGS
}

public GameScreenManager(KickOff app) {
this.app = app;

initGameScreens();
setScreen(STATE.MAIN_MENU);
setScreen(STATE.LOADING);
}

private void initGameScreens() {
this.gameScreens = new HashMap<>();
this.gameScreens.put(STATE.MAIN_MENU, new MainMenu(this.app));
this.gameScreens.put(STATE.PLAY, new Match(this.app));
this.gameScreens.put(STATE.LOADING, new LoadingScreen(this.app));
this.gameScreens.put(STATE.SPLASH, new SplashScreen(this.app));
this.gameScreens.put(STATE.MAIN_MENU, new MainMenuScreen(this.app));
this.gameScreens.put(STATE.PLAY, new MatchScreen(this.app));
}

public void setScreen(STATE nextScreen) {
Expand All @@ -38,7 +44,7 @@ public void setScreen(STATE nextScreen) {

public void dispose() {
for (AbstractScreen screen : this.gameScreens.values()) {
if (screen != null){
if (screen != null) {
screen.dispose();
}
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/com/senegas/kickoff/pitches/ArtificialPitch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;

public class ArtificialPitch extends Pitch {

public ArtificialPitch() {
super("pitches/synthetic.tmx", 0.975f );
public ArtificialPitch(KickOff app) {
super(app, "pitches/synthetic.tmx", 0.975f);
}

}
6 changes: 4 additions & 2 deletions core/src/com/senegas/kickoff/pitches/ClassicPitch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;

public class ClassicPitch extends Pitch {

public ClassicPitch() {
super("pitches/classic.tmx", 0.975f );
public ClassicPitch(KickOff app) {
super(app, "pitches/classic.tmx", 0.975f);
}

}
10 changes: 5 additions & 5 deletions core/src/com/senegas/kickoff/pitches/Pitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Disposable;
import com.senegas.kickoff.KickOff;
import com.senegas.kickoff.entities.Ball;

import static com.badlogic.gdx.math.Intersector.intersectSegments;
Expand Down Expand Up @@ -42,12 +42,12 @@ public enum Type {

/**
* Constructor
* @param fileName the tile map file name
* @param tmxMap the tile map file name
* @param friction the friction coefficient
*/
public Pitch(String fileName, float friction) {
Gdx.app.log("Pitch", "Load tile map " + fileName);
this.tiledMap = new TmxMapLoader().load(fileName);
public Pitch(KickOff app, String tmxMap, float friction) {
Gdx.app.log("Pitch", "Load tile map " + tmxMap);
this.tiledMap = app.assets.get(tmxMap);
this.friction = friction;
this.lastIntersection = new Vector2();
}
Expand Down
21 changes: 14 additions & 7 deletions core/src/com/senegas/kickoff/pitches/PitchFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;
import com.senegas.kickoff.pitches.Pitch.Type;

public class PitchFactory {
Expand All @@ -18,16 +19,22 @@ public static PitchFactory getInstance() {
* @param pitchType
* @return a pitch
*/
public Pitch make(Type pitchType)
public Pitch make(KickOff app, Type pitchType)
{
switch( pitchType )
{
case CLASSIC: return new ClassicPitch();
case WET: return new WetPitch();
case SOGGY: return new SoggyPitch();
case ARTIFICIAL: return new ArtificialPitch();
case PLAYERMANAGER: return new PlayerManagerPitch();
default: return new ClassicPitch();
case CLASSIC:
return new ClassicPitch(app);
case WET:
return new WetPitch(app);
case SOGGY:
return new SoggyPitch(app);
case ARTIFICIAL:
return new ArtificialPitch(app);
case PLAYERMANAGER:
return new PlayerManagerPitch(app);
default:
return new ClassicPitch(app);
}
}
}
6 changes: 4 additions & 2 deletions core/src/com/senegas/kickoff/pitches/PlayerManagerPitch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;

public class PlayerManagerPitch extends Pitch {

public PlayerManagerPitch() {
super("pitches/playermanager.tmx", 0.975f );
public PlayerManagerPitch(KickOff app) {
super(app, "pitches/playermanager.tmx", 0.975f);
}

}
6 changes: 3 additions & 3 deletions core/src/com/senegas/kickoff/pitches/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.badlogic.gdx.math.Vector2;
import com.senegas.kickoff.KickOff;
import com.senegas.kickoff.entities.Player;
import com.senegas.kickoff.screens.Match;
import com.senegas.kickoff.screens.MatchScreen;

import static com.senegas.kickoff.pitches.FootballDimensionConstants.GOAL_AREA_HEIGHT_IN_PX;
import static com.senegas.kickoff.pitches.FootballDimensionConstants.HALF_GOAL_AREA_WIDTH_IN_PX;
Expand Down Expand Up @@ -39,13 +39,13 @@ public class Scanner {
private boolean defaultMode;
private boolean withBackground;
private Vector2 origin;
private Match match;
private MatchScreen match;

/**
* Constructor
* @param match the match
*/
public Scanner(Match match) {
public Scanner(MatchScreen match) {
this.match = match;
this.isVisible = true;
this.zoomFactor = 3;
Expand Down
8 changes: 5 additions & 3 deletions core/src/com/senegas/kickoff/pitches/SoggyPitch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;

public class SoggyPitch extends Pitch {
public SoggyPitch() {
super("pitches/soggy.tmx", 1.125f );

public SoggyPitch(KickOff app) {
super(app, "pitches/soggy.tmx", 1.125f);
}

}
6 changes: 4 additions & 2 deletions core/src/com/senegas/kickoff/pitches/WetPitch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.senegas.kickoff.pitches;

import com.senegas.kickoff.KickOff;

public class WetPitch extends Pitch {

public WetPitch() {
super("pitches/wet.tmx", 0.775f );
public WetPitch(KickOff app) {
super(app, "pitches/wet.tmx", 0.775f);
}

}
6 changes: 3 additions & 3 deletions core/src/com/senegas/kickoff/scenes/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.senegas.kickoff.screens.Match;
import com.senegas.kickoff.screens.MatchScreen;

public class Hud implements Disposable {
public Stage stage;
Expand All @@ -22,9 +22,9 @@ public class Hud implements Disposable {
private Label timerLabel;
private Label scoreLabel;

private Match match;
private MatchScreen match;

public Hud(Match match) {
public Hud(MatchScreen match) {
this.match = match;

this.timeCount = 3 * 60;
Expand Down
Loading

0 comments on commit c7e4838

Please sign in to comment.