Provinz-Implementierung Teil 1

- Änderung an der Provinz-Klasse bezüglich zweier get-Funktionen für die Koordinaten
- Änderungen sowie Vereinfachungen an der Map_World-Klasse
- Implementierung des ersten Teils der Provinzen
pull/17/head
Achim 8 years ago
parent 2c4025db60
commit 3208010dcc

@ -5,69 +5,79 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
* (Also die normale Weltkarte mit allen Kontinenten)
*
* @author GruenerWal, MaxiJohl
* @version 0.2.0
* @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
*/
// Festlegung der Provinz-Anzahl
provinces = new Province[provinceCount + 1];
// Implementierung sämtlicher Provinzen
// ACHTUNG! Gaaaaanz viel Code!
// cID 1 - Nordamerika
neighbours = new int[3];
neighbours[0] = 2;
neighbours[1] = 3;
neighbours[2] = 36;
Province Alaska = new Province(1,1,64,106,1,"Alaska",neighbours);
addObject(Alaska,64,106);
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;
Province NWTerritorien = new Province(2,1,162,106,1,"NW-Territorien",neighbours);
addObject(Alaska,162,106);
provinces[2] = new Province(2,1,162,106,1,"NW-Territorien",neighbours);
neighbours = new int[4];
neighbours[0] = 1;
neighbours[1] = 2;
neighbours[2] = 4;
neighbours[3] = 5;
Province Alberta = new Province(3,1,53,170,1,"Alberta",neighbours);
addObject(Alberta,53,170);
provinces[3] = new Province(3,1,53,170,1,"Alberta",neighbours);
neighbours = new int[6];
neighbours[0] = 2;
@ -76,101 +86,125 @@ public class Map_World extends GeneralMap
neighbours[3] = 6;
neighbours[4] = 7;
neighbours[5] = 9;
Province Ontario = new Province(4,1,223,177,1,"Ontario",neighbours);
addObject(Ontario,223,177);
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;
Province Weststaaten = new Province(5,1,160,236,1,"Weststaaten",neighbours);
addObject(Weststaaten,160,236);
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;
Province Oststaaten = new Province(6,1,232,273,1,"Oststaaten",neighbours);
addObject(Oststaaten,232,273);
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] = ;
neighbours[1] = ;
neighbours[2] = ;
Province Quebec = new Province(7,1,300,180,1,"Quebec",neighbours);
addObject(Quebec,300,180);
neighbours = new int[1];
neighbours[] = ;
Province Mittelamerika = new Province(8,1,181,347,1,"Mittelamerika",neighbours);
addObject(Mittelamerika,181,347);
neighbours = new int[1];
neighbours[] = ;
Province Groenland = new Province(9,1,365,55,1,"Groenland",neighbours);
addObject(Groenland,365,55);
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[1];
neighbours[] = ;
Province Island = new Province(10,2,454,142,1,"Island",neighbours);
addObject(Island,454,142);
neighbours = new int[1];
neighbours[] = ;
Province Grossbritannien = new Province(11,2,424,221,1,"Grossbritannien",neighbours);
addObject(Grossbritannien,442,221);
neighbours = new int[1];
neighbours[] = ;
Province Skandinavien = new Province(12,2,520,153,1,"Skandinavien",neighbours);
addObject(Skandinavien,520,153);
neighbours = new int[1];
neighbours[] = ;
Province Russland = new Province(13,2,636,180,1,"Russland",neighbours);
addObject(Russland,636,180);
neighbours = new int[1];
neighbours[] = ;
Province Nordeuropa = new Province(14,2,,,1,"Nordeuropa",neighbours);
addObject(Nordeuropa,,);
neighbours = new int[1];
neighbours[] = ;
Province Westeuropa = new Province(15,2,528,232,1,"Westeuropa",neighbours);
addObject(Westeuropa,528,232);
neighbours = new int[1];
neighbours[] = ;
Province Suedeuropa = new Province(16,2,449,335,1,"Suedeuropa",neighbours);
addObject(Suedeuropa,449,335);
neighbours = new int[3];
neighbours[0] = 9;
neighbours[1] = 11;
neighbours[2] = 12;
provinces[10] = new Province(10,2,454,142,1,"Island",neighbours);
// cID 3 - Suedamerika
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[1];
neighbours[] = ;
Province Venezuela = new Province(17,3,245,396,1,"Venezuela",neighbours);
addObject(Venezuela,245,396);
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[1];
neighbours[] = ;
Province Peru = new Province(18,3,255,498,1,"Peru",neighbours);
addObject(Peru,255,498);
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[1];
neighbours[] = ;
Province Brasilien = new Province(19,3,327,467,1,"Brasilien",neighbours);
addObject(Brasilien,327,467);
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);
neighbours = new int[1];
neighbours[] = ;
Province Argentinien = new Province(20,3,274,572,1,"Argentinien",neighbours);
addObject(Argentinien,274,572);
// 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);
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()
@ -145,5 +157,5 @@ public class Province extends Actor
public void redrawProvince() {
//Platzhalter
}
}

Loading…
Cancel
Save