-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from mcgivrer/feature/add-gameobject-lifetime
feat(LifeTime): Add life duration to GameObject
- Loading branch information
Showing
10 changed files
with
165 additions
and
63 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/fr/snapgames/fromclasstogame/core/entity/DebugViewportGrid.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,37 @@ | ||
package fr.snapgames.fromclasstogame.core.entity; | ||
|
||
import fr.snapgames.fromclasstogame.core.physic.World; | ||
|
||
import java.util.List; | ||
|
||
public class DebugViewportGrid extends GameObject { | ||
public int gridX; | ||
public int gridY; | ||
private World w; | ||
|
||
|
||
public DebugViewportGrid(String objectName, World w) { | ||
super(objectName); | ||
this.w = w; | ||
this.gridX = 16; | ||
this.gridY = 16; | ||
} | ||
|
||
public DebugViewportGrid(String objectName, World w, int gridX, int gridY) { | ||
super(objectName); | ||
this.w = w; | ||
this.gridX = gridX; | ||
this.gridY = gridY; | ||
} | ||
|
||
@Override | ||
public List<String> getDebugInfo() { | ||
List<String> info = super.getDebugInfo(); | ||
info.add(String.format("world: %fx%f", w.width, w.height)); | ||
return info; | ||
} | ||
|
||
public World getWorld() { | ||
return w; | ||
} | ||
} |
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
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
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
34 changes: 34 additions & 0 deletions
34
...in/java/fr/snapgames/fromclasstogame/core/gfx/renderer/DebugViewportGridRenderHelper.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,34 @@ | ||
package fr.snapgames.fromclasstogame.core.gfx.renderer; | ||
|
||
import fr.snapgames.fromclasstogame.core.entity.DebugViewportGrid; | ||
import fr.snapgames.fromclasstogame.core.physic.World; | ||
|
||
import java.awt.*; | ||
|
||
public class DebugViewportGridRenderHelper extends AbstractRenderHelper implements RenderHelper<DebugViewportGrid> { | ||
|
||
private Color gridColor = Color.BLUE; | ||
|
||
@Override | ||
public String getType() { | ||
return DebugViewportGrid.class.getName(); | ||
} | ||
|
||
@Override | ||
public void draw(Graphics2D g, DebugViewportGrid dvg) { | ||
if (dvg.getWorld() != null && dvg.getDebug() > 0) { | ||
World w = dvg.getWorld(); | ||
g.setColor(gridColor); | ||
for (int x = 0; x < w.width; x += dvg.gridX) { | ||
g.drawRect(x, 0, dvg.gridX, (int) w.height); | ||
} | ||
for (int y = 0; y < w.height; y += dvg.gridY) { | ||
if (y + dvg.gridY < w.height) { | ||
g.drawRect(0, y, (int) w.width, dvg.gridY); | ||
} | ||
} | ||
g.setColor(debugBoxColor); | ||
g.drawRect(0, 0, (int) w.width, (int) w.height); | ||
} | ||
} | ||
} |
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
11 changes: 6 additions & 5 deletions
11
src/main/java/fr/snapgames/fromclasstogame/core/gfx/renderer/TextRenderHelper.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
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
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
Oops, something went wrong.