Added number font and points
authorJustin Worthe <justin@worthe-it.co.za>
Mon, 2 Apr 2018 13:35:28 +0000 (15:35 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Mon, 2 Apr 2018 13:35:28 +0000 (15:35 +0200)
src/main.rs
src_assets/tiles/NumberFont_t30.png [new file with mode: 0644]
src_assets/tiles/NumberFont_t30.svg [new file with mode: 0644]

index 960197f..ff8b64f 100644 (file)
@@ -15,7 +15,8 @@ mod entities;
 use entities::bug::Bug;
 
 struct BugBasherGame {
-    bugs: Vec<Bug>
+    bugs: Vec<Bug>,
+    points: i64
 }
 
 impl App<AssetId> for BugBasherGame {
@@ -44,8 +45,33 @@ impl App<AssetId> for BugBasherGame {
     }
 
     fn render(&mut self, renderer: &mut Renderer<AssetId>) {
+        let (app_width, app_height) = (renderer.app_width(), renderer.app_height());
         renderer.clear((255,255,255));
         {
+            let mut renderer = renderer.tiled_mode(app_width / 2. - 50., -app_height / 2. + 50.);
+            let spacing = 25.;
+            let point_str = format!("{}", self.points);
+            for (i, c) in point_str.chars().enumerate() {
+                let affine = Affine::translate(i as f64 * spacing, 0.);
+                let tile = match c {
+                    '-' => TileId::NumberFontR0C0,
+                    '0' => TileId::NumberFontR0C1,
+                    '1' => TileId::NumberFontR0C2,
+                    '2' => TileId::NumberFontR0C3,
+                    '3' => TileId::NumberFontR0C4,
+                    '4' => TileId::NumberFontR0C5,
+                    '5' => TileId::NumberFontR0C6,
+                    '6' => TileId::NumberFontR0C7,
+                    '7' => TileId::NumberFontR0C8,
+                    '8' => TileId::NumberFontR0C9,
+                    '9' => TileId::NumberFontR0C10,
+                    _ => TileId::NumberFontR0C0,
+                };
+                renderer.draw(&affine, tile);
+            };
+            
+        }
+        {
             let mut renderer = renderer.sprite_mode();
             for bug in &self.bugs {
                 renderer.draw(
@@ -72,6 +98,7 @@ fn main() {
             Bug::new(0., 1100., 0.),
             Bug::new(0., -1500., 0.3),
             Bug::new(300., -1200., 1.5),
-        )
+        ),
+        points: 0
     });
 }
diff --git a/src_assets/tiles/NumberFont_t30.png b/src_assets/tiles/NumberFont_t30.png
new file mode 100644 (file)
index 0000000..429b770
Binary files /dev/null and b/src_assets/tiles/NumberFont_t30.png differ
diff --git a/src_assets/tiles/NumberFont_t30.svg b/src_assets/tiles/NumberFont_t30.svg
new file mode 100644 (file)
index 0000000..8c89b70
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="330"
+   height="30"
+   viewBox="0 0 87.312498 7.9375002"
+   version="1.1"
+   id="svg5356"
+   inkscape:version="0.92.2 2405546, 2018-03-11"
+   sodipodi:docname="NumberFont_t30.svg"
+   inkscape:export-filename="/home/justin/proj/bug_basher/src_assets/tiles/NumberFont_t30.png"
+   inkscape:export-xdpi="96"
+   inkscape:export-ydpi="96">
+  <defs
+     id="defs5350" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="2.8"
+     inkscape:cx="113.68425"
+     inkscape:cy="4.8933727"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     units="px"
+     inkscape:window-width="1916"
+     inkscape:window-height="1055"
+     inkscape:window-x="0"
+     inkscape:window-y="21"
+     inkscape:window-maximized="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid5901"
+       spacingx="7.9375"
+       spacingy="7.9375"
+       empspacing="1" />
+    <inkscape:grid
+       type="xygrid"
+       id="grid5903"
+       spacingx="7.9375"
+       spacingy="7.9375"
+       originx="3.96875"
+       color="#3f3f00"
+       opacity="0.1254902"
+       empcolor="#ff0000"
+       empopacity="0.25098039"
+       empspacing="1" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5353">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-289.06248)">
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
+       x="-0.51676428"
+       y="296.85013"
+       id="text5907"><tspan
+         sodipodi:role="line"
+         id="tspan5905"
+         x="-0.51676428"
+         y="296.85013"
+         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:1.57691667px;stroke-width:0.26458332"
+         dx="1.3">-0123456789</tspan></text>
+  </g>
+</svg>