add map rendering to player scene
This commit is contained in:
parent
8cddd12850
commit
a49bd7c952
@ -65,13 +65,8 @@ impl SceneRenderDelegate {
|
|||||||
// Render the main menu if in it, otherwise, render the game
|
// Render the main menu if in it, otherwise, render the game
|
||||||
match self.menu_control_signal {
|
match self.menu_control_signal {
|
||||||
MenuStateSignal::StartGame => {
|
MenuStateSignal::StartGame => {
|
||||||
// self.scene_playable
|
self.scene_playable
|
||||||
// .render_frame(raylib, rl_thread, &discord, global_resources, constants)
|
.render_frame(raylib, rl_thread, &discord, global_resources, constants)
|
||||||
// .await;
|
|
||||||
|
|
||||||
// TODO: remove this test scene
|
|
||||||
self.scene_test_fox
|
|
||||||
.render_frame(raylib, rl_thread, &discord, global_resources)
|
|
||||||
.await;
|
.await;
|
||||||
self.scene_playable
|
self.scene_playable
|
||||||
.update_physics(raylib, constants)
|
.update_physics(raylib, constants)
|
||||||
|
@ -9,13 +9,14 @@ use crate::{
|
|||||||
global_resource_package::GlobalResources,
|
global_resource_package::GlobalResources,
|
||||||
model::player::Player,
|
model::player::Player,
|
||||||
project_constants::ProjectConstants,
|
project_constants::ProjectConstants,
|
||||||
rendering::utilities::anim_texture::AnimatedTexture,
|
rendering::utilities::{anim_texture::AnimatedTexture, map_render::MapRenderer},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PlayableScene {
|
pub struct PlayableScene {
|
||||||
has_updated_discord_rpc: bool,
|
has_updated_discord_rpc: bool,
|
||||||
player: Player,
|
player: Player,
|
||||||
|
world_map: MapRenderer,
|
||||||
camera: raylib::camera::Camera2D,
|
camera: raylib::camera::Camera2D,
|
||||||
last_update: SystemTime,
|
last_update: SystemTime,
|
||||||
}
|
}
|
||||||
@ -27,9 +28,13 @@ impl PlayableScene {
|
|||||||
thread: & raylib::RaylibThread,
|
thread: & raylib::RaylibThread,
|
||||||
constants: &ProjectConstants,
|
constants: &ProjectConstants,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
||||||
|
let map_renderer = MapRenderer::new("map_gameMap.tmx", raylib_handle, thread).unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
has_updated_discord_rpc: false,
|
has_updated_discord_rpc: false,
|
||||||
player: Player::new(na::Vector2::new(10.0, 10.0)),
|
player: Player::new(na::Vector2::new(10.0, 10.0)),
|
||||||
|
world_map: map_renderer,
|
||||||
camera: raylib::camera::Camera2D {
|
camera: raylib::camera::Camera2D {
|
||||||
target: raylib::math::Vector2 {
|
target: raylib::math::Vector2 {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
@ -77,6 +82,14 @@ impl PlayableScene {
|
|||||||
// Clear the screen
|
// Clear the screen
|
||||||
draw.clear_background(Color::WHITE);
|
draw.clear_background(Color::WHITE);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Begin camera mode
|
||||||
|
let mut ctx2d = draw.begin_mode2D(self.camera);
|
||||||
|
|
||||||
|
// Render the map
|
||||||
|
self.world_map.render_map(&mut ctx2d, &self.camera, true);
|
||||||
|
}
|
||||||
|
|
||||||
for i in 0..100 {
|
for i in 0..100 {
|
||||||
for j in 0..100 {
|
for j in 0..100 {
|
||||||
draw.draw_rectangle(
|
draw.draw_rectangle(
|
||||||
|
Reference in New Issue
Block a user