Browse Source

updated drop thingy and its size

john melesky 5 years ago
parent
commit
6cbd681b26
2 changed files with 18 additions and 15 deletions
  1. BIN
      assets/blip1.png
  2. 18 15
      src/main.rs

BIN
assets/blip1.png


+ 18 - 15
src/main.rs

@@ -42,15 +42,18 @@ fn init() -> (Sdl, Window) {
 
 fn main() {
 
+    let dropsize = 40;
+
     let mut running: bool = true;
-    let mut blitx: i32 = 7 * 80;
-    let mut blity: i32 = 5 * 80;
+    let mut blitx: i32 = 7 * dropsize;
+    let mut blity: i32 = 5 * dropsize;
     let mut direction = "";
     let stepsize = 8;
     let ticksize = 20;
     let mut next_tick: u32;
 
-    let mut blitrect = Rect::new(blitx * 80, blity * 80, 80, 80);
+    let mut blitrect = Rect::new(blitx * dropsize, blity * dropsize,
+                                 dropsize as u32, dropsize as u32);
 
     // grab the context and window, then set the window up for drawing
     let (context, window) = init();
@@ -101,22 +104,22 @@ fn main() {
                         running = false
                     },
                     Some(Keycode::Up) => {
-                        if (blitx % 80) == 0 {
+                        if (blitx % dropsize) == 0 {
                             direction = "up"
                         }
                     },
                     Some(Keycode::Down) => {
-                        if (blitx % 80) == 0 {
+                        if (blitx % dropsize) == 0 {
                             direction = "down"
                         }
                     },
                     Some(Keycode::Left) => {
-                        if (blity % 80) == 0 {
+                        if (blity % dropsize) == 0 {
                             direction = "left"
                         }
                     },
                     Some(Keycode::Right) => {
-                        if (blity % 80) == 0 {
+                        if (blity % dropsize) == 0 {
                             direction = "right"
                         }
                     },
@@ -135,18 +138,18 @@ fn main() {
                     direction = "";
                 } else {
                     blity -= stepsize;
-                    if (blity % 80) == 0 {
+                    if (blity % dropsize) == 0 {
                         direction = ""
                     }
                 }
             },
             "down" => {
-                if blity >= (HEIGHT - 80) as i32 {
-                    blity = (HEIGHT - 80) as i32;
+                if blity >= (HEIGHT as i32) - dropsize {
+                    blity = (HEIGHT as i32) - dropsize;
                     direction = "";
                 } else {
                     blity += stepsize;
-                    if (blity % 80) == 0 {
+                    if (blity % dropsize) == 0 {
                         direction = ""
                     }
                 }
@@ -157,18 +160,18 @@ fn main() {
                     direction = "";
                 } else {
                     blitx -= stepsize;
-                    if (blitx % 80) == 0 {
+                    if (blitx % dropsize) == 0 {
                         direction = ""
                     }
                 }
             },
             "right" => {
-                if blitx >= (WIDTH - 80) as i32 {
-                    blitx = (WIDTH - 80) as i32;
+                if blitx >= (WIDTH as i32) - dropsize {
+                    blitx = (WIDTH as i32) - dropsize;
                     direction = "";
                 } else {
                     blitx += stepsize;
-                    if (blitx % 80) == 0 {
+                    if (blitx % dropsize) == 0 {
                         direction = ""
                     }
                 }