diff --git a/Test.java b/com/danitheskunk/skunkworks/Test.java similarity index 95% rename from Test.java rename to com/danitheskunk/skunkworks/Test.java index fe6ff7e..c1beac2 100644 --- a/Test.java +++ b/com/danitheskunk/skunkworks/Test.java @@ -1,5 +1,5 @@ -import com.danitheskunk.skunkworks.BaseGame; -import com.danitheskunk.skunkworks.Vec2i; +package com.danitheskunk.skunkworks; + import com.danitheskunk.skunkworks.gfx.Color; import com.danitheskunk.skunkworks.gfx.IRenderContext; import com.danitheskunk.skunkworks.gfx.vt.Terminal; diff --git a/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java b/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java index e21cd1a..5aed44e 100644 --- a/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java +++ b/com/danitheskunk/skunkworks/gfx/BaseRenderContext.java @@ -62,7 +62,7 @@ abstract public class BaseRenderContext implements IRenderContext { var isHalfWidth = terminal.isHalfWidth(charPos); drawTexture(pixelPos, fullFont.getTexture(0xdb), bgColor); - if(isHalfWidth) { + if(isHalfWidth && halfFont != null) { drawTexture( pixelPos, halfFont.getTexture(terminal.getLeftHalfChar(charPos)), diff --git a/com/danitheskunk/skunkworks/gfx/vt/Terminal.java b/com/danitheskunk/skunkworks/gfx/vt/Terminal.java index bcd1f9b..f130551 100644 --- a/com/danitheskunk/skunkworks/gfx/vt/Terminal.java +++ b/com/danitheskunk/skunkworks/gfx/vt/Terminal.java @@ -50,6 +50,29 @@ public class Terminal { } } + public Terminal(Vec2i size, IFont fullFont) { + this.cells = new ArrayList<>(); + this.size = size; + this.fullFont = fullFont; + this.halfFont = null; + + if(!fullFont.isMonospace()) { + throw new RuntimeException("Fonts need to be monospace"); + } + + this.fullCharSize = fullFont.getMonospaceSize(); + + for(int i = 0; i < size.getY() * size.getX(); ++i) { + var cell = new Cell(); + cell.fullChar = 0; + cell.secondChar = 0; + cell.halfWidth = false; + cell.bgColor = Color.BLACK; + cell.fgColor = Color.WHITE; + cells.add(cell); + } + } + public Vec2i getFullCharSize() { return fullCharSize; }