Commits

Anonymous committed d594ac7

updated demo with text

Comments (0)

Files changed (1)

src/main/java/net/fishbulb/jcod/demo/Demo.java

 import com.badlogic.gdx.Input;
 import com.badlogic.gdx.InputAdapter;
 import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.FPSLogger;
 import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.scenes.scene2d.Stage;
+import com.badlogic.gdx.scenes.scene2d.actions.Actions;
 import net.fishbulb.jcod.Console;
 import net.fishbulb.jcod.display.TileDisplay;
 import net.fishbulb.jcod.display.Tileset;
+import net.fishbulb.jcod.util.BlendMode;
 
 import java.util.Random;
 
 public class Demo extends InputAdapter implements ApplicationListener {
     Stage stage;
 
-    int SAMPLE_SCREEN_WIDTH = 120;
-    int SAMPLE_SCREEN_HEIGHT = 90;
-
-    int TOPLEFT = 0;
-    int TOPRIGHT = 1;
-    int BOTTOMLEFT = 2;
-    int BOTTOMRIGHT = 3;
+    int SAMPLE_SCREEN_WIDTH = 46;
+    int SAMPLE_SCREEN_HEIGHT = 20;
 
     int[] dirr = {1, -1, 1, 1};
     int[] dirg = {1, -1, -1, 1};
     }; // random corner colors
 
     Random rng = new Random();
-    private Console console;
+    private Console sampleConsole;
+
+    FPSLogger fps = new FPSLogger();
+
+    Color top = new Color();
+    Color bottom = new Color();
+    Color cur = new Color();
+
+    Color matte = new Color(0.2f, 0.2f, 0.8f, 0.3f);
 
     private void renderConsole() {
         // tweak colors
             }
         }
 
-        Color top = new Color();
-        Color bottom = new Color();
-        Color cur = new Color();
 
         for (int x = 0; x < SAMPLE_SCREEN_WIDTH; x++) {
             float xcoef = (float) (x) / (SAMPLE_SCREEN_WIDTH - 1);
             // get the current column top and bottom colors
-            lerp(cols[TOPLEFT], cols[TOPRIGHT], xcoef, top);
-            lerp(cols[BOTTOMLEFT], cols[BOTTOMRIGHT], xcoef, bottom);
+            lerp(cols[0], cols[1], xcoef, top);
+            lerp(cols[2], cols[3], xcoef, bottom);
             for (int y = 0; y < SAMPLE_SCREEN_HEIGHT; y++) {
                 float ycoef = (float) (y) / (SAMPLE_SCREEN_HEIGHT - 1);
                 // get the current cell color
                 lerp(top, bottom, ycoef, cur);
-                console.setCharBackground(x, y, cur);
+                sampleConsole.setCharBackground(x, y, cur);
             }
         }
-        console.flush();
+
+        sampleConsole.putString(10, 10, "Hello World", Color.YELLOW, matte, BlendMode.AddWithSourceAlpha);
+
+        sampleConsole.flush();
     }
 
     @Override
         Texture tiles = new Texture(Gdx.files.internal("tiles/terminal_trans.png"));
         Tileset tileset = new Tileset(tiles, 8, 8, Tileset.Layout.InColumns);
 
-        TileDisplay display = new TileDisplay(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, 8, 8);
-        console = new Console(tileset, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, display);
+        TileDisplay display = new TileDisplay(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, 16, 16);
+        sampleConsole = new Console(tileset, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, display);
 
-        stage.addActor(console.getDisplay());
+        stage.addActor(sampleConsole.getDisplay());
 
+        display.addAction(Actions.moveTo(100, 100));
 
+        renderConsole();
     }
 
 
         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
         stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
         stage.draw();
+        fps.log();
     }
 
     @Override