Skip to content

Commit

Permalink
12 Billion million pounds of uranium GHZ
Browse files Browse the repository at this point in the history
fixes:
minor glitches to the board

Additions:
MULTIPLAYER ENGINE
BUG FIXING OVERHALL
  • Loading branch information
hitime1234 committed Jan 23, 2022
1 parent b8f3d8d commit 63ac85d
Show file tree
Hide file tree
Showing 17 changed files with 2,302 additions and 126 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ project(":core") {


dependencies {
implementation 'com.google.code.gson:gson:2.8.9'
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"
Expand Down
140 changes: 124 additions & 16 deletions core/src/Blocker/basicBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,109 @@

import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

import java.io.UnsupportedEncodingException;
import java.lang.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;

import static java.lang.Math.*;

public class basicBlock {
int x;
int y;
int speed;
ShapeRenderer draw;
public int x;
public int y;
public int speed;
public ShapeRenderer draw;
public int[][] Vector;
public int Shape = -1;
private int length = 25;
private int height = 25;
private int lowestX = 0;
private int lowestY = 0;
private int HighestX = 0;
private int HighestY = 0;
public BasicCube[] cube;
private Boolean Damage = false;
//this copium --jackus
//fix your code god dammit



public String WriteToCsv(int[][] myArray) throws UnsupportedEncodingException {
StringBuilder res = new StringBuilder();
for (int[] ints : myArray) {
for (int anInt : ints) res.append(URLEncoder.encode(String.valueOf(anInt), "UTF-8")).append(",");
res.append("\n");
}
return res.toString();
}


public int[][] read(String res) throws UnsupportedEncodingException {
String[] rows = res.split("\n");
int[][] myArray = new int[rows.length][];
for (int iRow = 0; iRow < rows.length; iRow++) {
String[] cols = rows[iRow].split(",");
myArray[iRow] = new int[cols.length];
for (int iCol = 0; iCol < cols.length; iCol++)
myArray[iRow][iCol] = Integer.parseInt(URLDecoder.decode(cols[iCol], "UTF-8"));
}
return myArray;
}




public ArrayList CloneData() throws UnsupportedEncodingException {
ArrayList<String> data = new ArrayList<>();
data.add(WriteToCsv(Vector));
data.add(String.valueOf(Shape));
data.add(String.valueOf(length));
data.add(String.valueOf(height));
data.add(Boolean.toString(Damage));
return data;
}



public void SetValues(int[][] Vector,int shape,int length,int height,boolean Damage){
this.Vector = Vector;
this.Shape = shape;
this.length = length;
this.height = height;
this.Damage = Damage;
}

public boolean CheckGreaterX(int x){
boolean result = false;
for (int i=0;i<getNumberOCubes();i++) {
if (cube[i].getX() >= x){
result = true;
}
}
return result;
}

public boolean CheckLessX(int x){
boolean result = false;
for (int i=0;i<getNumberOCubes();i++) {
if (cube[i].getX() <= x){
result = true;
}
}
return result;
}

public int HeightOfBlock(){
int TempHigh = cube[0].getY();
int TempLow = cube[0].getY();
for (int i=0;i<getNumberOCubes();i++){
if (TempHigh <= cube[i].getY()){
TempHigh = cube[i].getY();
}
if (TempLow >= cube[i].getY()){
TempLow = cube[i].getY();
}
}
return TempHigh - TempLow;
}

private void CubeCreator(){
switch (Shape) {
//cube
Expand Down Expand Up @@ -91,6 +171,19 @@ private void CubeCreator(){
cube[2] = new BasicCube(x-25,y+25,25,25,FindVector(x+25,y+25,25,25));
cube[3] = new BasicCube(x-50,y+25,25,25,FindVector(x+50,y+25,25,25));
break;
//sent line piece
case 7:
cube = new BasicCube[9];
cube[0] = new BasicCube(x,y,25,25,FindVector(x,y,25,25));
cube[1] = new BasicCube(x+25,y,25,25,FindVector(x+25,y,25,25));
cube[2] = new BasicCube(x+50,y,25,25,FindVector(x+50,y,25,25));
cube[3] = new BasicCube(x+75,y,25,25,FindVector(x+75,y,25,25));
cube[4] = new BasicCube(x+100,y,25,25,FindVector(x+100,y,25,25));
cube[5] = new BasicCube(x+150,y,25,25,FindVector(x+150,y,25,25));
cube[6] = new BasicCube(x+175,y,25,25,FindVector(x+175,y,25,25));
cube[7] = new BasicCube(x+200,y,25,25,FindVector(x+200,y,25,25));
cube[8] = new BasicCube(x+225,y,25,25,FindVector(x+225,y,25,25));
break;

default:
length = 0;
Expand All @@ -102,6 +195,7 @@ private void CubeCreator(){




public basicBlock(ShapeRenderer draw, int x, int y, int speed, int[][] vector, int shape) {
this.x = x;
this.y = y;
Expand All @@ -117,6 +211,8 @@ public basicBlock clone() {
return new basicBlock(draw,x,y,speed,Vector,Shape);
}



public void flip() {
if (Shape != -1) {
for (int i = 0; i < getNumberOCubes(); i++) {
Expand Down Expand Up @@ -535,24 +631,37 @@ public void dropY(int yDrop,int newStart){
}
}



public void moveX(int x) {
this.x = this.x - x;
for (int i = 0; i < getNumberOCubes(); i++) {
cube[i].setX(cube[i].getX() + x);
if (cube[i] != null) {
cube[i].setX(cube[i].getX() + x);
}
}
}

public void moveY(int x) {
y = y - x;
for (int i = 0; i < getNumberOCubes(); i++) {
cube[i].setY(cube[i].getY() - x);
if (cube[i] != null) {
cube[i].setY(cube[i].getY() - x);
}
}
}

public int getX() {
return cube[1].getX();
}

public int RealX(){
return this.x;
}
public int RealY(){
return this.y;
}

public int getY() {
return cube[1].getY();
}
Expand Down Expand Up @@ -652,13 +761,12 @@ public void pass() {
}

public void draw() {
for (int i = 0; i < 4; i++) {
for (int i = 0; i < cube.length; i++) {
try {
if (cube[i] != null) {
if (Damage == true){
System.out.println("debug mode");
}

int xHold = cube[i].getX();
int yHold = cube[i].getY();
int BLength = cube[i].getLength();
Expand All @@ -683,7 +791,7 @@ public int getXHighest() {
for (int i=0;i<getNumberOCubes();i++) {
if (hold < cube[i].getX()){
hold =cube[i].getX();
HighestX = cube[i].getX();
int highestX = cube[i].getX();
}
}
return hold;
Expand All @@ -693,7 +801,7 @@ public int getXLowest() {
for (int i=0;i<getNumberOCubes();i++) {
if (hold > cube[i].getX()){
hold =cube[i].getX();
lowestX = cube[i].getX();
int lowestX = cube[i].getX();
}
}
return hold;
Expand All @@ -703,7 +811,7 @@ public int getYHighest() {
for (int i=0;i<getNumberOCubes();i++) {
if (hold < cube[i].getY()){
hold =cube[i].getY();
HighestY = cube[i].getY();
int highestY = cube[i].getY();
}
}
return hold;
Expand All @@ -714,7 +822,7 @@ public int getYLowest() {
for (int i=0;i<getNumberOCubes();i++) {
if (hold > cube[i].getY()){
hold =cube[i].getY();
lowestY = cube[i].getY();
int lowestY = cube[i].getY();
}
}
return hold;
Expand Down
6 changes: 0 additions & 6 deletions core/src/Blocker/board.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package Blocker;

import com.mygdx.game.TetrisTheGame;
import com.mygdx.game.gameConstants;
import org.graalvm.compiler.lir.LIRInstruction;

import javax.sound.sampled.Line;
import java.util.Vector;

public class board {
public int[][] Boarder;
Expand Down
36 changes: 23 additions & 13 deletions core/src/Blocker/queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ public class queue {
private int index = 0;
private int GenIndex =0;

public basicBlock getObjects(int i) {
return objects.get(i);
}

public int getIndex() {
return index;
}

public int ClassicBlockGeneration(ShapeRenderer Drawing,int speed){
public int ClassicBlockGeneration(ShapeRenderer Drawing, int speed){
int block = 0;
//This uses the bag randomizer method
//were a bag is picked in order then randomized
BAG = new ArrayList<>();
//something goes here
//https://stackoverflow.com/questions/29551450/tetris-shape-generation-algorithm-in-java/
//https://harddrop.com/forums/index.php?showtopic=1925
for (int i=0;i<7;i++) {
RNGblock hold = new RNGblock(Drawing, i, speed);
basicBlock BUILT = hold.getHold();
BAG.add(BUILT);
}

Collections.shuffle(BAG);
for (int i=0;i<BAG.size();i++) {
objects.add(BAG.get(i));
}
for (int x = 0; x < 7; x++) {
RNGblock hold = new RNGblock(Drawing, x, speed);
basicBlock BUILT = hold.getHold();
BAG.add(BUILT);
}

Collections.shuffle(BAG);
for (int y = 0; y < BAG.size(); y++) {
objects.add(BAG.get(y));
}
System.out.println("Size:" + (objects.size()-index));
return 1;
}

Expand Down Expand Up @@ -107,7 +115,8 @@ public basicBlock DeQueue(ShapeRenderer Drawing,int speed){
objects.remove(index);
switch (Type) {
case 1:
if (GenIndex > 5){
if (GenIndex > 3){
ClassicBlockGeneration(Drawing,speed);
ClassicBlockGeneration(Drawing,speed);
GenIndex =0;
}
Expand All @@ -120,7 +129,8 @@ public basicBlock DeQueue(ShapeRenderer Drawing,int speed){
objects.add(index, BUILT);
index++;
GenIndex++;
if (GenIndex > 19) {
if (GenIndex > 14) {
generate(Drawing, speed);
generate(Drawing, speed);
GenIndex =0;
}
Expand Down
18 changes: 18 additions & 0 deletions core/src/Handling/BugFixThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void running(){
@Override
public void run() {
lineChecksBlanks();
UnderFlow();
applyValues();
}

Expand Down Expand Up @@ -67,4 +68,21 @@ public void lineChecksBlanks(){
}
}
}
public void UnderFlow(){
for (int i=0;i<DUMP.size();i++){
for (int y=0;y<DUMP.get(i).cube.length;y++) {
if (DUMP.get(i).cube[y] != null) {
if (DUMP.get(i).cube[y].getY() < 25) {
DeadBlock.BuildArray();
for (int x = 0; x < DUMP.size(); x++) {
DUMP.get(x).moveY(-25);
DeadBlock.DrawTypeRectangle(DUMP.get(x));
}
i = DUMP.size() + 2;
break;
}
}
}
}
}
}
Loading

0 comments on commit 63ac85d

Please sign in to comment.