Hallo, ich habe mal wieder ein Problem.
Ich entwickle gerade eine App, komme auch gut voran, aber scheitere immer wieder an Kleineren Hürden. Ich habe aktuell ein Spielfeld, komplett aus ImageViews zusammengestellt, in einem Raster 9x9, in dem man, wie z.B. bei Pokemon oder Zelda auf dem Gameboy herumlaufen kann. Tileset steht, beweguns-Input läuft, alles gut. Jetzt möchte ich aber dass z.B. das Gras drei verschiedene Texturen haben kann, die zufällig bei jedem Schritt für jedes Feld wechseln soll, aber alle Felder nehmen IMMER die gleiche Textur an. Immer wenn ich das SPiel starte, haben alle Tiles, die Gras enthalten sollen, die gleiche Gras-Textur. Zwar bei jedem STart eine andere, aber alle immer die gleiche. Wo ist mein Fehler?
[CODE lang="java" title="Randomizer.java"]package com.manticore.monochromia;
public class Randomizer {
//hiermit erzeuge ich eine zufällige Zahl
public int Randymizer(int min, int max){
java.util.Random random = new java.util.Random();
return(random.nextInt(max - min) + min);
}
}[/CODE]
[CODE lang="java" title="MultiTiles.java"]package com.manticore.monochromia;
public class MultiTiles {
public String[] grass = new String[3];
MultiTiles(){
//das sind die drei Strings für die Gras-Texturen
grass[0] = "tile_grass16_a";
grass[1] = "tile_grass16_b";
grass[2] = "tile_grass16_c";
}
}[/CODE]
[CODE lang="java" title="TileDefinition.java"]package com.manticore.monochromia;
public class TileDefinition {
private Randomizer rnd = new Randomizer();
private MultiTiles multi = new MultiTiles();
public String[] tileDef = new String[3];
public int[] passable = new int[3];
TileDefinition(){
tileDef[0] = "tile_water16";
passable[0] = 0;
//die anderen Texturen sind noch in einfacher Ausführung, aber das hier unten drunter soll eine von drei Grastexturen erzeugen
tileDef[1] = multi.grass[rnd.Randymizer(0,3)];
passable[1] = 1;
tileDef[2] = "tile_path16";
passable[2] = 1;
}
}
[/CODE]
[CODE lang="java" title="NosgTiles.java"]package com.manticore.monochromia;
//das ist meine TileMap für meine erste Karte
public class NosgTiles {
public int[][] tileMap = new int[22][18]; //x y Werte
public int[][] locations = new int[22][18]; //x y Werte
public int[] specLoc = new int[3];
public int specLocX1, specLocX2, specLocX3;
public int specLocY1, specLocY2, specLocY3;
NosgTiles(){
specLoc[0] = 0; //calls Tower Scene
specLoc[1] = 1; //calls Tent Scene
specLoc[2] = 2; //calls Dock scene
locations[10][10] = 1; //tower scene
locations[17][9] = 1; //dock scene
locations[7][7] = 1; //tent scene
tileMap[0][0] = 0;
tileMap[1][0] = 0;
tileMap[2][0] = 0;
tileMap[3][0] = 0;
tileMap[4][0] = 0;
tileMap[5][0] = 0;
tileMap[6][0] = 0;
tileMap[7][0] = 0;
tileMap[8][0] = 0;
tileMap[9][0] = 0;
tileMap[10][0] = 0;
tileMap[11][0] = 0;
tileMap[12][0] = 0;
tileMap[13][0] = 0;
tileMap[14][0] = 0;
tileMap[15][0] = 0;
tileMap[16][0] = 0;
tileMap[17][0] = 0;
tileMap[18][0] = 0;
tileMap[19][0] = 0;
tileMap[20][0] = 0;
tileMap[21][0] = 0;
tileMap[0][1] = 0;
tileMap[1][1] = 0;
tileMap[2][1] = 0;
tileMap[3][1] = 0;
tileMap[4][1] = 0;
tileMap[5][1] = 0;
tileMap[6][1] = 0;
tileMap[7][1] = 0;
tileMap[8][1] = 0;
tileMap[9][1] = 0;
tileMap[10][1] = 0;
tileMap[11][1] = 0;
tileMap[12][1] = 0;
tileMap[13][1] = 0;
tileMap[14][1] = 0;
tileMap[15][1] = 0;
tileMap[16][1] = 0;
tileMap[17][1] = 0;
tileMap[18][1] = 0;
tileMap[19][1] = 0;
tileMap[20][1] = 0;
tileMap[21][1] = 0;
tileMap[0][2] = 0;
tileMap[1][2] = 0;
tileMap[2][2] = 0;
tileMap[3][2] = 0;
tileMap[4][2] = 0;
tileMap[5][2] = 0;
tileMap[6][2] = 0;
tileMap[7][2] = 0;
tileMap[8][2] = 0;
tileMap[9][2] = 0;
tileMap[10][2] = 0;
tileMap[11][2] = 0;
tileMap[12][2] = 0;
tileMap[13][2] = 0;
tileMap[14][2] = 0;
tileMap[15][2] = 0;
tileMap[16][2] = 0;
tileMap[17][2] = 0;
tileMap[18][2] = 0;
tileMap[19][2] = 0;
tileMap[20][2] = 0;
tileMap[21][2] = 0;
tileMap[0][3] = 0;
tileMap[1][3] = 0;
tileMap[2][3] = 0;
tileMap[3][3] = 0;
tileMap[4][3] = 0;
tileMap[5][3] = 0;
tileMap[6][3] = 0;
tileMap[7][3] = 0;
tileMap[8][3] = 0;
tileMap[9][3] = 5;
tileMap[10][3] = 5;
tileMap[11][3] = 5;
tileMap[12][3] = 5;
tileMap[13][3] = 5;
tileMap[14][3] = 0;
tileMap[15][3] = 0;
tileMap[16][3] = 0;
tileMap[17][3] = 0;
tileMap[18][3] = 0;
tileMap[19][3] = 0;
tileMap[20][3] = 0;
tileMap[21][3] = 0;
tileMap[0][4] = 0;
tileMap[1][4] = 0;
tileMap[2][4] = 0;
tileMap[3][4] = 0;
tileMap[4][4] = 0;
tileMap[5][4] = 5;
tileMap[6][4] = 5;
tileMap[7][4] = 5;
tileMap[8][4] = 5;
tileMap[9][4] = 1;
tileMap[10][4] = 1;
tileMap[11][4] = 1;
tileMap[12][4] = 1;
tileMap[13][4] = 1;
tileMap[14][4] = 5;
tileMap[15][4] = 0;
tileMap[16][4] = 0;
tileMap[17][4] = 0;
tileMap[18][4] = 0;
tileMap[19][4] = 0;
tileMap[20][4] = 0;
tileMap[21][4] = 0;
tileMap[0][5] = 0;
tileMap[1][5] = 0;
tileMap[2][5] = 0;
tileMap[3][5] = 0;
tileMap[4][5] = 5;
tileMap[5][5] = 1;
tileMap[6][5] = 1;
tileMap[7][5] = 1;
tileMap[8][5] = 1;
tileMap[9][5] = 1;
tileMap[10][5] = 1;
tileMap[11][5] = 1;
tileMap[12][5] = 1;
tileMap[13][5] = 1;
tileMap[14][5] = 1;
tileMap[15][5] = 5;
tileMap[16][5] = 5;
tileMap[17][5] = 0;
tileMap[18][5] = 0;
tileMap[19][5] = 0;
tileMap[20][5] = 0;
tileMap[21][5] = 0;
tileMap[0][6] = 0;
tileMap[1][6] = 0;
tileMap[2][6] = 0;
tileMap[3][6] = 0;
tileMap[4][6] = 1;
tileMap[5][6] = 1;
tileMap[6][6] = 1;
tileMap[7][6] = 1;
tileMap[8][6] = 1;
tileMap[9][6] = 1;
tileMap[10][6] = 1;
tileMap[11][6] = 1;
tileMap[12][6] = 1;
tileMap[13][6] = 1;
tileMap[14][6] = 1;
tileMap[15][6] = 1;
tileMap[16][6] = 1;
tileMap[17][6] = 5;
tileMap[18][6] = 0;
tileMap[19][6] = 0;
tileMap[20][6] = 0;
tileMap[21][6] = 0;
tileMap[0][7] = 0;
tileMap[1][7] = 0;
tileMap[2][7] = 0;
tileMap[3][7] = 0;
tileMap[4][7] = 1;
tileMap[5][7] = 1;
tileMap[6][7] = 6;
tileMap[7][7] = 2;
tileMap[8][7] = 2;
tileMap[9][7] = 2;
tileMap[10][7] = 2;
tileMap[11][7] = 1;
tileMap[12][7] = 1;
tileMap[13][7] = 1;
tileMap[14][7] = 1;
tileMap[15][7] = 1;
tileMap[16][7] = 1;
tileMap[17][7] = 1;
tileMap[18][7] = 0;
tileMap[19][7] = 0;
tileMap[20][7] = 0;
tileMap[21][7] = 0;
tileMap[0][8] = 0;
tileMap[1][8] = 0;
tileMap[2][8] = 0;
tileMap[3][8] = 0;
tileMap[4][8] = 1;
tileMap[5][8] = 1;
tileMap[6][8] = 1;
tileMap[7][8] = 1;
tileMap[8][8] = 1;
tileMap[9][8] = 1;
tileMap[10][8] = 2;
tileMap[11][8] = 1;
tileMap[12][8] = 1;
tileMap[13][8] = 1;
tileMap[14][8] = 1;
tileMap[15][8] = 1;
tileMap[16][8] = 1;
tileMap[17][8] = 1;
tileMap[18][8] = 0;
tileMap[19][8] = 0;
tileMap[20][8] = 0;
tileMap[21][8] = 0;
tileMap[0][9] = 0;
tileMap[1][9] = 0;
tileMap[2][9] = 0;
tileMap[3][9] = 0;
tileMap[4][9] = 1;
tileMap[5][9] = 1;
tileMap[6][9] = 1;
tileMap[7][9] = 1;
tileMap[8][9] = 1;
tileMap[9][9] = 1;
tileMap[10][9] = 2;
tileMap[11][9] = 2;
tileMap[12][9] = 2;
tileMap[13][9] = 2;
tileMap[14][9] = 2;
tileMap[15][9] = 2;
tileMap[16][9] = 2;
tileMap[17][9] = 2;
tileMap[18][9] = 3;
tileMap[19][9] = 0;
tileMap[20][9] = 0;
tileMap[21][9] = 0;
tileMap[0][10] = 0;
tileMap[1][10] = 0;
tileMap[2][10] = 0;
tileMap[3][10] = 0;
tileMap[4][10] = 0;
tileMap[5][10] = 1;
tileMap[6][10] = 1;
tileMap[7][10] = 1;
tileMap[8][10] = 1;
tileMap[9][10] = 1;
tileMap[10][10] = 2;
tileMap[11][10] = 1;
tileMap[12][10] = 1;
tileMap[13][10] = 1;
tileMap[14][10] = 1;
tileMap[15][10] = 1;
tileMap[16][10] = 1;
tileMap[17][10] = 1;
tileMap[18][10] = 0;
tileMap[19][10] = 0;
tileMap[20][10] = 0;
tileMap[21][10] = 0;
tileMap[0][11] = 0;
tileMap[1][11] = 0;
tileMap[2][11] = 0;
tileMap[3][11] = 0;
tileMap[4][11] = 0;
tileMap[5][11] = 1;
tileMap[6][11] = 1;
tileMap[7][11] = 1;
tileMap[8][11] = 1;
tileMap[9][11] = 8;
tileMap[10][11] = 7;
tileMap[11][11] = 9;
tileMap[12][11] = 1;
tileMap[13][11] = 1;
tileMap[14][11] = 1;
tileMap[15][11] = 1;
tileMap[16][11] = 1;
tileMap[17][11] = 1;
tileMap[18][11] = 0;
tileMap[19][11] = 0;
tileMap[20][11] = 0;
tileMap[21][11] = 0;
tileMap[0][12] = 0;
tileMap[1][12] = 0;
tileMap[2][12] = 0;
tileMap[3][12] = 0;
tileMap[4][12] = 0;
tileMap[5][12] = 0;
tileMap[6][12] = 1;
tileMap[7][12] = 1;
tileMap[8][12] = 1;
tileMap[9][12] = 8;
tileMap[10][12] = 10;
tileMap[11][12] = 9;
tileMap[12][12] = 1;
tileMap[13][12] = 1;
tileMap[14][12] = 1;
tileMap[15][12] = 1;
tileMap[16][12] = 1;
tileMap[17][12] = 0;
tileMap[18][12] = 0;
tileMap[19][12] = 0;
tileMap[20][12] = 0;
tileMap[21][12] = 0;
tileMap[0][13] = 0;
tileMap[1][13] = 0;
tileMap[2][13] = 0;
tileMap[3][13] = 0;
tileMap[4][13] = 0;
tileMap[5][13] = 0;
tileMap[6][13] = 0;
tileMap[7][13] = 1;
tileMap[8][13] = 1;
tileMap[9][13] = 8;
tileMap[10][13] = 10;
tileMap[11][13] = 9;
tileMap[12][13] = 1;
tileMap[13][13] = 1;
tileMap[14][13] = 1;
tileMap[15][13] = 0;
tileMap[16][13] = 0;
tileMap[17][13] = 0;
tileMap[18][13] = 0;
tileMap[19][13] = 0;
tileMap[20][13] = 0;
tileMap[21][13] = 0;
tileMap[0][14] = 0;
tileMap[1][14] = 0;
tileMap[2][14] = 0;
tileMap[3][14] = 0;
tileMap[4][14] = 0;
tileMap[5][14] = 0;
tileMap[6][14] = 0;
tileMap[7][14] = 0;
tileMap[8][14] = 0;
tileMap[9][14] = 8;
tileMap[10][14] = 10;
tileMap[11][14] = 9;
tileMap[12][14] = 0;
tileMap[13][14] = 0;
tileMap[14][14] = 0;
tileMap[15][14] = 0;
tileMap[16][14] = 0;
tileMap[17][14] = 0;
tileMap[18][14] = 0;
tileMap[19][14] = 0;
tileMap[20][14] = 0;
tileMap[21][14] = 0;
tileMap[0][15] = 0;
tileMap[1][15] = 0;
tileMap[2][15] = 0;
tileMap[3][15] = 0;
tileMap[4][15] = 0;
tileMap[5][15] = 0;
tileMap[6][15] = 0;
tileMap[7][15] = 0;
tileMap[8][15] = 0;
tileMap[9][15] = 8;
tileMap[10][15] = 10;
tileMap[11][15] = 9;
tileMap[12][15] = 0;
tileMap[13][15] = 0;
tileMap[14][15] = 0;
tileMap[15][15] = 0;
tileMap[16][15] = 0;
tileMap[17][15] = 0;
tileMap[18][15] = 0;
tileMap[19][15] = 0;
tileMap[20][15] = 0;
tileMap[21][15] = 0;
tileMap[0][16] = 0;
tileMap[1][16] = 0;
tileMap[2][16] = 0;
tileMap[3][16] = 0;
tileMap[4][16] = 0;
tileMap[5][16] = 0;
tileMap[6][16] = 0;
tileMap[7][16] = 0;
tileMap[8][16] = 0;
tileMap[9][16] = 8;
tileMap[10][16] = 10;
tileMap[11][16] = 9;
tileMap[12][16] = 0;
tileMap[13][16] = 0;
tileMap[14][16] = 0;
tileMap[15][16] = 0;
tileMap[16][16] = 0;
tileMap[17][16] = 0;
tileMap[18][16] = 0;
tileMap[19][16] = 0;
tileMap[20][16] = 0;
tileMap[21][16] = 0;
tileMap[0][17] = 0;
tileMap[1][17] = 0;
tileMap[2][17] = 0;
tileMap[3][17] = 0;
tileMap[4][17] = 0;
tileMap[5][17] = 0;
tileMap[6][17] = 0;
tileMap[7][17] = 0;
tileMap[8][17] = 0;
tileMap[9][17] = 8;
tileMap[10][17] = 10;
tileMap[11][17] = 9;
tileMap[12][17] = 0;
tileMap[13][17] = 0;
tileMap[14][17] = 0;
tileMap[15][17] = 0;
tileMap[16][17] = 0;
tileMap[17][17] = 0;
tileMap[18][17] = 0;
tileMap[19][17] = 0;
tileMap[20][17] = 0;
tileMap[21][17] = 0;
}
}[/CODE]
[CODE lang="java" title="TilemapActivity.java"]package com.manticore.monochromia;
//und dieses Ungetüm initiiert alle ImageViews und läd sie bei jedem Schritt neu.
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
public class TilemapActivity extends AppCompatActivity {
PlaySounds ps = new PlaySounds();
private NosgTiles nosgTls = new NosgTiles();
private TileDefinition tlDef = new TileDefinition();
private int playerPosition, newPlayerPosition, playerStartX, playerStartY;
private String enter, enterFade;
private int resIDCenter;
private int passLeft, passRight, passUp, passDown;
private int benter, benterfade, location;
private int t33; //central Tile
private int t03, t13, t23, t43, t53, t63, tm13, t73; //horizontal
private int t30, t31, t32, t34, t35, t36, t37, t3m1; //vertical
private int tm14, tm15, tm16, tm17, t07, t17, t27, t04, t05, t06, t14, t15, t16, t24, t25, t26; //upper left sector
private int tm12, tm11, tm10, tm1m1, t0m1, t1m1, t2m1, t00, t01, t02, t10, t11, t12, t20, t21, t22; //lower left sector
private int t4m1, t5m1, t6m1, t7m1, t70, t71, t72, t40, t41, t42, t50, t51, t52, t60, t61, t62; //lower right sector
private int t74, t75, t76, t77, t67, t57, t47, t44, t45, t46, t54, t55, t56, t64, t65, t66; //upper right sector
ImageView cx3y3; //central Tile
ImageView xm1y3, x0y3, x1y3, x2y3, x4y3, x5y3, x6y3, x7y3; //horizontal
ImageView x3ym1, x3y0, x3y1, x3y2, x3y4, x3y5, x3y6, x3y7; //vertical
ImageView xm1y4, xm1y5, xm1y6, xm1y7, x0y7, x1y7, x2y7, x0y4, x0y5, x0y6, x1y4, x1y5, x1y6, x2y4, x2y5, x2y6; //upper left sector
ImageView xm1y2, xm1y1, xm1y0, xm1ym1, x0ym1, x1ym1, x2ym1, x0y0, x0y1, x0y2, x1y0, x1y1, x1y2, x2y0, x2y1, x2y2; //lower left sector
ImageView x4ym1, x5ym1, x6ym1, x7ym1, x7y0, x7y1, x7y2, x4y0, x4y1, x4y2, x5y0, x5y1, x5y2, x6y0, x6y1, x6y2; //lower right sector
ImageView x4y7, x5y7, x6y7, x7y7, x7y6, x7y5, x7y4, x4y4, x4y5, x4y6, x5y4, x5y5, x5y6, x6y4, x6y5, x6y6; //upper right sector
ImageView bUp, bDown, bLeft, bRight, bEnter, bMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_tilemap);
enter = "button_enter";
enterFade = "button_enter_fade";
playerStartX = 10;
playerStartY = 7;
playerPosition = nosgTls.tileMap[playerStartX][playerStartY];
bUp = findViewById(R.id.bUp);
bDown = findViewById(R.id.bDown);
bLeft = findViewById(R.id.bLeft);
bRight = findViewById(R.id.bRight);
bEnter = findViewById(R.id.bEnter);
bMenu = findViewById(R.id.bMenu);
//central Tile
cx3y3 = findViewById(R.id.x3y3);
//Cross section
xm1y3 = findViewById(R.id.xm1y3);
x0y3 = findViewById(R.id.x0y3);
x1y3 = findViewById(R.id.x1y3);
x2y3 = findViewById(R.id.x2y3);
x4y3 = findViewById(R.id.x4y3);
x5y3 = findViewById(R.id.x5y3);
x6y3 = findViewById(R.id.x6y3);
x7y3 = findViewById(R.id.x7y3);
x3ym1 = findViewById(R.id.x3ym1);
x3y0 = findViewById(R.id.x3y0);
x3y1 = findViewById(R.id.x3y1);
x3y2 = findViewById(R.id.x3y2);
x3y4 = findViewById(R.id.x3y4);
x3y5 = findViewById(R.id.x3y5);
x3y6 = findViewById(R.id.x3y6);
x3y7 = findViewById(R.id.x3y7);
//upper left sector
x0y4 = findViewById(R.id.x0y4);
x0y5 = findViewById(R.id.x0y5);
x0y6 = findViewById(R.id.x0y6);
x1y4 = findViewById(R.id.x1y4);
x1y5 = findViewById(R.id.x1y5);
x1y6 = findViewById(R.id.x1y6);
x2y4 = findViewById(R.id.x2y4);
x2y5 = findViewById(R.id.x2y5);
x2y6 = findViewById(R.id.x2y6);
xm1y4 = findViewById(R.id.xm1y4);
xm1y5 = findViewById(R.id.xm1y5);
xm1y6 = findViewById(R.id.xm1y6);
xm1y7 = findViewById(R.id.xm1y7);
x0y7 = findViewById(R.id.x0y7);
x1y7 = findViewById(R.id.x1y7);
x2y7 = findViewById(R.id.x2y7);
//lower left sector
x0y0 = findViewById(R.id.x0y0);
x0y1 = findViewById(R.id.x0y1);
x0y2 = findViewById(R.id.x0y2);
x1y0 = findViewById(R.id.x1y0);
x1y1 = findViewById(R.id.x1y1);
x1y2 = findViewById(R.id.x1y2);
x2y0 = findViewById(R.id.x2y0);
x2y1 = findViewById(R.id.x2y1);
x2y2 = findViewById(R.id.x2y2);
xm1y2 = findViewById(R.id.xm1y2);
xm1y1 = findViewById(R.id.xm1y1);
xm1y0 = findViewById(R.id.xm1y0);
xm1ym1 = findViewById(R.id.xm1ym1);
x0ym1 = findViewById(R.id.x0ym1);
x1ym1 = findViewById(R.id.x1ym1);
x2ym1 = findViewById(R.id.x2ym1);
//lower right sector
x4y0 = findViewById(R.id.x4y0);
x4y1 = findViewById(R.id.x4y1);
x4y2 = findViewById(R.id.x4y2);
x5y0 = findViewById(R.id.x5y0);
x5y1 = findViewById(R.id.x5y1);
x5y2 = findViewById(R.id.x5y2);
x6y0 = findViewById(R.id.x6y0);
x6y1 = findViewById(R.id.x6y1);
x6y2 = findViewById(R.id.x6y2);
x4ym1 = findViewById(R.id.x4ym1);
x5ym1 = findViewById(R.id.x5ym1);
x6ym1 = findViewById(R.id.x6ym1);
x7ym1 = findViewById(R.id.x7ym1);
x7y0 = findViewById(R.id.x7y0);
x7y1 = findViewById(R.id.x7y1);
x7y2 = findViewById(R.id.x7y2);
//upper right sector
x4y4 = findViewById(R.id.x4y4);
x4y5 = findViewById(R.id.x4y5);
x4y6 = findViewById(R.id.x4y6);
x5y4 = findViewById(R.id.x5y4);
x5y5 = findViewById(R.id.x5y5);
x5y6 = findViewById(R.id.x5y6);
x6y4 = findViewById(R.id.x6y4);
x6y5 = findViewById(R.id.x6y5);
x6y6 = findViewById(R.id.x6y6);
x7y4 = findViewById(R.id.x7y4);
x7y5 = findViewById(R.id.x7y5);
x7y6 = findViewById(R.id.x7y6);
x7y7 = findViewById(R.id.x7y7);
x6y7 = findViewById(R.id.x6y7);
x5y7 = findViewById(R.id.x5y7);
x4y7 = findViewById(R.id.x4y7);
InitiateMap();
MoveLeft();
MoveRight();
MoveUp();
MoveDown();
Enter();
Menu();
}
@Override
public void onBackPressed(){
super.onBackPressed();
this.finish();
Intent i = new Intent(this, DebugMenuActivity.class);
startActivity(i);
overridePendingTransition(0,0);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
}
public void SetPlayerPositionXY(){
resIDCenter = getResources().getIdentifier(tlDef.tileDef[playerPosition], "drawable", getPackageName());
cx3y3.setImageResource(resIDCenter);
}
public void LoadCenterTileXY(){
cx3y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY]], "drawable", getPackageName()));
}
public void LoadCrossXY(){
//Horizontale
xm1y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY]], "drawable", getPackageName()));
x0y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY]], "drawable", getPackageName()));
x1y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY]], "drawable", getPackageName()));
t23 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY]], "drawable", getPackageName());
x2y3.setImageResource(t23);
//Get Passability Left
passLeft = tlDef.passable[nosgTls.tileMap[playerStartX - 1][playerStartY]];
//middle
t43 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY]], "drawable", getPackageName());
x4y3.setImageResource(t43);
//Get Passability Right
passRight = tlDef.passable[nosgTls.tileMap[playerStartX + 1][playerStartY]];
t53 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY]], "drawable", getPackageName());
x5y3.setImageResource(t53);
t63 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY]], "drawable", getPackageName());
x6y3.setImageResource(t63);
t73 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY]], "drawable", getPackageName());
x7y3.setImageResource(t73);
//Verticale
t37 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 4]], "drawable", getPackageName());
x3y7.setImageResource(t37);
t36 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 3]], "drawable", getPackageName());
x3y6.setImageResource(t36);
t35 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 2]], "drawable", getPackageName());
x3y5.setImageResource(t35);
t34 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 1]], "drawable", getPackageName());
x3y4.setImageResource(t34);
//get passability up
passUp = tlDef.passable[nosgTls.tileMap[playerStartX][playerStartY + 1]];
//middle
t32 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 1]], "drawable", getPackageName());
x3y2.setImageResource(t32);
//get passability down
passDown = tlDef.passable[nosgTls.tileMap[playerStartX][playerStartY - 1]];
t31 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 2]], "drawable", getPackageName());
x3y1.setImageResource(t31);
t30 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 3]], "drawable", getPackageName());
x3y0.setImageResource(t30);
t3m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 4]], "drawable", getPackageName());
x3ym1.setImageResource(t3m1);
}
public void LoadSectorUpperLeft(){
t04 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 1]], "drawable", getPackageName());
x0y4.setImageResource(t04);
t05 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 2]], "drawable", getPackageName());
x0y5.setImageResource(t05);
t06 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 3]], "drawable", getPackageName());
x0y6.setImageResource(t06);
//
t14 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 1]], "drawable", getPackageName());
x1y4.setImageResource(t14);
t15 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 2]], "drawable", getPackageName());
x1y5.setImageResource(t15);
t16 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 3]], "drawable", getPackageName());
x1y6.setImageResource(t16);
//
t24 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 1]], "drawable", getPackageName());
x2y4.setImageResource(t24);
t25 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 2]], "drawable", getPackageName());
x2y5.setImageResource(t25);
t26 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 3]], "drawable", getPackageName());
x2y6.setImageResource(t26);
//new
tm14 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 1]], "drawable", getPackageName());
xm1y4.setImageResource(tm14);
tm15 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 2]], "drawable", getPackageName());
xm1y5.setImageResource(tm15);
tm16 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 3]], "drawable", getPackageName());
xm1y6.setImageResource(tm16);
tm17 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 4]], "drawable", getPackageName());
xm1y7.setImageResource(tm17);
t07 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 4]], "drawable", getPackageName());
x0y7.setImageResource(t07);
t17 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 4]], "drawable", getPackageName());
x1y7.setImageResource(t17);
t27 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 4]], "drawable", getPackageName());
x2y7.setImageResource(t27);
}
public void LoadSectorLowerLeft(){
t00 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 3]], "drawable", getPackageName());
x0y0.setImageResource(t00);
t01 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 2]], "drawable", getPackageName());
x0y1.setImageResource(t01);
t02 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 1]], "drawable", getPackageName());
x0y2.setImageResource(t02);
//
t10 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 3]], "drawable", getPackageName());
x1y0.setImageResource(t10);
t11 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 2]], "drawable", getPackageName());
x1y1.setImageResource(t11);
t12 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 1]], "drawable", getPackageName());
x1y2.setImageResource(t12);
//
t20 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 3]], "drawable", getPackageName());
x2y0.setImageResource(t20);
t21 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 2]], "drawable", getPackageName());
x2y1.setImageResource(t21);
t22 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 1]], "drawable", getPackageName());
x2y2.setImageResource(t22);
//new
tm12 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 1]], "drawable", getPackageName());
xm1y2.setImageResource(tm12);
tm11 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 2]], "drawable", getPackageName());
xm1y1.setImageResource(tm11);
tm10 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 3]], "drawable", getPackageName());
xm1y0.setImageResource(tm10);
tm1m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 4]], "drawable", getPackageName());
xm1ym1.setImageResource(tm1m1);
t0m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 4]], "drawable", getPackageName());
x0ym1.setImageResource(t0m1);
t1m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 4]], "drawable", getPackageName());
x1ym1.setImageResource(t1m1);
t2m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 4]], "drawable", getPackageName());
x2ym1.setImageResource(t2m1);
}
public void LoadSectorLowerRight(){
t40 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 3]], "drawable", getPackageName());
x4y0.setImageResource(t40);
t50 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 3]], "drawable", getPackageName());
x5y0.setImageResource(t50);
t60 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 3]], "drawable", getPackageName());
x6y0.setImageResource(t60);
//
t41 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 2]], "drawable", getPackageName());
x4y1.setImageResource(t41);
t51 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 2]], "drawable", getPackageName());
x5y1.setImageResource(t51);
t61 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 2]], "drawable", getPackageName());
x6y1.setImageResource(t61);
//
t42 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 1]], "drawable", getPackageName());
x4y2.setImageResource(t42);
t52 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 1]], "drawable", getPackageName());
x5y2.setImageResource(t52);
t62 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 1]], "drawable", getPackageName());
x6y2.setImageResource(t62);
//new
t4m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 4]], "drawable", getPackageName());
x4ym1.setImageResource(t4m1);
t5m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 4]], "drawable", getPackageName());
x5ym1.setImageResource(t5m1);
t6m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 4]], "drawable", getPackageName());
x6ym1.setImageResource(t6m1);
t7m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 4]], "drawable", getPackageName());
x7ym1.setImageResource(t7m1);
t70 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 3]], "drawable", getPackageName());
x7y0.setImageResource(t70);
t71 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 2]], "drawable", getPackageName());
x7y1.setImageResource(t71);
t72 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 1]], "drawable", getPackageName());
x7y2.setImageResource(t72);
}
public void LoadSectorUpperRight(){
t44 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 1]], "drawable", getPackageName());
x4y4.setImageResource(t44);
t54 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 1]], "drawable", getPackageName());
x5y4.setImageResource(t54);
t64 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 1]], "drawable", getPackageName());
x6y4.setImageResource(t64);
//
t45 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 2]], "drawable", getPackageName());
x4y5.setImageResource(t45);
t55 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 2]], "drawable", getPackageName());
x5y5.setImageResource(t55);
t65 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 2]], "drawable", getPackageName());
x6y5.setImageResource(t65);
//
t46 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 3]], "drawable", getPackageName());
x4y6.setImageResource(t46);
t56 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 3]], "drawable", getPackageName());
x5y6.setImageResource(t56);
t66 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 3]], "drawable", getPackageName());
x6y6.setImageResource(t66);
//new
t74 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 1]], "drawable", getPackageName());
x7y4.setImageResource(t74);
t75 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 2]], "drawable", getPackageName());
x7y5.setImageResource(t75);
t76 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 3]], "drawable", getPackageName());
x7y6.setImageResource(t76);
t77 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 4]], "drawable", getPackageName());
x7y7.setImageResource(t77);
t67 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 4]], "drawable", getPackageName());
x6y7.setImageResource(t67);
t57 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 4]], "drawable", getPackageName());
x5y7.setImageResource(t57);
t47 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 4]], "drawable", getPackageName());
x4y7.setImageResource(t47);
}
public void InitiateMap(){
SetPlayerPositionXY();
LoadTiles();
}
public void LoadTiles(){
LoadCenterTileXY();
LoadCrossXY();
LoadSectorUpperLeft();
LoadSectorUpperRight();
LoadSectorLowerLeft();
LoadSectorLowerRight();
CheckIfSpecialPosition(); //soll prüfen, ob der enter-button klickbar wird und man zu einer szene wechseln können soll
}
public void CheckIfSpecialPosition(){
location = nosgTls.locations[playerStartX][playerStartY];
switch(location){
case 0://wenn position nicht speziell: deaktiviere enter button
benter = getResources().getIdentifier(enterFade, "drawable", getPackageName());
bEnter.setImageResource(benter);
bEnter.setClickable(false);
break;
case 1://wenn position speziell: aktiviere enter button
benter = getResources().getIdentifier(enter, "drawable", getPackageName());
bEnter.setImageResource(benter);
bEnter.setClickable(true);
break;
}
}
public void MoveLeft(){
bLeft.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passLeft){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartX - 1;
playerStartX = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void Enter(){
bEnter.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(playerStartX){
case 7://tent scene
if(playerStartY == 7){
}
break;
case 10://tower scene
if(playerStartY == 10){
TilemapActivity.this.finish();
Intent i = new Intent(TilemapActivity.this, SceneNosgTowerActivity.class);
startActivity(i);
overridePendingTransition(0,0);
}
break;
case 17://dock scene
if(playerStartY == 9){
}
break;
}
}
}
);
}
public void Menu(){
bMenu.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
}
}
);
}
public void MoveRight(){
bRight.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passRight){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartX + 1;
playerStartX = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void MoveUp(){
bUp.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passUp){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartY + 1;
playerStartY = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void MoveDown(){
bDown.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passDown){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartY - 1;
playerStartY = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
}[/CODE]
So, dieses Ungetüm funktioniert soweit, aber es sollte für jedes Feld ein zufälliges Gras-Teil anzeigen, und nicht immer für alle das gleiche -.-
Ich entwickle gerade eine App, komme auch gut voran, aber scheitere immer wieder an Kleineren Hürden. Ich habe aktuell ein Spielfeld, komplett aus ImageViews zusammengestellt, in einem Raster 9x9, in dem man, wie z.B. bei Pokemon oder Zelda auf dem Gameboy herumlaufen kann. Tileset steht, beweguns-Input läuft, alles gut. Jetzt möchte ich aber dass z.B. das Gras drei verschiedene Texturen haben kann, die zufällig bei jedem Schritt für jedes Feld wechseln soll, aber alle Felder nehmen IMMER die gleiche Textur an. Immer wenn ich das SPiel starte, haben alle Tiles, die Gras enthalten sollen, die gleiche Gras-Textur. Zwar bei jedem STart eine andere, aber alle immer die gleiche. Wo ist mein Fehler?
[CODE lang="java" title="Randomizer.java"]package com.manticore.monochromia;
public class Randomizer {
//hiermit erzeuge ich eine zufällige Zahl
public int Randymizer(int min, int max){
java.util.Random random = new java.util.Random();
return(random.nextInt(max - min) + min);
}
}[/CODE]
[CODE lang="java" title="MultiTiles.java"]package com.manticore.monochromia;
public class MultiTiles {
public String[] grass = new String[3];
MultiTiles(){
//das sind die drei Strings für die Gras-Texturen
grass[0] = "tile_grass16_a";
grass[1] = "tile_grass16_b";
grass[2] = "tile_grass16_c";
}
}[/CODE]
[CODE lang="java" title="TileDefinition.java"]package com.manticore.monochromia;
public class TileDefinition {
private Randomizer rnd = new Randomizer();
private MultiTiles multi = new MultiTiles();
public String[] tileDef = new String[3];
public int[] passable = new int[3];
TileDefinition(){
tileDef[0] = "tile_water16";
passable[0] = 0;
//die anderen Texturen sind noch in einfacher Ausführung, aber das hier unten drunter soll eine von drei Grastexturen erzeugen
tileDef[1] = multi.grass[rnd.Randymizer(0,3)];
passable[1] = 1;
tileDef[2] = "tile_path16";
passable[2] = 1;
}
}
[/CODE]
[CODE lang="java" title="NosgTiles.java"]package com.manticore.monochromia;
//das ist meine TileMap für meine erste Karte
public class NosgTiles {
public int[][] tileMap = new int[22][18]; //x y Werte
public int[][] locations = new int[22][18]; //x y Werte
public int[] specLoc = new int[3];
public int specLocX1, specLocX2, specLocX3;
public int specLocY1, specLocY2, specLocY3;
NosgTiles(){
specLoc[0] = 0; //calls Tower Scene
specLoc[1] = 1; //calls Tent Scene
specLoc[2] = 2; //calls Dock scene
locations[10][10] = 1; //tower scene
locations[17][9] = 1; //dock scene
locations[7][7] = 1; //tent scene
tileMap[0][0] = 0;
tileMap[1][0] = 0;
tileMap[2][0] = 0;
tileMap[3][0] = 0;
tileMap[4][0] = 0;
tileMap[5][0] = 0;
tileMap[6][0] = 0;
tileMap[7][0] = 0;
tileMap[8][0] = 0;
tileMap[9][0] = 0;
tileMap[10][0] = 0;
tileMap[11][0] = 0;
tileMap[12][0] = 0;
tileMap[13][0] = 0;
tileMap[14][0] = 0;
tileMap[15][0] = 0;
tileMap[16][0] = 0;
tileMap[17][0] = 0;
tileMap[18][0] = 0;
tileMap[19][0] = 0;
tileMap[20][0] = 0;
tileMap[21][0] = 0;
tileMap[0][1] = 0;
tileMap[1][1] = 0;
tileMap[2][1] = 0;
tileMap[3][1] = 0;
tileMap[4][1] = 0;
tileMap[5][1] = 0;
tileMap[6][1] = 0;
tileMap[7][1] = 0;
tileMap[8][1] = 0;
tileMap[9][1] = 0;
tileMap[10][1] = 0;
tileMap[11][1] = 0;
tileMap[12][1] = 0;
tileMap[13][1] = 0;
tileMap[14][1] = 0;
tileMap[15][1] = 0;
tileMap[16][1] = 0;
tileMap[17][1] = 0;
tileMap[18][1] = 0;
tileMap[19][1] = 0;
tileMap[20][1] = 0;
tileMap[21][1] = 0;
tileMap[0][2] = 0;
tileMap[1][2] = 0;
tileMap[2][2] = 0;
tileMap[3][2] = 0;
tileMap[4][2] = 0;
tileMap[5][2] = 0;
tileMap[6][2] = 0;
tileMap[7][2] = 0;
tileMap[8][2] = 0;
tileMap[9][2] = 0;
tileMap[10][2] = 0;
tileMap[11][2] = 0;
tileMap[12][2] = 0;
tileMap[13][2] = 0;
tileMap[14][2] = 0;
tileMap[15][2] = 0;
tileMap[16][2] = 0;
tileMap[17][2] = 0;
tileMap[18][2] = 0;
tileMap[19][2] = 0;
tileMap[20][2] = 0;
tileMap[21][2] = 0;
tileMap[0][3] = 0;
tileMap[1][3] = 0;
tileMap[2][3] = 0;
tileMap[3][3] = 0;
tileMap[4][3] = 0;
tileMap[5][3] = 0;
tileMap[6][3] = 0;
tileMap[7][3] = 0;
tileMap[8][3] = 0;
tileMap[9][3] = 5;
tileMap[10][3] = 5;
tileMap[11][3] = 5;
tileMap[12][3] = 5;
tileMap[13][3] = 5;
tileMap[14][3] = 0;
tileMap[15][3] = 0;
tileMap[16][3] = 0;
tileMap[17][3] = 0;
tileMap[18][3] = 0;
tileMap[19][3] = 0;
tileMap[20][3] = 0;
tileMap[21][3] = 0;
tileMap[0][4] = 0;
tileMap[1][4] = 0;
tileMap[2][4] = 0;
tileMap[3][4] = 0;
tileMap[4][4] = 0;
tileMap[5][4] = 5;
tileMap[6][4] = 5;
tileMap[7][4] = 5;
tileMap[8][4] = 5;
tileMap[9][4] = 1;
tileMap[10][4] = 1;
tileMap[11][4] = 1;
tileMap[12][4] = 1;
tileMap[13][4] = 1;
tileMap[14][4] = 5;
tileMap[15][4] = 0;
tileMap[16][4] = 0;
tileMap[17][4] = 0;
tileMap[18][4] = 0;
tileMap[19][4] = 0;
tileMap[20][4] = 0;
tileMap[21][4] = 0;
tileMap[0][5] = 0;
tileMap[1][5] = 0;
tileMap[2][5] = 0;
tileMap[3][5] = 0;
tileMap[4][5] = 5;
tileMap[5][5] = 1;
tileMap[6][5] = 1;
tileMap[7][5] = 1;
tileMap[8][5] = 1;
tileMap[9][5] = 1;
tileMap[10][5] = 1;
tileMap[11][5] = 1;
tileMap[12][5] = 1;
tileMap[13][5] = 1;
tileMap[14][5] = 1;
tileMap[15][5] = 5;
tileMap[16][5] = 5;
tileMap[17][5] = 0;
tileMap[18][5] = 0;
tileMap[19][5] = 0;
tileMap[20][5] = 0;
tileMap[21][5] = 0;
tileMap[0][6] = 0;
tileMap[1][6] = 0;
tileMap[2][6] = 0;
tileMap[3][6] = 0;
tileMap[4][6] = 1;
tileMap[5][6] = 1;
tileMap[6][6] = 1;
tileMap[7][6] = 1;
tileMap[8][6] = 1;
tileMap[9][6] = 1;
tileMap[10][6] = 1;
tileMap[11][6] = 1;
tileMap[12][6] = 1;
tileMap[13][6] = 1;
tileMap[14][6] = 1;
tileMap[15][6] = 1;
tileMap[16][6] = 1;
tileMap[17][6] = 5;
tileMap[18][6] = 0;
tileMap[19][6] = 0;
tileMap[20][6] = 0;
tileMap[21][6] = 0;
tileMap[0][7] = 0;
tileMap[1][7] = 0;
tileMap[2][7] = 0;
tileMap[3][7] = 0;
tileMap[4][7] = 1;
tileMap[5][7] = 1;
tileMap[6][7] = 6;
tileMap[7][7] = 2;
tileMap[8][7] = 2;
tileMap[9][7] = 2;
tileMap[10][7] = 2;
tileMap[11][7] = 1;
tileMap[12][7] = 1;
tileMap[13][7] = 1;
tileMap[14][7] = 1;
tileMap[15][7] = 1;
tileMap[16][7] = 1;
tileMap[17][7] = 1;
tileMap[18][7] = 0;
tileMap[19][7] = 0;
tileMap[20][7] = 0;
tileMap[21][7] = 0;
tileMap[0][8] = 0;
tileMap[1][8] = 0;
tileMap[2][8] = 0;
tileMap[3][8] = 0;
tileMap[4][8] = 1;
tileMap[5][8] = 1;
tileMap[6][8] = 1;
tileMap[7][8] = 1;
tileMap[8][8] = 1;
tileMap[9][8] = 1;
tileMap[10][8] = 2;
tileMap[11][8] = 1;
tileMap[12][8] = 1;
tileMap[13][8] = 1;
tileMap[14][8] = 1;
tileMap[15][8] = 1;
tileMap[16][8] = 1;
tileMap[17][8] = 1;
tileMap[18][8] = 0;
tileMap[19][8] = 0;
tileMap[20][8] = 0;
tileMap[21][8] = 0;
tileMap[0][9] = 0;
tileMap[1][9] = 0;
tileMap[2][9] = 0;
tileMap[3][9] = 0;
tileMap[4][9] = 1;
tileMap[5][9] = 1;
tileMap[6][9] = 1;
tileMap[7][9] = 1;
tileMap[8][9] = 1;
tileMap[9][9] = 1;
tileMap[10][9] = 2;
tileMap[11][9] = 2;
tileMap[12][9] = 2;
tileMap[13][9] = 2;
tileMap[14][9] = 2;
tileMap[15][9] = 2;
tileMap[16][9] = 2;
tileMap[17][9] = 2;
tileMap[18][9] = 3;
tileMap[19][9] = 0;
tileMap[20][9] = 0;
tileMap[21][9] = 0;
tileMap[0][10] = 0;
tileMap[1][10] = 0;
tileMap[2][10] = 0;
tileMap[3][10] = 0;
tileMap[4][10] = 0;
tileMap[5][10] = 1;
tileMap[6][10] = 1;
tileMap[7][10] = 1;
tileMap[8][10] = 1;
tileMap[9][10] = 1;
tileMap[10][10] = 2;
tileMap[11][10] = 1;
tileMap[12][10] = 1;
tileMap[13][10] = 1;
tileMap[14][10] = 1;
tileMap[15][10] = 1;
tileMap[16][10] = 1;
tileMap[17][10] = 1;
tileMap[18][10] = 0;
tileMap[19][10] = 0;
tileMap[20][10] = 0;
tileMap[21][10] = 0;
tileMap[0][11] = 0;
tileMap[1][11] = 0;
tileMap[2][11] = 0;
tileMap[3][11] = 0;
tileMap[4][11] = 0;
tileMap[5][11] = 1;
tileMap[6][11] = 1;
tileMap[7][11] = 1;
tileMap[8][11] = 1;
tileMap[9][11] = 8;
tileMap[10][11] = 7;
tileMap[11][11] = 9;
tileMap[12][11] = 1;
tileMap[13][11] = 1;
tileMap[14][11] = 1;
tileMap[15][11] = 1;
tileMap[16][11] = 1;
tileMap[17][11] = 1;
tileMap[18][11] = 0;
tileMap[19][11] = 0;
tileMap[20][11] = 0;
tileMap[21][11] = 0;
tileMap[0][12] = 0;
tileMap[1][12] = 0;
tileMap[2][12] = 0;
tileMap[3][12] = 0;
tileMap[4][12] = 0;
tileMap[5][12] = 0;
tileMap[6][12] = 1;
tileMap[7][12] = 1;
tileMap[8][12] = 1;
tileMap[9][12] = 8;
tileMap[10][12] = 10;
tileMap[11][12] = 9;
tileMap[12][12] = 1;
tileMap[13][12] = 1;
tileMap[14][12] = 1;
tileMap[15][12] = 1;
tileMap[16][12] = 1;
tileMap[17][12] = 0;
tileMap[18][12] = 0;
tileMap[19][12] = 0;
tileMap[20][12] = 0;
tileMap[21][12] = 0;
tileMap[0][13] = 0;
tileMap[1][13] = 0;
tileMap[2][13] = 0;
tileMap[3][13] = 0;
tileMap[4][13] = 0;
tileMap[5][13] = 0;
tileMap[6][13] = 0;
tileMap[7][13] = 1;
tileMap[8][13] = 1;
tileMap[9][13] = 8;
tileMap[10][13] = 10;
tileMap[11][13] = 9;
tileMap[12][13] = 1;
tileMap[13][13] = 1;
tileMap[14][13] = 1;
tileMap[15][13] = 0;
tileMap[16][13] = 0;
tileMap[17][13] = 0;
tileMap[18][13] = 0;
tileMap[19][13] = 0;
tileMap[20][13] = 0;
tileMap[21][13] = 0;
tileMap[0][14] = 0;
tileMap[1][14] = 0;
tileMap[2][14] = 0;
tileMap[3][14] = 0;
tileMap[4][14] = 0;
tileMap[5][14] = 0;
tileMap[6][14] = 0;
tileMap[7][14] = 0;
tileMap[8][14] = 0;
tileMap[9][14] = 8;
tileMap[10][14] = 10;
tileMap[11][14] = 9;
tileMap[12][14] = 0;
tileMap[13][14] = 0;
tileMap[14][14] = 0;
tileMap[15][14] = 0;
tileMap[16][14] = 0;
tileMap[17][14] = 0;
tileMap[18][14] = 0;
tileMap[19][14] = 0;
tileMap[20][14] = 0;
tileMap[21][14] = 0;
tileMap[0][15] = 0;
tileMap[1][15] = 0;
tileMap[2][15] = 0;
tileMap[3][15] = 0;
tileMap[4][15] = 0;
tileMap[5][15] = 0;
tileMap[6][15] = 0;
tileMap[7][15] = 0;
tileMap[8][15] = 0;
tileMap[9][15] = 8;
tileMap[10][15] = 10;
tileMap[11][15] = 9;
tileMap[12][15] = 0;
tileMap[13][15] = 0;
tileMap[14][15] = 0;
tileMap[15][15] = 0;
tileMap[16][15] = 0;
tileMap[17][15] = 0;
tileMap[18][15] = 0;
tileMap[19][15] = 0;
tileMap[20][15] = 0;
tileMap[21][15] = 0;
tileMap[0][16] = 0;
tileMap[1][16] = 0;
tileMap[2][16] = 0;
tileMap[3][16] = 0;
tileMap[4][16] = 0;
tileMap[5][16] = 0;
tileMap[6][16] = 0;
tileMap[7][16] = 0;
tileMap[8][16] = 0;
tileMap[9][16] = 8;
tileMap[10][16] = 10;
tileMap[11][16] = 9;
tileMap[12][16] = 0;
tileMap[13][16] = 0;
tileMap[14][16] = 0;
tileMap[15][16] = 0;
tileMap[16][16] = 0;
tileMap[17][16] = 0;
tileMap[18][16] = 0;
tileMap[19][16] = 0;
tileMap[20][16] = 0;
tileMap[21][16] = 0;
tileMap[0][17] = 0;
tileMap[1][17] = 0;
tileMap[2][17] = 0;
tileMap[3][17] = 0;
tileMap[4][17] = 0;
tileMap[5][17] = 0;
tileMap[6][17] = 0;
tileMap[7][17] = 0;
tileMap[8][17] = 0;
tileMap[9][17] = 8;
tileMap[10][17] = 10;
tileMap[11][17] = 9;
tileMap[12][17] = 0;
tileMap[13][17] = 0;
tileMap[14][17] = 0;
tileMap[15][17] = 0;
tileMap[16][17] = 0;
tileMap[17][17] = 0;
tileMap[18][17] = 0;
tileMap[19][17] = 0;
tileMap[20][17] = 0;
tileMap[21][17] = 0;
}
}[/CODE]
[CODE lang="java" title="TilemapActivity.java"]package com.manticore.monochromia;
//und dieses Ungetüm initiiert alle ImageViews und läd sie bei jedem Schritt neu.
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
public class TilemapActivity extends AppCompatActivity {
PlaySounds ps = new PlaySounds();
private NosgTiles nosgTls = new NosgTiles();
private TileDefinition tlDef = new TileDefinition();
private int playerPosition, newPlayerPosition, playerStartX, playerStartY;
private String enter, enterFade;
private int resIDCenter;
private int passLeft, passRight, passUp, passDown;
private int benter, benterfade, location;
private int t33; //central Tile
private int t03, t13, t23, t43, t53, t63, tm13, t73; //horizontal
private int t30, t31, t32, t34, t35, t36, t37, t3m1; //vertical
private int tm14, tm15, tm16, tm17, t07, t17, t27, t04, t05, t06, t14, t15, t16, t24, t25, t26; //upper left sector
private int tm12, tm11, tm10, tm1m1, t0m1, t1m1, t2m1, t00, t01, t02, t10, t11, t12, t20, t21, t22; //lower left sector
private int t4m1, t5m1, t6m1, t7m1, t70, t71, t72, t40, t41, t42, t50, t51, t52, t60, t61, t62; //lower right sector
private int t74, t75, t76, t77, t67, t57, t47, t44, t45, t46, t54, t55, t56, t64, t65, t66; //upper right sector
ImageView cx3y3; //central Tile
ImageView xm1y3, x0y3, x1y3, x2y3, x4y3, x5y3, x6y3, x7y3; //horizontal
ImageView x3ym1, x3y0, x3y1, x3y2, x3y4, x3y5, x3y6, x3y7; //vertical
ImageView xm1y4, xm1y5, xm1y6, xm1y7, x0y7, x1y7, x2y7, x0y4, x0y5, x0y6, x1y4, x1y5, x1y6, x2y4, x2y5, x2y6; //upper left sector
ImageView xm1y2, xm1y1, xm1y0, xm1ym1, x0ym1, x1ym1, x2ym1, x0y0, x0y1, x0y2, x1y0, x1y1, x1y2, x2y0, x2y1, x2y2; //lower left sector
ImageView x4ym1, x5ym1, x6ym1, x7ym1, x7y0, x7y1, x7y2, x4y0, x4y1, x4y2, x5y0, x5y1, x5y2, x6y0, x6y1, x6y2; //lower right sector
ImageView x4y7, x5y7, x6y7, x7y7, x7y6, x7y5, x7y4, x4y4, x4y5, x4y6, x5y4, x5y5, x5y6, x6y4, x6y5, x6y6; //upper right sector
ImageView bUp, bDown, bLeft, bRight, bEnter, bMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_tilemap);
enter = "button_enter";
enterFade = "button_enter_fade";
playerStartX = 10;
playerStartY = 7;
playerPosition = nosgTls.tileMap[playerStartX][playerStartY];
bUp = findViewById(R.id.bUp);
bDown = findViewById(R.id.bDown);
bLeft = findViewById(R.id.bLeft);
bRight = findViewById(R.id.bRight);
bEnter = findViewById(R.id.bEnter);
bMenu = findViewById(R.id.bMenu);
//central Tile
cx3y3 = findViewById(R.id.x3y3);
//Cross section
xm1y3 = findViewById(R.id.xm1y3);
x0y3 = findViewById(R.id.x0y3);
x1y3 = findViewById(R.id.x1y3);
x2y3 = findViewById(R.id.x2y3);
x4y3 = findViewById(R.id.x4y3);
x5y3 = findViewById(R.id.x5y3);
x6y3 = findViewById(R.id.x6y3);
x7y3 = findViewById(R.id.x7y3);
x3ym1 = findViewById(R.id.x3ym1);
x3y0 = findViewById(R.id.x3y0);
x3y1 = findViewById(R.id.x3y1);
x3y2 = findViewById(R.id.x3y2);
x3y4 = findViewById(R.id.x3y4);
x3y5 = findViewById(R.id.x3y5);
x3y6 = findViewById(R.id.x3y6);
x3y7 = findViewById(R.id.x3y7);
//upper left sector
x0y4 = findViewById(R.id.x0y4);
x0y5 = findViewById(R.id.x0y5);
x0y6 = findViewById(R.id.x0y6);
x1y4 = findViewById(R.id.x1y4);
x1y5 = findViewById(R.id.x1y5);
x1y6 = findViewById(R.id.x1y6);
x2y4 = findViewById(R.id.x2y4);
x2y5 = findViewById(R.id.x2y5);
x2y6 = findViewById(R.id.x2y6);
xm1y4 = findViewById(R.id.xm1y4);
xm1y5 = findViewById(R.id.xm1y5);
xm1y6 = findViewById(R.id.xm1y6);
xm1y7 = findViewById(R.id.xm1y7);
x0y7 = findViewById(R.id.x0y7);
x1y7 = findViewById(R.id.x1y7);
x2y7 = findViewById(R.id.x2y7);
//lower left sector
x0y0 = findViewById(R.id.x0y0);
x0y1 = findViewById(R.id.x0y1);
x0y2 = findViewById(R.id.x0y2);
x1y0 = findViewById(R.id.x1y0);
x1y1 = findViewById(R.id.x1y1);
x1y2 = findViewById(R.id.x1y2);
x2y0 = findViewById(R.id.x2y0);
x2y1 = findViewById(R.id.x2y1);
x2y2 = findViewById(R.id.x2y2);
xm1y2 = findViewById(R.id.xm1y2);
xm1y1 = findViewById(R.id.xm1y1);
xm1y0 = findViewById(R.id.xm1y0);
xm1ym1 = findViewById(R.id.xm1ym1);
x0ym1 = findViewById(R.id.x0ym1);
x1ym1 = findViewById(R.id.x1ym1);
x2ym1 = findViewById(R.id.x2ym1);
//lower right sector
x4y0 = findViewById(R.id.x4y0);
x4y1 = findViewById(R.id.x4y1);
x4y2 = findViewById(R.id.x4y2);
x5y0 = findViewById(R.id.x5y0);
x5y1 = findViewById(R.id.x5y1);
x5y2 = findViewById(R.id.x5y2);
x6y0 = findViewById(R.id.x6y0);
x6y1 = findViewById(R.id.x6y1);
x6y2 = findViewById(R.id.x6y2);
x4ym1 = findViewById(R.id.x4ym1);
x5ym1 = findViewById(R.id.x5ym1);
x6ym1 = findViewById(R.id.x6ym1);
x7ym1 = findViewById(R.id.x7ym1);
x7y0 = findViewById(R.id.x7y0);
x7y1 = findViewById(R.id.x7y1);
x7y2 = findViewById(R.id.x7y2);
//upper right sector
x4y4 = findViewById(R.id.x4y4);
x4y5 = findViewById(R.id.x4y5);
x4y6 = findViewById(R.id.x4y6);
x5y4 = findViewById(R.id.x5y4);
x5y5 = findViewById(R.id.x5y5);
x5y6 = findViewById(R.id.x5y6);
x6y4 = findViewById(R.id.x6y4);
x6y5 = findViewById(R.id.x6y5);
x6y6 = findViewById(R.id.x6y6);
x7y4 = findViewById(R.id.x7y4);
x7y5 = findViewById(R.id.x7y5);
x7y6 = findViewById(R.id.x7y6);
x7y7 = findViewById(R.id.x7y7);
x6y7 = findViewById(R.id.x6y7);
x5y7 = findViewById(R.id.x5y7);
x4y7 = findViewById(R.id.x4y7);
InitiateMap();
MoveLeft();
MoveRight();
MoveUp();
MoveDown();
Enter();
Menu();
}
@Override
public void onBackPressed(){
super.onBackPressed();
this.finish();
Intent i = new Intent(this, DebugMenuActivity.class);
startActivity(i);
overridePendingTransition(0,0);
i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
}
public void SetPlayerPositionXY(){
resIDCenter = getResources().getIdentifier(tlDef.tileDef[playerPosition], "drawable", getPackageName());
cx3y3.setImageResource(resIDCenter);
}
public void LoadCenterTileXY(){
cx3y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY]], "drawable", getPackageName()));
}
public void LoadCrossXY(){
//Horizontale
xm1y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY]], "drawable", getPackageName()));
x0y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY]], "drawable", getPackageName()));
x1y3.setImageResource(getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY]], "drawable", getPackageName()));
t23 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY]], "drawable", getPackageName());
x2y3.setImageResource(t23);
//Get Passability Left
passLeft = tlDef.passable[nosgTls.tileMap[playerStartX - 1][playerStartY]];
//middle
t43 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY]], "drawable", getPackageName());
x4y3.setImageResource(t43);
//Get Passability Right
passRight = tlDef.passable[nosgTls.tileMap[playerStartX + 1][playerStartY]];
t53 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY]], "drawable", getPackageName());
x5y3.setImageResource(t53);
t63 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY]], "drawable", getPackageName());
x6y3.setImageResource(t63);
t73 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY]], "drawable", getPackageName());
x7y3.setImageResource(t73);
//Verticale
t37 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 4]], "drawable", getPackageName());
x3y7.setImageResource(t37);
t36 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 3]], "drawable", getPackageName());
x3y6.setImageResource(t36);
t35 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 2]], "drawable", getPackageName());
x3y5.setImageResource(t35);
t34 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY + 1]], "drawable", getPackageName());
x3y4.setImageResource(t34);
//get passability up
passUp = tlDef.passable[nosgTls.tileMap[playerStartX][playerStartY + 1]];
//middle
t32 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 1]], "drawable", getPackageName());
x3y2.setImageResource(t32);
//get passability down
passDown = tlDef.passable[nosgTls.tileMap[playerStartX][playerStartY - 1]];
t31 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 2]], "drawable", getPackageName());
x3y1.setImageResource(t31);
t30 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 3]], "drawable", getPackageName());
x3y0.setImageResource(t30);
t3m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX][playerStartY - 4]], "drawable", getPackageName());
x3ym1.setImageResource(t3m1);
}
public void LoadSectorUpperLeft(){
t04 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 1]], "drawable", getPackageName());
x0y4.setImageResource(t04);
t05 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 2]], "drawable", getPackageName());
x0y5.setImageResource(t05);
t06 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 3]], "drawable", getPackageName());
x0y6.setImageResource(t06);
//
t14 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 1]], "drawable", getPackageName());
x1y4.setImageResource(t14);
t15 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 2]], "drawable", getPackageName());
x1y5.setImageResource(t15);
t16 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 3]], "drawable", getPackageName());
x1y6.setImageResource(t16);
//
t24 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 1]], "drawable", getPackageName());
x2y4.setImageResource(t24);
t25 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 2]], "drawable", getPackageName());
x2y5.setImageResource(t25);
t26 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 3]], "drawable", getPackageName());
x2y6.setImageResource(t26);
//new
tm14 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 1]], "drawable", getPackageName());
xm1y4.setImageResource(tm14);
tm15 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 2]], "drawable", getPackageName());
xm1y5.setImageResource(tm15);
tm16 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 3]], "drawable", getPackageName());
xm1y6.setImageResource(tm16);
tm17 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY + 4]], "drawable", getPackageName());
xm1y7.setImageResource(tm17);
t07 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY + 4]], "drawable", getPackageName());
x0y7.setImageResource(t07);
t17 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY + 4]], "drawable", getPackageName());
x1y7.setImageResource(t17);
t27 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY + 4]], "drawable", getPackageName());
x2y7.setImageResource(t27);
}
public void LoadSectorLowerLeft(){
t00 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 3]], "drawable", getPackageName());
x0y0.setImageResource(t00);
t01 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 2]], "drawable", getPackageName());
x0y1.setImageResource(t01);
t02 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 1]], "drawable", getPackageName());
x0y2.setImageResource(t02);
//
t10 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 3]], "drawable", getPackageName());
x1y0.setImageResource(t10);
t11 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 2]], "drawable", getPackageName());
x1y1.setImageResource(t11);
t12 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 1]], "drawable", getPackageName());
x1y2.setImageResource(t12);
//
t20 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 3]], "drawable", getPackageName());
x2y0.setImageResource(t20);
t21 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 2]], "drawable", getPackageName());
x2y1.setImageResource(t21);
t22 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 1]], "drawable", getPackageName());
x2y2.setImageResource(t22);
//new
tm12 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 1]], "drawable", getPackageName());
xm1y2.setImageResource(tm12);
tm11 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 2]], "drawable", getPackageName());
xm1y1.setImageResource(tm11);
tm10 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 3]], "drawable", getPackageName());
xm1y0.setImageResource(tm10);
tm1m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 4][playerStartY - 4]], "drawable", getPackageName());
xm1ym1.setImageResource(tm1m1);
t0m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 3][playerStartY - 4]], "drawable", getPackageName());
x0ym1.setImageResource(t0m1);
t1m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 2][playerStartY - 4]], "drawable", getPackageName());
x1ym1.setImageResource(t1m1);
t2m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX - 1][playerStartY - 4]], "drawable", getPackageName());
x2ym1.setImageResource(t2m1);
}
public void LoadSectorLowerRight(){
t40 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 3]], "drawable", getPackageName());
x4y0.setImageResource(t40);
t50 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 3]], "drawable", getPackageName());
x5y0.setImageResource(t50);
t60 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 3]], "drawable", getPackageName());
x6y0.setImageResource(t60);
//
t41 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 2]], "drawable", getPackageName());
x4y1.setImageResource(t41);
t51 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 2]], "drawable", getPackageName());
x5y1.setImageResource(t51);
t61 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 2]], "drawable", getPackageName());
x6y1.setImageResource(t61);
//
t42 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 1]], "drawable", getPackageName());
x4y2.setImageResource(t42);
t52 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 1]], "drawable", getPackageName());
x5y2.setImageResource(t52);
t62 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 1]], "drawable", getPackageName());
x6y2.setImageResource(t62);
//new
t4m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY - 4]], "drawable", getPackageName());
x4ym1.setImageResource(t4m1);
t5m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY - 4]], "drawable", getPackageName());
x5ym1.setImageResource(t5m1);
t6m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY - 4]], "drawable", getPackageName());
x6ym1.setImageResource(t6m1);
t7m1 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 4]], "drawable", getPackageName());
x7ym1.setImageResource(t7m1);
t70 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 3]], "drawable", getPackageName());
x7y0.setImageResource(t70);
t71 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 2]], "drawable", getPackageName());
x7y1.setImageResource(t71);
t72 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY - 1]], "drawable", getPackageName());
x7y2.setImageResource(t72);
}
public void LoadSectorUpperRight(){
t44 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 1]], "drawable", getPackageName());
x4y4.setImageResource(t44);
t54 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 1]], "drawable", getPackageName());
x5y4.setImageResource(t54);
t64 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 1]], "drawable", getPackageName());
x6y4.setImageResource(t64);
//
t45 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 2]], "drawable", getPackageName());
x4y5.setImageResource(t45);
t55 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 2]], "drawable", getPackageName());
x5y5.setImageResource(t55);
t65 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 2]], "drawable", getPackageName());
x6y5.setImageResource(t65);
//
t46 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 3]], "drawable", getPackageName());
x4y6.setImageResource(t46);
t56 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 3]], "drawable", getPackageName());
x5y6.setImageResource(t56);
t66 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 3]], "drawable", getPackageName());
x6y6.setImageResource(t66);
//new
t74 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 1]], "drawable", getPackageName());
x7y4.setImageResource(t74);
t75 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 2]], "drawable", getPackageName());
x7y5.setImageResource(t75);
t76 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 3]], "drawable", getPackageName());
x7y6.setImageResource(t76);
t77 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 4][playerStartY + 4]], "drawable", getPackageName());
x7y7.setImageResource(t77);
t67 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 3][playerStartY + 4]], "drawable", getPackageName());
x6y7.setImageResource(t67);
t57 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 2][playerStartY + 4]], "drawable", getPackageName());
x5y7.setImageResource(t57);
t47 = getResources().getIdentifier(tlDef.tileDef[nosgTls.tileMap[playerStartX + 1][playerStartY + 4]], "drawable", getPackageName());
x4y7.setImageResource(t47);
}
public void InitiateMap(){
SetPlayerPositionXY();
LoadTiles();
}
public void LoadTiles(){
LoadCenterTileXY();
LoadCrossXY();
LoadSectorUpperLeft();
LoadSectorUpperRight();
LoadSectorLowerLeft();
LoadSectorLowerRight();
CheckIfSpecialPosition(); //soll prüfen, ob der enter-button klickbar wird und man zu einer szene wechseln können soll
}
public void CheckIfSpecialPosition(){
location = nosgTls.locations[playerStartX][playerStartY];
switch(location){
case 0://wenn position nicht speziell: deaktiviere enter button
benter = getResources().getIdentifier(enterFade, "drawable", getPackageName());
bEnter.setImageResource(benter);
bEnter.setClickable(false);
break;
case 1://wenn position speziell: aktiviere enter button
benter = getResources().getIdentifier(enter, "drawable", getPackageName());
bEnter.setImageResource(benter);
bEnter.setClickable(true);
break;
}
}
public void MoveLeft(){
bLeft.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passLeft){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartX - 1;
playerStartX = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void Enter(){
bEnter.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(playerStartX){
case 7://tent scene
if(playerStartY == 7){
}
break;
case 10://tower scene
if(playerStartY == 10){
TilemapActivity.this.finish();
Intent i = new Intent(TilemapActivity.this, SceneNosgTowerActivity.class);
startActivity(i);
overridePendingTransition(0,0);
}
break;
case 17://dock scene
if(playerStartY == 9){
}
break;
}
}
}
);
}
public void Menu(){
bMenu.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
}
}
);
}
public void MoveRight(){
bRight.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passRight){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartX + 1;
playerStartX = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void MoveUp(){
bUp.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passUp){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartY + 1;
playerStartY = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
public void MoveDown(){
bDown.setOnClickListener(
new View.OnClickListener(){
@Override
public void onClick(View v){
switch(passDown){
case 0:
ps.PlayActionSound(TilemapActivity.this);
break;
case 1:
newPlayerPosition = playerStartY - 1;
playerStartY = newPlayerPosition;
LoadTiles();
break;
}
}
}
);
}
}[/CODE]
So, dieses Ungetüm funktioniert soweit, aber es sollte für jedes Feld ein zufälliges Gras-Teil anzeigen, und nicht immer für alle das gleiche -.-