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,
// When space is pressed, start a session
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
_ => {},

View File

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

View File

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

View File

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

View File

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