4ngelica 8 years ago
commit 2a5ef3e290

@ -4,51 +4,364 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
* Klasse der Standard-Welt
* (Also die normale Weltkarte mit allen Kontinenten)
*
* @author GruenerWal
* @version 0.0.1
* @author GruenerWal, MaxiJohl
* @version 0.3.0
*/
public class Map_World extends GeneralMap
{
/**
* Anzahl der Provinzen
* Muss später ggf. korrigiert werden!
* Anzahl der Provinzen.
*/
int provinzen = 42;
int provinceCount = 42;
/**
* Konstruktor der Weltkarte
* Ausdehnung 1280x720 eingetragen
* Muss später ggf. korrigiert werden!
* Konstruktor der Weltkarte;
* konstruiert eine GeneralMap mit den Ausmassen 1600 auf 900 Pixel.
*/
public Map_World()
{
super(1280,720,1);
super(1600,900,1);
Province[] provinces;
int[] neighbours;
/**
* Hier werden später sämtliche Provinzen der Standard-Map erstellt.
* Dies funktioniert folgendermassen:
* =================================================================
*
* Im Folgenden wird nun jede Provinz einzeln erstellt:
* |---
* nextProvinces = new int[<Anzahl angrenzende Provinzen>];
* <Zuweisung der angrenzenden Provinzen>
* Province <Name> = new Province(<Provinz-ID>,<Kontinent-ID>,<X-Position>,<Y-Position>,<Anzahl Sterne>,"<Anzeigename>",nextProvinces);
* addObject(<Name>,<x-Position>,<y-Position>);
* provinces[<Provinz-ID>] = new Province(<Provinz-ID>,<Kontinent-ID>,<X-Position>,<Y-Position>,<Anzahl Sterne>,"<Anzeigename>",nextProvinces);
* addObject(provinces[<Provinz-ID>],<x-Position>,<y-Position>);
* ---|
*
* Zwei Provinzen sind bereits als Beispiel erstellt.
* Muss später auf jeden Fall korrigiert werden!
* =================================================================
* Der Speicherplatz für provinces[0] bleibt leer, da es keine Provinz mit der ID 0 gibt!
*
* Und ja, ich weiss, dass das scheisse viel Schreibarbeit ist.
* Aber da muss man durch, wir habens auch hinbekommen :P
*
* ~GruenerWal
*/
neighbours = new int[1];
neighbours[0] = 2;
Province Mongolei = new Province(1,1,1000,100,1,"Mongolei",neighbours);
addObject(Mongolei,1000,100);
// Festlegung der Provinz-Anzahl
provinces = new Province[provinceCount + 1];
// Implementierung sämtlicher Provinzen
// ACHTUNG! Gaaaaanz viel Code!
neighbours = new int[1];
// cID 1 - Nordamerika
neighbours = new int[3];
neighbours[0] = 2;
neighbours[1] = 3;
neighbours[2] = 36;
provinces[1] = new Province(1,1,64,106,1,"Alaska",neighbours);
neighbours = new int[4];
neighbours[0] = 1;
neighbours[1] = 3;
neighbours[2] = 4;
neighbours[3] = 9;
provinces[2] = new Province(2,1,162,106,1,"NW-Territorien",neighbours);
neighbours = new int[4];
neighbours[0] = 1;
Province China = new Province(2,1,1000,350,2,"China",neighbours);
addObject(China,1000,350);
neighbours[1] = 2;
neighbours[2] = 4;
neighbours[3] = 5;
provinces[3] = new Province(3,1,53,170,1,"Alberta",neighbours);
neighbours = new int[6];
neighbours[0] = 2;
neighbours[1] = 3;
neighbours[2] = 5;
neighbours[3] = 6;
neighbours[4] = 7;
neighbours[5] = 9;
provinces[4] = new Province(4,1,223,177,2,"Ontario",neighbours);
neighbours = new int[4];
neighbours[0] = 3;
neighbours[1] = 4;
neighbours[2] = 6;
neighbours[3] = 8;
provinces[5] = new Province(5,1,160,236,2,"Weststaaten",neighbours);
neighbours = new int[4];
neighbours[0] = 4;
neighbours[1] = 5;
neighbours[2] = 7;
neighbours[3] = 8;
provinces[6] = new Province(6,1,232,273,2,"Oststaaten",neighbours);
neighbours = new int[3];
neighbours[0] = 4;
neighbours[1] = 6;
neighbours[2] = 9;
provinces[7] = new Province(7,1,300,180,2,"Quebec",neighbours);
neighbours = new int[3];
neighbours[0] = 5;
neighbours[1] = 6;
neighbours[2] = 17;
provinces[8] = new Province(8,1,181,347,1,"Mittelamerika",neighbours);
neighbours = new int[4];
neighbours[0] = 2;
neighbours[1] = 4;
neighbours[2] = 7;
neighbours[3] = 10;
provinces[9] = new Province(9,1,365,55,1,"Groenland",neighbours);
// cID 2 - Europa
neighbours = new int[3];
neighbours[0] = 9;
neighbours[1] = 11;
neighbours[2] = 12;
provinces[10] = new Province(10,2,454,142,1,"Island",neighbours);
neighbours = new int[4];
neighbours[0] = 10;
neighbours[1] = 12;
neighbours[2] = 14;
neighbours[3] = 15;
provinces[11] = new Province(11,2,424,221,2,"Grossbritannien",neighbours);
neighbours = new int[4];
neighbours[0] = 10;
neighbours[1] = 11;
neighbours[2] = 13;
neighbours[3] = 14;
provinces[12] = new Province(12,2,520,153,1,"Skandinavien",neighbours);
neighbours = new int[6];
neighbours[0] = 12;
neighbours[1] = 14;
neighbours[2] = 16;
neighbours[3] = 27;
neighbours[4] = 31;
neighbours[5] = 32;
provinces[13] = new Province(13,2,636,180,2,"Russland",neighbours);
neighbours = new int[5];
neighbours[0] = 11;
neighbours[1] = 12;
neighbours[2] = 13;
neighbours[3] = 15;
neighbours[4] = 16;
provinces[14] = new Province(14,2,528,232,2,"Nordeuropa",neighbours);
neighbours = new int[4];
neighbours[0] = 11;
neighbours[1] = 14;
neighbours[2] = 16;
neighbours[3] = 25;
provinces[15] = new Province(15,2,449,335,2,"Westeuropa",neighbours);
neighbours = new int[6];
neighbours[0] = 13;
neighbours[1] = 14;
neighbours[2] = 15;
neighbours[3] = 25;
neighbours[4] = 26;
neighbours[5] = 27;
provinces[16] = new Province(16,2,537,296,2,"Suedeuropa",neighbours);
// cID 3 - Suedamerika
neighbours = new int[3];
neighbours[0] = 8;
neighbours[1] = 18;
neighbours[2] = 19;
provinces[17] = new Province(17,3,245,396,1,"Venezuela",neighbours);
neighbours = new int[3];
neighbours[0] = 17;
neighbours[1] = 19;
neighbours[2] = 20;
provinces[18] = new Province(18,3,255,498,1,"Peru",neighbours);
neighbours = new int[4];
neighbours[0] = 17;
neighbours[1] = 18;
neighbours[2] = 20;
neighbours[3] = 25;
provinces[19] = new Province(19,3,327,467,2,"Brasilien",neighbours);
neighbours = new int[2];
neighbours[0] = 18;
neighbours[1] = 19;
provinces[20] = new Province(20,3,274,572,1,"Argentinien",neighbours);
// cID 4 - Afrika
neighbours = new int[2];
neighbours [0] = 24;
neighbours [1] = 22;
provinces[21] = new Province (21,4,680,630,1,"Madagaskar",neighbours);
neighbours = new int[3];
neighbours [0] = 21;
neighbours [1] = 23;
neighbours [2] = 24;
provinces[22] = new Province (22,4,580,624,1,"Südafrika",neighbours);
neighbours = new int[3];
neighbours [0] = 22;
neighbours [1] = 25;
neighbours [2] = 24;
provinces[23] = new Province (23,4,572,537,2,"Zentralafrika",neighbours);
neighbours = new int[5];
neighbours [0] = 21;
neighbours [1] = 22;
neighbours [2] = 25;
neighbours [3] = 23;
neighbours [4] = 26;
provinces[24] = new Province (24,4,632,500,2,"Ostafrika",neighbours);
addObject(provinces[24],632,500);
neighbours = new int[5];
neighbours [0] = 15;
neighbours [1] = 16;
neighbours [2] = 26;
neighbours [3] = 23;
neighbours [4] = 24;
provinces[25] = new Province (25,4,491,444,1,"Nordafrika",neighbours);
neighbours = new int[4];
neighbours [0] = 27;
neighbours [1] = 25;
neighbours [2] = 24;
neighbours [3] = 16;
provinces[26] = new Province (26,4,574,414,1,"Aegypten",neighbours);
// cID 5 - Asien
neighbours = new int[6];
neighbours [0] = 24;
neighbours [1] = 26;
neighbours [2] = 16;
neighbours [3] = 13;
neighbours [4] = 31;
neighbours [5] = 28;
provinces[27] = new Province (27,5,664,345,2,"Mittlerer Osten",neighbours);
neighbours = new int[4];
neighbours [0] = 29;
neighbours [1] = 31;
neighbours [2] = 27;
neighbours [3] = 30;
provinces[28] = new Province (28,5,784,370,2,"Indien",neighbours);
neighbours = new int[6];
neighbours [0] = 30;
neighbours [1] = 28;
neighbours [2] = 31;
neighbours [3] = 32;
neighbours [4] = 33;
neighbours [5] = 37;
provinces[29] = new Province (29,5,863,322,2,"China",neighbours);
neighbours = new int[3];
neighbours [0] = 29;
neighbours [1] = 39;
neighbours [2] = 28;
provinces[30] = new Province (30,5,867,400,1,"Südost Asien",neighbours);
neighbours = new int[5];
neighbours [0] = 29;
neighbours [1] = 28;
neighbours [2] = 27;
neighbours [3] = 13;
neighbours [4] = 32;
provinces[31] = new Province (31,5,724,262,1,"Afganistan",neighbours);
neighbours = new int[4];
neighbours [0] = 29;
neighbours [1] = 33;
neighbours [2] = 31;
neighbours [3] = 13;
provinces[32] = new Province (32,5,740,163,1,"Ural",neighbours);
neighbours = new int[5];
neighbours [0] = 34;
neighbours [1] = 35;
neighbours [2] = 37;
neighbours [3] = 29;
neighbours [4] = 32;
provinces[33] = new Province (33,5,802,128,1,"Sibirien",neighbours);
neighbours = new int[3];
neighbours [0] = 36;
neighbours [1] = 35;
neighbours [2] = 33;
provinces[34] = new Province (34,5,884,82,1,"Jakutien",neighbours);
neighbours = new int[4];
neighbours [0] = 34;
neighbours [1] = 36;
neighbours [2] = 37;
neighbours [3] = 33;
provinces[35] = new Province (35,5,867,176,2,"Irkutsk",neighbours);
neighbours = new int[5];
neighbours [0] = 1;
neighbours [1] = 38;
neighbours [2] = 37;
neighbours [3] = 35;
neighbours [4] = 34;
provinces[36] = new Province (36,5,973,89,1,"Kamtschatka",neighbours);
neighbours = new int[5];
neighbours [0] = 29;
neighbours [1] = 33;
neighbours [2] = 35;
neighbours [3] = 36;
neighbours [4] = 38;
provinces[37] = new Province (37,5,882,243,1,"Mongolei",neighbours);
neighbours = new int[2];
neighbours [0] = 37;
neighbours [1] = 36;
provinces[38] = new Province (38,5,994,249,2,"Japan",neighbours);
// cID 6 - Ozeanien
neighbours = new int[3];
neighbours [0] = 30;
neighbours [1] = 40;
neighbours [2] = 42;
provinces[39] = new Province (39,6,889,519,1,"Indonesien",neighbours);
neighbours = new int[3];
neighbours [0] = 39;
neighbours [1] = 41;
neighbours [2] = 42;
provinces[40] = new Province (40,6,983,492,2,"Neuguinea",neighbours);
neighbours = new int[2];
neighbours [0] = 40;
neighbours [1] = 42;
provinces[41] = new Province (41,6,1000,595,1,"Ost Australien",neighbours);
neighbours = new int[3];
neighbours [0] = 40;
neighbours [1] = 41;
neighbours [2] = 39;
provinces[42] = new Province (42,6,934,628,1,"West Australien",neighbours);
for (int c = 1; c <= provinceCount; c++)
{
addObject(provinces[c],provinces[c].getXPos(),provinces[c].getYPos());
}
}
}

