-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I think the screen possibly repaints now
- Loading branch information
Showing
7 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/gmail/vitalatron/game/visual/AbstractGameWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.gmail.vitalatron.game.visual; | ||
|
||
import com.gmail.vitalatron.game.exec.ExecutorGameLoop; | ||
import com.gmail.vitalatron.game.exec.GameTask; | ||
import com.gmail.vitalatron.game.exec.TimedLoop; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class AbstractGameWindow implements GameWindow { | ||
protected final List<Drawable> drawableItems = new ArrayList<>(); | ||
protected TimedLoop repaintLoop; | ||
protected GameTask repaintTask = GameTask.EMPTY; | ||
|
||
public AbstractGameWindow() { | ||
repaintLoop = new ExecutorGameLoop(); | ||
repaintLoop.addTask(repaintTask); | ||
} | ||
|
||
@Override | ||
public void setFps(int fps) { | ||
repaintLoop.setIterationsPerSecond(fps); | ||
} | ||
|
||
@Override | ||
public void addDrawableItem(Drawable drawable) { | ||
drawableItems.add(drawable); | ||
} | ||
|
||
@Override | ||
public void removeDrawableItem(Drawable drawable) { | ||
drawableItems.remove(drawable); | ||
} | ||
|
||
@Override | ||
public void clearDrawableItems() { | ||
drawableItems.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.gmail.vitalatron.game.visual; | ||
|
||
import java.awt.*; | ||
|
||
public interface Drawable { | ||
public void draw(Graphics2D g); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/gmail/vitalatron/game/visual/DrawableSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gmail.vitalatron.game.visual; | ||
|
||
import java.awt.*; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
public class DrawableSet implements Drawable { | ||
private final List<Drawable> drawableItems = new ArrayList<>(); | ||
|
||
@Override | ||
public void draw(Graphics2D g) { | ||
for (Drawable d : drawableItems) { | ||
d.draw(g); | ||
} | ||
} | ||
|
||
public void add(Drawable drawable) { | ||
drawableItems.add(drawable); | ||
} | ||
|
||
public void remove(Drawable drawable) { | ||
drawableItems.remove(drawable); | ||
} | ||
|
||
public void clear() { | ||
drawableItems.clear(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/gmail/vitalatron/game/visual/GameWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package com.gmail.vitalatron.game.visual; | ||
|
||
import java.awt.*; | ||
|
||
public interface GameWindow { | ||
public void show(); | ||
public void close(); | ||
public void setIcon(Image icon); | ||
|
||
public void setFps(int fps); | ||
|
||
public void addDrawableItem(Drawable drawable); | ||
public void removeDrawableItem(Drawable drawable); | ||
public void clearDrawableItems(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/gmail/vitalatron/game/visual/Sprite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.gmail.vitalatron.game.visual; | ||
|
||
import java.awt.*; | ||
|
||
public class Sprite implements Drawable { | ||
|
||
@Override | ||
public void draw(Graphics2D g) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters