Praktikum 9 V2
This commit is contained in:
parent
686f7442c8
commit
5cae1734d7
@ -28,6 +28,9 @@ class GameObjectManager {
|
|||||||
private Background background;
|
private Background background;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
|
private RandomBall randomBall;
|
||||||
|
private FollowerBall followerBall;
|
||||||
|
|
||||||
private LinkedList<GameObject> gameObjects;
|
private LinkedList<GameObject> gameObjects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,6 +52,9 @@ class GameObjectManager {
|
|||||||
this.background = new Background(gameView);
|
this.background = new Background(gameView);
|
||||||
|
|
||||||
this.player = new Player(gameView);
|
this.player = new Player(gameView);
|
||||||
|
|
||||||
|
this.randomBall = new RandomBall(gameView);
|
||||||
|
this.followerBall = new FollowerBall(gameView, randomBall);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,6 +70,9 @@ class GameObjectManager {
|
|||||||
gameObjects.add(scoreLabel);
|
gameObjects.add(scoreLabel);
|
||||||
gameObjects.add(livesIcon);
|
gameObjects.add(livesIcon);
|
||||||
gameObjects.add(player);
|
gameObjects.add(player);
|
||||||
|
gameObjects.add(randomBall);
|
||||||
|
gameObjects.add(followerBall);
|
||||||
|
|
||||||
|
|
||||||
gameObjects.forEach(gameObject ->{
|
gameObjects.forEach(gameObject ->{
|
||||||
gameObject.update();
|
gameObject.update();
|
||||||
|
@ -100,6 +100,16 @@ public class Position implements Cloneable{
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the distance to any other position.
|
||||||
|
*
|
||||||
|
* @param other Position to calculate the distance to.
|
||||||
|
* @return The distance.
|
||||||
|
*/
|
||||||
|
public double distance(Position other) {
|
||||||
|
return Math.sqrt(Math.pow((x - other.x), 2) + Math.pow((y - other.y), 2));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Position(" + (int) Math.round(x) + ", " + (int) Math.round(y) + ')';
|
return "Position(" + (int) Math.round(x) + ", " + (int) Math.round(y) + ')';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package de.thdeg.berl.ufofight.graphics.movingobjects;
|
package de.thdeg.greiner.superpangworld.graphics.moveable;
|
||||||
|
|
||||||
import de.thdeg.berl.ufofight.gameview.GameView;
|
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.GameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.GameObject;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.MovingGameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.MovingGameObject;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.Position;
|
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ public class Harpoon extends CollidingGameObject implements MovingGameObject {
|
|||||||
@Override
|
@Override
|
||||||
public void addToCanvas(){
|
public void addToCanvas(){
|
||||||
gameView.addBlockImageToCanvas(HARPOON, getPosition().x, getPosition().y,size, rotation);
|
gameView.addBlockImageToCanvas(HARPOON, getPosition().x, getPosition().y,size, rotation);
|
||||||
gameView.addRectangleToCanvas(hitBox.x, hitBox.y, hitBox.width, hitBox.height,1,false, Color.red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,6 @@ public class HexagonalBubble extends Bubble {
|
|||||||
@Override
|
@Override
|
||||||
public void addToCanvas() {
|
public void addToCanvas() {
|
||||||
gameView.addImageToCanvas("hexagon.png",position.x,position.y,size,rotation);
|
gameView.addImageToCanvas("hexagon.png",position.x,position.y,size,rotation);
|
||||||
gameView.addRectangleToCanvas(hitBox.x, hitBox.y, hitBox.width, hitBox.height,1,false, Color.red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +73,6 @@ public class Player extends CollidableGameObject {
|
|||||||
gameView.addBlockImageToCanvas(SPIELFIGUR, position.x, position.y, size, rotation);
|
gameView.addBlockImageToCanvas(SPIELFIGUR, position.x, position.y, size, rotation);
|
||||||
}
|
}
|
||||||
shooting = false;
|
shooting = false;
|
||||||
gameView.addRectangleToCanvas(hitBox.x, hitBox.y, hitBox.width, hitBox.height,1,false, Color.red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package de.thdeg.berl.ufofight.graphics.movingobjects;
|
package de.thdeg.greiner.superpangworld.graphics.moveable;
|
||||||
|
|
||||||
import de.thdeg.berl.ufofight.gameview.GameView;
|
import de.thdeg.greiner.superpangworld.gameview.GameView;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.GameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.GameObject;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.MovingGameObject;
|
import de.thdeg.greiner.superpangworld.graphics.base.MovingGameObject;
|
||||||
import de.thdeg.berl.ufofight.graphics.base.Position;
|
import de.thdeg.greiner.superpangworld.graphics.base.Position;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -57,7 +57,6 @@ public class RoundBubble extends Bubble {
|
|||||||
@Override
|
@Override
|
||||||
public void addToCanvas(){
|
public void addToCanvas(){
|
||||||
gameView.addBlockImageToCanvas(RED_BUBBLE, getPosition().x, getPosition().y,size, rotation);
|
gameView.addBlockImageToCanvas(RED_BUBBLE, getPosition().x, getPosition().y,size, rotation);
|
||||||
gameView.addRectangleToCanvas(hitBox.x, hitBox.y, hitBox.width, hitBox.height,1,false, Color.yellow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,7 +57,6 @@ public class SpecialBubble extends Bubble {
|
|||||||
@Override
|
@Override
|
||||||
public void addToCanvas() {
|
public void addToCanvas() {
|
||||||
gameView.addBlockImageToCanvas(GREEN_BUBBLE,position.x,position.y,size, rotation);
|
gameView.addBlockImageToCanvas(GREEN_BUBBLE,position.x,position.y,size, rotation);
|
||||||
gameView.addRectangleToCanvas(hitBox.x, hitBox.y, hitBox.width, hitBox.height,1,false, Color.red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
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.
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.
Loading…
Reference in New Issue
Block a user