clean up the rest of the files
This commit is contained in:
parent
5e1ae73b2b
commit
733839ca10
@ -2,7 +2,6 @@ use raylib::{
|
|||||||
color::Color,
|
color::Color,
|
||||||
math::{Rectangle, Vector2},
|
math::{Rectangle, Vector2},
|
||||||
prelude::{RaylibDraw, RaylibDrawHandle},
|
prelude::{RaylibDraw, RaylibDrawHandle},
|
||||||
texture::Texture2D,
|
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ use raylib::prelude::*;
|
|||||||
use crate::{
|
use crate::{
|
||||||
gamecore::{GameCore, GameState},
|
gamecore::{GameCore, GameState},
|
||||||
lib::wrappers::audio::player::AudioPlayer,
|
lib::wrappers::audio::player::AudioPlayer,
|
||||||
pallette::WATER_DARK,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::screen::Screen;
|
use super::screen::Screen;
|
||||||
@ -20,8 +19,8 @@ impl Screen for MainMenuScreen {
|
|||||||
fn render(
|
fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
draw_handle: &mut RaylibDrawHandle,
|
draw_handle: &mut RaylibDrawHandle,
|
||||||
thread: &RaylibThread,
|
_thread: &RaylibThread,
|
||||||
audio_system: &mut AudioPlayer,
|
_audio_system: &mut AudioPlayer,
|
||||||
game_core: &mut GameCore,
|
game_core: &mut GameCore,
|
||||||
) -> Option<GameState> {
|
) -> Option<GameState> {
|
||||||
// Window dimensions
|
// Window dimensions
|
||||||
@ -55,7 +54,7 @@ impl Screen for MainMenuScreen {
|
|||||||
draw_handle.draw_text(
|
draw_handle.draw_text(
|
||||||
"Play",
|
"Play",
|
||||||
(win_height / 2) + 120,
|
(win_height / 2) + 120,
|
||||||
(win_width / 4),
|
win_width / 4,
|
||||||
60,
|
60,
|
||||||
match hovering_play_button {
|
match hovering_play_button {
|
||||||
true => Color::BLUE,
|
true => Color::BLUE,
|
||||||
@ -96,7 +95,7 @@ impl Screen for MainMenuScreen {
|
|||||||
return Some(GameState::InGame);
|
return Some(GameState::InGame);
|
||||||
} else if hovering_shop_button {
|
} else if hovering_shop_button {
|
||||||
return Some(GameState::InShop);
|
return Some(GameState::InShop);
|
||||||
}else if hovering_quit_button {
|
} else if hovering_quit_button {
|
||||||
return Some(GameState::GameQuit);
|
return Some(GameState::GameQuit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ impl Screen for WinScreen {
|
|||||||
fn render(
|
fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
draw_handle: &mut RaylibDrawHandle,
|
draw_handle: &mut RaylibDrawHandle,
|
||||||
thread: &RaylibThread,
|
_thread: &RaylibThread,
|
||||||
audio_system: &mut AudioPlayer,
|
_audio_system: &mut AudioPlayer,
|
||||||
game_core: &mut GameCore,
|
game_core: &mut GameCore,
|
||||||
) -> Option<GameState> {
|
) -> Option<GameState> {
|
||||||
let win_height = draw_handle.get_screen_height();
|
let win_height = draw_handle.get_screen_height();
|
||||||
@ -57,7 +57,8 @@ impl Screen for WinScreen {
|
|||||||
// Render message
|
// Render message
|
||||||
draw_handle.draw_text(
|
draw_handle.draw_text(
|
||||||
"You can use the transponder to \ncontact help!",
|
"You can use the transponder to \ncontact help!",
|
||||||
((win_width / 2) - ((SCREEN_PANEL_SIZE.x as i32 + 6) / 2)) + (0.15 * SCREEN_PANEL_SIZE.x)as i32,
|
((win_width / 2) - ((SCREEN_PANEL_SIZE.x as i32 + 6) / 2))
|
||||||
|
+ (0.15 * SCREEN_PANEL_SIZE.x) as i32,
|
||||||
(win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 80,
|
(win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 80,
|
||||||
15,
|
15,
|
||||||
Color::BLACK,
|
Color::BLACK,
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -12,14 +12,9 @@ use gamecore::{GameCore, GameProgress, GameState};
|
|||||||
use lib::{utils::profiler::GameProfiler, wrappers::audio::player::AudioPlayer};
|
use lib::{utils::profiler::GameProfiler, wrappers::audio::player::AudioPlayer};
|
||||||
use log::info;
|
use log::info;
|
||||||
use logic::{
|
use logic::{
|
||||||
gameend::GameEndScreen,
|
gameend::GameEndScreen, ingame::InGameScreen, loadingscreen::LoadingScreen,
|
||||||
ingame::InGameScreen,
|
mainmenu::MainMenuScreen, pausemenu::PauseMenuScreen, screen::Screen, shop::ShopScreen,
|
||||||
loadingscreen::LoadingScreen,
|
winscreen::WinScreen,
|
||||||
mainmenu::MainMenuScreen,
|
|
||||||
pausemenu::PauseMenuScreen,
|
|
||||||
screen::Screen,
|
|
||||||
shop::ShopScreen,
|
|
||||||
winscreen::{self, WinScreen},
|
|
||||||
};
|
};
|
||||||
use raylib::prelude::*;
|
use raylib::prelude::*;
|
||||||
use world::{load_world_colliders, World};
|
use world::{load_world_colliders, World};
|
||||||
|
@ -21,27 +21,6 @@ pub const TRANSLUCENT_WHITE_64: Color = Color {
|
|||||||
a: 64,
|
a: 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SKY: Color = Color {
|
|
||||||
r: 15,
|
|
||||||
g: 193,
|
|
||||||
b: 217,
|
|
||||||
a: 255
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const WATER: Color = Color {
|
|
||||||
r: 24,
|
|
||||||
g: 66,
|
|
||||||
b: 143,
|
|
||||||
a: 255
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const WATER_DARK: Color = Color {
|
|
||||||
r: 8,
|
|
||||||
g: 24,
|
|
||||||
b: 54,
|
|
||||||
a: 255
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const TRANSLUCENT_RED_64: Color = Color {
|
pub const TRANSLUCENT_RED_64: Color = Color {
|
||||||
r: 230,
|
r: 230,
|
||||||
g: 41,
|
g: 41,
|
||||||
|
@ -10,9 +10,6 @@ use crate::{
|
|||||||
use raylib::prelude::*;
|
use raylib::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
const AOE_RING_MAX_RADIUS: f32 = 60.0;
|
|
||||||
const STUN_ATTACK_TIME: f64 = 0.75;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
||||||
pub struct PlayerInventory {
|
pub struct PlayerInventory {
|
||||||
pub stun_gun: Option<StunGun>,
|
pub stun_gun: Option<StunGun>,
|
||||||
@ -74,33 +71,6 @@ impl Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn collides_with_rec(&self, rectangle: &Rectangle) -> bool {
|
pub fn collides_with_rec(&self, rectangle: &Rectangle) -> bool {
|
||||||
// // Build a bounding box of the player by their corners
|
|
||||||
// let top_left_corner = self.position - (self.size / 2.0);
|
|
||||||
// let bottom_right_corner = self.position + (self.size / 2.0);
|
|
||||||
// let top_right_corner = Vector2 {
|
|
||||||
// x: bottom_right_corner.x,
|
|
||||||
// y: top_left_corner.y,
|
|
||||||
// };
|
|
||||||
// let bottom_left_corner = Vector2 {
|
|
||||||
// x: top_left_corner.x,
|
|
||||||
// y: bottom_right_corner.y,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // Get the rotation
|
|
||||||
// let rotation = Vector2::zero().angle_to(self.direction);
|
|
||||||
|
|
||||||
// // Rotate the bounds
|
|
||||||
// let top_left_corner = rotate_vector(top_left_corner, rotation);
|
|
||||||
// let bottom_right_corner = rotate_vector(bottom_right_corner, rotation);
|
|
||||||
// let top_right_corner = rotate_vector(top_right_corner, rotation);
|
|
||||||
// let bottom_left_corner = rotate_vector(bottom_left_corner, rotation);
|
|
||||||
|
|
||||||
// // Check for collisions
|
|
||||||
// return rectangle.check_collision_point_rec(top_left_corner)
|
|
||||||
// || rectangle.check_collision_point_rec(bottom_right_corner)
|
|
||||||
// || rectangle.check_collision_point_rec(top_right_corner)
|
|
||||||
// || rectangle.check_collision_point_rec(bottom_left_corner);
|
|
||||||
|
|
||||||
return rectangle.check_collision_circle_rec(self.position, self.radius);
|
return rectangle.check_collision_circle_rec(self.position, self.radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
use failure::Error;
|
use raylib::{
|
||||||
use raylib::{RaylibHandle, RaylibThread, math::Vector2, shaders::Shader, texture::{Image, RenderTexture2D, Texture2D}};
|
math::Vector2,
|
||||||
|
shaders::Shader,
|
||||||
|
texture::{Image, RenderTexture2D, Texture2D},
|
||||||
|
RaylibHandle, RaylibThread,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::lib::wrappers::animation::FrameAnimationWrapper;
|
use crate::lib::wrappers::animation::FrameAnimationWrapper;
|
||||||
|
|
||||||
@ -39,25 +43,24 @@ pub struct GlobalResources {
|
|||||||
// Shop & items
|
// Shop & items
|
||||||
pub shop_background: Texture2D,
|
pub shop_background: Texture2D,
|
||||||
|
|
||||||
pub flashlight_one: Texture2D,
|
pub flashlight_one: Texture2D,
|
||||||
pub flashlight_two: Texture2D,
|
pub flashlight_two: Texture2D,
|
||||||
pub flashlight_three: Texture2D,
|
pub flashlight_three: Texture2D,
|
||||||
|
|
||||||
pub stun_gun_one: Texture2D,
|
pub stun_gun_one: Texture2D,
|
||||||
pub stun_gun_two: Texture2D,
|
pub stun_gun_two: Texture2D,
|
||||||
pub stun_gun_three: Texture2D,
|
pub stun_gun_three: Texture2D,
|
||||||
|
|
||||||
pub air_one: Texture2D,
|
pub air_one: Texture2D,
|
||||||
pub air_two: Texture2D,
|
pub air_two: Texture2D,
|
||||||
pub air_three: Texture2D,
|
pub air_three: Texture2D,
|
||||||
|
|
||||||
pub flippers_one: Texture2D,
|
pub flippers_one: Texture2D,
|
||||||
pub flippers_two: Texture2D,
|
pub flippers_two: Texture2D,
|
||||||
pub flippers_three: Texture2D,
|
pub flippers_three: Texture2D,
|
||||||
|
|
||||||
// Treasure
|
|
||||||
pub transponder: FrameAnimationWrapper,
|
|
||||||
|
|
||||||
|
// Treasure
|
||||||
|
pub transponder: FrameAnimationWrapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalResources {
|
impl GlobalResources {
|
||||||
@ -130,7 +133,11 @@ impl GlobalResources {
|
|||||||
&Image::load_image("./assets/img/map/cave.png")?,
|
&Image::load_image("./assets/img/map/cave.png")?,
|
||||||
)?,
|
)?,
|
||||||
pixel_shader: raylib.load_shader(&thread, None, Some("./assets/shaders/pixel.fs"))?,
|
pixel_shader: raylib.load_shader(&thread, None, Some("./assets/shaders/pixel.fs"))?,
|
||||||
shader_texture: raylib.load_render_texture(&thread, raylib.get_screen_width() as u32, raylib.get_screen_height() as u32)?,
|
shader_texture: raylib.load_render_texture(
|
||||||
|
&thread,
|
||||||
|
raylib.get_screen_width() as u32,
|
||||||
|
raylib.get_screen_height() as u32,
|
||||||
|
)?,
|
||||||
jellyfish_animation_regular: FrameAnimationWrapper::new(
|
jellyfish_animation_regular: FrameAnimationWrapper::new(
|
||||||
raylib.load_texture_from_image(
|
raylib.load_texture_from_image(
|
||||||
&thread,
|
&thread,
|
||||||
@ -240,7 +247,6 @@ impl GlobalResources {
|
|||||||
6,
|
6,
|
||||||
2,
|
2,
|
||||||
),
|
),
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/world.rs
15
src/world.rs
@ -1,11 +1,16 @@
|
|||||||
use std::{fs::File, io::BufReader};
|
use std::{fs::File, io::BufReader};
|
||||||
|
|
||||||
|
use failure::Error;
|
||||||
use raylib::math::{Rectangle, Vector2};
|
use raylib::math::{Rectangle, Vector2};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Read;
|
|
||||||
use failure::Error;
|
|
||||||
|
|
||||||
use crate::{entities::{enemy::{jellyfish::JellyFish, octopus::Octopus}, fish::FishEntity}, player::Player};
|
use crate::{
|
||||||
|
entities::{
|
||||||
|
enemy::{jellyfish::JellyFish, octopus::Octopus},
|
||||||
|
fish::FishEntity,
|
||||||
|
},
|
||||||
|
player::Player,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct World {
|
pub struct World {
|
||||||
@ -23,7 +28,6 @@ pub struct World {
|
|||||||
|
|
||||||
pub jellyfish: Vec<JellyFish>,
|
pub jellyfish: Vec<JellyFish>,
|
||||||
pub octopus: Vec<Octopus>,
|
pub octopus: Vec<Octopus>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
@ -40,7 +44,7 @@ impl World {
|
|||||||
|
|
||||||
// Init colliders
|
// Init colliders
|
||||||
result.colliders = Vec::new();
|
result.colliders = Vec::new();
|
||||||
for collider in colliders.iter(){
|
for collider in colliders.iter() {
|
||||||
result.colliders.push(Rectangle {
|
result.colliders.push(Rectangle {
|
||||||
x: collider.x - (collider.width / 2.0),
|
x: collider.x - (collider.width / 2.0),
|
||||||
y: collider.y - (collider.height / 2.0),
|
y: collider.y - (collider.height / 2.0),
|
||||||
@ -67,7 +71,6 @@ impl World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn load_world_colliders(file: String) -> Result<Vec<Rectangle>, Error> {
|
pub fn load_world_colliders(file: String) -> Result<Vec<Rectangle>, Error> {
|
||||||
// Load the file
|
// Load the file
|
||||||
let file = File::open(file)?;
|
let file = File::open(file)?;
|
||||||
|
Reference in New Issue
Block a user