diff --git a/assets/blue_star.png b/assets/blue_star.png
new file mode 100644
index 0000000..b060993
Binary files /dev/null and b/assets/blue_star.png differ
diff --git a/assets/green_star.png b/assets/green_star.png
new file mode 100644
index 0000000..e6c4401
Binary files /dev/null and b/assets/green_star.png differ
diff --git a/assets/star.png b/assets/pink_star.png
similarity index 100%
rename from assets/star.png
rename to assets/pink_star.png
diff --git a/assets/star.svg b/assets/star.svg
index fc0c008..d2a3662 100644
--- a/assets/star.svg
+++ b/assets/star.svg
@@ -15,8 +15,8 @@
version="1.1"
id="svg8"
inkscape:version="0.92.1 r15371"
- sodipodi:docname="star_template.svg"
- inkscape:export-filename="/home/cmdln/src/git/susuwatari-game/assets/star.png"
+ sodipodi:docname="star.svg"
+ inkscape:export-filename="/home/cmdln/src/git/susuwatari-game/assets/green_star.png"
inkscape:export-xdpi="9.6000004"
inkscape:export-ydpi="9.6000004">
@@ -48,21 +48,22 @@
image/svg+xml
-
+
+ transform="translate(-13.253985,-58.111215)"
+ style="display:none">
+
+
+
+
+
+
+
+
+
diff --git a/assets/yellow_star.png b/assets/yellow_star.png
new file mode 100644
index 0000000..91c1051
Binary files /dev/null and b/assets/yellow_star.png differ
diff --git a/src/lib.rs b/src/lib.rs
index 62666a7..3d7e0c9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,8 +34,14 @@ impl Game {
pub fn new(w: &mut PistonWindow) -> Game {
let mut scene = Scene::new();
let mut stars: Vec = vec![];
- for _ in 1..7 {
- stars.push(Star::new(w, &mut scene));
+ for number in 1..7 {
+ let color = match number % 4 {
+ 1 => "yellow",
+ 2 => "green",
+ 3 => "blue",
+ _ => "pink",
+ };
+ stars.push(Star::new(color, w, &mut scene));
}
let player = Hero::new(w, &mut scene);
Game {
diff --git a/src/mobs/star.rs b/src/mobs/star.rs
index f63edd7..0a58f56 100644
--- a/src/mobs/star.rs
+++ b/src/mobs/star.rs
@@ -19,23 +19,23 @@ pub struct Star {
dir: u32,
pub collider: Cuboid2,
pub destroyed: bool,
+ accel: f64,
}
const DESIGNED_FOR_WIDTH: f64 = 640.0;
const SCALE_FACTOR: f64 = 0.5;
-const ACCEL: f64 = 2.0;
const MOVE_DUR: f64 = 0.75;
const DESTROY_DUR: f64 = 0.75;
impl Star {
- pub fn new(w: &mut PistonWindow, scene: &mut Scene>) -> Star {
+ pub fn new(color: &str, w: &mut PistonWindow, scene: &mut Scene>) -> Star {
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets")
.unwrap();
let tex = Rc::new(Texture::from_path(&mut w.factory,
- assets.join("star.png"),
+ assets.join(format!("{}_star.png", color)),
Flip::None,
&TextureSettings::new())
.unwrap());
@@ -43,6 +43,12 @@ impl Star {
let x = rand_pos(width as f64);
let y = rand_pos(height as f64);
let scale = width as f64 / DESIGNED_FOR_WIDTH * SCALE_FACTOR;
+ let accel = match color {
+ "yellow" => 3.0,
+ "blue" => 1.0,
+ "green" => 2.0,
+ _ => 2.0,
+ };
let mut sprite = Sprite::from_texture(tex);
sprite.set_scale(scale, scale);
sprite.set_position(x, y);
@@ -57,6 +63,7 @@ impl Star {
dir: rand_dir(),
collider: Cuboid2::new(Vector2::new(bounds[2], bounds[3])),
destroyed: false,
+ accel: accel,
}
}
@@ -81,8 +88,8 @@ impl Star {
}
self.dir = rand_turn(self.dir);
let dir = lookup_dir(self.dir);
- let mov_x = ACCEL * dir.0;
- let mov_y = ACCEL * dir.1;
+ let mov_x = self.accel * dir.0;
+ let mov_y = self.accel * dir.1;
scene.run(self.sprite_id,
&Action(Ease(EaseFunction::CubicOut,
Box::new(MoveBy(dt * MOVE_DUR, mov_x, mov_y)))));