Change maptileinfo to be an indexed image. Move tile-specific code into editor renderer.

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 4c526ba594
commit 5e1f69a9d0
  1. BIN
      sprites/maptileinfo.gif
  2. 5
      src/sig/engine/Sprite.java
  3. 8
      src/sig/objects/EditorRenderer.java
  4. 12
      src/sig/objects/LevelRenderer.java

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 425 B

@ -3,17 +3,16 @@ package sig.engine;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.awt.image.DataBufferByte;
import javax.imageio.ImageIO;
public enum Sprite{
NANA(new File(new File("..","sprites"),"3x.png")),
//NANA(new File(new File("..","sprites"),"3x.png")),
NANA_SMALL(new File(new File("..","sprites"),"1x.gif")),
TILE_SHEET(new File(new File("..","sprites"),"tiles.gif")),
MAP_TILE_INFO(new File(new File("..","sprites"),"maptileinfo-1.png.png")),
MAP_TILE_INFO(new File(new File("..","sprites"),"maptileinfo.gif")),
;

@ -4,6 +4,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import sig.RabiClone;
import sig.engine.Alpha;
import sig.engine.MouseScrollValue;
import sig.engine.Panel;
import sig.engine.Sprite;
@ -58,5 +59,12 @@ public class EditorRenderer extends LevelRenderer{
public void draw(byte[] p) {
super.draw(p);
Draw_Sprite(16, 16, Sprite.MAP_TILE_INFO);
}
@Override
protected void drawMapTileForEditorMode(int x, int y) {
if (x==RabiClone.p.highlightedSquare.getX()&&y==RabiClone.p.highlightedSquare.getY()) {
DrawTransparentTile(x*Tile.TILE_WIDTH-this.getX(),y*Tile.TILE_HEIGHT-this.getY(),selectedTile,Alpha.ALPHA160);
}
}
}

@ -10,8 +10,6 @@ import sig.map.Tile;
public class LevelRenderer extends Object{
Tile selectedTile = Tile.WALL;
public LevelRenderer(Panel panel) {
super(panel);
this.setSprite(Sprite.TILE_SHEET);
@ -35,17 +33,15 @@ public class LevelRenderer extends Object{
DrawTile(x*Tile.TILE_WIDTH-this.getX(),y*Tile.TILE_HEIGHT-this.getY(),RabiClone.CURRENT_MAP.getTile(x,y));
//System.out.println((x*Tile.TILE_WIDTH+(this.getX()%Tile.TILE_WIDTH) )+","+(y*Tile.TILE_HEIGHT+(this.getY()%Tile.TILE_HEIGHT)));
}
if (this instanceof EditorRenderer) {
if (x==RabiClone.p.highlightedSquare.getX()&&y==RabiClone.p.highlightedSquare.getY()) {
DrawTransparentTile(x*Tile.TILE_WIDTH-this.getX(),y*Tile.TILE_HEIGHT-this.getY(),selectedTile,Alpha.ALPHA160);
}
}
drawMapTileForEditorMode(x,y);
}
}
Draw_Object(RabiClone.player);
Draw_Object(RabiClone.player2);
}
protected void drawMapTileForEditorMode(int x, int y) {}
/**
* Draws an object where its sprite is centered among its position and drawn relative to the camera position.
* @param object
@ -58,7 +54,7 @@ public class LevelRenderer extends Object{
Draw_Sprite_Partial(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite());
}
private void DrawTransparentTile(double x, double y, Tile tile, Alpha alpha) {
protected void DrawTransparentTile(double x, double y, Tile tile, Alpha alpha) {
Draw_Sprite_Partial_Ext(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), alpha);
}

Loading…
Cancel
Save