Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: byang223/TurnBAPI
...
head fork: byang223/TurnBAPI
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
27 src/frame/display/CommandDisplay.java
@@ -6,6 +6,10 @@
import com.golden.gamedev.object.SpriteGroup;
+import frame.TBComponent;
+import frame.layout.container.LayoutContainer;
+import frame.layout.container.VerticalLayoutContainer;
+
import modes.models.GameModel;
import modes.selections.Selections;
import units.Unit;
@@ -16,18 +20,20 @@
private Unit myUnit;
private ArrayList<ButtonSprite> myButtons;
+ private LayoutContainer lc;
public CommandDisplay(BufferedImage i, int x, int y) {
super(i);
xLoc = x;
yLoc = y;
+
}
public CommandDisplay(BufferedImage i, int x, int y, int dx, int dy){
this(i, x, y);
xDim = dx;
yDim = dy;
-
+ lc = new VerticalLayoutContainer(x, y, xDim, yDim);
myBackground.resize(xDim, yDim);
}
@@ -36,6 +42,7 @@ public CommandDisplay(BufferedImage i, int x, int y, int dx, int dy){
public void render(Graphics2D g) {
myBackground.render(g, xLoc, yLoc);
+ lc.setLocation(xLoc, yLoc);
Unit s = Selections.getSelectedUnit();
@@ -45,10 +52,24 @@ public void render(Graphics2D g) {
ButtonSpriteFactory b = new ButtonSpriteFactory(s);
ArrayList<ButtonSprite> buttons = b.getButtonSpriteList();
+ ArrayList<TBComponent> comps = new ArrayList<TBComponent>();
+
+ for(ButtonSprite temp: buttons){
+ comps.add(temp);
+ }
SpriteGroup newgroup = new SpriteGroup("buttons");
+
+ lc.addAll(comps);
+ lc.update();
+
+ for(ButtonSprite temp: buttons){
+ temp.render(g);
+ newgroup.add(temp);
+ }
+
- int i = 0;
+ /*int i = 0;
for(ButtonSprite temp: buttons){
newgroup.add(temp);
temp.setLocation(xLoc, 100*i + yLoc);
@@ -56,7 +77,7 @@ public void render(Graphics2D g) {
i++;
- }
+ }*/
Selections.setButtonGroup(newgroup);
}else{
View
82 src/frame/display/UnitDisplay.java
@@ -2,76 +2,58 @@
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
+import java.util.ArrayList;
-import modes.selections.Selections;
-import modes.models.GameModel;
+import com.golden.gamedev.object.SpriteGroup;
+import frame.TBComponent;
+import frame.layout.container.LayoutContainer;
+import frame.layout.container.VerticalLayoutContainer;
+import modes.models.GameModel;
+import modes.selections.Selections;
import units.Unit;
-import attribute.AttributeHealth;
+import units.interactions.ButtonSprite;
+import units.interactions.ButtonSpriteFactory;
+
+public class UnitDisplay extends Display {
-public class UnitDisplay extends Display{
-
private Unit myUnit;
- private Selections myState;
-
- public UnitDisplay(Selections s){
- super();
- myState = s;
- xLoc = 500;
- yLoc = 0;
- }
-
- public UnitDisplay(Selections s, int x, int y){
- super(x, y);
- myState = s;
+
+ public UnitDisplay(BufferedImage i, int x, int y) {
+ super(i);
xLoc = x;
yLoc = y;
+
}
- public UnitDisplay(BufferedImage i, int x, int y){
- super(i);
- xLoc = x;
- yLoc = y;
+ public UnitDisplay(BufferedImage i, int x, int y, int dx, int dy){
+ this(i, x, y);
+ xDim = dx;
+ yDim = dy;
+ myBackground.resize(xDim, yDim);
+
}
@Override
- public void render(Graphics2D g) {
+ public void render(Graphics2D g) {
- myUnit = myState.getSelectedUnit();
-
myBackground.render(g, xLoc, yLoc);
-
- if(myUnit != null){
-
- String unitType = myUnit.unitName();
-
- String unitHealth = "HEALTH: " + ((AttributeHealth) myUnit.getAttribute("Health")).getHP(); //Bryan, I made this modification, health is in Attribute health, not in stats anymore
+
+ Unit s = Selections.getSelectedUnit();
- font.drawString(g, unitType.toUpperCase(), xLoc, yLoc);
- font.drawString(g, unitHealth.toUpperCase(), xLoc, yLoc+20);
- }else{
- font.drawString(g, "NONE", xLoc, yLoc);
+ if (s != null) {
+ font.drawString(g, s.unitName().toUpperCase(), xLoc, yLoc);
+
+
}
-
- }
- @Override
- public void update() {
- // TODO Auto-generated method stub
-
- }
+ }
- public int getXLocation() {
- return xLoc;
- }
+ @Override
+ public void update() {
- public int getYLocation() {
- return yLoc;
- }
-
-
-
+ }
}
View
6 src/frame/layout/container/LayoutContainer.java
@@ -36,5 +36,11 @@ public void remove(TBComponent t){
update();
}
+ public void setLocation(int x, int y){
+ xLoc = x;
+ yLoc = y;
+ update();
+ }
+
public abstract void update();
}
View
8 src/modes/GameMode.java
@@ -43,6 +43,7 @@
import frame.TBPanel;
import frame.display.CommandDisplay;
import frame.display.Display;
+import frame.display.UnitDisplay;
import frame.layout.BorderLayout;
public class GameMode extends TBGameMode {
@@ -50,6 +51,7 @@
//for testing
TBPanel gameFrame;
Display d;
+ Display dd;
public GameMode(GameEngine arg0) {
super(arg0);
@@ -118,15 +120,21 @@ public void initResources() {
try {
s = ImageIO.read(new File("resources/TBBackgrounds/WHITE.jpg"));
d = new CommandDisplay(s, 500, 0, 200, 200);
+ dd = new UnitDisplay(s, 0, 0, 200, 200);
} catch (IOException e) {
e.printStackTrace();
}
gameFrame.setLayout(new BorderLayout());
+ TBPanel buttonFrame = new TBPanel(0,0, 100, 400);
+
gameFrame.add(getMap(), "LEFT");
+ gameFrame.add(dd, "RIGHT");
gameFrame.add(d, "RIGHT");
+
+
System.out.println("STATE");
View
6 src/units/interactions/ButtonSprite.java
@@ -1,5 +1,7 @@
package units.interactions;
+import java.awt.Graphics2D;
+
import modes.GameMode;
import modes.models.GameModel;
import modes.selections.Selections;
@@ -47,5 +49,9 @@ public int getYLocation() {
public void resize(int dx, int dy) {
setImage(ImageUtil.resize(this.getImage(), dx, dy));
}
+
+ public void render(Graphics2D g){
+ super.render(g, xLoc, yLoc);
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.