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));
|
||||
for (int i=0;i<collisionColumnRanges.length;i++) {
|
||||
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+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,(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]-collisionColumnRanges[i][0]))),block_width,block_height*(collisionColumnRanges[i][1]-collisionColumnRanges[i][0]+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,45 +63,27 @@ public class Board {
|
||||
DestroyOutsideBlocks(blocks);
|
||||
if (checkForMatches(blocks)) {continue;}
|
||||
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
|
||||
List<CollisionRangeIdentifier> ranges = new ArrayList<CollisionRangeIdentifier>();
|
||||
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;
|
||||
for (int x=0;x<width;x++) {
|
||||
if (blocks.collisionColumnRanges[x][0]!=-1) {
|
||||
for (int j=0;j<blockData.size();j++) {
|
||||
BlockClump blocks2 = blockData.get(j);
|
||||
if (!blocks.equals(blocks2)&&blocks2.collisionColumnRanges[x][1]!=-1) {
|
||||
if (blocks.yspd>0) {
|
||||
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])*block_height) {
|
||||
CombineAToBFromBelow(blocks,blocks2);
|
||||
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][0])*block_height-blocks.maxBlockHeight*block_height);
|
||||
continue outerloop;
|
||||
if (FUTURE_FALL_POSITION<blocks2.y) {
|
||||
if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][1]*block_height>blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height) {
|
||||
HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height);
|
||||
continue outerloop;
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
if (blocks.launched==-1) {
|
||||
CombineAToB(blocks,blocks2);
|
||||
blocks.launched=-2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (FUTURE_FALL_POSITION+(blocks.collisionColumnRanges[x][0])*block_height<=0) { //Handle reaching the ground.
|
||||
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);
|
||||
System.out.println(ranges);
|
||||
if (blocks.launched==-1) {
|
||||
CombineAToB(blocks,blocks2);
|
||||
blocks.launched=-2;
|
||||
}
|
||||
continue outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
continue outerloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,7 +166,7 @@ public class Board {
|
||||
b.y-=minY;
|
||||
}
|
||||
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;
|
||||
@ -288,59 +270,34 @@ public class Board {
|
||||
g.drawString(Integer.toString(blockData.size()),4,Meteo.SCREEN_HEIGHT-20);
|
||||
}
|
||||
}
|
||||
public void handleMouse(MouseQueue mq) {
|
||||
MouseEvent e = mq.ev;
|
||||
switch (mq.type) {
|
||||
case CLICK:
|
||||
//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 mouseClicked(MouseEvent e) {
|
||||
//System.out.println("Clicked: "+e.getPoint());
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
//System.out.println("Pressed: "+e.getPoint());
|
||||
//Adjust Y coordinate based on where the board is positioned.
|
||||
clickBlock=null;
|
||||
clumpClickId=null;
|
||||
outer:
|
||||
for (int i=0;i<blockData.size();i++) {
|
||||
BlockClump bc = blockData.get(i);
|
||||
for (int j=0;j<bc.getBlocks().size();j++) {
|
||||
Block b = bc.getBlocks().get(j);
|
||||
if (new Rectangle(b.draw_x,b.draw_y,block_width,block_height).contains(e.getPoint())) {
|
||||
clickBlock=b;
|
||||
clumpClickId=bc;
|
||||
break outer;
|
||||
}
|
||||
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());
|
||||
//Adjust Y coordinate based on where the board is positioned.
|
||||
clickBlock=null;
|
||||
clumpClickId=null;
|
||||
outer:
|
||||
for (int i=0;i<blockData.size();i++) {
|
||||
BlockClump bc = blockData.get(i);
|
||||
for (int j=0;j<bc.getBlocks().size();j++) {
|
||||
Block b = bc.getBlocks().get(j);
|
||||
if (new Rectangle(b.draw_x,b.draw_y,block_width,block_height).contains(e.getPoint())) {
|
||||
clickBlock=b;
|
||||
clumpClickId=bc;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
public class Meteo implements MouseListener,MouseMotionListener{
|
||||
public class Meteo implements MouseListener{
|
||||
public final static int SCREEN_WIDTH=640;
|
||||
public final static int SCREEN_HEIGHT=640;
|
||||
public static long FRAMECOUNT=0;
|
||||
@ -23,15 +20,8 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
||||
public final static long TIMEPERTICK = 16666667l;
|
||||
public static DebugMode DEBUG_DRAWING = DebugMode.MODE2;
|
||||
|
||||
public static List<MouseQueue> MOUSE_QUEUE = new ArrayList<MouseQueue>();
|
||||
|
||||
public static void runGameLoop() {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -70,7 +60,6 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
||||
}.start();
|
||||
|
||||
f.getContentPane().addMouseListener(this);
|
||||
f.getContentPane().addMouseMotionListener(this);
|
||||
f.add(p);
|
||||
f.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@ -84,36 +73,26 @@ public class Meteo implements MouseListener,MouseMotionListener{
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.CLICK,e));
|
||||
b.mouseClicked(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.PRESS,e));
|
||||
b.mousePressed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.RELEASE,e));
|
||||
b.mouseReleased(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.ENTER,e));
|
||||
b.mouseEntered(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
MOUSE_QUEUE.add(new MouseQueue(MouseEventType.EXIT,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));
|
||||
b.mouseExited(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