Implemented Block Launch Groups. Added Group Merging.

master
sigonasr2 6 years ago
parent eb9af94847
commit eda70a8a16
  1. 2
      meteos_war-core/.classpath
  2. 18
      meteos_war-core/.settings/org.eclipse.jdt.core.prefs
  3. 102
      meteos_war-core/assets/fonts/main.fnt
  4. BIN
      meteos_war-core/assets/fonts/main.png
  5. 4
      meteos_war-core/src/sig/meteos/Block.java
  6. 21
      meteos_war-core/src/sig/meteos/BlockGroup.java
  7. 25
      meteos_war-core/src/sig/meteos/MeteosWar.java
  8. 65
      meteos_war-core/src/sig/meteos/MouseProcessor.java
  9. 162
      meteos_war-core/src/sig/meteos/Planet.java

@ -2,7 +2,7 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="assets"/> <classpathentry kind="src" path="assets"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6/"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.9.8/a35a0076fbce873f9c2d5a1a1c8066244231bb3c/gdx-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.9.8/bac17f395be5010619b31280fe84e9f53118d0b9/gdx-1.9.8-sources.jar"/> <classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.9.8/a35a0076fbce873f9c2d5a1a1c8066244231bb3c/gdx-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.9.8/bac17f395be5010619b31280fe84e9f53118d0b9/gdx-1.9.8-sources.jar"/>
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-box2d/1.9.8/6f0497b7958216464101adfb7bdc3a0f7b88d6d3/gdx-box2d-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-box2d/1.9.8/1fd1df309f965e52196900b270afc2bcd0acd0a2/gdx-box2d-1.9.8-sources.jar"/> <classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-box2d/1.9.8/6f0497b7958216464101adfb7bdc3a0f7b88d6d3/gdx-box2d-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-box2d/1.9.8/1fd1df309f965e52196900b270afc2bcd0acd0a2/gdx-box2d-1.9.8-sources.jar"/>
<classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-controllers/1.9.8/8cdc9ab6826a74594c3b0084d8a7669f8124592b/gdx-controllers-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-controllers/1.9.8/5be4e61f2a04718e82f5fecbaffeff0035021902/gdx-controllers-1.9.8-sources.jar"/> <classpathentry kind="lib" path="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-controllers/1.9.8/8cdc9ab6826a74594c3b0084d8a7669f8124592b/gdx-controllers-1.9.8.jar" sourcepath="C:/Users/Joshua Sigona/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx-controllers/1.9.8/5be4e61f2a04718e82f5fecbaffeff0035021902/gdx-controllers-1.9.8-sources.jar"/>

