Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android rpg game isometric view

Tags:

android

 9 represented by 9

7 represented by 7

8represented by 8

6represented by 6

2d array the -1 is empty region and 0 is grass full

this is the code i am using to render the view

//map class
        private int[][] terrain = new int[20][20];
        }


        //constructor
        protected Drawable[] tiles = new Drawable[10];

        tiles[GameMap.GRASS]  = getResources().getDrawable(R.drawable.grass);
        tiles[GameMap.GRASS_WU]  = getResources().getDrawable(R.drawable.grass_wu);
        tiles[GameMap.GRASS_WD]  = getResources().getDrawable(R.drawable.grass_wd);
        tiles[GameMap.GRASS_EU]  = getResources().getDrawable(R.drawable.grass_eu);
        tiles[GameMap.GRASS_ED]  = getResources().getDrawable(R.drawable.grass_ed);

            protected void onDraw(Canvas canvas) {
        //move_Unit();

        for (int x=0;x<map.getWidthInTiles();x++) {
            for (int y=0;y<map.getHeightInTiles();y++) {

                if(map.getTerrain(x,y) != -1){

                tiles[map.getTerrain(x,y)].setBounds(x*16,y*16,(x*16) + 16,(y*16) + 16);


                if (map.getUnit(x,y) != 0) {
                    tiles[map.getUnit(x,y)].setBounds(x*16,y*16,(x*16) + 16,(y*16) + 16);
                } 
                tiles[map.getTerrain(x, y)].draw(canvas);
                tiles[map.getUnit(x, y)].draw(canvas);
                }
            }
        }

        }

    } 

why does my view appear like this and how do i fix it?enter image description here

like image 892
2 revs, 2 users 92% Avatar asked Jun 06 '26 12:06

2 revs, 2 users 92%


1 Answers

Have you checked cocos2d-x? You have that stuff already.

like image 59
Macarse Avatar answered Jun 09 '26 00:06

Macarse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!