Optimized Ticking and Rendering #5
@ -12,7 +12,7 @@ import java.awt.Rectangle;
|
|||||||
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
delvh
commented
Review
```suggestion
* @since Snake 1.2
```
|
|||||||
* Created: <strong>01.07.2020</strong><br>
|
* Created: <strong>01.07.2020</strong><br>
|
||||||
*
|
*
|
||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public final class Food implements Updateable {
|
public final class Food implements Updateable {
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public final class Food implements Updateable {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
* @param color the color of the food item
|
* @param color the color of the food item
|
||||||
* @param lengthBonus the length added to the snake when the food item is eaten
|
* @param lengthBonus the length added to the snake when the food item is eaten
|
||||||
* @param bounds the bounds of the food item
|
* @param bounds the bounds of the food item
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public Food(Color color, int lengthBonus, Rectangle bounds) {
|
public Food(Color color, int lengthBonus, Rectangle bounds) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
@ -42,13 +42,13 @@ public final class Food implements Updateable {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the length added to the snake when the food item is eaten
|
* @return the length added to the snake when the food item is eaten
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public int getLengthBonus() { return lengthBonus; }
|
public int getLengthBonus() { return lengthBonus; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the bounds of the food item
|
* @return the bounds of the food item
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public Rectangle getBounds() { return bounds; }
|
public Rectangle getBounds() { return bounds; }
|
||||||
}
|
}
|
||||||
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
@ -36,7 +36,7 @@ public final class FoodFactory {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*
|
*
|
||||||
* @param width the width of the viewport
|
* @param width the width of the viewport
|
||||||
* @param height the height of the viewport
|
* @param height the height of the viewport
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public FoodFactory(int width, int height) {
|
public FoodFactory(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
@ -45,7 +45,7 @@ public final class FoodFactory {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a new food item
|
* @return a new food item
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public synchronized Food spawn() {
|
public synchronized Food spawn() {
|
||||||
nextSpawnTime = System.currentTimeMillis() + random.nextInt(15000) + 1000;
|
nextSpawnTime = System.currentTimeMillis() + random.nextInt(15000) + 1000;
|
||||||
@ -63,7 +63,7 @@ public final class FoodFactory {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the time after which a new food item should be spawned
|
* @return the time after which a new food item should be spawned
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public long getNextSpawnTime() { return nextSpawnTime; }
|
public long getNextSpawnTime() { return nextSpawnTime; }
|
||||||
}
|
}
|
||||||
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
@ -10,7 +10,7 @@ import java.awt.Graphics2D;
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
* Created: <strong>01.07.2020</strong><br>
|
* Created: <strong>01.07.2020</strong><br>
|
||||||
*
|
*
|
||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public final class Handler implements Updateable {
|
public final class Handler implements Updateable {
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public final class Handler implements Updateable {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*
|
*
|
||||||
* @param snake the snake
|
* @param snake the snake
|
||||||
* @param foodFactory the food factory
|
* @param foodFactory the food factory
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public Handler(Snake snake, FoodFactory foodFactory) {
|
public Handler(Snake snake, FoodFactory foodFactory) {
|
||||||
this.snake = snake;
|
this.snake = snake;
|
||||||
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
@ -147,7 +147,7 @@ public class Snake implements Updateable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the current {@link Direction} of the snake
|
* @return the current {@link Direction} of the snake
|
||||||
* @since Snake 1.0
|
* @since Snake 1.2
|
||||||
*/
|
*/
|
||||||
public Direction getDirection() { return direction; }
|
public Direction getDirection() { return direction; }
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public class Snake implements Updateable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a rectangle representing the head of the snake
|
* @return a rectangle representing the head of the snake
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
*/
|
*/
|
||||||
public Rectangle getHead() { return tiles.get(0); }
|
public Rectangle getHead() { return tiles.get(0); }
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public interface Updateable {
|
|||||||
* Here should the actions be implemented that are supposed to happen when a new
|
* Here should the actions be implemented that are supposed to happen when a new
|
||||||
* frame gets created.
|
* frame gets created.
|
||||||
```suggestion
* @since Snake 1.2
```
|
|||||||
*
|
*
|
||||||
* @since Snake 1.0
|
* @since Snake 1.2
|
||||||
*/
|
*/
|
||||||
default void tick() {}
|
default void tick() {}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import java.util.TimerTask;
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
* Created: <strong>01.07.2020</strong><br>
|
* Created: <strong>01.07.2020</strong><br>
|
||||||
*
|
*
|
||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @since Snake 1.0
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public class Viewport extends Canvas {
|
public class Viewport extends Canvas {
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class Viewport extends Canvas {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param gameRoot the game object responsible for updating the rest
|
* @param gameRoot the game object responsible for updating the rest
|
||||||
* @since Snake 1.0
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public Viewport(Updateable gameRoot) {
|
public Viewport(Updateable gameRoot) {
|
||||||
this.gameRoot = gameRoot;
|
this.gameRoot = gameRoot;
|
||||||
@ -43,7 +43,7 @@ public class Viewport extends Canvas {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
/**
|
/**
|
||||||
* Starts the render task.
|
* Starts the render task.
|
||||||
*
|
*
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
if (renderTask != null)
|
if (renderTask != null)
|
||||||
@ -72,7 +72,7 @@ public class Viewport extends Canvas {
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
/**
|
/**
|
||||||
* Stops the render task.
|
* Stops the render task.
|
||||||
*
|
*
|
||||||
* @since Snake 1.1
|
* @since Snake 1.2
|
||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
|||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
renderTask.cancel();
|
renderTask.cancel();
|
||||||
|
|||||||
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
```suggestion
* @since Snake 1.2
```
|
@ -32,7 +32,7 @@ public class Endscreen extends JDialog {
|
|||||||
public Endscreen(int score) {
|
public Endscreen(int score) {
|
||||||
this.score = score;
|
this.score = score;
|
||||||
setTitle("Endscreen");
|
setTitle("Endscreen");
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
setBounds(100, 100, 700, 700);
|
setBounds(100, 100, 700, 700);
|
||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
Loading…
Reference in New Issue
Block a user