@ -1,13 +1,11 @@
#
#Thu Jul 05 09:24:08 CDT 2018
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,102 @@
info face="07LightNovelPOP" size=12 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2
common lineHeight=13 base=11 scaleW=512 scaleH=512 pages=1 packed=0
page id=0 file="main.png"
chars count=97
char id=10 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=9 xadvance=6 page=0 chnl=0
char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=9 xadvance=6 page=0 chnl=0
char id=33 x=496 y=0 width=4 height=10 xoffset=0 yoffset=1 xadvance=4 page=0 chnl=0
char id=34 x=218 y=15 width=8 height=5 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=0
char id=35 x=35 y=15 width=10 height=10 xoffset=0 yoffset=1 xadvance=10 page=0 chnl=0
char id=36 x=76 y=0 width=8 height=12 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=0
char id=37 x=23 y=15 width=12 height=10 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=0
char id=38 x=45 y=15 width=12 height=10 xoffset=0 yoffset=1 xadvance=10 page=0 chnl=0
char id=39 x=232 y=15 width=6 height=5 xoffset=-1 yoffset=1 xadvance=4 page=0 chnl=0
char id=40 x=34 y=0 width=7 height=13 xoffset=0 yoffset=0 xadvance=6 page=0 chnl=0
char id=41 x=41 y=0 width=7 height=13 xoffset=-1 yoffset=0 xadvance=6 page=0 chnl=0
char id=42 x=199 y=15 width=8 height=7 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=0
char id=43 x=61 y=15 width=9 height=9 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0
char id=44 x=242 y=15 width=6 height=5 xoffset=-1 yoffset=7 xadvance=4 page=0 chnl=0
char id=45 x=248 y=15 width=6 height=5 xoffset=0 yoffset=4 xadvance=6 page=0 chnl=0
char id=46 x=238 y=15 width=4 height=5 xoffset=0 yoffset=6 xadvance=4 page=0 chnl=0
char id=47 x=84 y=0 width=9 height=11 xoffset=-1 yoffset=1 xadvance=7 page=0 chnl=0
char id=48 x=487 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=49 x=412 y=0 width=7 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=50 x=419 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=51 x=427 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=52 x=435 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=53 x=444 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=54 x=452 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=55 x=461 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=56 x=469 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=57 x=478 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=58 x=57 y=15 width=4 height=9 xoffset=1 yoffset=2 xadvance=5 page=0 chnl=0
char id=59 x=0 y=15 width=5 height=10 xoffset=0 yoffset=2 xadvance=5 page=0 chnl=0
char id=60 x=5 y=15 width=9 height=10 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0
char id=61 x=180 y=15 width=9 height=8 xoffset=0 yoffset=3 xadvance=9 page=0 chnl=0
char id=62 x=14 y=15 width=9 height=10 xoffset=0 yoffset=2 xadvance=8 page=0 chnl=0
char id=63 x=500 y=0 width=9 height=10 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=64 x=65 y=0 width=11 height=12 xoffset=0 yoffset=1 xadvance=11 page=0 chnl=0
char id=65 x=102 y=0 width=11 height=10 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=66 x=113 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=67 x=121 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=68 x=130 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=69 x=139 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=0
char id=70 x=147 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=0
char id=71 x=155 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=72 x=164 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=73 x=173 y=0 width=4 height=10 xoffset=0 yoffset=1 xadvance=4 page=0 chnl=0
char id=74 x=177 y=0 width=8 height=10 xoffset=-1 yoffset=1 xadvance=7 page=0 chnl=0
char id=75 x=185 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=76 x=194 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=77 x=202 y=0 width=10 height=10 xoffset=0 yoffset=1 xadvance=10 page=0 chnl=0
char id=78 x=212 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=79 x=221 y=0 width=10 height=10 xoffset=0 yoffset=1 xadvance=10 page=0 chnl=0
char id=80 x=231 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=81 x=48 y=0 width=11 height=12 xoffset=0 yoffset=1 xadvance=10 page=0 chnl=0
char id=82 x=240 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=83 x=249 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=84 x=257 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=85 x=266 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=0
char id=86 x=275 y=0 width=11 height=10 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=87 x=286 y=0 width=13 height=10 xoffset=-1 yoffset=1 xadvance=11 page=0 chnl=0
char id=88 x=299 y=0 width=10 height=10 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=89 x=309 y=0 width=10 height=10 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=90 x=319 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=91 x=0 y=0 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=0
char id=92 x=93 y=0 width=9 height=11 xoffset=-1 yoffset=1 xadvance=7 page=0 chnl=0
char id=93 x=7 y=0 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0
char id=94 x=189 y=15 width=10 height=7 xoffset=-1 yoffset=1 xadvance=8 page=0 chnl=0
char id=95 x=254 y=15 width=9 height=5 xoffset=-1 yoffset=9 xadvance=7 page=0 chnl=0
char id=96 x=226 y=15 width=6 height=5 xoffset=-1 yoffset=0 xadvance=4 page=0 chnl=0
char id=97 x=70 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=98 x=327 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=99 x=78 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=0
char id=100 x=335 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=101 x=86 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=0
char id=102 x=343 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=0
char id=103 x=351 y=0 width=8 height=10 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=104 x=359 y=0 width=8 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=105 x=367 y=0 width=4 height=10 xoffset=0 yoffset=1 xadvance=4 page=0 chnl=0
char id=106 x=59 y=0 width=6 height=12 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=0
char id=107 x=371 y=0 width=9 height=10 xoffset=0 yoffset=1 xadvance=8 page=0 chnl=0
char id=108 x=173 y=0 width=4 height=10 xoffset=0 yoffset=1 xadvance=4 page=0 chnl=0
char id=109 x=94 y=15 width=11 height=8 xoffset=0 yoffset=3 xadvance=10 page=0 chnl=0
char id=110 x=105 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=111 x=113 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=112 x=380 y=0 width=8 height=10 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=113 x=388 y=0 width=8 height=10 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=114 x=121 y=15 width=7 height=8 xoffset=0 yoffset=3 xadvance=6 page=0 chnl=0
char id=115 x=128 y=15 width=7 height=8 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=0
char id=116 x=396 y=0 width=7 height=10 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=0
char id=117 x=135 y=15 width=8 height=8 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0
char id=118 x=143 y=15 width=9 height=8 xoffset=-1 yoffset=3 xadvance=7 page=0 chnl=0
char id=119 x=152 y=15 width=12 height=8 xoffset=-1 yoffset=3 xadvance=10 page=0 chnl=0
char id=120 x=164 y=15 width=9 height=8 xoffset=-1 yoffset=3 xadvance=7 page=0 chnl=0
char id=121 x=403 y=0 width=9 height=10 xoffset=-1 yoffset=3 xadvance=7 page=0 chnl=0
char id=122 x=173 y=15 width=7 height=8 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=0
char id=123 x=14 y=0 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=7 page=0 chnl=0
char id=124 x=30 y=0 width=4 height=14 xoffset=1 yoffset=-1 xadvance=5 page=0 chnl=0
char id=125 x=22 y=0 width=8 height=15 xoffset=0 yoffset=-1 xadvance=7 page=0 chnl=0
char id=126 x=207 y=15 width=11 height=6 xoffset=-1 yoffset=4 xadvance=9 page=0 chnl=0
char id=127 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=0 page=0 chnl=0
kernings count=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

@ -13,12 +13,14 @@ public class Block {
Planet planet; Planet planet;
boolean onGround = false; boolean onGround = false;
boolean ignited=false; boolean ignited=false;
int id=0;
public Block(float xpos,float ypos, BlockColor col, Planet planet) { public Block(float xpos,float ypos, BlockColor col, Planet planet) {
this.xpos = xpos; this.xpos = xpos;
this.ypos = ypos; this.ypos = ypos;
this.col = col; this.col = col;
this.planet=planet; this.planet=planet;
this.id=Planet.BLOCK_ID++;
} }
public void draw(SpriteBatch batch) { public void draw(SpriteBatch batch) {
@ -33,7 +35,7 @@ public class Block {
public static Block BlockExists(List<Block> blocklist, float xpos, float ypos, BlockColor col, Block checkblock) { public static Block BlockExists(List<Block> blocklist, float xpos, float ypos, BlockColor col, Block checkblock) {
for (Block b : blocklist) { for (Block b : blocklist) {
if (b!=checkblock && b.col == col && if (b!=checkblock && b.col == col && b.col!=BlockColor.IGNITED &&
b.xpos == xpos && b.ypos == ypos) { b.xpos == xpos && b.ypos == ypos) {
return b; return b;
} }

@ -7,5 +7,26 @@ public class BlockGroup {
List<Block> blocks = new ArrayList<Block>(); List<Block> blocks = new ArrayList<Block>();
float yvel; float yvel;
float weight; float weight;
boolean landed=false;
Planet planet; Planet planet;
int id=0;
public BlockGroup(float yvel) {
this.yvel=yvel;
this.id=Planet.GROUP_ID++;
}
public void setYvelocity(float yvel) {
this.yvel = yvel;
}
public void setWeight(float weight) {
this.weight=weight;
}
public void addBlocks(Block...bg) {
for (Block b : bg) {
blocks.add(b);
}
}
} }

@ -7,9 +7,11 @@ import java.util.Random;
import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport; import com.badlogic.gdx.utils.viewport.Viewport;
@ -25,14 +27,19 @@ public class MeteosWar extends ApplicationAdapter {
Camera cam; Camera cam;
Calendar lastCheck = Calendar.getInstance(); Calendar lastCheck = Calendar.getInstance();
int framesPassed=0; int framesPassed=0;
public static Random RANDOM = new Random(); public static Random RANDOM = new Random(59);
boolean singlePass=false;
boolean singleFlag=false;
static int targetFPS = 60;
@Override @Override
public void create () { public void create () {
batch = new SpriteBatch(); batch = new SpriteBatch();
Planet.debugfont.setColor(Color.RED);
LoadImages(); LoadImages();
cam = new PerspectiveCamera(); cam = new PerspectiveCamera();
view = new FitViewport(SCREEN_WIDTH,SCREEN_HEIGHT,cam); view = new FitViewport(SCREEN_WIDTH,SCREEN_HEIGHT,cam);
Gdx.input.setInputProcessor(new MouseProcessor());
} }
public void resize(int width, int height) { public void resize(int width, int height) {
@ -43,8 +50,21 @@ public class MeteosWar extends ApplicationAdapter {
onebyone = new Texture("1x1.png"); onebyone = new Texture("1x1.png");
} }
public static void scrollUp() {
System.out.println("Target FPS is now: "+(++targetFPS));
}
public static void scrollDown() {
System.out.println("Target FPS is now: "+(--targetFPS));
}
@Override @Override
public void render () { public void render () {
try {
Thread.sleep(1000/targetFPS);
} catch (InterruptedException e) {
e.printStackTrace();
}
run(); run();
Gdx.gl.glClearColor(0, 0, 0.3f, 1); Gdx.gl.glClearColor(0, 0, 0.3f, 1);
@ -56,8 +76,9 @@ public class MeteosWar extends ApplicationAdapter {
} }
private void run() { private void run() {
if (framesPassed%120==0) { if (framesPassed%60==0 && (!singlePass || (singlePass && !singleFlag))) {
Planet.GEOLYTE.SpawnRandomBlock(); Planet.GEOLYTE.SpawnRandomBlock();
singleFlag=true;
} }
Planet.GEOLYTE.run(); Planet.GEOLYTE.run();
} }

@ -0,0 +1,65 @@
package sig.meteos;
import com.badlogic.gdx.InputProcessor;
public class MouseProcessor implements InputProcessor{
@Override
public boolean keyDown(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean scrolled(int amount) {
switch (amount) {
case -1:{
MeteosWar.scrollUp();
}break;
case 1:{
MeteosWar.scrollDown();
}break;
default:{
MeteosWar.scrollUp();
}
}
return true;
}
}

@ -4,9 +4,14 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public enum Planet { public enum Planet {
@ -24,11 +29,11 @@ public enum Planet {
new Texture("block_unknown.png"), new Texture("block_unknown.png"),
new Texture("block1-11.png"), new Texture("block1-11.png"),
}, },
0.04f, -0.04f,
0.5f, 2.0f,
0.5f, 0.5f,
9, 9,
1.5f -1.5f
), ),
; ;
@ -41,6 +46,10 @@ public enum Planet {
int field_width; int field_width;
List<Block> blocklist = new ArrayList<Block>(); List<Block> blocklist = new ArrayList<Block>();
List<BlockGroup> grouplist = new ArrayList<BlockGroup>(); List<BlockGroup> grouplist = new ArrayList<BlockGroup>();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
public static int BLOCK_ID=0;
public static int GROUP_ID=0;
public static BitmapFont debugfont = new BitmapFont(Gdx.files.internal("fonts/main.fnt"));
Planet(int id, Texture[] textures, float gravity, float launch_power, float launch_power_mult, int field_width, float max_fall_spd) { Planet(int id, Texture[] textures, float gravity, float launch_power, float launch_power_mult, int field_width, float max_fall_spd) {
this.id = id; this.id = id;
@ -55,40 +64,131 @@ public enum Planet {
public void run() { public void run() {
for (Block b : blocklist) { for (Block b : blocklist) {
if (!b.isOnGround()) { if (!b.isOnGround()) {
b.yspd = Math.min(max_fall_spd, b.yspd + gravity); if (b.group==null) {
b.yspd = Math.max(max_fall_spd, b.yspd + gravity);
}
Block collide = null; Block collide = null;
if ((collide=ObstructedByBlock(b))!=null) { if ((collide=ObstructedByBlock(b))!=null) {
b.ypos = collide.ypos + MeteosWar.BLOCK_SIZE; if (b.group!=null && b.group.id==2) {
BlockLanded(b); System.out.println("Collision from block "+b.id+" in group 2.");
}
if (b.ypos>collide.ypos && (b.group==null || b.group!=collide.group)) {
if (b.group!=null && b.group.id==2) {
System.out.println("Collision in group "+b.group.id);
}
b.ypos = collide.ypos + MeteosWar.BLOCK_SIZE;
b.yspd = collide.yspd;
BlockLanded(b,collide);
}
} else } else
if (b.ypos-b.yspd < 32+MeteosWar.BLOCK_SIZE) { //Has it reached the bottom of the playing field? if (b.ypos+b.yspd < 32+MeteosWar.BLOCK_SIZE) { //Has it reached the bottom of the playing field?
b.ypos = 32+MeteosWar.BLOCK_SIZE; b.ypos = 32+MeteosWar.BLOCK_SIZE;
if (b.group!=null) {
b.group.yvel=0;
b.group.landed=true;
}
BlockLanded(b); BlockLanded(b);
} else { } else {
b.ypos -= b.yspd; if (b.group==null) {
b.ypos += b.yspd;
}
} }
} }
} }
scheduler.schedule(()->{
for (Block b: blocklist) {
if (b.isOnGround() || b.group!=null) {
List<Block> matched_blocks = new ArrayList<Block>();
//System.out.println(blocklist);
if (MatchFound(b,matched_blocks)) {
matched_blocks.add(b);
IgniteBlocks(matched_blocks);
}
}
}
}, 100, TimeUnit.MILLISECONDS);
for (BlockGroup bg : grouplist) {
if (!bg.landed) {
bg.yvel = Math.max(max_fall_spd, bg.yvel + gravity);
for (Block b : bg.blocks) {
b.yspd = bg.yvel;
b.ypos += b.yspd;
//System.out.println("Moving Block "+b);
}
} else {
bg.yvel=0;
//System.out.println("Block group has landed!");
}
}
} }
private void BlockLanded(Block b) { private void BlockLanded(Block b) {
b.onGround = true; BlockLanded(b,null);
b.yspd = 0; }
private void BlockLanded(Block b, Block collide) {
if (b.group==null || (b.group.landed)) {
b.onGround = true;
System.out.println("Block "+b+" is on the ground.");
}
b.yspd = 0;
if (collide!=null) {
if (collide.group!=null) {
b.onGround = false;
b.yspd = collide.group.yvel;
if (b.group==null) {
b.group = collide.group;
b.group.addBlocks(b);
} else {
MergeGroup(b.group,collide.group);
}
}
}
}
List<Block> matched_blocks = new ArrayList<Block>(); private void MergeGroup(BlockGroup group1, BlockGroup group2) {
//System.out.println(blocklist); for (int i=0;i<group1.blocks.size();i++) {
if (MatchFound(b,matched_blocks)) { AddToBlockGroup(group1.blocks.get(i),group2);
matched_blocks.add(b); RemoveFromBlockGroup(group1.blocks.get(i--),group1);
IgniteBlocks(matched_blocks); }
if (grouplist.remove(group1)) {
System.out.println("Group "+group1.id+" has been deleted.");
} }
} }
private void RemoveFromBlockGroup(Block b, BlockGroup group1) {
group1.blocks.remove(b);
System.out.println("Block "+b.id+" removed from group "+group1.id);
}
private void IgniteBlocks(List<Block> matched_blocks) { private void IgniteBlocks(List<Block> matched_blocks) {
BlockGroup bg = new BlockGroup(launch_power);
for (Block b : matched_blocks) { for (Block b : matched_blocks) {
b.ignited=true; b.ignited = true;
b.col = BlockColor.IGNITED; b.col = BlockColor.IGNITED;
AddToBlockGroup(b,bg);
b.onGround = false;
b.yspd = bg.yvel;
b.group = bg;
for (Block bb : blocklist) {
if (!matched_blocks.contains(bb) &&
bb.isOnGround() && bb.xpos==b.xpos &&
bb.ypos>b.ypos) {
System.out.println("Block "+bb+" has been additionally found.");
AddToBlockGroup(bb,bg);
bb.onGround = false;
bb.yspd = bg.yvel;
bb.group = bg;
}
}
} }
grouplist.add(bg);
}
private void AddToBlockGroup(Block b, BlockGroup bg) {
bg.addBlocks(b);
b.group = bg;
System.out.println("Block "+b+" added to Block Group "+bg.id+".");
} }
private boolean MatchFound(Block checkblock,List<Block> detectedblocks) { private boolean MatchFound(Block checkblock,List<Block> detectedblocks) {
@ -131,8 +231,10 @@ public enum Planet {
//TODO Improve speed by dividing block checks into columns. //TODO Improve speed by dividing block checks into columns.
for (Block b : blocklist) { for (Block b : blocklist) {
if (b!=checkblock) { if (b!=checkblock) {
if (b.xpos == checkblock.xpos && b.ypos+MeteosWar.BLOCK_SIZE > checkblock.ypos if (b.xpos == checkblock.xpos &&
&& b.isOnGround()) { b.ypos+MeteosWar.BLOCK_SIZE > checkblock.ypos &&
b.ypos < checkblock.ypos+MeteosWar.BLOCK_SIZE
/*&& b.isOnGround()*/) {
//Yes, there is a collision. //Yes, there is a collision.
return b; return b;
} }
@ -158,6 +260,7 @@ public enum Planet {
batch.setColor(Color.WHITE); batch.setColor(Color.WHITE);
for (Block b : blocklist) { for (Block b : blocklist) {
b.draw(batch); b.draw(batch);
debugfont.draw(batch, Integer.toString(b.id), b.xpos, b.ypos+12);
} }
} }
@ -182,5 +285,28 @@ public enum Planet {
Block b = new Block(baseX,MeteosWar.SCREEN_HEIGHT,BlockColor.GetRandomColor(2),this); Block b = new Block(baseX,MeteosWar.SCREEN_HEIGHT,BlockColor.GetRandomColor(2),this);
AddBlock(b); AddBlock(b);
/*for (int i=0;i<2;i++) {
int baseX = MeteosWar.SCREEN_WIDTH/2 - ((field_width/2+1) * MeteosWar.BLOCK_SIZE)
+ (0+1)*MeteosWar.BLOCK_SIZE;
Block b = new Block(baseX,MeteosWar.SCREEN_HEIGHT-48+i*48,BlockColor.GetRandomColor(1),this);
AddBlock(b);
baseX = MeteosWar.SCREEN_WIDTH/2 - ((field_width/2+1) * MeteosWar.BLOCK_SIZE)
+ (1+1)*MeteosWar.BLOCK_SIZE;
b = new Block(baseX,MeteosWar.SCREEN_HEIGHT-48+i*48,BlockColor.GetRandomColor(1),this);
AddBlock(b);
baseX = MeteosWar.SCREEN_WIDTH/2 - ((field_width/2+1) * MeteosWar.BLOCK_SIZE)
+ (2+1)*MeteosWar.BLOCK_SIZE;
b = new Block(baseX,MeteosWar.SCREEN_HEIGHT-48+i*48,BlockColor.GetRandomColor(1),this);
AddBlock(b);
baseX = MeteosWar.SCREEN_WIDTH/2 - ((field_width/2+1) * MeteosWar.BLOCK_SIZE)
+ (3+1)*MeteosWar.BLOCK_SIZE;
b = new Block(baseX,MeteosWar.SCREEN_HEIGHT-48+i*48,BlockColor.GetRandomColor(1),this);
AddBlock(b);
}*/
/*baseX = MeteosWar.SCREEN_WIDTH/2 - ((field_width/2+1) * MeteosWar.BLOCK_SIZE)
+ (2+1)*MeteosWar.BLOCK_SIZE;
b = new Block(baseX,MeteosWar.SCREEN_HEIGHT+64-48,BlockColor.GREEN,this);
AddBlock(b);*/
} }
} }

Loading…
Cancel
Save