Skip to content

Format using 'cargo fmt' #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions raylib-test/src/audio.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#[cfg(test)]
mod audio_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;
#[test]
fn test_init_audio() {
let _ = RaylibAudio::init_audio_device();
Expand Down
4 changes: 2 additions & 2 deletions raylib-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Permission is granted to anyone to use this software for any purpose, including
#![test_runner(crate::tests::test_runner)]
#![allow(dead_code)]
#![doc(
html_logo_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust_256x256.png",
html_favicon_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust.ico"
html_logo_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust_256x256.png",
html_favicon_url = "https://github.com/deltaphc/raylib-rs/raw/master/logo/raylib-rust.ico"
)]
#![feature(test)]
extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion raylib-test/src/misc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(test)]
mod core_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;
ray_test!(test_screenshot);
fn test_screenshot(t: &RaylibThread) {
let mut handle = TEST_HANDLE.write().unwrap();
Expand Down
3 changes: 1 addition & 2 deletions raylib-test/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#[cfg(test)]
mod model_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;

ray_test!(test_load_model);
fn test_load_model(thread: &RaylibThread) {
Expand Down
3 changes: 1 addition & 2 deletions raylib-test/src/texture.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#[cfg(test)]
mod texture_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;
#[test]
fn test_image_loading() {
let i = Image::load_image("resources/billboard.png").expect("image not found");
Expand Down
5 changes: 3 additions & 2 deletions raylib/src/core/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ impl RaylibHandle {
pub fn load_model_from_mesh(&mut self, _: &RaylibThread, mesh: &Mesh) -> Result<Model, String> {
let m = unsafe { ffi::LoadModelFromMesh(mesh.0) };

if m.meshes.is_null() || m.materials.is_null() || m.bones.is_null() || m.bindPose.is_null() {
return Err("Could not load model from mesh".to_owned())
if m.meshes.is_null() || m.materials.is_null() || m.bones.is_null() || m.bindPose.is_null()
{
return Err("Could not load model from mesh".to_owned());
}

Ok(Model(m))
Expand Down
52 changes: 22 additions & 30 deletions samples/3d_camera_first_person.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use raylib::prelude::*;
use rand::prelude::*;
use arr_macro::arr;
use rand::prelude::*;
use raylib::prelude::*;

const WINDOW_WIDTH: i32 = 1280;
const WINDOW_HEIGHT: i32 = 720;

struct Column {
height: f32,
position: Vector3,
color: Color
color: Color,
}

impl Column {
Expand All @@ -20,17 +20,12 @@ impl Column {
height / 2.0,
rng.gen_range(-15.0, 15.0),
);
let color = Color::new(
rng.gen_range(20, 255),
rng.gen_range(10, 55),
30,
255
);

let color = Color::new(rng.gen_range(20, 255), rng.gen_range(10, 55), 30, 255);

Column {
height,
position,
color
color,
}
}
}
Expand All @@ -42,10 +37,10 @@ fn main() {
.build();

let mut camera = Camera3D::perspective(
Vector3::new(4.0, 2.0, 4.0),
Vector3::new(0.0, 1.8, 0.0),
Vector3::new(0.0, 1.0, 0.0),
60.0
Vector3::new(4.0, 2.0, 4.0),
Vector3::new(0.0, 1.8, 0.0),
Vector3::new(0.0, 1.0, 0.0),
60.0,
);
let columns: [Column; 20] = arr![Column::create_random(); 20];

Expand All @@ -64,29 +59,26 @@ fn main() {
d2.draw_plane(
Vector3::new(0.0, 0.0, 0.0),
Vector2::new(32.0, 32.0),
Color::LIGHTGRAY
);
d2.draw_cube(
Vector3::new(-16.0, 2.5, 0.0),
1.0, 5.0, 32.0, Color::BLUE
);
d2.draw_cube(
Vector3::new(16.0, 2.5, 0.0),
1.0, 5.0, 32.0, Color::LIME
);
d2.draw_cube(
Vector3::new(0.0, 2.5, 16.0),
32.0, 5.0, 1.0, Color::GOLD
Color::LIGHTGRAY,
);
d2.draw_cube(Vector3::new(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, Color::BLUE);
d2.draw_cube(Vector3::new(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, Color::LIME);
d2.draw_cube(Vector3::new(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, Color::GOLD);

for column in columns.into_iter() {
d2.draw_cube(column.position, 2.0, column.height, 2.0, column.color);
d2.draw_cube_wires(column.position, 2.0, column.height, 2.0, Color::MAROON);
};
}
}
d.draw_rectangle(10, 10, 220, 70, Color::SKYBLUE);
d.draw_rectangle_lines(10, 10, 220, 70, Color::BLUE);
d.draw_text("First person camera default controls:", 20, 20, 10, Color::BLACK);
d.draw_text(
"First person camera default controls:",
20,
20,
10,
Color::BLACK,
);
d.draw_text("- Move with keys: W, A, S, D", 40, 40, 10, Color::DARKGRAY);
d.draw_text("- Mouse move to look around", 40, 60, 10, Color::DARKGRAY);
}
Expand Down
12 changes: 8 additions & 4 deletions samples/rgui_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ pub fn main() {

let mut wb = rgui::WindowBox {
bounds: Rectangle::new(64.0, 64.0, 128.0, 72.0),
text: CString::new("Hello World").unwrap()
text: CString::new("Hello World").unwrap(),
};

rl.set_target_fps(200);

let btn = rgui::Button {
bounds: Rectangle::new(72.0, 172.0 + 24.0, 64.0, 16.0),
text: CString::new("Click Me").unwrap()
text: CString::new("Click Me").unwrap(),
};

let mut exit_program = false;
Expand All @@ -27,11 +27,15 @@ pub fn main() {
d.clear_background(Color::WHITE);

if let rgui::DrawResult::Bool(b) = d.draw_gui(&wb) {
if b { exit_program = true; }
if b {
exit_program = true;
}
}

if let rgui::DrawResult::Bool(b) = d.draw_gui(&btn) {
if b { wb.bounds.x += 8.0; }
if b {
wb.bounds.x += 8.0;
}
}
}
}
4 changes: 2 additions & 2 deletions samples/roguelike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// IMHO Don't write code like this. Use ECS and other methods to have game objects and components.
/// Only do this as an exercise.
extern crate raylib;
use rand::distributions::{ WeightedIndex };
use rand::distributions::WeightedIndex;
use rand::prelude::*;
use rand::Rng;
use raylib::prelude::*;
Expand Down Expand Up @@ -731,7 +731,7 @@ fn place_objects(room: Rectangle, map: &Map, objects: &mut Vec<Object>, level: u
Item::Fireball,
Item::Confuse,
Item::Sword,
Item::Shield
Item::Shield,
];
let item_weights = [
32,
Expand Down
16 changes: 7 additions & 9 deletions samples/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ fn main() {
let opt = options::Opt::from_args();
let (mut rl, thread) = opt.open_window("Texture");
let (_w, _h) = (opt.width, opt.height);
let i =
Image::load_image("static/billboard.png").expect("could not load image billboard");
let _ = rl
.load_texture(&thread, "static/billboard.png")
.expect("could not load texture billboard");
let t = rl
.load_texture_from_image(&thread, &i)
.expect("could not load texture from image");

let i = Image::load_image("static/billboard.png").expect("could not load image billboard");
let _ = rl
.load_texture(&thread, "static/billboard.png")
.expect("could not load texture billboard");
let t = rl
.load_texture_from_image(&thread, &i)
.expect("could not load texture from image");

rl.set_target_fps(60);
while !rl.window_should_close() {
Expand Down