color fishies!

This commit is contained in:
Evan Pratten 2021-04-24 16:07:47 -04:00
parent 5be5d00c86
commit eb3c508c68

View File

@ -1,7 +1,9 @@
use rand::{Rng, prelude::ThreadRng}; use rand::{prelude::ThreadRng, Rng};
use raylib::prelude::*; use raylib::prelude::*;
use crate::{gamecore::GameCore, lib::utils::triangles::rotate_vector, player::Player, world::World}; use crate::{
gamecore::GameCore, lib::utils::triangles::rotate_vector, player::Player, world::World,
};
const FISH_FOLLOW_PLAYER_DISTANCE: f32 = 30.0; const FISH_FOLLOW_PLAYER_DISTANCE: f32 = 30.0;
const FISH_FOLLOW_PLAYER_SPEED: f32 = 1.8; const FISH_FOLLOW_PLAYER_SPEED: f32 = 1.8;
@ -24,18 +26,26 @@ pub struct FishEntity {
velocity: Vector2, velocity: Vector2,
pub following_player: bool, pub following_player: bool,
size: Vector2, size: Vector2,
rng: ThreadRng rng: ThreadRng,
color: Color,
} }
impl FishEntity { impl FishEntity {
pub fn new(position: Vector2) -> Self { pub fn new(position: Vector2) -> Self {
let mut rng = rand::thread_rng();
Self { Self {
position: position, position: position,
direction: Vector2::zero(), direction: Vector2::zero(),
velocity: Vector2::zero(), velocity: Vector2::zero(),
following_player: false, following_player: false,
size: Vector2 { x: 5.0, y: 8.0 }, size: Vector2 { x: 5.0, y: 8.0 },
rng: rand::thread_rng() color: Color {
r: rng.gen_range(128..225),
g: rng.gen_range(128..225),
b: rng.gen_range(128..225),
a: 140,
},
rng,
} }
} }
@ -186,7 +196,7 @@ impl FishEntity {
self.position + fish_front, self.position + fish_front,
self.position + fish_bl, self.position + fish_bl,
self.position + fish_br, self.position + fish_br,
Color::BLACK, self.color,
); );
} }
} }