Oddity with 32x32 tiles... Graphics help needed, please? :)


Last Updated:

  1. l0ki

    l0ki Member This Topic's Starter

    Joined:
    Oct 24, 2010
    Messages:
    5
    Likes Received:
    1
    Hey folks,

    I'm currently writing a game. The game uses 32x32 tiles and is drawn to a SurfaceView. Trouble is, that when the map area is drawn, the 32x32 tiles wont draw correctly unless I manually set the draw routine to draw them at a tile size of 44x44 ?! Is this android, or me? I don't want to show all the code, due to my (eventually) wanting to stick it on the market, but here are some snippets of the problem code:

    Code (Text):
    1.  
    2. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_WIDTH[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = 240;[/SIZE]
    3. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_HEIGHT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = 320;[/SIZE]
    4. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = 32; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// max tile dimensions[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
    5. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE_2[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = 44; // stupidly sized tiles for correct drawing...???[/SIZE]
    6.  
    Code (Text):
    1.  
    2. [LEFT][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirtTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = BitmapFactory.[I]decodeResource[/I](getResources(), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirt_01[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/SIZE][SIZE=2]
    3. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]goldTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = BitmapFactory.[I]decodeResource[/I](getResources(), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirt_gold[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    4. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]silverTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = BitmapFactory.[I]decodeResource[/I](getResources(), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirt_silver[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    5. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]copperTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = BitmapFactory.[I]decodeResource[/I](getResources(), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirt_copper[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
    6. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Bitmap [/SIZE][U][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]startTile[/COLOR][/SIZE][/COLOR][/SIZE][/U][SIZE=2] = BitmapFactory.[I]decodeResource[/I](getResources(), R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dave_start[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    7. [/SIZE]
    Code (Text):
    1.  
    2. [LEFT][SIZE=2][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] createBlankMap(){[/SIZE][/SIZE][SIZE=2]
    3. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x=0; x<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_WIDTH[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; x++){[/SIZE]
    4. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y=0; y<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_HEIGHT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; y++){[/SIZE]
    5. [SIZE=2]setMapData(x, y, [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DEFAULT_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    6. [SIZE=2]}[/SIZE]
    7. [SIZE=2]}[/SIZE]
    8. [SIZE=2]}[/SIZE][/LEFT]
    9.  
    10. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] mapStringToMap(String mapString){[/SIZE]
    11. [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// clear the map first[/COLOR][/SIZE][/COLOR][/SIZE]
    12. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] i= 0;[/SIZE]
    13. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x = 0; x<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_WIDTH[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; x++){[/SIZE]
    14. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y =0; y<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_HEIGHT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; y++){[/SIZE]
    15. [SIZE=2]setMapData(x, y, Integer.[I]parseInt[/I](String.[I]valueOf[/I](mapString.charAt(i))));[/SIZE]
    16. [SIZE=2]i++;[/SIZE]
    17. [SIZE=2]}[/SIZE]
    18. [SIZE=2]} [/SIZE]
    19. [SIZE=2]}[/SIZE][/LEFT]
    20.  
    21. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] setMapData([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] v){[/SIZE]
    22. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]map_area[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][x][y] = v;[/SIZE][/LEFT]
    23. [SIZE=2]}[/SIZE]
    24. [/SIZE][/SIZE]


    ... and the main drawing routine for each tile
    Code (Text):
    1.  
    2. [LEFT][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] drawMapTiles(Canvas canvas){[/SIZE][/SIZE][SIZE=2]
    3. [SIZE=2]Paint p = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Paint();[/SIZE]
    4. [SIZE=2]p.setColor(Color.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WHITE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    5. [SIZE=2]p.setStyle(Paint.Style.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]STROKE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
    6.  
    7. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x=0; x<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_WIDTH[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; x++){[/SIZE]
    8. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y=0; y<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_HEIGHT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; y++){[/SIZE]
    9. [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// DRAW GRID[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
    10.  
    11.  
    12. [LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// DIRT SPRITE DEFAULT TILE //////////////////////////////////////////////////////////////////////[/COLOR][/SIZE][/COLOR][/SIZE]
    13. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](getMapData(x,y) == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DEFAULT_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE]
    14. [SIZE=2]canvas.drawBitmap([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dirtTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], x*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], y*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
    15.  
    16. [LEFT][SIZE=2]}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](getMapData(x,y) == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]GOLD_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE]
    17. [SIZE=2]canvas.drawBitmap([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]goldTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], x*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], y*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
    18.  
    19. [LEFT][SIZE=2]}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](getMapData(x,y) == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SILVER_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE]
    20. [SIZE=2]canvas.drawBitmap([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]silverTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], x*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], y*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
    21.  
    22. [LEFT][SIZE=2]}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](getMapData(x,y) == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]COPPER_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE]
    23. [SIZE=2]canvas.drawBitmap([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]copperTile[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], x*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], y*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
    24.  
    25. [LEFT][SIZE=2]}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](getMapData(x,y) == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]START_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]){[/SIZE]
    26. [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// reset this tile to a default dirt block, so we don't see the[/COLOR][/SIZE][/COLOR][/SIZE]
    27. [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// player start[/COLOR][/SIZE][/COLOR][/SIZE]
    28. [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// draw the default dirt tile[/COLOR][/SIZE][/COLOR][/SIZE]
    29. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dave[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setX(x*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    30. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dave[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setY(y*[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
    31.  
    32. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](![/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]editor_mode[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]){ [/SIZE]
    33. [SIZE=2]setMapData(x, y, [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DEFAULT_TILE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]); [/SIZE]
    34. [SIZE=2]}[/SIZE]
    35. [SIZE=2]}[/SIZE][/LEFT]
    36.  
    37. [LEFT][SIZE=2]} [/SIZE]
    38. [SIZE=2]}[/SIZE][/LEFT]
    39.  
    40. [SIZE=2]}[/SIZE]
    41. [/SIZE]
    and a few others if it helps:
    Code (Text):
    1.  
    2. [LEFT][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] getMapData([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y){[/SIZE][/SIZE][SIZE=2]
    3. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]map_area[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][x][y];[/SIZE]
    4. [SIZE=2]}[/SIZE][/LEFT]
    5.  
    6. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String mapDataToString(){[/SIZE]
    7. [SIZE=2]StringBuilder sb = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] StringBuilder();[/SIZE][/LEFT]
    8.  
    9. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] x=0; x<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_WIDTH[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; x++){[/SIZE]
    10. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] y=0; y<[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MAX_HEIGHT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]/[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TILE_SIZE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]; y++){[/SIZE]
    11. [SIZE=2]sb.append(getMapData(x, y));[/SIZE]
    12. [SIZE=2]}[/SIZE]
    13. [SIZE=2]}[/SIZE][/LEFT]
    14.  
    15. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] sb.toString();[/SIZE][/LEFT]
    16. [SIZE=2]}[/SIZE]
    17. [/SIZE]
    - I'm not sure what the problem is, but using the TILE_SIZE_2 member will make the map draw perfectly, but will in turn knock out all of the collision detection I have up and running.

    Any help is greatly appreciated. This isn't my first game, but it is my first tile based game on android, and rather than using an engine, I thought I'd start from scratch, but this is quite litterally doing my head in!

    I should point out that I have indeed checked that my tiles are indeed 32x32 - MANY times ....

    :( TIA.

    {edit - The functions didn't paste correctly... This isn't intentional ;)}
     

    Advertisement

Share This Page

Loading...