Blocks render.
This commit is contained in:
parent
d0fbfb812f
commit
6179f12dbb
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
@ -1,5 +1,7 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
public class Block{
|
public class Block{
|
||||||
BlockState state;
|
BlockState state;
|
||||||
int x,y; //Relative to its block clump
|
int x,y; //Relative to its block clump
|
||||||
@ -19,4 +21,8 @@ public class Block{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "Block [state=" + state + ", x=" + x + ", y=" + y + "]";
|
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;
|
package sig;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockClump {
|
public class BlockClump {
|
||||||
@ -16,4 +17,9 @@ public class BlockClump {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "BlockClump [blocks=" + blocks + ", x=" + x + ", y=" + y + ", yspd=" + yspd + "]";
|
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;
|
package sig;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
public enum BlockState {
|
public enum BlockState {
|
||||||
RED,
|
RED(Color.RED),
|
||||||
BLUE,
|
BLUE(Color.BLUE),
|
||||||
GREEN,
|
GREEN(Color.GREEN),
|
||||||
YELLOW,
|
YELLOW(Color.YELLOW),
|
||||||
ORANGE,
|
ORANGE(Color.ORANGE),
|
||||||
PURPLE,
|
PURPLE(Color.MAGENTA),
|
||||||
WHITE,
|
WHITE(Color.WHITE),
|
||||||
IGNITED
|
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;
|
package sig;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -37,6 +38,15 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockClump defaultClump = new BlockClump(initialBlocks,0,0,0);
|
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) {
|
public void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
g.drawString(Long.toString(Meteo.FRAMECOUNT),0,16);
|
Meteo.b.drawBoard(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user