Compare commits

...
This repository has been archived on 2022-04-04. You can view files and clone it, but cannot push or open issues or pull requests.

13 Commits

Author SHA1 Message Date
4f8f03a3dc
Merge pull request #48 from Ewpratten/rsninja/fixes
Rsninja/fixes
2022-04-04 00:50:26 -04:00
rsninja722
b72051ebbe Merge remote-tracking branch 'origin/master' into rsninja/fixes 2022-04-04 00:47:25 -04:00
rsninja722
14d8a73c02 fixes 2022-04-04 00:47:18 -04:00
c44b9191f3 Discord RPC 2022-04-04 00:19:24 -04:00
e1b6311025 Give the game a name 2022-04-04 00:13:55 -04:00
1b32c57447 Possibly fix volume 2022-04-04 00:11:43 -04:00
7ef95458e3
Merge pull request #47 from Ewpratten/ewpratten/cutscene
Arty art
2022-04-04 00:07:35 -04:00
ab82ec626d Arty art 2022-04-04 00:07:07 -04:00
5a4729c78d
Merge pull request #46 from Ewpratten/demilurii/art2
intro cutscene comic
2022-04-03 23:49:48 -04:00
3b1b9c79ce intro cutscene comic 2022-04-03 23:47:40 -04:00
f2007d1d2b
Merge pull request #45 from Ewpratten/melting
Melting
2022-04-03 23:39:03 -04:00
f1d8ff3408 Pre-render footprints 2022-04-03 23:33:42 -04:00
00fa6edb20 Fix render order 2022-04-03 23:03:44 -04:00
28 changed files with 480 additions and 299 deletions

View File

