Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hampe committed Apr 17, 2014
2 parents 96329b8 + c7c2dea commit b450304
Show file tree
Hide file tree
Showing 37 changed files with 441 additions and 314 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>de.spareribsproduction.madn</groupId>
<artifactId>Mensch-aergere-dich-nicht</artifactId>
<version>0.0.3</version>
<version>1.0.1</version>
<packaging>jar</packaging>

<name>Maven Quick Start Archetype</name>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/de/spareripsproduction/madn/client/Game.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.spareripsproduction.madn.client;

import de.spareripsproduction.madn.client.scene.*;
import de.spareripsproduction.tinyengine.FontManager;
import de.spareripsproduction.tinyengine.graphics.RenderInterface;
import de.spareripsproduction.tinyengine.logic.Fps;
import de.spareripsproduction.tinyengine.logic.GitVersion;
Expand All @@ -15,7 +14,7 @@
*/
public class Game
extends de.spareripsproduction.tinyengine.Game
implements RenderInterface, UpdateInterface
implements RenderInterface, UpdateInterface

{
public static final String ENV_DEV = "dev";
Expand All @@ -27,7 +26,7 @@ public class Game

private Fps fps;

private HashMap<String,Scene> scenes;
private HashMap<String, Scene> scenes;

private Scene activeScene;

Expand All @@ -53,24 +52,24 @@ private Game(String environment) {
}

public static Game getInstance() {
if(Game.instance == null) {
if (Game.instance == null) {
Game.instance = new Game();
}
return Game.instance;
}

public static Game getInstance(String environment) {
if(Game.instance == null) {
if (Game.instance == null) {
Game.instance = new Game(environment);
}
return Game.instance;
}

public void render(Graphics2D context) {
this.activeScene.render(context);
if(this.environment.equals(Game.ENV_DEV)) {
if (this.environment.equals(Game.ENV_DEV)) {
this.fps.render(context);
this.version.render(context);
//this.version.render(context);
}

}
Expand All @@ -80,9 +79,9 @@ public void update() {
}

public boolean loadScene(String sceneName) {
if(this.scenes.containsKey(sceneName)) {
if (this.scenes.containsKey(sceneName)) {
// check for the first scene
if(this.activeScene != null) {
if (this.activeScene != null) {
this.activeScene.unload();
}
this.activeScene = this.scenes.get(sceneName);
Expand All @@ -100,8 +99,8 @@ private void initScenes() {
this.scenes.put(Scene.SCENE_INTRO, new IntroScene());
this.scenes.put(Scene.SCENE_MENU, new MenuScene());
this.scenes.put(Scene.SCENE_SCORE, new ScoreScene());
this.scenes.put(Scene.SCENE_SETTINGS,new SettingsScene());
this.scenes.put(Scene.SCENE_CREDITS,new CreditsScene());
this.scenes.put(Scene.SCENE_SETTINGS, new SettingsScene());
this.scenes.put(Scene.SCENE_CREDITS, new CreditsScene());
}

public Scene getScene(String sceneName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import de.spareripsproduction.madn.client.graphics.field.NormalField;
import de.spareripsproduction.madn.client.graphics.field.SpawnField;
import de.spareripsproduction.madn.client.graphics.figure.*;
import de.spareripsproduction.tinyengine.*;
import de.spareripsproduction.tinyengine.Timer;
import de.spareripsproduction.madn.client.logic.Dice;
import de.spareripsproduction.madn.client.logic.Player;
import de.spareripsproduction.madn.client.logic.Settings;
import de.spareripsproduction.tinyengine.FontManager;
import de.spareripsproduction.tinyengine.GameWindow;
import de.spareripsproduction.tinyengine.entity.Entity;
import de.spareripsproduction.tinyengine.gui.TELabel;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import de.spareripsproduction.madn.client.logic.*;
import de.spareripsproduction.tinyengine.input.Keyboard;
import java.util.ArrayList;

/**
* Created by marian on 12/03/14.
Expand All @@ -30,34 +31,32 @@ public class Board extends Entity implements RenderAndUpdateable {

private static Board instance;

private long last = Timer.getTime();
private TELabel gameLabelMensch;
private TELabel gameLabelAegere;
private TELabel gameLabelDich;
private TELabel gameLabelNicht;

public static Board getInstance() {
if(instance == null) {
instance = new Board(0,0);
if (instance == null) {
instance = new Board(0, 0);
}
return instance;
}

private boolean inBetween(int i, int min, int max) {
return i >= min && i <= max;
}

public Board(int x, int y) {
super("sprites/board.png", x, y);
// center the board
this.setLocation(GameWindow.getInstance().getWidth() / 2 - this.getWidth() / 2, GameWindow.getInstance().getHeight() / 2 - this.getHeight() / 2);

this.dice = new Dice(0,0);
this.dice = new Dice(0, 0);
this.dice.setX(GameWindow.getInstance().getWidth() / 2 - this.dice.getWidth() / 2);
this.dice.setY(GameWindow.getInstance().getHeight() / 2 - this.dice.getHeight() / 2);



this.fields = new ArrayList<Field>();
for(int i = 0; i < 40; i++ ) {
if(i%10 == 0) {
switch (i/10) {
for (int i = 0; i < 40; i++) {
if (i % 10 == 0) {
switch (i / 10) {
case 0:
this.fields.add(new SpawnField(SpawnField.SPRITE_RED, i));
break;
Expand All @@ -71,39 +70,64 @@ public Board(int x, int y) {
this.fields.add(new SpawnField(SpawnField.SPRITE_YELLOW, i));
break;
}
}else {
} else {
this.fields.add(new NormalField(i));
}
}
// home fields
String[] spirtes = {Field.SPRITE_RED, Field.SPRITE_BLUE, Field.SPRITE_GREEN, Field.SPRITE_YELLOW};
for(int i = 0; i < 4; i++) {
String spriteRef = spirtes[i];
for(int j = i*10+40;j < i*10+44; j++){
for (int i = 0; i < 4; i++) {
String spriteRef = spirtes[i];
for (int j = i * 10 + 40; j < i * 10 + 44; j++) {
this.fields.add(new HomeEntryField(spriteRef, j));
}
}
}


this.gameFigures = new ArrayList<GameFigure>();

for(int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {

this.gameFigures.add(new RedFigure(i));
this.gameFigures.add(new BlueFigure(i));
this.gameFigures.add(new GreenFigure(i));
this.gameFigures.add(new YellowFigure(i));
if (Settings.playerCount >= 3) this.gameFigures.add(new GreenFigure(i));
if (Settings.playerCount >= 4) this.gameFigures.add(new YellowFigure(i));
}

this.players = new ArrayList<Player>();
for(int i = 0; i < 4; i++) {
for (int i = 0; i < Settings.playerCount; i++) {
this.players.add(new Player(i));
}


Font titleFont = FontManager.getFont(FontManager.FONT_COMIC_NEUE_BOLD, 40);

int xLabel = getIntX() + (getIntWidth() - 11 * BoardEntity.FIELD_SIZE) / 2;
int yLabel = getIntY() + (getIntHeight() - 11 * BoardEntity.FIELD_SIZE) / 2;

this.gameLabelMensch = new TELabel("Mensch", xLabel, yLabel + 3 * BoardEntity.FIELD_SIZE - 10, titleFont);
this.gameLabelMensch.verticalAlignCenter(xLabel, xLabel + 4 * BoardEntity.FIELD_SIZE);

this.gameLabelAegere = new TELabel("ärgere", xLabel, yLabel + 3 * BoardEntity.FIELD_SIZE - 10, titleFont);
this.gameLabelAegere.verticalAlignCenter(xLabel + 7 * BoardEntity.FIELD_SIZE, xLabel + 11 * BoardEntity.FIELD_SIZE);

this.gameLabelDich = new TELabel("Dich", xLabel, yLabel + 7 * BoardEntity.FIELD_SIZE, titleFont);
this.gameLabelDich.verticalAlignCenter(xLabel, xLabel + 4 * BoardEntity.FIELD_SIZE);

this.gameLabelNicht = new TELabel("nicht", xLabel, yLabel + 7 * BoardEntity.FIELD_SIZE, titleFont);
this.gameLabelNicht.verticalAlignCenter(xLabel + 7 * BoardEntity.FIELD_SIZE, xLabel + 11 * BoardEntity.FIELD_SIZE);


}

@Override
public void update() {

gameLabelMensch.update();
gameLabelAegere.update();
gameLabelDich.update();
gameLabelNicht.update();

getActivePlayer().makeMove();

dice.update();
Expand All @@ -123,6 +147,11 @@ public void update() {
public void render(Graphics2D g) {
super.render(g);

gameLabelMensch.render(g);
gameLabelAegere.render(g);
gameLabelDich.render(g);
gameLabelNicht.render(g);

for (Player player : this.players) {
player.render(g);
}
Expand All @@ -146,8 +175,8 @@ public ArrayList<Player> getPlayers() {
}

public Player getActivePlayer() {
for(Player player : this.getPlayers()) {
if(player.isActive()) {
for (Player player : this.getPlayers()) {
if (player.isActive()) {
return player;
}
}
Expand All @@ -159,4 +188,6 @@ public Player getActivePlayer() {
public Dice getDice() {
return dice;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public BoardEntity(String spriteRef, int id) {
public float getX() {
Point p = getBoardPosition();
int width = (Board.getInstance().getIntWidth() - 11 * FIELD_SIZE) / 2;
return Board.getInstance().getIntX()+p.x*FIELD_SIZE + width;
return Board.getInstance().getIntX() + p.x * FIELD_SIZE + width;
}

@Override
public float getY() {
Point p = getBoardPosition();
int width = (Board.getInstance().getIntHeight() - 11 * FIELD_SIZE) / 2;
return Board.getInstance().getIntY()+p.y*FIELD_SIZE + width;
return Board.getInstance().getIntY() + p.y * FIELD_SIZE + width;
}

@Override
Expand All @@ -53,7 +53,7 @@ public void update() {
}

public Point getBoardPosition() {
if(boardPosition == null) {
if (boardPosition == null) {
boardPosition = updateBoardPosition();
}
return boardPosition;
Expand All @@ -69,53 +69,53 @@ public int getId() {
}

protected Point updateBoardPosition() {
int corner = id/10;
int positionInCorner = id - (10*corner);
int x = 0,y = 0;
int corner = id / 10;
int positionInCorner = id - (10 * corner);
int x = 0, y = 0;
switch (corner) {
case 0:
if(positionInCorner <= 4) {
if (positionInCorner <= 4) {
x = positionInCorner;
y = 4;
}else if(positionInCorner <= 8){
} else if (positionInCorner <= 8) {
x = 4;
y = 4-positionInCorner+4;
y = 4 - positionInCorner + 4;
} else {
x = 5;
y = 0;
}
break;
case 1:
if(positionInCorner <= 4) {
if (positionInCorner <= 4) {
x = 6;
y = positionInCorner;
}else if(positionInCorner <= 8){
x = 6+positionInCorner-4;
} else if (positionInCorner <= 8) {
x = 6 + positionInCorner - 4;
y = 4;
} else {
x = 10;
y = 5;
}
break;
case 2:
if(positionInCorner <= 4) {
x = 10-positionInCorner;
if (positionInCorner <= 4) {
x = 10 - positionInCorner;
y = 6;
}else if(positionInCorner <= 8){
} else if (positionInCorner <= 8) {
x = 6;
y = 6+positionInCorner-4;
y = 6 + positionInCorner - 4;
} else {
x = 5;
y = 10;
}

break;
case 3:
if(positionInCorner <= 4) {
if (positionInCorner <= 4) {
x = 4;
y = 10 - positionInCorner;
}else if(positionInCorner <= 8) {
x = 4 - positionInCorner +4;
} else if (positionInCorner <= 8) {
x = 4 - positionInCorner + 4;
y = 6;
} else {
x = 0;
Expand All @@ -124,14 +124,14 @@ protected Point updateBoardPosition() {
break;
case 4:
//home fields blue
x = positionInCorner+1;
x = positionInCorner + 1;
y = 5;
break;

case 5:
//home fields red
x = 5;
y = positionInCorner+1;
y = positionInCorner + 1;
break;
case 6:
//home fields green
Expand All @@ -146,7 +146,7 @@ protected Point updateBoardPosition() {
break;
}

return new Point(x,y);
return new Point(x, y);
}

protected boolean isHover() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
public interface RenderAndUpdateable {

public void update();

public void render(Graphics2D g);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package de.spareripsproduction.madn.client.graphics.field;

import de.spareripsproduction.madn.client.graphics.Board;
import de.spareripsproduction.madn.client.graphics.BoardEntity;
import de.spareripsproduction.madn.client.graphics.RenderAndUpdateable;
import de.spareripsproduction.tinyengine.entity.Entity;

import java.awt.*;

/**
* Created by marian on 12/03/14.
Expand Down
Loading

0 comments on commit b450304

Please sign in to comment.