Gravity engine added. Fixed graphical position offset with Block clumps.

concurrentModificationException1
sigonasr2, Sig, Sigo 3 years ago
parent 092958d7ab
commit 7c70ccb76a
  1. BIN
      Meteo_Engine.jar
  2. 2
      src/sig/BlockClump.java
  3. 15
      src/sig/Board.java
  4. 3
      src/sig/Meteo.java

Binary file not shown.

@ -19,7 +19,7 @@ public class BlockClump {
} }
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) { public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) {
for (Block b : blocks) { for (Block b : blocks) {
b.draw(g,originX+x*block_width,originY-y*block_height,block_width,block_height); b.draw(g,originX+x*block_width,originY-y,block_width,block_height);
} }
} }
} }

@ -16,6 +16,7 @@ public class Board {
double[] combo_power_bonus; double[] combo_power_bonus;
int x,y; int x,y;
int block_width,block_height; int block_width,block_height;
double vspeed;
public Board(int centerX,int centerY,int block_width,int block_height,int boardWidth, int boardHeight, double gravity, double launch_power, double max_rise_spd, double max_fall_spd, public Board(int centerX,int centerY,int block_width,int block_height,int boardWidth, int boardHeight, double gravity, double launch_power, double max_rise_spd, double max_fall_spd,
double[] combo_power_bonus) { double[] combo_power_bonus) {
this.x=centerX; this.x=centerX;
@ -38,10 +39,22 @@ public class Board {
} }
} }
BlockClump defaultClump = new BlockClump(initialBlocks,0,0,0); BlockClump defaultClump = new BlockClump(initialBlocks,0,260,0);
blockData.add(defaultClump); blockData.add(defaultClump);
} }
public void run() {
for (BlockClump blocks : blockData) {
if (blocks.y+blocks.yspd+gravity>0) {
blocks.yspd=Math.max(blocks.yspd+gravity,max_fall_spd);
blocks.y+=blocks.yspd;
} else {
//We have hit the bottom.
blocks.yspd=0;
blocks.y=0;
}
}
}
public void drawBoard(Graphics g) { public void drawBoard(Graphics g) {
final int DRAW_STARTX = (int)(x - block_width*((double)width/2)); final int DRAW_STARTX = (int)(x - block_width*((double)width/2));
final int DRAW_STARTY = (int)(y + block_height*((double)height/2)); final int DRAW_STARTY = (int)(y + block_height*((double)height/2));

@ -15,11 +15,12 @@ public class Meteo {
public static void runGameLoop() { public static void runGameLoop() {
FRAMECOUNT++; FRAMECOUNT++;
b.run();
} }
public static void main(String[] args) { public static void main(String[] args) {
double[] val = {0,0,}; double[] val = {0,0,};
b = new Board(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,16,16,8,14,0.05,1,4,1,val); b = new Board(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,16,16,8,14,-0.065,1,4,-2,val);
JFrame f = new JFrame("Meteo Engine"); JFrame f = new JFrame("Meteo Engine");
Panel p = new Panel(); Panel p = new Panel();

Loading…
Cancel
Save