From 1d8438bc9a48341fbc074f03420cdced787752a8 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 30 May 2022 03:16:04 -0500 Subject: [PATCH] Load images as gif indexed images Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- 1x.gif | Bin 0 -> 458 bytes 1x.png | Bin 9690 -> 8667 bytes GamePalette.icc | Bin 0 -> 672 bytes src/sig/DrawLoop.java | 53 ++------------ src/sig/engine/Alpha.java | 13 ++++ src/sig/engine/GameEntity.java | 2 +- src/sig/engine/Object.java | 4 +- src/sig/engine/Panel.java | 114 +++++++++++++---------------- src/sig/engine/Sprite.java | 13 ++-- src/sig/objects/LevelRenderer.java | 7 +- src/sig/objects/Player.java | 2 +- 11 files changed, 87 insertions(+), 121 deletions(-) create mode 100644 1x.gif create mode 100644 GamePalette.icc create mode 100644 src/sig/engine/Alpha.java diff --git a/1x.gif b/1x.gif new file mode 100644 index 0000000000000000000000000000000000000000..6c22ce7777276e5a9768f6c6d5fbdbfaf2b05b93 GIT binary patch literal 458 zcmV;*0X6UpH3Q7<;8!1<{4?9`dc7tf6=dz_r{V4h*PvF@pBrI8fJli*OeJz8`m6~-QiI8vA}ssV)s97{S&GL8|02|(rOnIJ6| zCkDDkY`XCi=mZ+4EI3^hE2#)eED1S%dM(malY~YPYlTajSvC{c%p@AN(TETLJD^R= Aod5s; literal 0 HcmV?d00001 diff --git a/1x.png b/1x.png index 66e874d4ee712d6a307706d103e1d06be773e833..7bd2a0747d9c6a81d34983712206897437fa81c6 100644 GIT binary patch delta 4968 zcmV-u6PN7TOWQ+`8Gix*008_L?V|ty4HSA*SaechcOY_& z`xifwOLQ@5$u;MTpIBoJjX%nD|FrY%uXw)CPk3(e|4-N5=YK}vk}%5sZ^_U6_qzWq za1V{Y(wBwGcy9EcZ`Am#U%oB$Y$RrpSuvl5>a&o9`-XoOX!o(MT#J4^LSOed-;kBawZVjl@%iI%Z(A%kx+G`8v~m&L(PGBc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DU%p0BfQMi`5X0%}!zdRCR>}i-Ft@NMbig~%(SD*O5K0wFe`PkUtvdjO5X^66_{R86>~fV* zz(jcp&(*oOxWc~vUQjT-u*N_-&1>h*u~w<_)idWgKG021dm9qSY!wLm{g_r!{ov}= zXJ3AE>{7amA z`p@~ue;+@?nbT)U#^NO7aio-Nlx_ZdY?_zHt|$PjR8nKJbBgl?#kG_Ks^Z3c9Xl(A{ z?eR$t9eaeH10x(h_I?tzDSQ!w5`K4l;nq7!F2U@|>eX+)`o^ax7jHWwd%7M98Ai{~ aF8DvbphUrc5BvrI0000ZBmPaMUV@pirtpeGDe4twIw^QgLwRdji^i*0R0w4zQiPn;4Gi$*F0*>WK=P zsicn{!}4+i@%Shu*ZU12WnQy+mZfSvcM_DtBURH zvYahg>W1NYXL4Njs60&!Gr|~gbWE06Buk!l*&R_l65_{7y4{+`j^Go~C_a^#AQH$9hUOW=p.length||p[index]==sprite.getBi_array()[Y*sprite.getWidth()+X]) { continue; } else { - Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],true); + Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],Alpha.ALPHA0); //Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],false); } } @@ -47,8 +48,8 @@ public class DrawLoop { } } - public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, int alpha){ - int[] p = panel.pixel; + public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha){ + byte[] p = panel.pixel; for(int X=(int)xOffset;X<(int)(w+xOffset);X++){ for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){ if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) { @@ -58,52 +59,14 @@ public class DrawLoop { if (index<0||index>=p.length||p[index]==sprite.getBi_array()[Y*sprite.getWidth()+X]) { continue; } else { - if (alpha==255) { - Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],true); - } else { - int oldAlpha = sprite.getBi_array()[Y*sprite.getWidth()+X]>>>24; - if (oldAlpha==0) { - Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],true); - } else - if (oldAlpha==255) { - Draw(p,index,(sprite.getBi_array()[Y*sprite.getWidth()+X]&0x00FFFFFF)|(alpha<<24),true); - } else { - Draw(p,index,(sprite.getBi_array()[Y*sprite.getWidth()+X]&0x00FFFFFF)|((int)((alpha/255d)*oldAlpha)<<24),true); - } - } - //Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],false); + Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X],alpha); } } } } } - public static void Draw(int[] canvas,int index, int col,boolean transparency) { - if (!transparency) { - canvas[index]=col; - return; - } - int alpha = col>>>24; - if (alpha==0) { - return;} - else - if (alpha==255) { - canvas[index]=col; - } else { - float ratio=alpha/255f; - int prev_col=canvas[index]; - int prev_r=(prev_col&0xFF); - int prev_g=(prev_col&0xFF00)>>>8; - int prev_b=(prev_col&0xFF0000)>>>16; - int r=(col&0xFF); - int g=(col&0xFF00)>>>8; - int b=(col&0xFF0000)>>>16; - - int new_r=(int)(ratio*r+(1-ratio)*prev_r); - int new_g=(int)(ratio*g+(1-ratio)*prev_g); - int new_b=(int)(ratio*b+(1-ratio)*prev_b); - - canvas[index]=new_r+(new_g<<8)+(new_b<<16)+(col&0xFF000000); - } + public static void Draw(byte[] canvas,int index, byte col, Alpha alpha) { + canvas[index]=(byte)(((int)(col)&0xff)+(alpha.ordinal()*(32))); } } diff --git a/src/sig/engine/Alpha.java b/src/sig/engine/Alpha.java new file mode 100644 index 0000000..dfd61f5 --- /dev/null +++ b/src/sig/engine/Alpha.java @@ -0,0 +1,13 @@ +package sig.engine; + +public enum Alpha { + ALPHA0, + ALPHA32, + ALPHA64, + ALPHA96, + ALPHA128, + ALPHA160, + ALPHA192, + ALPHA224, + ALPHA256; +} diff --git a/src/sig/engine/GameEntity.java b/src/sig/engine/GameEntity.java index df2cd1c..c8581fa 100644 --- a/src/sig/engine/GameEntity.java +++ b/src/sig/engine/GameEntity.java @@ -2,5 +2,5 @@ package sig.engine; public interface GameEntity { public void update(double updateMult); - public void draw(int[] p); + public void draw(byte[] p); } diff --git a/src/sig/engine/Object.java b/src/sig/engine/Object.java index ac86c42..ea2bd5b 100644 --- a/src/sig/engine/Object.java +++ b/src/sig/engine/Object.java @@ -47,7 +47,7 @@ public abstract class Object implements GameEntity{ this.spr = spr; } - public void drawOverlay(int[] p) { + public void drawOverlay(byte[] p) { } protected void Draw_Sprite(double x, double y, Sprite sprite){ @@ -58,7 +58,7 @@ public abstract class Object implements GameEntity{ DrawLoop.Draw_Sprite_Partial(x,y,xOffset,yOffset,w,h,sprite); } - protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, int alpha){ + protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha){ DrawLoop.Draw_Sprite_Partial_Ext(x,y,xOffset,yOffset,w,h,sprite,alpha); } diff --git a/src/sig/engine/Panel.java b/src/sig/engine/Panel.java index 1e21bda..9db31f4 100644 --- a/src/sig/engine/Panel.java +++ b/src/sig/engine/Panel.java @@ -51,6 +51,40 @@ public class Panel extends JPanel implements Runnable,KeyListener { public Point highlightedSquare = new Point(0,0); public HashMap KEYS = new HashMap<>(); public HashMap MOUSE = new HashMap<>(); + public static byte[] generalPalette = new byte[]{ + (byte)0x5b,(byte)0xa6,(byte)0x75, + (byte)0x6b,(byte)0xc9,(byte)0x6c, + (byte)0xab,(byte)0xdd,(byte)0x64, + (byte)0xfc,(byte)0xef,(byte)0x8d, + (byte)0xff,(byte)0xb8,(byte)0x79, + (byte)0xea,(byte)0x62,(byte)0x62, + (byte)0xcc,(byte)0x42,(byte)0x5e, + (byte)0xa3,(byte)0x28,(byte)0x58, + (byte)0x75,(byte)0x17,(byte)0x56, + (byte)0x39,(byte)0x09,(byte)0x47, + (byte)0x61,(byte)0x18,(byte)0x51, + (byte)0x87,(byte)0x35,(byte)0x55, + (byte)0xa6,(byte)0x55,(byte)0x5f, + (byte)0xc9,(byte)0x73,(byte)0x73, + (byte)0xf2,(byte)0xae,(byte)0x99, + (byte)0xff,(byte)0xc3,(byte)0xf2, + (byte)0xee,(byte)0x8f,(byte)0xcb, + (byte)0xd4,(byte)0x6e,(byte)0xb3, + (byte)0x87,(byte)0x3e,(byte)0x84, + (byte)0x1f,(byte)0x10,(byte)0x2a, + (byte)0x4a,(byte)0x30,(byte)0x52, + (byte)0x7b,(byte)0x54,(byte)0x80, + (byte)0xa6,(byte)0x85,(byte)0x9f, + (byte)0xd9,(byte)0xbd,(byte)0xc8, + (byte)0xff,(byte)0xff,(byte)0xff, + (byte)0xae,(byte)0xe2,(byte)0xff, + (byte)0x8d,(byte)0xb7,(byte)0xff, + (byte)0x6d,(byte)0x80,(byte)0xfa, + (byte)0x84,(byte)0x65,(byte)0xec, + (byte)0x83,(byte)0x4d,(byte)0xc4, + (byte)0x7d,(byte)0x2d,(byte)0xa0, + (byte)0x4e,(byte)0x18,(byte)0x7c, + }; public Panel(JFrame f) { super(true); @@ -126,51 +160,17 @@ public class Panel extends JPanel implements Runnable,KeyListener { * @return color model */ protected static ColorModel getCustomPalette(){ - char[] generalPalette = new char[]{ - 0x5b,0xa6,0x75,0xff, - 0x6b,0xc9,0x6c,0xff, - 0xab,0xdd,0x64,0xff, - 0xfc,0xef,0x8d,0xff, - 0xff,0xb8,0x79,0xff, - 0xea,0x62,0x62,0xff, - 0xcc,0x42,0x5e,0xff, - 0xa3,0x28,0x58,0xff, - 0x75,0x17,0x56,0xff, - 0x39,0x09,0x47,0xff, - 0x61,0x18,0x51,0xff, - 0x87,0x35,0x55,0xff, - 0xa6,0x55,0x5f,0xff, - 0xc9,0x73,0x73,0xff, - 0xf2,0xae,0x99,0xff, - 0xff,0xc3,0xf2,0xff, - 0xee,0x8f,0xcb,0xff, - 0xd4,0x6e,0xb3,0xff, - 0x87,0x3e,0x84,0xff, - 0x1f,0x10,0x2a,0xff, - 0x4a,0x30,0x52,0xff, - 0x7b,0x54,0x80,0xff, - 0xa6,0x85,0x9f,0xff, - 0xd9,0xbd,0xc8,0xff, - 0xff,0xff,0xff,0xff, - 0xae,0xe2,0xff,0xff, - 0x8d,0xb7,0xff,0xff, - 0x6d,0x80,0xfa,0xff, - 0x84,0x65,0xec,0xff, - 0x83,0x4d,0xc4,0xff, - 0x7d,0x2d,0xa0,0xff, - 0x4e,0x18,0x7c,0xff, - }; - byte[] finalPalette = new byte[32*3*8]; + byte[] finalPalette = new byte[32*4*8]; for (int i=0;i<8;i++) { for (int j=0;j edges_sorted = new ArrayList(); @@ -301,7 +310,8 @@ public class Panel extends JPanel implements Runnable,KeyListener { for (int x=(int)Math.round(e1.x_of_min_y);x<=e2.x_of_min_y;x++) { int index = (scanLine+(int)y_offset)*getWidth()+x+(int)x_offset; if (index=0) { - Draw(p,index,col.getColor()); + //TODO Old color system. + //Draw(p,index,col.getColor()); } } } @@ -363,29 +373,8 @@ public class Panel extends JPanel implements Runnable,KeyListener { } } - public void Draw(int[] canvas,int index, int col) { - int alpha = col>>>24; - if (alpha==0) { - return;} - else - if (alpha==255) { - canvas[index]=col; - } else { - float ratio=alpha/255f; - int prev_col=canvas[index]; - int prev_r=(prev_col&0xFF); - int prev_g=(prev_col&0xFF00)>>>8; - int prev_b=(prev_col&0xFF0000)>>>16; - int r=(col&0xFF); - int g=(col&0xFF00)>>>8; - int b=(col&0xFF0000)>>>16; - - int new_r=(int)(ratio*r+(1-ratio)*prev_r); - int new_g=(int)(ratio*g+(1-ratio)*prev_g); - int new_b=(int)(ratio*b+(1-ratio)*prev_b); - - canvas[index]=new_r+(new_g<<8)+(new_b<<16)+(col&0xFF000000); - } + public void Draw(byte[] canvas,int index, byte col) { + canvas[index]=col; } @Override @@ -425,7 +414,6 @@ public class Panel extends JPanel implements Runnable,KeyListener { @Override public void keyTyped(KeyEvent e) { - // TODO Auto-generated method stub } diff --git a/src/sig/engine/Sprite.java b/src/sig/engine/Sprite.java index 218c2d5..557533a 100644 --- a/src/sig/engine/Sprite.java +++ b/src/sig/engine/Sprite.java @@ -3,13 +3,15 @@ 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("..","3x.png")), - NANA_SMALL(new File("..","1x.png")), + NANA_SMALL(new File("..","1x.gif")), TILE_SHEET(new File("..","tiles.png")), ; @@ -18,15 +20,14 @@ public enum Sprite{ BufferedImage img; int height; int width; - int[] bi_array; + byte[] bi_array; Sprite(File filename){ try { BufferedImage img = ImageIO.read(filename); this.width=img.getWidth(); this.height=img.getHeight(); - this.bi_array = new int[width*height]; - img.getRGB(0,0,width,height,this.bi_array,0,width); + bi_array = ((DataBufferByte)(img.getRaster().getDataBuffer())).getData(); } catch (IOException e) { e.printStackTrace(); } @@ -57,11 +58,11 @@ public enum Sprite{ this.width = width; } - public int[] getBi_array() { + public byte[] getBi_array() { return bi_array; } - public void setBi_array(int[] bi_array) { + public void setBi_array(byte[] bi_array) { this.bi_array = bi_array; }; diff --git a/src/sig/objects/LevelRenderer.java b/src/sig/objects/LevelRenderer.java index ab73a2a..d4958c2 100644 --- a/src/sig/objects/LevelRenderer.java +++ b/src/sig/objects/LevelRenderer.java @@ -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.Object; import sig.engine.Panel; @@ -59,7 +60,7 @@ public class LevelRenderer extends Object{ } @Override - public void draw(int[] p) { + public void draw(byte[] p) { for (int y=(int)(this.getY()/Tile.TILE_HEIGHT);y<(int)(RabiClone.BASE_HEIGHT/Tile.TILE_HEIGHT+this.getY()/Tile.TILE_HEIGHT+1);y++) { if (y<0||y>Map.MAP_HEIGHT) { continue; @@ -73,7 +74,7 @@ public class LevelRenderer extends Object{ //System.out.println((x*Tile.TILE_WIDTH+(this.getX()%Tile.TILE_WIDTH) )+","+(y*Tile.TILE_HEIGHT+(this.getY()%Tile.TILE_HEIGHT))); } 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,64); + DrawTransparentTile(x*Tile.TILE_WIDTH-this.getX(),y*Tile.TILE_HEIGHT-this.getY(),selectedTile,Alpha.ALPHA64); } } } @@ -83,7 +84,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, int alpha) { + private 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); } diff --git a/src/sig/objects/Player.java b/src/sig/objects/Player.java index 9db9408..17e438b 100644 --- a/src/sig/objects/Player.java +++ b/src/sig/objects/Player.java @@ -45,7 +45,7 @@ public class Player extends Object{ } @Override - public void draw(int[] p) { + public void draw(byte[] p) { Draw_Sprite(RabiClone.BASE_WIDTH/2-getSprite().getWidth()/2,RabiClone.BASE_HEIGHT*(2/3d)-getSprite().getHeight()/2, this.getSprite()); }