Compare commits
No commits in common. "master" and "fixedEngine" have entirely different histories.
master
...
fixedEngin
@ -1,7 +0,0 @@
|
|||||||
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
|
|
||||||
tasks:
|
|
||||||
- init: sh ./coauthors.sh
|
|
||||||
vscode:
|
|
||||||
extensions:
|
|
||||||
- redhat.java
|
|
||||||
- mhutchie.git-graph
|
|
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
45
coauthors.sh
45
coauthors.sh
@ -1,45 +0,0 @@
|
|||||||
npm i -g git-mob
|
|
||||||
cat <<-EOF > ~/.git-coauthors
|
|
||||||
{
|
|
||||||
"coauthors": {
|
|
||||||
"sig": {
|
|
||||||
"name": "sigonasr2",
|
|
||||||
"email": "sigonasr2@gmail.com"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
git mob sig
|
|
||||||
cat <<-EOF > .git/hooks/prepare-commit-msg
|
|
||||||
#!/usr/bin/env node
|
|
||||||
let exec = require('child_process').exec,
|
|
||||||
fs = require('fs');
|
|
||||||
|
|
||||||
const commitMessage = process.argv[2];
|
|
||||||
// expect .git/COMMIT_EDITMSG
|
|
||||||
if(/COMMIT_EDITMSG/g.test(commitMessage)){
|
|
||||||
let contents = "";
|
|
||||||
exec("git mob-print",
|
|
||||||
function (err, stdout) {
|
|
||||||
if(err) {
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// opens .git/COMMIT_EDITMSG
|
|
||||||
contents = fs.readFileSync(commitMessage);
|
|
||||||
|
|
||||||
if(contents.indexOf(stdout.trim()) !== -1) {
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const commentPos = contents.indexOf('# ');
|
|
||||||
const gitMessage = contents.slice(0, commentPos);
|
|
||||||
const gitComments = contents.slice(commentPos)
|
|
||||||
|
|
||||||
fs.writeFileSync(commitMessage, gitMessage + stdout + gitComments);
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
chmod +x .git/hooks/prepare-commit-msg
|
|
||||||
echo "Environment is setup!"
|
|
3
gitpod.yml
Normal file
3
gitpod.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
vscode:
|
||||||
|
extensions:
|
||||||
|
- redhat.java
|
@ -72,8 +72,8 @@ public class BlockClump {
|
|||||||
g.setColor(new Color(0,255,0,128));
|
g.setColor(new Color(0,255,0,128));
|
||||||
for (int i=0;i<collisionColumnRanges.length;i++) {
|
for (int i=0;i<collisionColumnRanges.length;i++) {
|
||||||
if (collisionColumnRanges[i][0]!=-1) {
|
if (collisionColumnRanges[i][0]!=-1) {
|
||||||
g.drawRect((int)(x+i*block_width)+originX,(int)(originY-y-(block_height*(collisionColumnRanges[i][1]))),block_width,block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]+1));
|
g.drawRect((int)(x+i*block_width)+originX,(int)(originY-y-(block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]))),block_width,block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]+1));
|
||||||
g.drawRect((int)(x+i*block_width)+originX+1,(int)(originY+1-y-(block_height*(collisionColumnRanges[i][1]))),block_width,block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]+1));
|
g.drawRect((int)(x+i*block_width)+originX+1,(int)(originY+1-y-(block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]))),block_width,block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]+1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,36 +63,19 @@ public class Board {
|
|||||||
DestroyOutsideBlocks(blocks);
|
DestroyOutsideBlocks(blocks);
|
||||||
if (checkForMatches(blocks)) {continue;}
|
if (checkForMatches(blocks)) {continue;}
|
||||||
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
|
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
|
||||||
List<CollisionRangeIdentifier> ranges = new ArrayList<CollisionRangeIdentifier>();
|
for (int x=0;x<width;x++) {
|
||||||
for (int k=0;k<blocks.collisionColumnRanges.length;k++) {
|
|
||||||
int[] range = blocks.collisionColumnRanges[k];
|
|
||||||
ranges.add(new CollisionRangeIdentifier(k, range));
|
|
||||||
}
|
|
||||||
ranges = ranges.stream().sorted((a,b)->a.range[0]-b.range[0]).collect(Collectors.toList());
|
|
||||||
//System.out.println(ranges);
|
|
||||||
for (int l=0;l<ranges.size();l++) {
|
|
||||||
int x=ranges.get(l).index;
|
|
||||||
if (blocks.collisionColumnRanges[x][0]!=-1) {
|
if (blocks.collisionColumnRanges[x][0]!=-1) {
|
||||||
for (int j=0;j<blockData.size();j++) {
|
for (int j=0;j<blockData.size();j++) {
|
||||||
BlockClump blocks2 = blockData.get(j);
|
BlockClump blocks2 = blockData.get(j);
|
||||||
if (!blocks.equals(blocks2)&&blocks2.collisionColumnRanges[x][1]!=-1) {
|
if (!blocks.equals(blocks2)&&blocks2.collisionColumnRanges[x][1]!=-1) {
|
||||||
if (blocks.yspd>0) {
|
if (FUTURE_FALL_POSITION<blocks2.y) {
|
||||||
if (blocks2.y+(blocks2.collisionColumnRanges[x][0])*block_height>FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][1])*block_height) {
|
if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][1]*block_height>blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height) {
|
||||||
if (FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][1])*block_height>blocks2.y+(blocks2.collisionColumnRanges[x][0])*block_height) {
|
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height);
|
||||||
CombineAToBFromBelow(blocks,blocks2);
|
|
||||||
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][0])*block_height-blocks.maxBlockHeight*block_height);
|
|
||||||
continue outerloop;
|
continue outerloop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][0])*block_height<=0) { //Handle reaching the ground.
|
if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][0]*block_height<blocks2.y+(blocks2.collisionColumnRanges[x][1]+1)*block_height) {
|
||||||
HandleBlockLand(blocks, x, 0);
|
|
||||||
continue outerloop;
|
|
||||||
} else
|
|
||||||
if (blocks2.y<FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][0])*block_height) {
|
|
||||||
if (FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][0])*block_height<blocks2.y+(blocks2.collisionColumnRanges[x][1]+1)*block_height) {
|
|
||||||
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][1]+1)*block_height);
|
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][1]+1)*block_height);
|
||||||
System.out.println(ranges);
|
|
||||||
if (blocks.launched==-1) {
|
if (blocks.launched==-1) {
|
||||||
CombineAToB(blocks,blocks2);
|
CombineAToB(blocks,blocks2);
|
||||||
blocks.launched=-2;
|
blocks.launched=-2;
|
||||||
@ -104,7 +87,6 @@ public class Board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (FUTURE_FALL_POSITION>0) {
|
if (FUTURE_FALL_POSITION>0) {
|
||||||
blocks.yspd=Math.max(blocks.yspd+gravity,max_fall_spd);
|
blocks.yspd=Math.max(blocks.yspd+gravity,max_fall_spd);
|
||||||
blocks.y+=blocks.yspd;
|
blocks.y+=blocks.yspd;
|
||||||
@ -184,7 +166,7 @@ public class Board {
|
|||||||
b.y-=minY;
|
b.y-=minY;
|
||||||
}
|
}
|
||||||
blockClumpAddList.add(
|
blockClumpAddList.add(
|
||||||
new BlockClump(newClumpBlocks, blocks.x, blocks.y+minY*block_height, launch_power, width, 120)
|
new BlockClump(newClumpBlocks, blocks.x, blocks.y+minY*block_height+4, launch_power, width, 120)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return markedBlocks.size()>0;
|
return markedBlocks.size()>0;
|
||||||
@ -288,36 +270,10 @@ public class Board {
|
|||||||
g.drawString(Integer.toString(blockData.size()),4,Meteo.SCREEN_HEIGHT-20);
|
g.drawString(Integer.toString(blockData.size()),4,Meteo.SCREEN_HEIGHT-20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void handleMouse(MouseQueue mq) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
MouseEvent e = mq.ev;
|
|
||||||
switch (mq.type) {
|
|
||||||
case CLICK:
|
|
||||||
//System.out.println("Clicked: "+e.getPoint());
|
//System.out.println("Clicked: "+e.getPoint());
|
||||||
break;
|
|
||||||
case DRAG:
|
|
||||||
//System.out.println("Dragged: "+e.getPoint());
|
|
||||||
if (clumpClickId!=null&&clickBlock!=null) {
|
|
||||||
List<Block> adjacentBlocks = clumpClickId.getBlocks().stream().filter((block)->Math.abs(clickBlock.y-block.y)==1&&clickBlock.x==block.x).collect(Collectors.toList());
|
|
||||||
for (Block b : adjacentBlocks) {
|
|
||||||
if (new Rectangle(0,b.draw_y,Meteo.SCREEN_WIDTH,block_height).contains(e.getPoint())) {
|
|
||||||
int newY = b.y;
|
|
||||||
b.y=clickBlock.y;
|
|
||||||
clickBlock.y = newY;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
public void mousePressed(MouseEvent e) {
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ENTER:
|
|
||||||
//System.out.println("Entered: "+e.getPoint());
|
|
||||||
break;
|
|
||||||
case EXIT:
|
|
||||||
//System.out.println("Exited: "+e.getPoint());
|
|
||||||
break;
|
|
||||||
case MOVE:
|
|
||||||
//System.out.println("Moved: "+e.getPoint());
|
|
||||||
break;
|
|
||||||
case PRESS:
|
|
||||||
//System.out.println("Pressed: "+e.getPoint());
|
//System.out.println("Pressed: "+e.getPoint());
|
||||||
//Adjust Y coordinate based on where the board is positioned.
|
//Adjust Y coordinate based on where the board is positioned.
|
||||||
clickBlock=null;
|
clickBlock=null;
|
||||||
@ -334,13 +290,14 @@ public class Board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case RELEASE:
|
|
||||||
//System.out.println("Released: "+e.getPoint());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
//System.out.println("Released: "+e.getPoint());
|
||||||
|
}
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
//System.out.println("Entered: "+e.getPoint());
|
||||||
|
}
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
//System.out.println("Exited: "+e.getPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package sig;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class CollisionRangeIdentifier {
|
|
||||||
int index;
|
|
||||||
int[] range;
|
|
||||||
CollisionRangeIdentifier(int index,int[] range) {
|
|
||||||
this.index=index;
|
|
||||||
this.range=range;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "CollisionRangeIdentifier [index=" + index + ", range=" + Arrays.toString(range) + "]";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +1,13 @@
|
|||||||
package sig;
|
package sig;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
|
||||||
|
|
||||||
public class Meteo implements MouseListener,MouseMotionListener{
|
public class Meteo implements MouseListener{
|
||||||
public final static int SCREEN_WIDTH=640;
|
public final static int SCREEN_WIDTH=640;
|
||||||
public final static int SCREEN_HEIGHT=640;
|
public final static int SCREEN_HEIGHT=640;
|
||||||
public static long FRAMECOUNT=0;
|
public static long FRAMECOUNT=0;
|
||||||
@ -23,15 +20,8 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
|||||||
public final static long TIMEPERTICK = 16666667l;
|
public final static long TIMEPERTICK = 16666667l;
|
||||||
public static DebugMode DEBUG_DRAWING = DebugMode.MODE2;
|
public static DebugMode DEBUG_DRAWING = DebugMode.MODE2;
|
||||||
|
|
||||||
public static List<MouseQueue> MOUSE_QUEUE = new ArrayList<MouseQueue>();
|
|
||||||
|
|
||||||
public static void runGameLoop() {
|
public static void runGameLoop() {
|
||||||
FRAMECOUNT++;
|
FRAMECOUNT++;
|
||||||
for (int i=0;i<MOUSE_QUEUE.size();i++) {
|
|
||||||
MouseQueue mq = MOUSE_QUEUE.get(i);
|
|
||||||
b.handleMouse(mq);
|
|
||||||
}
|
|
||||||
MOUSE_QUEUE.clear();
|
|
||||||
b.run(FRAMECOUNT);
|
b.run(FRAMECOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +60,6 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
|||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
f.getContentPane().addMouseListener(this);
|
f.getContentPane().addMouseListener(this);
|
||||||
f.getContentPane().addMouseMotionListener(this);
|
|
||||||
f.add(p);
|
f.add(p);
|
||||||
f.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
|
f.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
|
||||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
@ -84,36 +73,26 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.CLICK,e));
|
b.mouseClicked(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.PRESS,e));
|
b.mousePressed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.RELEASE,e));
|
b.mouseReleased(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.ENTER,e));
|
b.mouseEntered(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.EXIT,e));
|
b.mouseExited(e);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.DRAG,e));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.MOVE,e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
package sig;
|
|
||||||
|
|
||||||
public enum MouseEventType {
|
|
||||||
CLICK,
|
|
||||||
PRESS,
|
|
||||||
RELEASE,
|
|
||||||
ENTER,
|
|
||||||
EXIT,
|
|
||||||
DRAG,
|
|
||||||
MOVE;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package sig;
|
|
||||||
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
public class MouseQueue {
|
|
||||||
MouseEventType type;
|
|
||||||
MouseEvent ev;
|
|
||||||
MouseQueue(MouseEventType type,MouseEvent ev) {
|
|
||||||
this.type=type;
|
|
||||||
this.ev=ev;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user