Nana has been summoned

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 1076ff2aa0
commit ca15225ecc
  1. BIN
      3x.png
  2. 10
      scripts/md5
  3. 2
      sig
  4. 14
      src/sig/RabiClone.java
  5. 75
      src/sig/engine/Panel.java
  6. 8
      src/sig/engine/Sprite.java
  7. 10
      utils/md5

BIN
3x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@ -1,5 +1,5 @@
build.sh:a833e7598ad65672a9c01306d244b49f -
clean.sh:96ce35f2d2dcb555421e00a6afda23ca -
commit.sh:21af1fa6f09d01679c9e11408967264a -
jar.sh:2ac636f584c43a1124affb9ea6bdc7bf -
lean.sh:3be7b8b182ccd96e48989b4e57311193 -
build.sh:de32fdf9f3ce9eb5d4ea9902ee48dbe0 *-
clean.sh:8aec15e447257f1c3a4e978f1b56a78e *-
commit.sh:21af1fa6f09d01679c9e11408967264a *-
jar.sh:2ac636f584c43a1124affb9ea6bdc7bf *-
lean.sh:3be7b8b182ccd96e48989b4e57311193 *-

2
sig

@ -1,6 +1,6 @@
source utils/define.sh
define PROJECT_NAME "JavaProjectTemplate"
define PROJECT_NAME "RabiClone"
define PROJECT_DIR "src/sig"
define MAIN_CLASS "sig.${PROJECT_NAME}"
define OUT_DIR "bin"

@ -1,14 +1,17 @@
package sig;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import sig.engine.Panel;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class JavaProjectTemplate {
public class RabiClone {
public static final String PROGRAM_NAME="Sig's Java Project Template";
public static void main(String[] args) {
JFrame f = new JFrame(PROGRAM_NAME);
Panel p = new Panel(f);
p.init();
f.add(p);
@ -17,5 +20,12 @@ public class JavaProjectTemplate {
f.setVisible(true);
p.render();
BufferedImage nana;
try {
nana = ImageIO.read(new File("..","3x.png"));
p.Draw_Nana(p.Get_Nana(nana));
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -6,13 +6,17 @@ import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ColorModel;
import java.awt.image.MemoryImageSource;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import sig.JavaProjectTemplate;
import sig.RabiClone;
public class Panel extends JPanel implements Runnable {
JFrame window;
@ -32,6 +36,7 @@ public class Panel extends JPanel implements Runnable {
int frameCount=0;
long lastSecond=0;
int lastFrameCount=0;
Sprite nana_sprite;
public Panel(JFrame f) {
super(true);
@ -54,6 +59,13 @@ public class Panel extends JPanel implements Runnable {
* Call it after been visible and after resizes.
*/
public void init(){
BufferedImage nana;
try {
nana = ImageIO.read(new File("..","3x.png"));
nana_sprite = Get_Nana(nana);
} catch (IOException e) {
e.printStackTrace();
}
cm = getCompatibleColorModel();
int screenSize = width * height;
if(pixel == null || pixel.length < screenSize){
@ -80,7 +92,7 @@ public class Panel extends JPanel implements Runnable {
if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) {
window.setTitle(JavaProjectTemplate.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount));
window.setTitle(RabiClone.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount));
lastFrameCount=frameCount;
lastSecond=System.currentTimeMillis();
}
@ -99,49 +111,25 @@ public class Panel extends JPanel implements Runnable {
* Do your draws in here !!
* pixel is your canvas!
*/
public /* abstract */ void render(){
int[] p = pixel; // this avoid crash when resizing
//a=h/w
for (int x=0;x<width;x++) {
for (int y=0;y<height;y++) {
p[y*width+x]=(0<<16)+(0<<8)+0;
for (int y=0;y<height;y++) {
for (int x=0;x<width;x++) {
p[y*width+x]=(0<<16)+(0<<8)+0;//RGB
}
}
x_offset+=1;
y_offset=50;
FillPolygon(p,Color.WHITE,50,50,new Point[] {
new Point(135,2),
new Point(166,96),
new Point(265,97),
new Point(185,156),
new Point(215,251),
new Point(134,192),
new Point(54,251),
new Point(84,156),
new Point(4,97),
new Point(103,96),
});
FillPolygon(p,Color.BRIGHT_CYAN,x_offset,y_offset,new Point[] {
new Point(28,29),
new Point(78,103),
new Point(120,31),
new Point(123,221),
new Point(30,218),
});
//FillRect(p,Color.BRIGHT_RED,200,200,600,64);
final Color testAlpha = new Color(150,0,0,128);
FillCircle(p,testAlpha,150,150,100);
FillOval(p,Color.BRIGHT_GREEN,300,150,100,50);
Draw_Nana(nana_sprite);
}
public void FillRect(int[] p,Color col,double x,double y,double w,double h) {
for (int xx=0;xx<w;xx++) {
for (int yy=0;yy<h;yy++) {
int index = ((int)y+yy)*width+(int)x+xx;
p[index]=col.getColor();
Draw(p,index,col.getColor());
}
}
}
@ -302,6 +290,27 @@ public class Panel extends JPanel implements Runnable {
}
}
public Sprite Get_Nana(BufferedImage b_image){
Sprite sprite_input = new Sprite();
sprite_input.height = b_image.getHeight();
sprite_input.width = b_image.getWidth();
sprite_input.bi_array = new int [b_image.getWidth()*b_image.getHeight()];
for(int x=0;x<b_image.getHeight();x++){
for(int y=0;y<b_image.getWidth();y++){
sprite_input.bi_array[y*b_image.getWidth()+x] = b_image.getRGB(x,y);
}
}
return sprite_input;
}
public void Draw_Nana(Sprite sprite){
int[] p = pixel;
for(int x=0;x<sprite.height;x++){
for(int y=0;y<sprite.width;y++){
p[y*width+x] = sprite.bi_array[y*sprite.width+x];
}
}
}
@Override
public void run() {
while (true) {

@ -0,0 +1,8 @@
package sig.engine;
public class Sprite{
int height;
int width;
int[] bi_array;
}

@ -1,5 +1,5 @@
.coauthors:3785ad38663e5fc43e574914ad067294 -
define.sh:d6b20a25a04a60d94f466e48fa60ac69 -
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 -
search.sh:28d0ede8345514d80cc68cc756870002 -
.updateDirectories:0ede00461e947494545e694040787b3f -
.coauthors:f2c4a4cf2e4c3e2fb437ac4017970ae5 *-
.updateDirectories:0ede00461e947494545e694040787b3f *-
define.sh:d6b20a25a04a60d94f466e48fa60ac69 *-
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 *-
search.sh:28d0ede8345514d80cc68cc756870002 *-

Loading…
Cancel
Save