Merge branch 'master' into push-mob

This commit is contained in:
wm-c 2021-04-26 18:25:39 -04:00
commit 6c22f05a30
6 changed files with 36 additions and 24 deletions

View File

@ -6,7 +6,7 @@ use crate::{
use raylib::prelude::*; use raylib::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const JELLYFISH_STUN_DURATION: f64 = 0.75; const JELLYFISH_STUN_DURATION: f64 = 1.5;
const JELLYFISH_STUN_REACH: f32 = 20.0; const JELLYFISH_STUN_REACH: f32 = 20.0;
#[derive(Debug, Serialize, Deserialize, Default, Clone)] #[derive(Debug, Serialize, Deserialize, Default, Clone)]

View File

@ -32,25 +32,25 @@ impl StunGun {
pub fn lvl1() -> Self { pub fn lvl1() -> Self {
Self { Self {
range: 30.0, range: 30.0,
duration: 0.75, duration: 2.0,
level: 1, level: 1,
cost: 30, cost: 15,
} }
} }
pub fn lvl2() -> Self { pub fn lvl2() -> Self {
Self { Self {
range: 60.0, range: 60.0,
duration: 1.25, duration: 2.5,
level: 2, level: 2,
cost: 40, cost: 25,
} }
} }
pub fn lvl3() -> Self { pub fn lvl3() -> Self {
Self { Self {
range: 80.0, range: 80.0,
duration: 1.0, duration: 3.0,
level: 3, level: 3,
cost: 50, cost: 40,
} }
} }
} }
@ -111,14 +111,14 @@ impl AirBag {
Self { Self {
extra_oxygen: 0.15, extra_oxygen: 0.15,
level: 1, level: 1,
cost: 30, cost: 25,
} }
} }
pub fn lvl2() -> Self { pub fn lvl2() -> Self {
Self { Self {
extra_oxygen: 0.30, extra_oxygen: 0.30,
level: 2, level: 2,
cost: 40, cost: 35,
} }
} }
pub fn lvl3() -> Self { pub fn lvl3() -> Self {
@ -186,21 +186,21 @@ impl Flashlight {
Self { Self {
radius: 0.25, radius: 0.25,
level: 1, level: 1,
cost: 40, cost: 20,
} }
} }
pub fn lvl2() -> Self { pub fn lvl2() -> Self {
Self { Self {
radius: 0.5, radius: 0.5,
level: 2, level: 2,
cost: 50, cost: 30,
} }
} }
pub fn lvl3() -> Self { pub fn lvl3() -> Self {
Self { Self {
radius: 1.0, radius: 1.0,
level: 3, level: 3,
cost: 60, cost: 50,
} }
} }
} }
@ -259,21 +259,21 @@ pub struct Flippers {
impl Flippers { impl Flippers {
pub fn lvl1() -> Self { pub fn lvl1() -> Self {
Self { Self {
speed_increase: 1.2, speed_increase: 1.1,
level: 1, level: 1,
cost: 30, cost: 30,
} }
} }
pub fn lvl2() -> Self { pub fn lvl2() -> Self {
Self { Self {
speed_increase: 1.5, speed_increase: 1.2,
level: 2, level: 2,
cost: 40, cost: 40,
} }
} }
pub fn lvl3() -> Self { pub fn lvl3() -> Self {
Self { Self {
speed_increase: 1.8, speed_increase: 1.3,
level: 3, level: 3,
cost: 50, cost: 50,
} }

View File

@ -39,3 +39,10 @@ impl std::ops::Deref for AudioPlayer {
&self.backend &self.backend
} }
} }
impl std::ops::DerefMut for AudioPlayer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.backend
}
}

View File

@ -1,6 +1,7 @@
use raylib::core::audio::RaylibAudio;
use raylib::prelude::*; use raylib::prelude::*;
use crate::gamecore::GameCore; use crate::{gamecore::GameCore, lib::wrappers::audio::player::AudioPlayer};
const NORMAL_PLAYER_SPEED: i32 = 1; const NORMAL_PLAYER_SPEED: i32 = 1;
const BOOST_PLAYER_SPEED: i32 = NORMAL_PLAYER_SPEED * 2; const BOOST_PLAYER_SPEED: i32 = NORMAL_PLAYER_SPEED * 2;
@ -11,11 +12,16 @@ const BOOST_DECREASE_PER_SECOND: f32 = 0.65;
const BOOST_REGEN_PER_SECOND: f32 = 0.25; const BOOST_REGEN_PER_SECOND: f32 = 0.25;
const BREATH_DECREASE_PER_SECOND: f32 = 0.02; const BREATH_DECREASE_PER_SECOND: f32 = 0.02;
pub fn update_player_movement( pub fn update_player_movement(
draw_handle: &mut RaylibDrawHandle, draw_handle: &mut RaylibDrawHandle,
game_core: &mut GameCore, game_core: &mut GameCore,
window_center: Vector2, window_center: Vector2,
) { ) {
// let mut p: AudioPlayer = AudioPlayer::new(RaylibAudio::init_audio_device());
// p.play_sound(&game_core.resources.breath);
// Calculate DT // Calculate DT
let dt = draw_handle.get_time() - game_core.last_frame_time; let dt = draw_handle.get_time() - game_core.last_frame_time;

View File

@ -125,7 +125,7 @@ impl Screen for PauseMenuScreen {
draw_handle.draw_text( draw_handle.draw_text(
"Credits:\n\t- @ewpratten\n\t- @rsninja722\n\t- @wm-c\n\t- @catarinaburghi\n\t- @kondroel", "Credits:\n\t- @ewpratten\n\t- @rsninja722\n\t- @wm-c\n\t- @catarinaburghi\n\t- @kondroel",
(win_width / 2) - (SCREEN_PANEL_SIZE.x as i32 / 2) + 10, (win_width / 2) - (SCREEN_PANEL_SIZE.x as i32 / 2) + 10,
(win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 170, (win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 150,
20, 20,
Color::BLACK, Color::BLACK,
); );

View File

@ -1,9 +1,4 @@
use raylib::{ use raylib::{RaylibHandle, RaylibThread, audio::Sound, 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;
@ -66,6 +61,9 @@ pub struct GlobalResources {
// Treasure // Treasure
pub transponder: FrameAnimationWrapper, pub transponder: FrameAnimationWrapper,
// Audio
pub breath: Sound,
} }
impl GlobalResources { impl GlobalResources {
@ -159,7 +157,7 @@ impl GlobalResources {
)?, )?,
Vector2 { x: 20.0, y: 20.0 }, Vector2 { x: 20.0, y: 20.0 },
15, 15,
4, 6,
), ),
octopus_animation_regular: FrameAnimationWrapper::new( octopus_animation_regular: FrameAnimationWrapper::new(
raylib.load_texture_from_image( raylib.load_texture_from_image(
@ -297,6 +295,7 @@ impl GlobalResources {
4, 4,
2, 2,
), ),
breath: Sound::load_sound("./assets/audio/breath.mp3")?
}) })
} }
} }