Commit edf01499 authored by Luke Jones's avatar Luke Jones

Update to Rust 2018

parent 8bee79ce
Pipeline #45853132 passed with stages
in 5 minutes and 30 seconds
......@@ -4,17 +4,18 @@ version = "0.1.1"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke Jones <luke.nukem.jones@gmail.com>"]
edition = "2018"
[dependencies]
rand = "*"
num-traits = "0.1.40"
num-traits = "0.2"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
clippy = { version = "*", optional = true }
[dependencies.sdl2]
version = "0.31"
version = "0.32"
default-features = false
features = ["image"]
......@@ -27,6 +28,3 @@ lto = true
opt-level = 3
debuginfo = 0
panic = "abort"
[profile.debug]
lto = true
......@@ -5,11 +5,11 @@
use sdl2::rect::Rect;
use super::*;
use components::parts::*;
use manager::bindings::Bindings;
use manager::world::World;
use resource::SpriteSheets;
use vec2d::Vec2d;
use crate::components::parts::*;
use crate::manager::bindings::Bindings;
use crate::manager::world::World;
use crate::resource::SpriteSheets;
use crate::vec2d::Vec2d;
/// Create a Player entity at the X,Y coords in the World
pub fn player(world: &mut World, x: u32, y: u32, sprite_id: &str, sprite_sheets: &SpriteSheets) {
......
......@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use components::parts::*;
use crate::components::parts::*;
use std::collections::HashMap;
#[derive(Clone, Debug)]
......
......@@ -2,10 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use manager::bindings::Bindings;
use crate::manager::bindings::Bindings;
use sdl2::rect::Rect;
use std::collections::HashMap;
use vec2d::Vec2d;
use crate::vec2d::Vec2d;
const GRAVITY: f32 = 9.81;
......
......@@ -3,10 +3,10 @@
// generate collision contacts
// resolve contacts
use components::*;
use components::systems::has_mask;
use crate::components::*;
use crate::components::systems::has_mask;
use std::f32;
use vec2d::Vec2d;
use crate::vec2d::Vec2d;
/// Set in conjunction with `physics.damping` expectations
///
......@@ -42,7 +42,7 @@ impl Contact {
}
/// Called by `resolve_velocity`
pub fn calc_separating_v(&self, entities: &Entities, dt: f32) -> f32 {
pub fn calc_separating_v(&self, entities: &Entities, _dt: f32) -> f32 {
if let Some(velocity) = entities.parts.velocity.get(&self.first) {
let mut relative_velocity = velocity.vel.clone();
if let Some(id) = self.second {
......@@ -114,7 +114,7 @@ impl Contact {
}
}
pub fn resolve_interpen(&mut self, entities: &mut Entities, dt: f32) {
pub fn resolve_interpen(&mut self, entities: &mut Entities, _dt: f32) {
if self.penetration < 0.0 {
return;
}
......@@ -157,7 +157,7 @@ impl Contact {
///
/// The book shows this as an object that forces against bodies can be
/// registered with. May follow that later.
pub fn update_forces(entity: u32, entities: &mut Entities, dt: f32) {
pub fn update_forces(entity: u32, entities: &mut Entities, _dt: f32) {
let mask = &entities.mask[entity as usize];
// a general safety check
if !has_mask(mask, VELOCITY | PHYSICS) {
......@@ -229,11 +229,11 @@ pub fn integrate(entity: u32, entities: &mut Entities, dt: f32) {
physics.acceleration.y = 0.0;
}
pub fn collision_check(entity: u32, entities: &Entities, dt: f32) {
let mask = &entities.mask[entity as usize];
pub fn collision_check(entity: u32, entities: &Entities, _dt: f32) {
let _mask = &entities.mask[entity as usize];
// TODO: Work out an appropriate initial size
let mut contacts: Vec<Contact> = Vec::new();
let mut num_contacts = 0;
let _contacts: Vec<Contact> = Vec::new();
let _num_contacts = 0;
// Circle vs circle, AABB, OBB, Plane
// AABB vs AABB, OBB, Circle, Plane
// OBB vs OBB, AABB, circle, plane
......
......@@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![allow(unused_variables)]
use components::*;
use components::messages::*;
use components::parts::{InputTypes, Sprite};
use components::physics::{Contact, update_forces, integrate, resolve_contacts};
use manager::input::{Input};
use crate::components::*;
use crate::components::messages::*;
use crate::components::parts::{InputTypes, Sprite};
use crate::components::physics::{Contact, update_forces, integrate, resolve_contacts};
use crate::manager::input::{Input};
use std::collections::HashMap;
use std::f32;
......
......@@ -2,13 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![macro_use]
use manager::bindings::Bindings;
use manager::input::Input;
use states::States;
use states::menu::*;
use states::pause::*;
use states::play::*;
use crate::manager::bindings::Bindings;
use crate::manager::input::Input;
use crate::states::States;
use crate::states::menu::*;
use crate::states::pause::*;
use crate::states::play::*;
use sdl2::Sdl;
use sdl2::keyboard::Scancode;
......
......@@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![macro_use] // the enum of buttons
use components::messages::*;
use crate::components::messages::*;
use sdl2::keyboard::Scancode as Sc;
use sdl2::mouse::MouseButton as Mb;
......
......@@ -92,7 +92,7 @@ pub struct TileSet {
height: u32,
}
impl TileSet {
pub fn new(id: &str, tw: u32, th: u32, sp: u32, m: u32, col: u32, h: u32) -> TileSet {
pub fn new(_id: &str, tw: u32, th: u32, sp: u32, m: u32, col: u32, h: u32) -> TileSet {
TileSet {
tile_width: tw,
tile_height: th,
......
......@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![macro_use]
/// Player object and menu control bindings
pub mod bindings;
/// A generalised input manager
......
......@@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use components::*;
use components::messages::MessageBus;
use manager::input::Input;
use resource::SpriteSheets;
use vec2d::Vec2d;
use crate::components::*;
use crate::components::messages::MessageBus;
use crate::manager::input::Input;
use crate::resource::SpriteSheets;
use crate::vec2d::Vec2d;
use sdl2::pixels::PixelFormatEnum;
use sdl2::rect::Rect;
......@@ -210,7 +210,7 @@ impl<'a> World<'a> {
/// The final stage after a world update
///
/// Fetch all textures and positions, then draw what is visible.
pub fn render(&mut self, dt: f32, sf: &mut Surface, sprite_sheets: &SpriteSheets) {
pub fn render(&mut self, _dt: f32, sf: &mut Surface, sprite_sheets: &SpriteSheets) {
let sprite_mask = POSITION | SPRITE;
let anim_mask = POSITION | SPRITE | ANIMATION;
......
......@@ -6,8 +6,8 @@ use sdl2::pixels::Color as SdlColour;
use sdl2::surface::Surface as SdlSurface;
use super::GameState;
use manager::bindings::Bindings;
use manager::input::Input;
use crate::manager::bindings::Bindings;
use crate::manager::input::Input;
pub struct Menu {
id: String,
......@@ -19,8 +19,8 @@ impl Menu {
}
impl GameState for Menu {
fn update(&mut self, dt: f32, input: &Input, bindings: &mut Bindings) {}
fn render(&mut self, dt: f32, sdl_surface: &mut SdlSurface) {
fn update(&mut self, _dt: f32, _input: &Input, _bindings: &mut Bindings) {}
fn render(&mut self, _dt: f32, sdl_surface: &mut SdlSurface) {
let alive = SdlColour::RGB(200, 200, 230);
sdl_surface.fill_rect(None, alive).unwrap();
}
......
......@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![macro_use]
/// The menu state and its related data and logic
pub mod menu;
/// The play state and its related data and logic
......@@ -10,8 +9,8 @@ pub mod play;
/// The pause state and its related data and logic
pub mod pause;
use manager::bindings::Bindings;
use manager::input::Input;
use crate::manager::bindings::Bindings;
use crate::manager::input::Input;
use sdl2::pixels::Color as SdlColour;
use sdl2::surface::Surface as SdlSurface;
use std::collections::VecDeque;
......
......@@ -6,8 +6,8 @@ use sdl2::pixels::Color as SdlColour;
use sdl2::surface::Surface as SdlSurface;
use super::GameState;
use manager::bindings::Bindings;
use manager::input::Input;
use crate::manager::bindings::Bindings;
use crate::manager::input::Input;
pub struct Pause {
id: String,
......@@ -19,8 +19,8 @@ impl Pause {
}
impl GameState for Pause {
fn update(&mut self, dt: f32, input: &Input, bindings: &mut Bindings) {}
fn render(&mut self, dt: f32, sdl_surface: &mut SdlSurface) {
fn update(&mut self, _dt: f32, _input: &Input, _bindings: &mut Bindings) {}
fn render(&mut self, _dt: f32, sdl_surface: &mut SdlSurface) {
let alive = SdlColour::RGB(60, 1, 1);
sdl_surface.fill_rect(None, alive).unwrap();
}
......
......@@ -6,12 +6,12 @@ use sdl2::pixels::Color;
use sdl2::surface::Surface;
use super::GameState;
use components::create;
use manager::bindings::Bindings;
use manager::input::Input;
use manager::levels::*;
use manager::world::World;
use resource::SpriteSheets;
use crate::components::create;
use crate::manager::bindings::Bindings;
use crate::manager::input::Input;
use crate::manager::levels::*;
use crate::manager::world::World;
use crate::resource::SpriteSheets;
use std::collections::HashMap;
......@@ -87,7 +87,7 @@ impl<'a> Play<'a> {
}
impl<'a> GameState for Play<'a> {
fn update(&mut self, dt: f32, input: &Input, bindings: &mut Bindings) {
fn update(&mut self, dt: f32, input: &Input, _bindings: &mut Bindings) {
self.world.update(dt, input);
}
fn render(&mut self, dt: f32, mut sf: &mut Surface) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment