parent
							
								
									a24d6c37a4
								
							
						
					
					
						commit
						307d8d2b10
					
				| 
		 After Width: | Height: | Size: 875 B  | 
									
										Binary file not shown.
									
								
							
						| 
		 Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.8 KiB  | 
									
										Binary file not shown.
									
								
							
						@ -0,0 +1,45 @@ | 
				
			|||||||
 | 
					package mightypork.rogue.world; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Sides { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//@formatter:off
 | 
				
			||||||
 | 
						public static final byte NW = (byte) 0b10000000; | 
				
			||||||
 | 
						public static final byte N  = 0b01000000; | 
				
			||||||
 | 
						public static final byte NE = 0b00100000; | 
				
			||||||
 | 
						public static final byte E  = 0b00010000; | 
				
			||||||
 | 
						public static final byte SE = 0b00001000; | 
				
			||||||
 | 
						public static final byte S  = 0b00000100; | 
				
			||||||
 | 
						public static final byte SW = 0b00000010; | 
				
			||||||
 | 
						public static final byte W  = 0b00000001; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public static final byte CARDINAL = N|S|E|W; | 
				
			||||||
 | 
						public static final byte DIAGONAL = NE|NW|SE|SW; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public static final byte NW_CORNER = W|NW|N; | 
				
			||||||
 | 
						public static final byte NE_CORNER = E|NE|N; | 
				
			||||||
 | 
						public static final byte SW_CORNER = W|SW|S; | 
				
			||||||
 | 
						public static final byte SE_CORNER = E|SE|S; | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						private final static Coord[] side = { | 
				
			||||||
 | 
								Coord.make(-1, -1), | 
				
			||||||
 | 
								Coord.make(0, -1), | 
				
			||||||
 | 
								Coord.make(1, -1), | 
				
			||||||
 | 
								Coord.make(1, 0), | 
				
			||||||
 | 
								Coord.make(1, 1), | 
				
			||||||
 | 
								Coord.make(0, 1), | 
				
			||||||
 | 
								Coord.make(-1, 1), | 
				
			||||||
 | 
								Coord.make(-1, 0) | 
				
			||||||
 | 
						}; | 
				
			||||||
 | 
						//@formatter:on
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static Coord get(int i) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return side[i]; // FIXME Coord is mutable
 | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static byte bit(int i) | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							return (byte) (1 << (7 - i)); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,81 +0,0 @@ | 
				
			|||||||
package mightypork.rogue.world.tile.renderers; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import mightypork.gamecore.render.Render; | 
					 | 
				
			||||||
import mightypork.gamecore.render.textures.TxQuad; | 
					 | 
				
			||||||
import mightypork.rogue.Res; | 
					 | 
				
			||||||
import mightypork.rogue.world.level.render.TileRenderContext; | 
					 | 
				
			||||||
import mightypork.rogue.world.tile.Tile; | 
					 | 
				
			||||||
import mightypork.rogue.world.tile.TileRenderData; | 
					 | 
				
			||||||
import mightypork.util.math.constraints.rect.Rect; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class FloorRenderer extends BasicTileRenderer { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	private static boolean inited; | 
					 | 
				
			||||||
	private static TxQuad SH_N, SH_S, SH_E, SH_W, SH_NW, SH_NE, SH_SW, SH_SE; | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public FloorRenderer(String sheetKey) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		super(sheetKey); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (!inited) { | 
					 | 
				
			||||||
			SH_N = Res.getTxQuad("tile.shadow.n"); | 
					 | 
				
			||||||
			SH_S = Res.getTxQuad("tile.shadow.s"); | 
					 | 
				
			||||||
			SH_E = Res.getTxQuad("tile.shadow.e"); | 
					 | 
				
			||||||
			SH_W = Res.getTxQuad("tile.shadow.w"); | 
					 | 
				
			||||||
			SH_NW = Res.getTxQuad("tile.shadow.nw"); | 
					 | 
				
			||||||
			SH_NE = Res.getTxQuad("tile.shadow.ne"); | 
					 | 
				
			||||||
			SH_SW = Res.getTxQuad("tile.shadow.sw"); | 
					 | 
				
			||||||
			SH_SE = Res.getTxQuad("tile.shadow.se"); | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	@Override | 
					 | 
				
			||||||
	public void render(TileRenderContext context) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		super.render(context); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		final Rect rect = context.getRect(); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		final TileRenderData trd = context.getTile().renderData; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (!trd.shadowsComputed) { | 
					 | 
				
			||||||
			// no shadows computed yet
 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			trd.shadows = 0; // reset the mask
 | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			int move = 0; | 
					 | 
				
			||||||
			for (int y = -1; y <= 1; y++) { | 
					 | 
				
			||||||
				for (int x = -1; x <= 1; x++) { | 
					 | 
				
			||||||
					if (x == 0 && y == 0) continue; | 
					 | 
				
			||||||
					 | 
					 | 
				
			||||||
					final Tile t2 = context.getAdjacentTile(x, y); | 
					 | 
				
			||||||
					 | 
					 | 
				
			||||||
					if (t2.doesCastShadow()) { | 
					 | 
				
			||||||
						trd.shadows |= 1 << move; | 
					 | 
				
			||||||
					} | 
					 | 
				
			||||||
					 | 
					 | 
				
			||||||
					move++; | 
					 | 
				
			||||||
				} | 
					 | 
				
			||||||
			} | 
					 | 
				
			||||||
			 | 
					 | 
				
			||||||
			trd.shadowsComputed = true; | 
					 | 
				
			||||||
		} | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if (trd.shadows == 0) return; | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 0)) != 0) Render.quadTextured(rect, SH_NW); | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 1)) != 0) Render.quadTextured(rect, SH_N); | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 2)) != 0) Render.quadTextured(rect, SH_NE); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 3)) != 0) Render.quadTextured(rect, SH_W); | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 4)) != 0) Render.quadTextured(rect, SH_E); | 
					 | 
				
			||||||
		 | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 5)) != 0) Render.quadTextured(rect, SH_SW); | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 6)) != 0) Render.quadTextured(rect, SH_S); | 
					 | 
				
			||||||
		if ((trd.shadows & (1 << 7)) != 0) Render.quadTextured(rect, SH_SE); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,11 +0,0 @@ | 
				
			|||||||
package mightypork.rogue.world.tile.renderers; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class WallRenderer extends BasicTileRenderer { | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
	public WallRenderer(String sheetKey) | 
					 | 
				
			||||||
	{ | 
					 | 
				
			||||||
		super(sheetKey); | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
	 | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue