Merge branch 'master' into ewpratten/core
This commit is contained in:
commit
f7d231b6b3
@ -14,9 +14,9 @@ use crate::project_constants::ProjectConstants;
|
|||||||
use crate::rendering::core_renderer_sm::{PreloadState, RenderBackendStates};
|
use crate::rendering::core_renderer_sm::{PreloadState, RenderBackendStates};
|
||||||
use crate::rendering::screens::sm_failure_screen;
|
use crate::rendering::screens::sm_failure_screen;
|
||||||
use crate::scenes::SceneRenderDelegate;
|
use crate::scenes::SceneRenderDelegate;
|
||||||
use raylib::RaylibBuilder;
|
|
||||||
use raylib::consts::KeyboardKey;
|
use raylib::consts::KeyboardKey;
|
||||||
use raylib::prelude::RaylibDraw;
|
use raylib::prelude::RaylibDraw;
|
||||||
|
use raylib::RaylibBuilder;
|
||||||
|
|
||||||
/// Will begin rendering graphics. Returns when the window closes
|
/// Will begin rendering graphics. Returns when the window closes
|
||||||
pub async fn handle_graphics_blocking<ConfigBuilder>(
|
pub async fn handle_graphics_blocking<ConfigBuilder>(
|
||||||
@ -48,7 +48,7 @@ pub async fn handle_graphics_blocking<ConfigBuilder>(
|
|||||||
|
|
||||||
// Set up the main render delegate
|
// Set up the main render delegate
|
||||||
let mut render_delegate =
|
let mut render_delegate =
|
||||||
SceneRenderDelegate::on_game_start(&mut raylib_handle, &raylib_thread);
|
SceneRenderDelegate::on_game_start(&mut raylib_handle, &raylib_thread, constants);
|
||||||
|
|
||||||
// Handle loading the resources and rendering the loading screen
|
// Handle loading the resources and rendering the loading screen
|
||||||
log::trace!("Running event loop");
|
log::trace!("Running event loop");
|
||||||
@ -102,12 +102,15 @@ pub async fn handle_graphics_blocking<ConfigBuilder>(
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
RenderBackendStates::RenderGame(ref m) => {
|
RenderBackendStates::RenderGame(ref m) => {
|
||||||
render_delegate.process_ingame_frame(
|
render_delegate
|
||||||
&mut raylib_handle,
|
.process_ingame_frame(
|
||||||
&raylib_thread,
|
&mut raylib_handle,
|
||||||
&discord_signaling,
|
&raylib_thread,
|
||||||
&global_resources,
|
&discord_signaling,
|
||||||
).await;
|
&global_resources,
|
||||||
|
constants,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
_ => backend_sm = RenderBackendStates::sm_failed(),
|
_ => backend_sm = RenderBackendStates::sm_failed(),
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
//! This will probably become a messy module over time. Stick your rendering code here
|
//! This will probably become a messy module over time. Stick your rendering code here
|
||||||
use raylib::prelude::*;
|
use raylib::prelude::*;
|
||||||
|
|
||||||
use crate::{discord::DiscordChannel, global_resource_package::GlobalResources};
|
use crate::{
|
||||||
|
discord::DiscordChannel, global_resource_package::GlobalResources,
|
||||||
|
project_constants::ProjectConstants,
|
||||||
|
};
|
||||||
|
|
||||||
use self::{player_interaction::PlayableScene, test_fox::TestFoxScene};
|
use self::{player_interaction::PlayableScene, test_fox::TestFoxScene};
|
||||||
mod player_interaction;
|
mod player_interaction;
|
||||||
@ -21,12 +24,16 @@ pub struct SceneRenderDelegate {
|
|||||||
|
|
||||||
impl SceneRenderDelegate {
|
impl SceneRenderDelegate {
|
||||||
/// This is called when the game first loads
|
/// This is called when the game first loads
|
||||||
pub fn on_game_start(raylib: &mut RaylibHandle, rl_thread: &RaylibThread) -> Self {
|
pub fn on_game_start(
|
||||||
|
raylib: &mut RaylibHandle,
|
||||||
|
rl_thread: &RaylibThread,
|
||||||
|
constants: &ProjectConstants,
|
||||||
|
) -> Self {
|
||||||
// TODO: Stick any init code you want here.
|
// TODO: Stick any init code you want here.
|
||||||
|
|
||||||
// Init some scenes
|
// Init some scenes
|
||||||
let scene_test_fox = TestFoxScene::new(raylib, rl_thread);
|
let scene_test_fox = TestFoxScene::new(raylib, rl_thread);
|
||||||
let scene_playable = PlayableScene::new(raylib, rl_thread);
|
let scene_playable = PlayableScene::new(raylib, rl_thread, constants);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
scene_test_fox,
|
scene_test_fox,
|
||||||
@ -43,10 +50,12 @@ impl SceneRenderDelegate {
|
|||||||
rl_thread: &RaylibThread,
|
rl_thread: &RaylibThread,
|
||||||
discord: &DiscordChannel,
|
discord: &DiscordChannel,
|
||||||
global_resources: &GlobalResources,
|
global_resources: &GlobalResources,
|
||||||
|
constants: &ProjectConstants,
|
||||||
) {
|
) {
|
||||||
// For now, we will just render the game scene
|
// For now, we will just render the game scene
|
||||||
self.scene_playable
|
self.scene_playable
|
||||||
.render_frame(raylib, rl_thread, &discord, global_resources).await;
|
.render_frame(raylib, rl_thread, &discord, global_resources, constants)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,22 +4,29 @@ use nalgebra as na;
|
|||||||
use raylib::prelude::*;
|
use raylib::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
discord::{DiscordChannel, DiscordRpcSignal}, global_resource_package::GlobalResources,
|
discord::{DiscordChannel, DiscordRpcSignal},
|
||||||
rendering::utilities::anim_texture::AnimatedTexture, model::player::Player,
|
global_resource_package::GlobalResources,
|
||||||
|
model::player::Player,
|
||||||
|
project_constants::ProjectConstants,
|
||||||
|
rendering::utilities::anim_texture::AnimatedTexture,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PlayableScene {
|
pub struct PlayableScene {
|
||||||
has_updated_discord_rpc: bool,
|
has_updated_discord_rpc: bool,
|
||||||
player: Player
|
player: Player,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlayableScene {
|
impl PlayableScene {
|
||||||
/// Construct a new `PlayableScene`
|
/// Construct a new `PlayableScene`
|
||||||
pub fn new(raylib_handle: &mut RaylibHandle, thread: &RaylibThread) -> Self {
|
pub fn new(
|
||||||
|
raylib_handle: &mut RaylibHandle,
|
||||||
|
thread: &RaylibThread,
|
||||||
|
constants: &ProjectConstants,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
has_updated_discord_rpc: false,
|
has_updated_discord_rpc: false,
|
||||||
player: Player::new(na::Vector2::new(10.0, 10.0))
|
player: Player::new(na::Vector2::new(10.0, 10.0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,12 +37,21 @@ impl PlayableScene {
|
|||||||
rl_thread: &RaylibThread,
|
rl_thread: &RaylibThread,
|
||||||
discord: &DiscordChannel,
|
discord: &DiscordChannel,
|
||||||
global_resources: &GlobalResources,
|
global_resources: &GlobalResources,
|
||||||
|
constants: &ProjectConstants,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Handle updating discord RPC
|
// Handle updating discord RPC
|
||||||
if !self.has_updated_discord_rpc {
|
if !self.has_updated_discord_rpc {
|
||||||
discord.send(DiscordRpcSignal::BeginGameTimer).await.unwrap();
|
discord
|
||||||
discord.send(DiscordRpcSignal::ChangeDetails { details: "Playing the game".to_string(), party_status: None }).await.unwrap();
|
.send(DiscordRpcSignal::BeginGameTimer)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
discord
|
||||||
|
.send(DiscordRpcSignal::ChangeDetails {
|
||||||
|
details: "Playing the game".to_string(),
|
||||||
|
party_status: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
self.has_updated_discord_rpc = true;
|
self.has_updated_discord_rpc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user