@ -66,6 +66,18 @@ public class Province extends Actor
displayName = s1;
nextProvinces = Utils.copyArray(ba1);
}
// Liefert die X-Position als Integer
public int getXPos()
{
return xPos;
}
// Liefert die Y-Position als Integer
public int getYPos()
{
return yPos;
}
// Liefert die Provinz-ID als Integer
public int getID()
@ -142,8 +154,74 @@ public class Province extends Actor
return eCount;
}
public void redrawProvince() {
//Platzhalter
public void redrawProvince()
{
GreenfootImage province = new GreenfootImage(100,65);
GreenfootImage provinceName = new GreenfootImage(displayName,16,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));
province.drawImage(provinceName,0,0);
eCalculate(province);
}
private void eCalculate(GreenfootImage province)
{
int eCountTanks = eCount / 5;
GreenfootImage tryOut = new GreenfootImage("C:\\Users\\samue\\Documents\\GitHub\\zweiundvierzig\\Tank.jpg");
if(eCountTanks <= 3)
{
if(eCountTanks == 1)
{
province.drawImage(tryOut,0,17);
}
if(eCountTanks == 2)
{
province.drawImage(tryOut,0,17);
province.drawImage(tryOut,17,17);
}
if(eCountTanks == 3)
{
province.drawImage(tryOut,0,17);
province.drawImage(tryOut,17,17);
province.drawImage(tryOut,34,17);
}
}
else
{
GreenfootImage eCountTanksImage = new GreenfootImage(Integer.toString(eCountTanks) + "x",16,Color.CYAN,new Color(1.0f,1.0f,1.0f,0.5f));
province.drawImage(eCountTanksImage,0,17);
province.drawImage(tryOut,22,18);
}
int eCountHorse = (eCount - (eCountTanks * 5))/3;
if(eCountHorse == 1)
{
province.drawImage(tryOut,0,34);
}
int eCountInf = eCount - (eCountTanks * 5) - (eCountHorse * 3);
if(eCountInf <= 4)
{
if(eCountInf == 1)
{
province.drawImage(tryOut,0,51);
}
if(eCountInf == 2)
{
province.drawImage(tryOut,0,51);
province.drawImage(tryOut,17,51);
}
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);
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save