jellyfish rendering
This commit is contained in:
parent
296d5fff8f
commit
a3d79a5ebc
66
assets/img/enemies/jelly.json
Normal file
66
assets/img/enemies/jelly.json
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{ "frames": {
|
||||||
|
"Sprite-0001 0.": {
|
||||||
|
"frame": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
},
|
||||||
|
"Sprite-0001 1.": {
|
||||||
|
"frame": { "x": 10, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
},
|
||||||
|
"Sprite-0001 2.": {
|
||||||
|
"frame": { "x": 20, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
},
|
||||||
|
"Sprite-0001 3.": {
|
||||||
|
"frame": { "x": 30, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
},
|
||||||
|
"Sprite-0001 4.": {
|
||||||
|
"frame": { "x": 40, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
},
|
||||||
|
"Sprite-0001 5.": {
|
||||||
|
"frame": { "x": 50, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"rotated": false,
|
||||||
|
"trimmed": false,
|
||||||
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 10 },
|
||||||
|
"sourceSize": { "w": 10, "h": 10 },
|
||||||
|
"duration": 300
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"app": "http://www.aseprite.org/",
|
||||||
|
"version": "1.2.27-x64",
|
||||||
|
"image": "jelly.png",
|
||||||
|
"format": "RGBA8888",
|
||||||
|
"size": { "w": 60, "h": 10 },
|
||||||
|
"scale": "1",
|
||||||
|
"frameTags": [
|
||||||
|
],
|
||||||
|
"layers": [
|
||||||
|
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
|
||||||
|
],
|
||||||
|
"slices": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
BIN
assets/img/enemies/jelly.png
Normal file
BIN
assets/img/enemies/jelly.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 354 B |
File diff suppressed because one or more lines are too long
@ -1,7 +1,9 @@
|
|||||||
|
use raylib::prelude::*;
|
||||||
|
|
||||||
|
use crate::player::Player;
|
||||||
|
|
||||||
pub trait EnemyBase {
|
pub trait EnemyBase {
|
||||||
fn render();
|
fn render(&self, context_2d: &mut RaylibMode2D<RaylibDrawHandle>);
|
||||||
fn handle_logic();
|
fn handle_logic(&mut self, player: &mut Player, dt: f64);
|
||||||
fn handle_getting_attacked();
|
fn handle_getting_attacked(&mut self);
|
||||||
}
|
}
|
33
src/entities/enemy/jellyfish.rs
Normal file
33
src/entities/enemy/jellyfish.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
use super::base::EnemyBase;
|
||||||
|
use raylib::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use crate::player::Player;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
||||||
|
pub struct JellyFish {
|
||||||
|
pub position: Vector2,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
pub stunned_timer: f64
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JellyFish {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EnemyBase for JellyFish {
|
||||||
|
fn render(&self, context_2d: &mut raylib::prelude::RaylibMode2D<raylib::prelude::RaylibDrawHandle>) {
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
context_2d.draw_circle_v(self.position, 5.0, Color::RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_logic(&mut self, player: &mut Player, dt: f64) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_getting_attacked(&mut self) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,2 @@
|
|||||||
pub mod base;
|
pub mod base;
|
||||||
|
pub mod jellyfish;
|
@ -3,11 +3,7 @@ mod playerlogic;
|
|||||||
|
|
||||||
use raylib::prelude::*;
|
use raylib::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{entities::enemy::base::EnemyBase, gamecore::{GameCore, GameState}, lib::wrappers::audio::player::AudioPlayer, pallette::{SKY, WATER}};
|
||||||
gamecore::{GameCore, GameState},
|
|
||||||
lib::wrappers::audio::player::AudioPlayer,
|
|
||||||
pallette::{SKY, WATER},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::screen::Screen;
|
use super::screen::Screen;
|
||||||
|
|
||||||
@ -124,9 +120,11 @@ impl Screen for InGameScreen {
|
|||||||
fish.update_position(&mut game_core.player, dt, &fish_clone);
|
fish.update_position(&mut game_core.player, dt, &fish_clone);
|
||||||
fish.render(&mut context_2d);
|
fish.render(&mut context_2d);
|
||||||
}
|
}
|
||||||
|
for jellyfish in game_core.world.jellyfish.iter() {
|
||||||
|
jellyfish.render(&mut context_2d);
|
||||||
|
}
|
||||||
|
|
||||||
// Render Player
|
// Render Player
|
||||||
// playerlogic::render_player(&mut context_2d, game_core);
|
|
||||||
game_core.player.render(&mut context_2d, &mut game_core.resources, dt);
|
game_core.player.render(&mut context_2d, &mut game_core.resources, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
|
||||||
use crate::entities::fish::FishEntity;
|
use crate::entities::{enemy::jellyfish::JellyFish, fish::FishEntity};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct World {
|
pub struct World {
|
||||||
@ -19,7 +19,9 @@ pub struct World {
|
|||||||
pub fish: Vec<FishEntity>,
|
pub fish: Vec<FishEntity>,
|
||||||
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub colliders: Vec<Rectangle>
|
pub colliders: Vec<Rectangle>,
|
||||||
|
|
||||||
|
pub jellyfish: Vec<JellyFish>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
|
Reference in New Issue
Block a user