This repository has been archived on 2021-04-27. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-24 18:10:27 -04:00

60 lines
1.5 KiB
Rust

use super::base::EnemyBase;
use crate::{player::Player, resources::GlobalResources};
use raylib::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct JellyFish {
pub position: Vector2,
#[serde(skip)]
pub stunned_timer: f64,
#[serde(skip)]
pub do_stun_player: bool,
}
impl JellyFish {}
impl EnemyBase for JellyFish {
fn render(
&mut self,
context_2d: &mut raylib::prelude::RaylibMode2D<raylib::prelude::RaylibDrawHandle>,
resources: &mut GlobalResources,
) {
// Simple sine position
let v_trans = context_2d.get_time().sin();
// Render the jellyfish
resources.jellyfish_animation_regular.draw(
context_2d,
Vector2 {
x: self.position.x,
y: self.position.y + (2.0 * v_trans as f32),
},
0.0,
);
resources.jellyfish_animation_attack.draw(
context_2d,
Vector2 {
x: self.position.x,
y: self.position.y + (2.0 * v_trans as f32),
},
0.0,
);
self.do_stun_player = resources
.jellyfish_animation_attack
.get_current_frame_id(context_2d)
== 13;
}
fn handle_logic(&mut self, player: &mut Player, dt: f64) {
// Handle stunning the player
if self.do_stun_player {}
}
fn handle_getting_attacked(&mut self) {
todo!()
}
}