New cursors!!!
authorJustin Worthe <justin@worthe-it.co.za>
Sat, 11 Aug 2018 14:30:03 +0000 (16:30 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sat, 11 Aug 2018 14:30:03 +0000 (16:30 +0200)
src/main.rs
src_assets/sprites/Cursor.png [deleted file]
src_assets/sprites/Cursor.svg [deleted file]
src_assets/sprites/Cursor1.png [new file with mode: 0644]
src_assets/sprites/Cursor2.png [new file with mode: 0644]
src_assets/sprites/Cursor3.png [new file with mode: 0644]

index e6932af..55c8594 100644 (file)
@@ -35,7 +35,8 @@ struct BugBasherGame {
     game_over: bool,
     time_to_next_bug: f64,
     total_time: f64,
-    camera: Affine
+    camera: Affine,
+    cursor: SpriteId
 }
 
 impl App<AssetId> for BugBasherGame {
@@ -90,12 +91,16 @@ impl App<AssetId> for BugBasherGame {
         let (x, y) = self.camera.invert_translate().apply_f64(ctx.cursor());
         match key {
             KeyCode::MouseLeft => {
+                let mut hit = false;
                 for bug in self.bugs.iter_mut().filter(|bug| bug.touches_point(Vec2d { x, y })) {
                     if !self.game_over && bug.alive == true {
                         self.points += 1;
                     }
-
                     bug.alive = false;
+                    hit = true;
+                }
+                if hit {
+                    self.rotate_cursor();
                 }
             },
             KeyCode::Return => {
@@ -155,7 +160,7 @@ impl App<AssetId> for BugBasherGame {
             let mut renderer = renderer.sprite_mode();
             renderer.draw(
                 &Affine::translate(cursor_x, cursor_y),
-                SpriteId::Cursor
+                self.cursor
             );
         }
     }
@@ -178,7 +183,8 @@ impl BugBasherGame {
             game_over: true,
             time_to_next_bug: 0.,
             total_time: 0.,
-            camera: Affine::id()
+            camera: Affine::id(),
+            cursor: SpriteId::Cursor1
         };
         game.reset();
         game
@@ -221,6 +227,14 @@ impl BugBasherGame {
             renderer.draw(&affine, tile);
         };
     }
+
+    fn rotate_cursor(&mut self) {
+        self.cursor = match self.cursor {
+            SpriteId::Cursor1 => SpriteId::Cursor2,
+            SpriteId::Cursor2 => SpriteId::Cursor3,
+            _ => SpriteId::Cursor1
+        }
+    }
 }
 
 fn main() {
diff --git a/src_assets/sprites/Cursor.png b/src_assets/sprites/Cursor.png
deleted file mode 100644 (file)
index c097119..0000000
Binary files a/src_assets/sprites/Cursor.png and /dev/null differ
diff --git a/src_assets/sprites/Cursor.svg b/src_assets/sprites/Cursor.svg
deleted file mode 100644 (file)
index 9310f50..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?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="50"
-   height="50"
-   viewBox="0 0 50 50"
-   version="1.1"
-   id="svg4540"
-   inkscape:version="0.92.2 2405546, 2018-03-11"
-   sodipodi:docname="Cursor.svg"
-   inkscape:export-filename="/home/justin/proj/bug_basher/src_assets/sprites/Cursor.png"
-   inkscape:export-xdpi="96"
-   inkscape:export-ydpi="96">
-  <defs
-     id="defs4534" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="8"
-     inkscape:cx="26.000629"
-     inkscape:cy="24.118821"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     showgrid="false"
-     units="px"
-     inkscape:showpageshadow="false"
-     showborder="true"
-     inkscape:window-width="1916"
-     inkscape:window-height="1055"
-     inkscape:window-x="0"
-     inkscape:window-y="21"
-     inkscape:window-maximized="0" />
-  <metadata
-     id="metadata4537">
-    <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,-1072.5196)">
-    <circle
-       style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       id="path5085"
-       cx="25"
-       cy="1097.5197"
-       r="23.5" />
-    <path
-       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-       d="m 0,1072.5196 50,50"
-       id="path5087"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="cc" />
-    <path
-       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-       d="m 0,1122.5196 50,-50"
-       id="path5087-3"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="cc" />
-  </g>
-</svg>
diff --git a/src_assets/sprites/Cursor1.png b/src_assets/sprites/Cursor1.png
new file mode 100644 (file)
index 0000000..b5a87fb
Binary files /dev/null and b/src_assets/sprites/Cursor1.png differ
diff --git a/src_assets/sprites/Cursor2.png b/src_assets/sprites/Cursor2.png
new file mode 100644 (file)
index 0000000..e1e1e5d
Binary files /dev/null and b/src_assets/sprites/Cursor2.png differ
diff --git a/src_assets/sprites/Cursor3.png b/src_assets/sprites/Cursor3.png
new file mode 100644 (file)
index 0000000..8fdb660
Binary files /dev/null and b/src_assets/sprites/Cursor3.png differ