Added client localhost connection

Former-commit-id: d4dec70ef3ecad8f40196b87b0f5c8b55c51c44a
This commit is contained in:
Joshua Barretto 2019-03-03 22:11:38 +00:00
parent dbbcc1e80e
commit 2fffe21bc7
5 changed files with 13 additions and 20 deletions

View File

@ -46,7 +46,7 @@ impl PlayState for TitleState {
Event::Close => return PlayStateResult::Shutdown, Event::Close => return PlayStateResult::Shutdown,
// When space is pressed, start a session // When space is pressed, start a session
Event::Char(' ') => return PlayStateResult::Push( Event::Char(' ') => return PlayStateResult::Push(
Box::new(SessionState::new(global_state.window.renderer_mut())), Box::new(SessionState::new(global_state.window.renderer_mut()).unwrap()), // TODO: Handle this error
), ),
// Ignore all other events // Ignore all other events
_ => {}, _ => {},

View File

@ -11,15 +11,12 @@ use gfx::{
}; };
// Local // Local
use super::{ use super::super::{
Globals,
super::{
Pipeline, Pipeline,
TgtColorFmt, TgtColorFmt,
TgtDepthFmt, TgtDepthFmt,
Mesh, Mesh,
Quad, Quad,
},
}; };
gfx_defines! { gfx_defines! {

View File

@ -4,7 +4,7 @@ use std::marker::PhantomData;
// Library // Library
use gfx::{ use gfx::{
self, self,
traits::{Factory, FactoryExt}, traits::Factory,
}; };
use image::{ use image::{
DynamicImage, DynamicImage,
@ -14,7 +14,6 @@ use image::{
// Local // Local
use super::{ use super::{
RenderError, RenderError,
mesh::Mesh,
Pipeline, Pipeline,
gfx_backend, gfx_backend,
}; };

View File

@ -34,14 +34,14 @@ pub struct SessionState {
/// Represents an active game session (i.e: one that is being played) /// Represents an active game session (i.e: one that is being played)
impl SessionState { impl SessionState {
/// Create a new `SessionState` /// Create a new `SessionState`
pub fn new(renderer: &mut Renderer) -> Self { pub fn new(renderer: &mut Renderer) -> Result<Self, Error> {
let client = Client::new().with_test_state(); // <--- TODO: Remove this let client = Client::new(([127, 0, 0, 1], 59003))?.with_test_state(); // <--- TODO: Remove this
Self { Ok(Self {
// Create a scene for this session. The scene handles visible elements of the game world // Create a scene for this session. The scene handles visible elements of the game world
scene: Scene::new(renderer, &client), scene: Scene::new(renderer, &client),
client, client,
key_state: KeyState::new(), key_state: KeyState::new(),
} })
} }
} }

View File

@ -1,8 +1,5 @@
// Standard // Standard
use std::{ use std::rc::Rc;
rc::Rc,
cell::RefCell,
};
// Library // Library
use image::DynamicImage; use image::DynamicImage;