Skip to content

Commit

Permalink
Merge pull request #192 from raylib-rs/master
Browse files Browse the repository at this point in the history
Sync sample changes
  • Loading branch information
Dacode45 authored May 24, 2024
2 parents 4fc75d4 + 3659002 commit e95f0f2
Show file tree
Hide file tree
Showing 42 changed files with 33 additions and 31 deletions.
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[submodule "raylib-sys/raylib"]
path = raylib-sys/raylib
url = https://github.com/raysan5/raylib
branch = "5.0"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["raylib", "raylib-sys"]
exclude = ["raylib-test"]
exclude = ["raylib-test", "samples"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# raylib-rs

raylib-rs is a Rust binding for [raylib](http://www.raylib.com/) 5.0. It currently targets the _stable_ Rust toolchain, version 1.77 or higher.
raylib-rs is a Rust binding for [raylib](http://www.raylib.com/) 5.0. It currently targets the _stable_ Rust toolchain, version 1.78 or higher.

Please checkout the showcase directory to find usage examples!

Expand Down
2 changes: 1 addition & 1 deletion raylib-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raylib-sys"
version = "5.0.0"
version = "5.0.1"
authors = ["DeltaPHC <phclem@protonmail.com>"]
license = "Zlib"
description = "Raw FFI bindings for Raylib"
Expand Down
2 changes: 1 addition & 1 deletion raylib-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raylib-test"
version = "5.0.0"
version = "5.0.1"
authors = ["David Ayeke"]
edition = "2018"
license = "Zlib"
Expand Down
2 changes: 1 addition & 1 deletion raylib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raylib"
version = "5.0.0"
version = "5.0.1"
authors = ["DeltaPHC <phclem@protonmail.com>"]
license = "Zlib"
readme = "../README.md"
Expand Down
1 change: 1 addition & 0 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
8 changes: 4 additions & 4 deletions samples/3d_camera_first_person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ struct Column {
impl Column {
fn create_random() -> Column {
let mut rng = rand::thread_rng();
let height: f32 = rng.gen_range(1.0..12.0);
let height: f32 = rng.gen_range(1.0, 12.0);
let position = Vector3::new(
rng.gen_range(-15.0..15.0),
rng.gen_range(-15.0, 15.0),
height / 2.0,
rng.gen_range(-15.0..15.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,
Expand Down
10 changes: 3 additions & 7 deletions samples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raylib-examples"
version = "3.7.0"
version = "5.0.1"
authors = ["David Ayeke"]
edition = "2018"
license = "Zlib"
Expand All @@ -9,11 +9,11 @@ repository = "https://github.com/raylib-rs/raylib-rs"


[dependencies]
raylib = { version = "3.7", path = "../raylib" }
raylib = { version = "5.0", path = "../raylib" }
structopt = "0.2"
specs-derive = "0.4.1"
rand = "0.7"
tcod = "0.15"
#tcod = "0.14"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
arr_macro = "0.1.3"
Expand Down Expand Up @@ -64,10 +64,6 @@ path = "./texture.rs"
name = "yaw_pitch_roll"
path = "yaw_pitch_roll.rs"

[[bin]]
name = "roguelike"
path = "roguelike.rs"

[[bin]]
name = "input"
path = "input.rs"
Expand Down
2 changes: 1 addition & 1 deletion samples/raymarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use structopt::StructOpt;

mod options;

const SHADER: &str = include_str!("../../static/raymarching.fs");
const SHADER: &str = include_str!("static/raymarching.fs");

pub fn main() {
let opt = options::Opt::from_args();
Expand Down
30 changes: 18 additions & 12 deletions samples/roguelike.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* 2024 NOTE: this is currently disabled because tcod is considered a broken crate.
*/

/// Code almost verbatim from here: http://tomassedovic.github.io/roguelike-tutorial/index.html
/// This only covers up to Part 9 because I'm a human being who needs sleep. Feel free to submit a
/// PR to extend it.
Expand Down Expand Up @@ -589,10 +593,10 @@ fn make_map(objects: &mut Vec<Object>, level: u32) -> Map {

let mut rooms = vec![];
for _ in 0..MAX_ROOMS {
let w = rand::thread_rng().gen_range(ROOM_MIN_SIZE..ROOM_MAX_SIZE + 1);
let h = rand::thread_rng().gen_range(ROOM_MIN_SIZE..ROOM_MAX_SIZE + 1);
let x = rand::thread_rng().gen_range(0..MAP_WIDTH - w);
let y = rand::thread_rng().gen_range(0..MAP_HEIGHT - h);
let w = rand::thread_rng().gen_range::<f32>(ROOM_MIN_SIZE..ROOM_MAX_SIZE + 1);
let h = rand::thread_rng().gen_range::<f32>(ROOM_MIN_SIZE..ROOM_MAX_SIZE + 1);
let x = rand::thread_rng().gen_range::<f32>(0..MAP_WIDTH - w);
let y = rand::thread_rng().gen_range::<f32>(0..MAP_HEIGHT - h);

let new_room = Rectangle::new(x as f32, y as f32, w as f32, h as f32);
let failed = rooms
Expand Down Expand Up @@ -646,11 +650,11 @@ fn place_objects(room: Rectangle, map: &Map, objects: &mut Vec<Object>, level: u
);

// choose random number of monsters
let num_monsters = rand::thread_rng().gen_range(0..max_monsters + 1);
let num_monsters = rand::thread_rng().gen_range::<f32>(0..max_monsters + 1);

for _ in 0..num_monsters {
let x = rand::thread_rng().gen_range(room.x + 1.0..room.x + room.width) as i32;
let y = rand::thread_rng().gen_range(room.y + 1.0..room.y + room.height) as i32;
let x = rand::thread_rng().gen_range::<f32>(room.x + 1.0..room.x + room.width) as i32;
let y = rand::thread_rng().gen_range::<f32>(room.y + 1.0..room.y + room.height) as i32;

// monster random table
let troll_chance = from_dungeon_level(
Expand Down Expand Up @@ -767,11 +771,13 @@ fn place_objects(room: Rectangle, map: &Map, objects: &mut Vec<Object>, level: u
];

// choose random number of items
let num_items = rand::thread_rng().gen_range(0..max_items + 1);
let num_items = rand::thread_rng().gen_range::<f32>(0..max_items + 1);
for _ in 0..num_items {
// choose random spot for this item
let x = rand::thread_rng().gen_range(room.x as i32 + 1..(room.x + room.width) as i32);
let y = rand::thread_rng().gen_range(room.y as i32 + 1..(room.y + room.height) as i32);
let x =
rand::thread_rng().gen_range::<f32>(room.x as i32 + 1..(room.x + room.width) as i32);
let y =
rand::thread_rng().gen_range::<f32>(room.y as i32 + 1..(room.y + room.height) as i32);

// only place it if the tile is not blocked
if !is_blocked(x, y, map, objects) {
Expand Down Expand Up @@ -1411,8 +1417,8 @@ fn ai_confused(
// move in a random direction, and decrease the number of turns confused
move_by(
monster_id,
rand::thread_rng().gen_range(-1..2),
rand::thread_rng().gen_range(-1..2),
rand::thread_rng().gen_range::<f32>(-1..2),
rand::thread_rng().gen_range::<f32>(-1..2),
&game.map,
objects,
);
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion showcase/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raylib-showcase"
version = "5.0.0"
version = "5.0.1"
authors = ["David Ayeke"]
edition = "2018"
license = "Zlib"
Expand Down

0 comments on commit e95f0f2

Please sign in to comment.