@ -1,4 +1,4 @@
# Ludum Dare 50: *unnamed game*
# Ludum Dare 50: *Melting Point*
[![Build Full Release](https://github.com/Ewpratten/ludum-dare-50/actions/workflows/build.yml/badge.svg)](https://github.com/Ewpratten/ludum-dare-50/actions/workflows/build.yml)
## Navigating this repository

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -1,10 +1,10 @@
{
"name": "env_carBlue",
"bottom_texture": {
"file_path": "assets/env/env_cars/env_carWheels.png"
"file_path": "assets/env/env_car/env_carWheels.png"
},
"top_texture": {
"file_path": "assets/env/env_cars/env_carBlue.png"
"file_path": "assets/env/env_car/env_carBlue.png"
},
"footprint": [
{
@ -18,7 +18,7 @@
]
}
],
"visualization_radius": 220.0,
"visualization_radius": 220,
"physics_colliders": [
{
"position": [
@ -61,5 +61,5 @@
]
}
],
"temperature": 7.0
"temperature": 7
}

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,10 +1,10 @@
{
"name": "env_carGrey",
"bottom_texture": {
"file_path": "assets/env/env_cars/env_carWheels.png"
"file_path": "assets/env/env_car/env_carWheels.png"
},
"top_texture": {
"file_path": "assets/env/env_cars/env_carGrey.png"
"file_path": "assets/env/env_car/env_carGrey.png"
},
"footprint": [
{

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,10 +1,10 @@
{
"name": "env_carOrange",
"bottom_texture": {
"file_path": "assets/env/env_cars/env_carWheels.png"
"file_path": "assets/env/env_car/env_carWheels.png"
},
"top_texture": {
"file_path": "assets/env/env_cars/env_carOrange.png"
"file_path": "assets/env/env_car/env_carOrange.png"
},
"footprint": [
{

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -22,21 +22,21 @@
"physics_colliders": [
{
"position": [
44,
246
50,
-246
],
"size": [
60,
140,
20
]
},
{
"position": [
157,
246
-157,
-246
],
"size": [
200,
190,
20
]
},
@ -52,22 +52,12 @@
},
{
"position": [
-103,
-62
-100,
-50
],
"size": [
95,
35
]
},
{
"position": [
-188,
-216
],
"size": [
396,
77
77,
370
]
},
{
@ -76,13 +66,13 @@
-51
],
"size": [
340,
17
17,
340
]
},
{
"position": [
44,
74,
-10
],
"size": [

View File

@ -22,21 +22,21 @@
"physics_colliders": [
{
"position": [
44,
246
50,
-246
],
"size": [
60,
140,
20
]
},
{
"position": [
157,
246
-157,
-246
],
"size": [
200,
190,
20
]
},
@ -52,22 +52,12 @@
},
{
"position": [
-103,
-62
-100,
-50
],
"size": [
95,
35
]
},
{
"position": [
-188,
-216
],
"size": [
396,
77
77,
370
]
},
{
@ -76,13 +66,13 @@
-51
],
"size": [
340,
17
17,
340
]
},
{
"position": [
44,
74,
-10
],
"size": [

View File

@ -22,21 +22,21 @@
"physics_colliders": [
{
"position": [
44,
246
50,
-246
],
"size": [
60,
140,
20
]
},
{
"position": [
157,
246
-157,
-246
],
"size": [
200,
190,
20
]
},
@ -52,22 +52,12 @@
},
{
"position": [
-103,
-62
-100,
-50
],
"size": [
95,
35
]
},
{
"position": [
-188,
-216
],
"size": [
396,
77
77,
370
]
},
{
@ -76,13 +66,13 @@
-51
],
"size": [
340,
17
17,
340
]
},
{
"position": [
44,
74,
-10
],
"size": [

View File

@ -4,7 +4,7 @@
"file_path": "assets/env/env_person/env_blank.png"
},
"top_texture": {
"file_path": "assets/env/env_person/env_person1.png"
"file_path": "assets/env/env_person/env_personSit1.png"
},
"footprint":[
{

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,31 +1,82 @@
[
{
"type": "env",
"name": "env_umbrella",
"variant": "Blue",
"position": [
5,
7
],
"rotation_degrees": 90
},
{
"type": "env",
"name": "env_umbrella",
"variant": "RedTowels",
"position": [
7,
7
],
"rotation_degrees": 180
},
{
"type": "env",
"name": "env_towel",
"name": "env_market",
"variant": "Red",
"position": [
6,
9
14,120
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Yellow",
"position": [
14,115
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Purple",
"position": [
14,110
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Red",
"position": [
20,105
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Yellow",
"position": [
20,96
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Yellow",
"position": [
19,46
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Purple",
"position": [
19,32
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Purple",
"position": [
20,76
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Yellow",
"position": [
15,15
],
"rotation_degrees": 0
},
@ -34,17 +85,25 @@
"name": "env_chair",
"variant": "Dark",
"position": [
4,
9
4,124
],
"rotation_degrees": -90
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_market",
"variant": "Red",
"name": "env_chair",
"variant": "Dark",
"position": [
14,14
6,124
],
"rotation_degrees": 0
},
{
"type": "env",
"name": "env_chair",
"variant": "Light",
"position": [
19,119
],
"rotation_degrees": 0
}

View File

@ -522,10 +522,10 @@
4,29,29,48,49,29,29,29,29,29,29,29,29,50,51,29,29,29,29,29,50,51,29,29,29,59,52,52,52,52,52,52,
4,29,29,29,29,29,50,41,51,29,29,29,29,48,49,50,51,50,41,51,48,49,50,51,50,59,52,52,52,52,52,52,
4,29,29,29,50,51,44,24,40,51,29,29,29,29,50,42,40,42,24,40,41,41,42,43,44,59,52,52,52,52,52,52,
4,29,29,29,48,49,44,24,24,40,41,41,51,50,42,24,24,24,24,24,24,24,24,40,42,59,52,52,52,52,52,52,
4,29,29,29,29,29,44,24,24,24,24,24,40,42,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
2,7,29,29,29,29,44,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,1,29,29,29,29,48,47,24,24,24,19,20,20,20,20,20,20,20,20,20,20,20,20,20,59,52,52,52,52,52,52,
4,29,29,29,48,49,44,24,24,40,41,41,51,50,42,24,19,20,21,24,24,24,24,40,42,59,52,52,52,52,52,52,
4,29,29,29,29,29,44,24,24,24,24,24,40,42,24,24,17,9,18,24,24,24,24,24,24,59,52,52,52,52,52,52,
2,7,29,29,29,29,44,24,24,24,24,24,24,24,24,24,17,9,18,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,1,29,29,29,29,48,47,24,24,24,19,20,20,20,20,23,9,22,20,20,20,20,20,20,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,44,24,24,24,17,9,9,9,9,9,9,9,9,9,9,9,9,9,59,52,52,52,52,52,52,
2,7,29,29,29,29,50,42,24,24,24,17,9,9,9,9,9,9,9,9,9,9,9,9,9,59,52,52,52,52,52,52,
68,2,3,3,7,29,48,46,54,54,54,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,52,52,52,52,52,52,
@ -617,20 +617,20 @@
68,68,4,29,29,29,29,50,41,41,42,24,24,24,24,24,24,24,24,24,24,17,9,18,24,59,52,52,52,52,52,52,
68,68,4,29,29,29,29,48,47,24,19,20,20,20,20,20,20,20,20,20,20,23,9,18,24,59,52,52,52,52,52,52,
68,68,2,7,29,29,50,41,42,24,17,9,9,9,9,9,9,9,9,9,9,9,9,18,24,59,52,52,52,52,52,52,
68,68,5,1,29,29,48,47,24,24,17,9,25,15,15,15,15,15,15,15,15,15,15,16,24,59,52,52,52,52,52,52,
68,68,4,29,29,29,29,44,24,24,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
68,5,1,29,29,29,50,42,24,24,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,48,47,24,24,17,9,22,20,20,20,20,20,20,20,20,20,20,21,24,59,52,52,52,52,52,52,
68,68,5,1,29,29,48,47,24,24,17,9,25,15,26,9,25,15,15,15,15,15,15,16,24,59,52,52,52,52,52,52,
68,68,4,29,29,29,29,44,24,24,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
68,5,1,29,29,29,50,42,24,24,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,48,47,24,24,17,9,22,20,23,9,22,20,20,20,20,20,20,21,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,29,44,24,24,17,9,9,9,9,9,9,9,9,9,9,9,9,18,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,29,48,47,24,17,9,25,15,15,15,15,15,15,15,15,15,15,16,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,29,29,44,24,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,1,29,29,29,29,29,29,44,24,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,44,24,17,9,22,20,20,20,20,21,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,29,48,47,24,17,9,25,15,26,9,25,15,15,15,15,15,15,16,24,59,52,52,52,52,52,52,
68,4,29,29,29,29,29,29,44,24,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,1,29,29,29,29,29,29,44,24,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,44,24,17,9,22,20,23,9,22,21,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,44,24,17,9,9,9,9,9,9,18,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,48,47,17,9,25,15,15,15,15,16,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
2,3,7,29,29,29,29,29,29,44,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,6,1,29,29,29,29,29,29,44,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,29,48,17,9,18,24,24,24,24,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,48,47,17,9,25,15,26,9,25,16,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
2,3,7,29,29,29,29,29,29,44,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
5,6,1,29,29,29,29,29,29,44,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,29,48,17,9,18,24,17,9,18,24,24,24,24,24,24,24,24,59,52,52,52,52,52,52,
2,7,29,29,29,29,29,29,29,29,14,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,52,52,52,52,52,52,
5,1,29,29,29,29,29,29,29,50,24,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,52,52,52,52,52,52,
4,29,29,29,29,29,29,29,29,44,24,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,52,52,52,52,52,52,

View File

@ -1,5 +1,5 @@
{
"game_name": "Ludum Dare 50",
"game_name": "Melting Point",
"base_window_size": [
1080,
720

View File

@ -21,6 +21,8 @@
//! - If you want to add data to the save state file or settings file, check out the [`persistent`](persistent/index.html) module.
#![doc(issue_tracker_base_url = "https://github.com/Ewpratten/ludum-dare-50/issues/")]
use discord_sdk::activity::Assets;
use crate::{
asset_manager::load_json_structure,
discord::{DiscordRpcSignal, DiscordRpcThreadHandle},
@ -69,6 +71,12 @@ pub async fn entrypoint(force_recreate_savefiles: bool) {
.expect("Failed to connect to Discord RPC");
let event_loop_discord_tx = discord.get_channel();
let discord_task_handle = discord.begin_thread_non_blocking();
event_loop_discord_tx
.send(DiscordRpcSignal::ChangeAssets(Assets::default().large(
project_constants.discord.artwork.get("logo").unwrap(),
Some(""),
)))
.await.unwrap();
// Blocking call to the graphics rendering loop.
rendering::event_loop::handle_graphics_blocking(

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use nalgebra as na;
use raylib::{texture::Texture2D, RaylibHandle, RaylibThread};
use std::collections::HashMap;
use crate::{
asset_manager::{load_json_structure, load_texture_from_internal_data},
@ -34,6 +34,8 @@ pub struct WorldObjectPackage {
pub top_animated_textures: HashMap<String, AnimatedTexture>,
/// A list of colliders in the world. We pre-solve these to make comput happy :)
pub world_space_colliders: Vec<WorldSpaceObjectCollider>,
/// A list of footprints in the world. We pre-solve these to make comput happy :)
pub world_space_footprints: Vec<WorldSpaceObjectCollider>,
}
impl WorldObjectPackage {
@ -52,6 +54,7 @@ impl WorldObjectPackage {
let mut bottom_animated_textures = HashMap::new();
let mut top_animated_textures = HashMap::new();
let mut world_space_colliders: Vec<WorldSpaceObjectCollider> = Vec::new();
let mut world_space_footprints: Vec<WorldSpaceObjectCollider> = Vec::new();
for reference in &object_references {
// If this is a new object, load it.
let object_key = reference.into_key();
@ -118,6 +121,24 @@ impl WorldObjectPackage {
world_space_colliders.push(world_space_collider);
}
// Keep track of all the footprints in the world
for collider in &object_definition.footprint {
// Get the object's position
let object_position = reference.get_world_space_position();
// Convert the collider's position to world space
let mut world_space_collider = WorldSpaceObjectCollider {
position: (object_position + collider.position),
size: collider.size,
};
// Invert the Y axis of the collider's position
world_space_collider.position.y = -world_space_collider.position.y;
// Add the collider to the list
world_space_footprints.push(world_space_collider);
}
// Store the object definition
object_definitions.insert(object_key.to_string(), object_definition);
}
@ -131,6 +152,7 @@ impl WorldObjectPackage {
bottom_animated_textures,
top_animated_textures,
world_space_colliders,
world_space_footprints,
})
}
}

View File

@ -50,7 +50,7 @@ pub async fn handle_graphics_blocking<ConfigBuilder>(
// Set up audio
debug!("Set up Audio");
let audio_subsystem = RaylibAudio::init_audio_device();
audio_subsystem.set_master_volume(0.4);
audio_subsystem.set_master_volume(game_settings.volume.unwrap_or(0.5));
// Set up the internal screens
let mut loading_screen = crate::rendering::screens::loading_screen::LoadingScreen::new();

View File

@ -279,6 +279,9 @@ impl MapRenderer {
camera,
);
let player_position = na::Vector2::new(player_position.x, player_position.y * -1.0);
// Get the tile width and height
let tile_width = 128;
let tile_height = 128;
// Handle each layer from the bottom up
for layer in self.map.layers() {
@ -289,10 +292,6 @@ impl MapRenderer {
let mut sampler_x = 0;
let mut sampler_y = 0;
// Get the tile width and height
let tile_width = 128;
let tile_height = 128;
// Loop until we have covered all tiles on the screen
for y in (world_win_top_left.y as i64)..(world_win_bottom_right.y as i64) {
// Convert the pixel coordinates to tile coordinates
@ -331,154 +330,6 @@ impl MapRenderer {
Color::WHITE,
);
}
// Check if there is an object at this tile
for obj_ref in &self.world_objects.object_references {
if obj_ref.get_tile_space_position().x == sampler_x as f32
&& obj_ref.get_tile_space_position().y
== sampler_y as f32
{
// Get access to the actual object definition
let object_key = obj_ref.into_key();
// debug!("Found object: {}", object_key);
let obj_def = self
.world_objects
.object_definitions
.get(&object_key)
.unwrap();
// We need to render the base layer of the object
if obj_def.bottom_texture.animated.unwrap_or(false) {
let tex = self
.world_objects
.bottom_animated_textures
.get_mut(&object_key)
.unwrap();
tex.render_automatic(
draw_handle,
obj_ref.get_world_space_position()
- (tex.size() / 2.0),
None,
Some(tex.size() / 2.0),
Some(obj_ref.rotation_degrees),
None,
);
} else {
let tex = self
.world_objects
.bottom_static_textures
.get_mut(&object_key)
.unwrap();
let p: Vector2 =
obj_ref.get_world_space_position().into();
let r1 = Rectangle {
x: 0.0,
y: 0.0,
width: tex.width as f32,
height: tex.height as f32,
};
let r2 = Rectangle {
x: p.x,
y: p.y,
width: tex.width as f32,
height: tex.height as f32,
};
draw_handle.draw_texture_pro(
&tex,
r1,
r2,
Vector2::new(
tex.width as f32 / 2.0,
tex.height as f32 / 2.0,
),
obj_ref.rotation_degrees,
Color::WHITE,
);
}
// If needed we can render the top layer of the object
if let Some(top_texture) = &obj_def.top_texture {
// We need to detect if the player is in the footprint of the object
let mut tint = Color::WHITE;
if let Some(footprint_radius) =
obj_def.visualization_radius
{
let player_dist_to_object = (obj_ref
.get_world_space_position()
- player_position)
.norm();
// debug!(
// "Player dist to object: {}",
// player_dist_to_object
// );
if player_dist_to_object <= footprint_radius {
tint.a = 128;
}
}
if top_texture.animated.unwrap_or(false) {
let tex = self
.world_objects
.top_animated_textures
.get_mut(&object_key)
.unwrap();
tex.render_automatic(
draw_handle,
obj_ref.get_world_space_position()
- (tex.size() / 2.0),
None,
Some(tex.size() / 2.0),
Some(obj_ref.rotation_degrees),
Some(tint),
);
} else {
let tex = self
.world_objects
.top_static_textures
.get_mut(&object_key)
.unwrap();
let p: Vector2 =
obj_ref.get_world_space_position().into();
let r1 = Rectangle {
x: 0.0,
y: 0.0,
width: tex.width as f32,
height: tex.height as f32,
};
let r2 = Rectangle {
x: p.x,
y: p.y,
width: tex.width as f32,
height: tex.height as f32,
};
draw_handle.draw_texture_pro(
&tex,
r1,
r2,
Vector2::new(
tex.width as f32 / 2.0,
tex.height as f32 / 2.0,
),
obj_ref.rotation_degrees,
tint,
);
}
}
}
}
if show_debug_grid {
draw_handle.draw_rectangle_lines(
tile_x * tile_width as i32,
tile_y * tile_height as i32,
self.map.tile_width as i32,
self.map.tile_height as i32,
Color::RED,
);
draw_handle.draw_pixel(x as i32, y as i32, Color::BLUE);
}
}
}
}
@ -489,6 +340,181 @@ impl MapRenderer {
tiled::LayerType::GroupLayer(_) => todo!(),
}
}
// Keep track of our sampler X and Y values
let mut sampler_x = 0;
let mut sampler_y = 0;
// Loop until we have covered all tiles on the screen
for y in (world_win_top_left.y as i64)..(world_win_bottom_right.y as i64) {
// Convert the pixel coordinates to tile coordinates
let tile_y = (y as f32 / tile_height as f32).floor() as i32;
// If we are looking at a new tile, update the sampler
if sampler_y != tile_y {
sampler_y = tile_y;
for x in (world_win_top_left.x as i64)..(world_win_bottom_right.x as i64) {
// Convert the pixel coordinates to tile coordinates
let tile_x = (x as f32 / tile_width as f32).floor() as i32;
// debug!("Tile: ({}, {})", tile_x, tile_y);
// If we are looking at a new tile, update the sampler
if sampler_x != tile_x {
sampler_x = tile_x;
// Check if there is an object at this tile
for obj_ref in &self.world_objects.object_references {
if obj_ref.get_tile_space_position().x == sampler_x as f32
&& obj_ref.get_tile_space_position().y == sampler_y as f32
{
// Get access to the actual object definition
let object_key = obj_ref.into_key();
// debug!("Found object: {}", object_key);
let obj_def = self
.world_objects
.object_definitions
.get(&object_key)
.unwrap();
// We need to render the base layer of the object
if obj_def.bottom_texture.animated.unwrap_or(false) {
let tex = self
.world_objects
.bottom_animated_textures
.get_mut(&object_key)
.unwrap();
tex.render_automatic(
draw_handle,
obj_ref.get_world_space_position() - (tex.size() / 2.0),
None,
Some(tex.size() / 2.0),
Some(obj_ref.rotation_degrees),
None,
);
} else {
let tex = self
.world_objects
.bottom_static_textures
.get_mut(&object_key)
.unwrap();
let p: Vector2 = obj_ref.get_world_space_position().into();
let r1 = Rectangle {
x: 0.0,
y: 0.0,
width: tex.width as f32,
height: tex.height as f32,
};
let r2 = Rectangle {
x: p.x,
y: p.y,
width: tex.width as f32,
height: tex.height as f32,
};
draw_handle.draw_texture_pro(
&tex,
r1,
r2,
Vector2::new(
tex.width as f32 / 2.0,
tex.height as f32 / 2.0,
),
obj_ref.rotation_degrees,
Color::WHITE,
);
}
// If needed we can render the top layer of the object
if let Some(top_texture) = &obj_def.top_texture {
// We need to detect if the player is in the footprint of the object
let mut tint = Color::WHITE;
if let Some(footprint_radius) = obj_def.visualization_radius {
let player_dist_to_object =
(obj_ref.get_world_space_position() - player_position)
.norm();
// debug!(
// "Player dist to object: {}",
// player_dist_to_object
// );
if player_dist_to_object <= footprint_radius {
tint.a = 128;
}
}
if top_texture.animated.unwrap_or(false) {
let tex = self
.world_objects
.top_animated_textures
.get_mut(&object_key)
.unwrap();
tex.render_automatic(
draw_handle,
obj_ref.get_world_space_position() - (tex.size() / 2.0),
None,
Some(tex.size() / 2.0),
Some(obj_ref.rotation_degrees),
Some(tint),
);
} else {
let tex = self
.world_objects
.top_static_textures
.get_mut(&object_key)
.unwrap();
let p: Vector2 = obj_ref.get_world_space_position().into();
let r1 = Rectangle {
x: 0.0,
y: 0.0,
width: tex.width as f32,
height: tex.height as f32,
};
let r2 = Rectangle {
x: p.x,
y: p.y,
width: tex.width as f32,
height: tex.height as f32,
};
draw_handle.draw_texture_pro(
&tex,
r1,
r2,
Vector2::new(
tex.width as f32 / 2.0,
tex.height as f32 / 2.0,
),
obj_ref.rotation_degrees,
tint,
);
}
}
}
}
if show_debug_grid {
draw_handle.draw_rectangle_lines(
tile_x * tile_width as i32,
tile_y * tile_height as i32,
self.map.tile_width as i32,
self.map.tile_height as i32,
Color::RED,
);
draw_handle.draw_pixel(x as i32, y as i32, Color::BLUE);
}
}
// for collider in &self.world_objects.world_space_colliders {
// draw_handle.draw_rectangle_lines(
// (collider.position.x-collider.size.x/2.0) as i32,
// -(collider.position.y+collider.size.y/2.0) as i32,
// collider.size.x as i32,
// collider.size.y as i32,
// Color::BLUEVIOLET,
// );
// }
}
}
}
}
/// Get the list of world colliders

View File

@ -9,6 +9,7 @@ use raylib::{
};
use crate::{
asset_manager::load_texture_from_internal_data,
discord::{DiscordChannel, DiscordRpcSignal},
global_resource_package::GlobalResources,
persistent::settings::PersistentGameSettings,
@ -17,9 +18,24 @@ use crate::{
use super::main_menu::MenuStateSignal;
const MIWU_WHITE: Color = Color {
r: 247,
g: 239,
b: 231,
a: 255,
};
const MIWU_WHITE_V2: Color = Color {
r: 255,
g: 245,
b: 228,
a: 255,
};
#[derive(Debug)]
pub struct CutScenes {
show_debug_info: bool,
intro_art: Texture2D,
melted_art: Texture2D,
}
impl CutScenes {
@ -30,8 +46,24 @@ impl CutScenes {
constants: &ProjectConstants,
game_settings: &mut PersistentGameSettings,
) -> Self {
// Load art
let intro_art = load_texture_from_internal_data(
raylib_handle,
thread,
"assets/cut/cut_intro/cut_intro.png",
)
.unwrap();
let melted_art = load_texture_from_internal_data(
raylib_handle,
thread,
"assets/cut/cut_melty/cut_melty.png",
)
.unwrap();
Self {
show_debug_info: false,
intro_art,
melted_art,
}
}
@ -48,7 +80,7 @@ impl CutScenes {
let mut draw = raylib.begin_drawing(rl_thread);
// Clear the screen
draw.clear_background(Color::WHITE);
draw.clear_background(MIWU_WHITE);
//Obtain mouse position
let mouse_x = draw.get_mouse_x();
@ -71,8 +103,40 @@ impl CutScenes {
}
// Title
draw.draw_text("INTRO CUTSCENE GOES HERE", 100, 90, 60, Color::BLACK);
draw.draw_text("Press SPACE to skip", 100, 600, 20, Color::BLACK);
// draw.draw_text("INTRO CUTSCENE GOES HERE", 100, 90, 60, Color::BLACK);
// draw.draw_text("Press SPACE to skip", 100, 600, 20, Color::BLACK);
let screen_height = draw.get_screen_height();
let screen_width = draw.get_screen_width();
// Build a rect for the texture
let tex_rect = Rectangle::new(
0.0,
0.0,
self.intro_art.width as f32,
self.intro_art.height as f32,
);
// Draw the texture to the center of the screen.
// Keep in mind, textures are drawn from the top left
// corner, so we need to offset the rect by half the
// texture's width and height.
let dest_rect = Rectangle::new(
(screen_width / 2) as f32 - (tex_rect.width / 2.0),
(screen_height / 2) as f32 - (tex_rect.height / 2.0),
tex_rect.width,
tex_rect.height,
);
// Draw the texture
draw.draw_texture_pro(
&self.intro_art,
&tex_rect,
&dest_rect,
Vector2::zero(),
0.0,
Color::WHITE,
);
// Let the user leave this cutscene by pressing space
if draw.is_key_pressed(KeyboardKey::KEY_SPACE) {
@ -99,7 +163,7 @@ impl CutScenes {
let mut draw = raylib.begin_drawing(rl_thread);
// Clear the screen
draw.clear_background(Color::WHITE);
draw.clear_background(MIWU_WHITE_V2);
//Obtain mouse position
let mouse_x = draw.get_mouse_x();
@ -121,16 +185,48 @@ impl CutScenes {
);
}
// Title
draw.draw_text("MELTY CUTSCENE GOES HERE", 100, 90, 60, Color::BLACK);
draw.draw_text(
&format!("This took you {} seconds", playtime.num_seconds()),
100,
600,
20,
Color::BLACK,
// // Title
// draw.draw_text("MELTY CUTSCENE GOES HERE", 100, 90, 60, Color::BLACK);
// draw.draw_text(
// &format!("This took you {} seconds", playtime.num_seconds()),
// 100,
// 600,
// 20,
// Color::BLACK,
// );
// draw.draw_text("Press SPACE to skip", 100, 680, 20, Color::BLACK);
let screen_height = draw.get_screen_height();
let screen_width = draw.get_screen_width();
// Build a rect for the texture
let tex_rect = Rectangle::new(
0.0,
0.0,
self.melted_art.width as f32,
self.melted_art.height as f32,
);
// Draw the texture to the center of the screen.
// Keep in mind, textures are drawn from the top left
// corner, so we need to offset the rect by half the
// texture's width and height.
let dest_rect = Rectangle::new(
(screen_width / 2) as f32 - (tex_rect.width / 2.0),
(screen_height / 2) as f32 - (tex_rect.height / 2.0),
tex_rect.width,
tex_rect.height,
);
// Draw the texture
draw.draw_texture_pro(
&self.melted_art,
&tex_rect,
&dest_rect,
Vector2::zero(),
0.0,
Color::WHITE,
);
draw.draw_text("Press SPACE to skip", 100, 680, 20, Color::BLACK);
// Let the user leave this cutscene by pressing space
if draw.is_key_pressed(KeyboardKey::KEY_SPACE) {
@ -158,7 +254,7 @@ impl CutScenes {
let mut draw = raylib.begin_drawing(rl_thread);
// Clear the screen
draw.clear_background(Color::WHITE);
draw.clear_background(MIWU_WHITE);
//Obtain mouse position
let mouse_x = draw.get_mouse_x();
@ -217,7 +313,7 @@ impl CutScenes {
let mut draw = raylib.begin_drawing(rl_thread);
// Clear the screen
draw.clear_background(Color::WHITE);
draw.clear_background(MIWU_WHITE);
//Obtain mouse position
let mouse_x = draw.get_mouse_x();

View File

@ -315,9 +315,9 @@ impl PlayableScene {
for i in &self.world_colliders {
if player.position.x - player_size <= i.position.x + i.size.x / 2.0
&& player.position.x + player_size >= i.position.x + i.size.x / 2.0
&& player.position.x + player_size >= i.position.x - i.size.x / 2.0
&& player.position.y - player_size <= i.position.y + i.size.y / 2.0
&& player.position.y + player_size >= i.position.y + i.size.y / 2.0
&& player.position.y + player_size >= i.position.y - i.size.y / 2.0
{
// if player.velocity.x < 0.0 {
// player.position.x = i.position.x + i.size.x / 2.0 + player_size;
@ -346,9 +346,9 @@ impl PlayableScene {
for i in &self.world_colliders {
if player.position.x - player_size <= i.position.x + i.size.x / 2.0
&& player.position.x + player_size >= i.position.x + i.size.x / 2.0
&& player.position.y - player_size <= i.position.y + i.size.y / 2.0
&& player.position.y + player_size >= i.position.y + i.size.y / 2.0
&& player.position.x + player_size >= i.position.x - i.size.x / 2.0
&& player.position.y - player_size <= i.position.y + i.size.y / 2.0
&& player.position.y + player_size >= i.position.y - i.size.y / 2.0
{
// if player.velocity.y < 0.0 {
// player.position.y = i.position.y + i.size.y / 2.0 + player_size;