Blocks render.

concurrentModificationException1
sigonasr2, Sig, Sigo 3 years ago
parent d0fbfb812f
commit 6179f12dbb
  1. BIN
      Meteo_Engine.jar
  2. 6
      src/sig/Block.java
  3. 6
      src/sig/BlockClump.java
  4. 33
      src/sig/BlockState.java
  5. 12
      src/sig/Board.java
  6. 2
      src/sig/Panel.java

Binary file not shown.

@ -1,5 +1,7 @@
package sig;
import java.awt.Graphics;
public class Block{
BlockState state;
int x,y; //Relative to its block clump
@ -19,4 +21,8 @@ public class Block{
public String toString() {
return "Block [state=" + state + ", x=" + x + ", y=" + y + "]";
}
public void draw(Graphics g, double x, double y, int block_width, int block_height) {
g.setColor(state.getCol());
g.fill3DRect((int)x+this.x*block_width,(int)y+this.y*block_height, block_width, block_height, true);
}
}

@ -1,5 +1,6 @@
package sig;
import java.awt.Graphics;
import java.util.List;
public class BlockClump {
@ -16,4 +17,9 @@ public class BlockClump {
public String toString() {
return "BlockClump [blocks=" + blocks + ", x=" + x + ", y=" + y + ", yspd=" + yspd + "]";
}
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) {
for (Block b : blocks) {
b.draw(g,originX-x*block_width,originY-y*block_height,block_width,block_height);
}
}
}

@ -1,12 +1,29 @@
package sig;
import java.awt.Color;
public enum BlockState {
RED,
BLUE,
GREEN,
YELLOW,
ORANGE,
PURPLE,
WHITE,
IGNITED
RED(Color.RED),
BLUE(Color.BLUE),
GREEN(Color.GREEN),
YELLOW(Color.YELLOW),
ORANGE(Color.ORANGE),
PURPLE(Color.MAGENTA),
WHITE(Color.WHITE),
IGNITED(Color.BLACK);
Color col;
BlockState(Color col) {
this.col=col;
}
public Color getCol() {
return col;
}
public void setCol(Color col) {
this.col = col;
}
}

@ -1,5 +1,6 @@
package sig;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
@ -37,6 +38,15 @@ public class Board {
}
BlockClump defaultClump = new BlockClump(initialBlocks,0,0,0);
System.out.println(defaultClump);
blockData.add(defaultClump);
}
public void drawBoard(Graphics g) {
final int DRAW_STARTX = (int)(x - block_width*((double)width/2));
final int DRAW_STARTY = (int)(y + block_height*((double)height/2));
for (BlockClump bc : blockData) {
bc.drawBlocks(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height);
}
}
}

@ -11,6 +11,6 @@ public class Panel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString(Long.toString(Meteo.FRAMECOUNT),0,16);
Meteo.b.drawBoard(g);
}
}

Loading…
Cancel
Save