Hitboxen verbessert
This commit is contained in:
parent
5653c137f8
commit
56d563ecd5
@ -101,6 +101,8 @@ public class GamePlayManager {
|
|||||||
player.lives--;
|
player.lives--;
|
||||||
gameObjectManager.getLivesLabel().setLifeCount(player.lives);
|
gameObjectManager.getLivesLabel().setLifeCount(player.lives);
|
||||||
gameObjectManager.getBubbles().clear();
|
gameObjectManager.getBubbles().clear();
|
||||||
|
gameObjectManager.getHarpoons().forEach(h -> h.stopSound());
|
||||||
|
gameObjectManager.getHarpoons().clear();
|
||||||
specialBubblePresent = false;
|
specialBubblePresent = false;
|
||||||
spawnBubbles = true;
|
spawnBubbles = true;
|
||||||
gameObjectManager.getGameOverlay().flashScreen(Color.red, 100);
|
gameObjectManager.getGameOverlay().flashScreen(Color.red, 100);
|
||||||
@ -238,7 +240,7 @@ public class GamePlayManager {
|
|||||||
collidableGameObjects.add(gameObjectManager.getPlayerObject());
|
collidableGameObjects.add(gameObjectManager.getPlayerObject());
|
||||||
collidableGameObjects.addAll(gameObjectManager.getHarpoons());
|
collidableGameObjects.addAll(gameObjectManager.getHarpoons());
|
||||||
|
|
||||||
if(randomNumber<60){
|
if(randomNumber<10){
|
||||||
RoundBubble roundBubble = new RoundBubble(gameView, collidableGameObjects);
|
RoundBubble roundBubble = new RoundBubble(gameView, collidableGameObjects);
|
||||||
roundBubble.setGamePlayManager(this);
|
roundBubble.setGamePlayManager(this);
|
||||||
gameObjectManager.getBubbles().add(roundBubble);
|
gameObjectManager.getBubbles().add(roundBubble);
|
||||||
@ -279,7 +281,7 @@ public class GamePlayManager {
|
|||||||
public boolean shootHarpoon(Position startPosition){
|
public boolean shootHarpoon(Position startPosition){
|
||||||
if(gameView.timerExpired("ShootHarpoon","GamePlayManager") && gameObjectManager.getHarpoons().size()<2){
|
if(gameView.timerExpired("ShootHarpoon","GamePlayManager") && gameObjectManager.getHarpoons().size()<2){
|
||||||
Harpoon harpoon = new Harpoon(gameView,new ArrayList<>());
|
Harpoon harpoon = new Harpoon(gameView,new ArrayList<>());
|
||||||
harpoon.getPosition().setTo(startPosition.x+16, startPosition.y-15);
|
harpoon.getPosition().setTo(startPosition.x+6, startPosition.y-15);
|
||||||
harpoon.setGamePlayManager(this);
|
harpoon.setGamePlayManager(this);
|
||||||
gameObjectManager.getHarpoons().add(harpoon);
|
gameObjectManager.getHarpoons().add(harpoon);
|
||||||
gameObjectManager.getBubbles().forEach(b -> b.addCollidableGameObject(Collections.singletonList(harpoon)));
|
gameObjectManager.getBubbles().forEach(b -> b.addCollidableGameObject(Collections.singletonList(harpoon)));
|
||||||
|
@ -37,6 +37,7 @@ public abstract class Bubble extends CollidingGameObject implements MovingGameOb
|
|||||||
*/
|
*/
|
||||||
public Bubble(GameView gameView, ArrayList<CollidableGameObject> objectsToCollideWith){
|
public Bubble(GameView gameView, ArrayList<CollidableGameObject> objectsToCollideWith){
|
||||||
super(gameView,objectsToCollideWith);
|
super(gameView,objectsToCollideWith);
|
||||||
|
random = new Random();
|
||||||
rotation = 90;
|
rotation = 90;
|
||||||
size = 10;
|
size = 10;
|
||||||
width = (int) (12 * size);
|
width = (int) (12 * size);
|
||||||
@ -44,8 +45,7 @@ public abstract class Bubble extends CollidingGameObject implements MovingGameOb
|
|||||||
speedInPixel = 1;
|
speedInPixel = 1;
|
||||||
|
|
||||||
spawnID = UUID.randomUUID().getLeastSignificantBits();
|
spawnID = UUID.randomUUID().getLeastSignificantBits();
|
||||||
random = new Random();
|
position.setTo(HelperValues.FRAME_BORDER_WIDTH + random.nextInt((int)(GameView.WIDTH-width - (2*HelperValues.FRAME_BORDER_WIDTH))), -width);
|
||||||
position.setTo(random.nextInt(GameView.WIDTH-width),-width);
|
|
||||||
spawning = true;
|
spawning = true;
|
||||||
spawnSpeed = 500;
|
spawnSpeed = 500;
|
||||||
gameView.setTimer("spawn"+spawnID,"bubble"+spawnID,spawnSpeed);
|
gameView.setTimer("spawn"+spawnID,"bubble"+spawnID,spawnSpeed);
|
||||||
@ -110,16 +110,16 @@ public abstract class Bubble extends CollidingGameObject implements MovingGameOb
|
|||||||
// Wall bounce
|
// Wall bounce
|
||||||
if((newLocation.getX() >= GameView.WIDTH - width - HelperValues.FRAME_BORDER_WIDTH) || newLocation.getX() <= HelperValues.FRAME_BORDER_WIDTH){
|
if((newLocation.getX() >= GameView.WIDTH - width - HelperValues.FRAME_BORDER_WIDTH) || newLocation.getX() <= HelperValues.FRAME_BORDER_WIDTH){
|
||||||
velocity = new Point2D.Double(velocity.getX() * -1.0, velocity.getY());
|
velocity = new Point2D.Double(velocity.getX() * -1.0, velocity.getY());
|
||||||
if(this instanceof SpecialBubble){
|
|
||||||
switchSpecialBubbleState((SpecialBubble) this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Floor bounce
|
// Floor bounce
|
||||||
if(newLocation.getY() >= HelperValues.FRAME_WINDOW_HEIGHT + HelperValues.FRAME_BORDER_WIDTH - width){
|
if(newLocation.getY() >= HelperValues.FRAME_WINDOW_HEIGHT + HelperValues.FRAME_BORDER_WIDTH - width){
|
||||||
velocity = new Point2D.Double(velocity.getX(), velocity.getY() * -0.95);
|
velocity = new Point2D.Double(velocity.getX(), velocity.getY() * -0.95);
|
||||||
newLocation = new Point2D.Double(newLocation.getX(), HelperValues.FRAME_WINDOW_HEIGHT + HelperValues.FRAME_BORDER_WIDTH - width);
|
newLocation = new Point2D.Double(newLocation.getX(), HelperValues.FRAME_WINDOW_HEIGHT + HelperValues.FRAME_BORDER_WIDTH - width);
|
||||||
if(this instanceof SpecialBubble){
|
if(this instanceof SpecialBubble){
|
||||||
switchSpecialBubbleState((SpecialBubble) this);
|
SpecialBubble specialBubble = (SpecialBubble) this;
|
||||||
|
specialBubble.freezeState = !specialBubble.freezeState;
|
||||||
|
gameView.playSound("specialBounce.wav",false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +127,6 @@ public abstract class Bubble extends CollidingGameObject implements MovingGameOb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchSpecialBubbleState(SpecialBubble specialBubble){
|
|
||||||
specialBubble.freezeState = !specialBubble.freezeState;
|
|
||||||
gameView.playSound("specialBounce.wav",false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the score to add when bursting the bubble.
|
* Get the score to add when bursting the bubble.
|
||||||
*
|
*
|
||||||
|
@ -2,6 +2,7 @@ package de.thdeg.greiner.superpangworld.graphics.moveable;
|
|||||||
|
|
||||||
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
||||||
import de.thdeg.greiner.superpangworld.graphics.base.*;
|
import de.thdeg.greiner.superpangworld.graphics.base.*;
|
||||||
|
import de.thdeg.greiner.superpangworld.graphics.helper.HelperValues;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -51,7 +52,7 @@ public class Harpoon extends CollidingGameObject implements MovingGameObject {
|
|||||||
boolean right = true;
|
boolean right = true;
|
||||||
String rope = "";
|
String rope = "";
|
||||||
|
|
||||||
for(int i=0;i<100;i++){
|
for(int i = 0; i< HelperValues.FRAME_WINDOW_HEIGHT; i++){
|
||||||
rope += " ".repeat(pre) + "k" + " ".repeat(post)+"\n";
|
rope += " ".repeat(pre) + "k" + " ".repeat(post)+"\n";
|
||||||
if(right){
|
if(right){
|
||||||
pre++;
|
pre++;
|
||||||
|
@ -29,8 +29,8 @@ public class HexagonalBubble extends Bubble {
|
|||||||
width = (int) (128 * size);
|
width = (int) (128 * size);
|
||||||
height = (int) (128 * size);
|
height = (int) (128 * size);
|
||||||
|
|
||||||
this.hitBox.width = width;
|
this.hitBox.width = (int)(width - (width*0.1) );
|
||||||
this.hitBox.height = height;
|
this.hitBox.height = (int)(width - (width*0.1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HexagonalBubble(GameView gameView, ArrayList<CollidableGameObject> objectsToCollideWith, double size, double speedInPixel, Position position, boolean spawning, Point2D velocity){
|
public HexagonalBubble(GameView gameView, ArrayList<CollidableGameObject> objectsToCollideWith, double size, double speedInPixel, Position position, boolean spawning, Point2D velocity){
|
||||||
@ -39,14 +39,14 @@ public class HexagonalBubble extends Bubble {
|
|||||||
width = (int) (128 * size);
|
width = (int) (128 * size);
|
||||||
height = (int) (128 * size);
|
height = (int) (128 * size);
|
||||||
|
|
||||||
this.hitBox.width = width;
|
this.hitBox.width = (int)(width - (width*0.1) );
|
||||||
this.hitBox.height = height;
|
this.hitBox.height = (int)(width - (width*0.1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateHitBoxPosition() {
|
protected void updateHitBoxPosition() {
|
||||||
hitBox.x = (int) position.x;
|
hitBox.x = (int) (position.x + (width*0.05));
|
||||||
hitBox.y = (int) position.y;
|
hitBox.y = (int) (position.y + (width*0.05));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,19 +55,16 @@ public class HexagonalBubble extends Bubble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus() {
|
public void updateStatus() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePosition() {
|
public void updatePosition() {
|
||||||
super.updatePosition();
|
super.updatePosition();
|
||||||
rotation = (rotation + 1) % 360;
|
rotation = (rotation + 2) % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBurstScore() {
|
public int getBurstScore() {
|
||||||
// 1 0.5 0.25 0.125
|
|
||||||
switch((int)(size*1000)){
|
switch((int)(size*1000)){
|
||||||
case 1000:
|
case 1000:
|
||||||
return 200;
|
return 200;
|
||||||
|
@ -3,6 +3,7 @@ package de.thdeg.greiner.superpangworld.graphics.moveable;
|
|||||||
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
||||||
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,8 +34,8 @@ public class PlayerObject extends CollidableGameObject implements Cloneable {
|
|||||||
height = (int) (41 * size);
|
height = (int) (41 * size);
|
||||||
speedInPixel = 2;
|
speedInPixel = 2;
|
||||||
|
|
||||||
this.hitBox.width = width;
|
this.hitBox.width = width - 20;
|
||||||
this.hitBox.height = height;
|
this.hitBox.height = height - 10;
|
||||||
|
|
||||||
movingRight = false;
|
movingRight = false;
|
||||||
movingLeft = false;
|
movingLeft = false;
|
||||||
@ -44,8 +45,8 @@ public class PlayerObject extends CollidableGameObject implements Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateHitBoxPosition() {
|
protected void updateHitBoxPosition() {
|
||||||
hitBox.x = (int) (position.x );
|
hitBox.x = (int) (position.x + 10);
|
||||||
hitBox.y = (int) (position.y);
|
hitBox.y = (int) (position.y + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import de.thdeg.greiner.superpangworld.graphics.base.Bubble;
|
|||||||
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
||||||
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -101,7 +102,6 @@ public class RoundBubble extends Bubble {
|
|||||||
gamePlayManager.addBubbles(bubbleLeft, bubbleRight);
|
gamePlayManager.addBubbles(bubbleLeft, bubbleRight);
|
||||||
}else if(timeFreeze){
|
}else if(timeFreeze){
|
||||||
gamePlayManager.freezeMovement(1000);
|
gamePlayManager.freezeMovement(1000);
|
||||||
System.out.println("FREEZING");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import de.thdeg.greiner.superpangworld.graphics.base.Bubble;
|
|||||||
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.CollidableGameObject;
|
||||||
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 336 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 336 B |
Loading…
Reference in New Issue
Block a user