Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (768)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: Geemili (posted 2013-08-15 09:29:55, viewed 612 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62  
public static final short UP = 0x01;
public static final short UP_RIGHT = 0x02;
public static final short RIGHT = 0x04;
public static final short DOWN_RIGHT = 0x08;
public static final short DOWN = 0x10;
public static final short DOWN_LEFT = 0x20;
public static final short LEFT = 0x40;
public static final short UP_LEFT = 0x80;

byte[] autoTileOrder = new byte[] {/*Forest tile id*/, /*Shallow Water tile id*/, /*Deep Water tile id*/};
short[][] transitionTile = new short[worldWidth][worldHeight];

public void preprocess() {
    for(int x=0; x<getMapWidth(); x++) {
        for(int y=0w; y<getMapHeight(); y++) {
            transitionTile[x][y] = 0x00;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x,y+1)) ? UP : 0; 
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x+1,y+1)) ? UP_RIGHT : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x+1,y)) ? RIGHT : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x+1,y-1)) ? DOWN_RIGHT : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x,y-1)) ? DOWN : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x-1,y-1)) ? DOWN_LEFT : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x-1,y)) ? LEFT : 0;
            transitionTile[x][y] += wio(getTile(x,y))<wio(getTile(x-1,y+1)) ? UP_LEFT : 0;
        }
    }
}

public int wio(int tileId) {// Short for where in order
    for(int i=0; i<autoTileOrder; i++) {
        if(tileId == autoTileOrder[i]) {
            return i;
        }
    }
    return 0;
}

public void render() {
    //Render your tiles how they are rendered now
    for(int x=leftSideOfView; x<rightSideOfView; x++) {
        for(int y=bottomOfView; y<topOfView; y++) {
            if(transitionTile[x][y]!=0x00) {
                if(aCheck(transitionTile[x][y], UP)) batch.draw(getTransitionTile(getTile(x, y+1), UP), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], UP_RIGHT) batch.draw(getTransitionTile(getTile(x+1, y+1), UP_RIGHT), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], RIGHT) batch.draw(getTransitionTile(getTile(x+1, y), RIGHT), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], DOWN_RIGHT) batch.draw(getTransitionTile(getTile(x+1, y-1), DOWN_RIGHT), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], DOWN) batch.draw(getTransitionTile(getTile(x, y-1), DOWN), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], DOWN_LEFT) batch.draw(getTransitionTile(getTile(x-1, y-1), DOWN_LEFT), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], LEFT) batch.draw(getTransitionTile(getTile(x-1, y), LEFT), x*tileWidth, y*tileHeight);
                if(aCheck(transitionTile[x][y], UP_LEFT) batch.draw(getTransitionTile(getTile(x-1, y+1), UP_LEFT), x*tileWidth, y*tileHeight);
            }
        }
    }
}

public boolean aCheck(int transitionTile, int position) {
    return (transitionTile & position) == position;
}

public TextureRegion getTransitionTile(byte tileId, int position) {
    //You'll have to figure this part out on your own
}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
EgonOlsen (1340 views)
2018-06-10 19:43:48

EgonOlsen (1229 views)
2018-06-10 19:43:44

EgonOlsen (939 views)
2018-06-10 19:43:20

DesertCoockie (1380 views)
2018-05-13 18:23:11

nelsongames (1112 views)
2018-04-24 18:15:36

nelsongames (1374 views)
2018-04-24 18:14:32

ivj94 (2120 views)
2018-03-24 14:47:39

ivj94 (1269 views)
2018-03-24 14:46:31

ivj94 (2286 views)
2018-03-24 14:43:53

Solater (808 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!