Selaa lähdekoodia

Art is useless now! FINALLY

Eiyeron Fulmincendii 9 vuotta sitten
vanhempi
commit
dc297012af
6 muutettua tiedostoa jossa 55 lisäystä ja 30 poistoa
  1. 14 14
      art/rules.mk
  2. BIN
      data/out.wrf
  3. 3 1
      src/engine/main.cpp
  4. 0 1
      src/map/Map.cpp
  5. 35 14
      src/render/Text.cpp
  6. 3 0
      src/render/Text.h

+ 14 - 14
art/rules.mk

@@ -5,20 +5,20 @@ art_SPR_DATA := $(addprefix $(OUT)/,$(art_SPRITES:%.png=%.cspr))
 art_SPR_SRC := $(OUT)/$(art_LOCAL_PATH)/sprites.c
 art_SPR_HDR := $(OUT)/$(art_LOCAL_PATH)/sprites.h
 
-BUILT_SRCS_C += $(art_SPR_SRC)
-INCLUDE += $(OUT)/$(art_LOCAL_PATH)
-BUILT_SRCS += $(art_SPR_HDR)
+# BUILT_SRCS_C += $(art_SPR_SRC)
+# INCLUDE += $(OUT)/$(art_LOCAL_PATH)
+# BUILT_SRCS += $(art_SPR_HDR)
 
-$(OUT)/%.cspr: %.png
-	@echo "SPRITE: $@"
-	@mkdir -p $(dir $@)
-	@ConvertImg --not-static --format n2dlib $< > $@
+# $(OUT)/%.cspr: %.png
+# 	@echo "SPRITE: $@"
+# 	@mkdir -p $(dir $@)
+# 	@ConvertImg --not-static --format n2dlib $< > $@
 
-$(art_SPR_SRC): $(art_SPR_DATA)
-	@echo "Catting sprites into sprites.c"
-	@rm -f $@
-	@echo "#include <stdint.h>" > $@
-	@cat $^ >> $@
+# $(art_SPR_SRC): $(art_SPR_DATA)
+# 	@echo "Catting sprites into sprites.c"
+# 	@rm -f $@
+# 	@echo "#include <stdint.h>" > $@
+# 	@cat $^ >> $@
 
-$(art_SPR_HDR): $(art_SPR_SRC)
-	@./$(art_LOCAL_PATH)/header.bash $< $@
+# $(art_SPR_HDR): $(art_SPR_SRC)
+# 	@./$(art_LOCAL_PATH)/header.bash $< $@

BIN
data/out.wrf


+ 3 - 1
src/engine/main.cpp

@@ -1,16 +1,17 @@
 #include "StateMachine.h"
 #include "Timing.h"
+#include "render/Text.h"
 #include "Graphics.h"
 #include "Quirks.h"
 #include "map/Map.h"
 #include "map/StateMap.h"
 #include "piaf/Archive.h"
 #include "utility/misc.h"
-#include "sprites.h"
 
 using namespace WalrusRPG;
 using WalrusRPG::PIAF::Archive;
 using WalrusRPG::Graphics::Texture;
+using namespace WalrusRPG::Graphics;
 
 int main(int argc, char *argv[])
 {
@@ -19,6 +20,7 @@ int main(int argc, char *argv[])
     Graphics::init();
     Timing::init();
     Quirks::init(argv[0]);
+    Text::init();
 
     Archive arc("data/out.wrf");
     Texture tex(arc.get("ov.png"));

+ 0 - 1
src/map/Map.cpp

@@ -1,7 +1,6 @@
 #include "Map.h"
 #include "render/TileRenderer.h"
 #include "Graphics.h"
-#include "sprites.h"
 #include "utility/Rect.h"
 #include "utility/misc.h"
 

+ 35 - 14
src/render/Text.cpp

@@ -1,33 +1,54 @@
 #include <cstdio>
 #include <cstdarg>
+#include <cstring>
 #include "Text.h"
-#include "sprites.h"
 #include "Graphics.h"
+#include "render/Font.h"
+#include "piaf/Archive.h"
 
 using namespace WalrusRPG::Graphics; /*Text*/
 using namespace WalrusRPG::Graphics;
 using namespace WalrusRPG::Utils;
+using namespace WalrusRPG::PIAF;
 
-Texture tex_font((char *) font);
+Font* fnt;
+Texture* tex;
+
+void Text::init()
+{
+    Archive arc("data/out.wrf");
+    tex = new Texture(arc.get("t_dbgfnt"));
+    fnt = new Font(*tex, arc.get("f_dbgfnt"));
+}
+
+void Text::deinit()
+{
+    delete fnt;
+    delete tex;
+}
 
 void Text::print_char(char c, unsigned x, unsigned y)
 {
-    put_sprite(tex_font, x, y, Rect((c % 16) * 8, (c / 16) * 8, 8, 8));
+    put_rectangle({static_cast<int>(x), static_cast<int>(y), 8, 8}, Black);
+    fnt->draw(x, y, c);
+    //put_sprite(tex_font, x, y, Rect((c % 16) * 8, (c / 16) * 8, 8, 8));
 }
 
 void Text::print_string(const char *str, unsigned x, unsigned y)
 {
-    Rect rect;
-    rect.width = 8;
-    rect.height = 8;
-    for (unsigned index = 0; str[index]; index++)
-    {
-        char c = str[index];
-        rect.x = (c % 16) * 8;
-        rect.y = (c / 16) * 8;
-        put_sprite(tex_font, x, y, rect);
-        x += 8;
-    }
+    put_rectangle({static_cast<int>(x), static_cast<int>(y), static_cast<unsigned>(8*strlen(str)), 8}, Black);
+    fnt->draw(x, y, str);
+    // Rect rect;
+    // rect.width = 8;
+    // rect.height = 8;
+    // for (unsigned index = 0; str[index]; index++)
+    // {
+    //     char c = str[index];
+    //     rect.x = (c % 16) * 8;
+    //     rect.y = (c / 16) * 8;
+    //     put_sprite(tex_font, x, y, rect);
+    //     x += 8;
+    // }
 }
 
 void Text::print_string(const std::string &str, unsigned x, unsigned y)

+ 3 - 0
src/render/Text.h

@@ -9,6 +9,9 @@ namespace WalrusRPG
     {
         namespace Text
         {
+            void init();
+            void deinit();
+
             void print_char(char c, unsigned x, unsigned y);
 
             void print_char(char c, unsigned x, unsigned y);