Province.redraw

Korigiert und fertiggestellt
master
SariusRu 8 years ago
parent ceba6849df
commit 46ed2b020b

@ -1,4 +1,5 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import greenfoot.*;
import java.awt.Color; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/** /**
* Write a description of class Province here. * Write a description of class Province here.
@ -156,70 +157,92 @@ public class Province extends Actor
public void redrawProvince() public void redrawProvince()
{ {
GreenfootImage province = new GreenfootImage(100,65); GreenfootImage province = new GreenfootImage(100,100);
GreenfootImage provinceName = new GreenfootImage(displayName,16,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); GreenfootImage provinceName = new GreenfootImage(displayName,25,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));
province.drawImage(provinceName,0,0); province.drawImage(provinceName,0,0);
eCalculate(province); oDecide(province);
}
public void oDecide(GreenfootImage province)
{
String ownerString;
switch(owner)
{
case 1:
ownerString = "schwarz";
eCalculate(province,ownerString);
case 2:
ownerString = "rot";
eCalculate(province,ownerString);
case 3:
ownerString = "blau";
eCalculate(province,ownerString);
case 4:
ownerString = "gelb";
eCalculate(province,ownerString);
case 5:
ownerString = "grün";
eCalculate(province,ownerString);
case 6:
ownerString = "lila";
eCalculate(province,ownerString);
}
} }
private void eCalculate(GreenfootImage province) private void eCalculate(GreenfootImage province, String ownerString)
{ {
int eCountTanks = eCount / 5; int eCountTanks = eCount / 5;
GreenfootImage tryOut = new GreenfootImage("C:\\Users\\samue\\Documents\\GitHub\\zweiundvierzig\\Tank.jpg"); GreenfootImage tank = new GreenfootImage("images\\dickebertaskal-" + ownerString + ".png");
tank.scale(25,25);
if(eCountTanks <= 3) if(eCountTanks <= 3)
{ {
if(eCountTanks == 1) if(eCountTanks == 1)
{ {
province.drawImage(tryOut,0,17); province.drawImage(tank,0,25);
} }
if(eCountTanks == 2) if(eCountTanks == 2)
{ {
province.drawImage(tryOut,0,17); province.drawImage(tank,0,25);
province.drawImage(tryOut,17,17); province.drawImage(tank,17,25);
} }
if(eCountTanks == 3) if(eCountTanks == 3)
{ {
province.drawImage(tryOut,0,17); province.drawImage(tank,0,25);
province.drawImage(tryOut,17,17); province.drawImage(tank,25,25);
province.drawImage(tryOut,34,17); province.drawImage(tank,25,25);
} }
} }
else else
{ {
GreenfootImage eCountTanksImage = new GreenfootImage(Integer.toString(eCountTanks) + "x",16,Color.CYAN,new Color(1.0f,1.0f,1.0f,0.5f)); GreenfootImage eCountTanksImage = new GreenfootImage(Integer.toString(eCountTanks) + "x",25,Color.CYAN,new Color(1.0f,1.0f,1.0f,0.5f));
province.drawImage(eCountTanksImage,0,17); province.drawImage(eCountTanksImage,0,25);
province.drawImage(tryOut,22,18); province.drawImage(tank,45,25);
} }
int eCountHorse = (eCount - (eCountTanks * 5))/3; int eCountHorse = (eCount - (eCountTanks * 5))/3;
GreenfootImage horse = new GreenfootImage("images\\pferdreiterskal-" + ownerString + ".png");
horse.scale(25,25);
if(eCountHorse == 1) if(eCountHorse == 1)
{ {
province.drawImage(tryOut,0,34); province.drawImage(horse,0,50);
} }
GreenfootImage Inf = new GreenfootImage("images\\infanterieskal-" + ownerString + ".png");
int eCountInf = eCount - (eCountTanks * 5) - (eCountHorse * 3); int eCountInf = eCount - (eCountTanks * 5) - (eCountHorse * 3);
Inf.scale(25,25);
if(eCountInf <= 4) if(eCountInf <= 4)
{ {
if(eCountInf == 1) if(eCountInf == 1)
{ {
province.drawImage(tryOut,0,51); province.drawImage(Inf,0,75);
} }
if(eCountInf == 2) if(eCountInf == 2)
{ {
province.drawImage(tryOut,0,51); province.drawImage(Inf,0,75);
province.drawImage(tryOut,17,51); province.drawImage(Inf,25,75);
} }
if(eCountInf == 3)
{
province.drawImage(tryOut,0,51);
province.drawImage(tryOut,17,51);
province.drawImage(tryOut,34,51);
}
if(eCountInf == 4)
{
province.drawImage(tryOut,0,51);
province.drawImage(tryOut,17,51);
province.drawImage(tryOut,34,51);
province.drawImage(tryOut,51,51);
}
} }
setImage(province); setImage(province);
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Loading…
Cancel
Save