Merge branch 'assets' into suck-monster

This commit is contained in:
wm-c 2021-04-25 20:20:09 -04:00
commit dfeb6dfbf7
21 changed files with 187 additions and 32 deletions

BIN
assets/audio/breath.mp3 Normal file

Binary file not shown.

BIN
assets/audio/die.mp3 Normal file

Binary file not shown.

BIN
assets/audio/fishPickup.mp3 Normal file

Binary file not shown.

BIN
assets/audio/swim1.mp3 Normal file

Binary file not shown.

BIN
assets/audio/swim2.mp3 Normal file

Binary file not shown.

BIN
assets/audio/swim3.mp3 Normal file

Binary file not shown.

BIN
assets/audio/swim4.mp3 Normal file

Binary file not shown.

BIN
assets/audio/uiBuy.mp3 Normal file

Binary file not shown.

BIN
assets/audio/uiClick.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,51 @@
{ "frames": {
"whirlpool 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 300
},
"whirlpool 1.aseprite": {
"frame": { "x": 20, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 300
},
"whirlpool 2.aseprite": {
"frame": { "x": 40, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 300
},
"whirlpool 3.aseprite": {
"frame": { "x": 60, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 300
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.27-x64",
"image": "whirlpool.png",
"format": "RGBA8888",
"size": { "w": 80, "h": 20 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" },
{ "name": "Layer 2", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
assets/img/map/backBack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -8,25 +8,43 @@ in vec4 fragColor;
uniform sampler2D texture0; uniform sampler2D texture0;
uniform vec4 colDiffuse; uniform vec4 colDiffuse;
// Time fed from CPU
uniform float time = 0.0;
// Output fragment color // Output fragment color
out vec4 finalColor; out vec4 finalColor;
// Viewport dimensions // Viewport dimensions
const float renderWidth = 1080; const vec2 viewport = vec2(1080.0, 720.0);
const float renderHeight = 720;
// Pixel scaling // Pixel scaling
uniform float pixelWidth = 2.0; const vec2 pixelScale = vec2(2.0, 2.0);
uniform float pixelHeight = 2.0;
void main() void main()
{ {
float dx = pixelWidth * (1.0 / renderWidth);
float dy = pixelHeight * (1.0 / renderHeight);
vec2 coord = vec2(dx * floor(fragTexCoord.x / dx), dy * floor(fragTexCoord.y / dy)); // Calculate the distance to merge pixels
float dx = pixelScale.x * (1.0 / viewport.x);
float dy = pixelScale.y * (1.0 / viewport.y);
vec3 tc = texture(texture0, coord).rgb; // Get the base UV coordinate of the pixel
vec2 baseUV = fragTexCoord;
// Use a wave function to translate the pixel UV
float X = baseUV.x*0.5+time;
float Y = baseUV.y*0.25+time;
baseUV.y += cos(X+Y)*0.0025*cos(Y);
baseUV.x += sin(X-Y)*0.012*sin(Y);
// Calculate a UV for this new blocky pixel
vec2 pixelatedUV = vec2(dx * floor(baseUV.x / dx), dy * floor(baseUV.y / dy));
// Rebuild the texture with the new UVs
vec3 tc = texture(texture0, pixelatedUV).rgb;
// Apply a color filter
tc = tc + vec3(0, 0.05, 0.15);
// Build the final pixel
finalColor = vec4(tc, 1.0); finalColor = vec4(tc, 1.0);
} }

View File

@ -1,7 +1,7 @@
{ {
"end_position": { "end_position": {
"x": 350.0, "x": 350.0,
"y": 2100.0 "y": 2050.0
}, },
"player_spawn": { "player_spawn": {
"x": 220.0, "x": 220.0,

View File

@ -16,12 +16,17 @@ pub enum InGameState {
pub struct InGameScreen { pub struct InGameScreen {
current_state: InGameState, current_state: InGameState,
shader_time_var_location: i32,
} }
impl InGameScreen { impl InGameScreen {
pub fn new() -> Self { pub unsafe fn new(game_core: &GameCore) -> Self {
Self { Self {
current_state: InGameState::SWIMMING, current_state: InGameState::SWIMMING,
shader_time_var_location: raylib::ffi::GetShaderLocation(
*game_core.resources.pixel_shader,
rstr!("time").as_ptr(),
),
} }
} }
@ -46,13 +51,49 @@ impl InGameScreen {
}; };
// Clear the background // Clear the background
context_2d.draw_rectangle_gradient_v( // context_2d.draw_rectangle_gradient_v(
world_bounds.x as i32, // world_bounds.x as i32,
world_bounds.y as i32, // world_bounds.y as i32,
world_bounds.width as i32, // world_bounds.width as i32,
world_bounds.height as i32, // world_bounds.height as i32,
WATER, // WATER,
WATER_DARK, // WATER_DARK,
// );
context_2d.draw_texture_pro(
&game_core.resources.background_back,
Rectangle {
x: 0.0,
y: 0.0,
width: game_core.resources.background_back.width as f32,
height: game_core.resources.background_back.height as f32,
},
Rectangle::new(
0.0,
0.0,
(game_core.resources.background_back.width * 2) as f32,
(game_core.resources.background_back.height * 2) as f32,
),
Vector2 { x: 0.0, y: 0.0 },
0.0,
Color::WHITE,
);
context_2d.draw_texture_pro(
&game_core.resources.background_front,
Rectangle {
x: 0.0,
y: 0.0,
width: game_core.resources.background_front.width as f32,
height: game_core.resources.background_front.height as f32,
},
Rectangle::new(
0.0,
0.0,
(game_core.resources.background_front.width * 2) as f32,
(game_core.resources.background_front.height * 2) as f32,
),
Vector2 { x: 0.0, y: 0.0 },
0.0,
Color::WHITE,
); );
// Render fish // Render fish
@ -176,11 +217,9 @@ impl Screen for InGameScreen {
{ {
let mut context_2d = draw_handle.begin_mode2D(game_core.master_camera); let mut context_2d = draw_handle.begin_mode2D(game_core.master_camera);
// Clear frame // Clear frame
context_2d.clear_background(Color::BLACK); context_2d.clear_background(Color::BLACK);
// Render the world // Render the world
self.render_world(&mut context_2d, game_core, dt); self.render_world(&mut context_2d, game_core, dt);
if game_core.show_simple_debug_info { if game_core.show_simple_debug_info {
@ -223,8 +262,6 @@ impl Screen for InGameScreen {
game_core.world.whirlpool.retain(|x| !x.should_remove()); game_core.world.whirlpool.retain(|x| !x.should_remove());
// Render transponder
game_core.resources.transponder.draw(&mut context_2d, game_core.world.end_position + Vector2::new(0.0, -50.0), 0.0);
@ -233,6 +270,13 @@ impl Screen for InGameScreen {
// Render transponder
game_core.resources.transponder.draw(
&mut context_2d,
game_core.world.end_position,
0.0,
);
// Render Player // Render Player
game_core game_core
.player .player
@ -243,13 +287,19 @@ impl Screen for InGameScreen {
} }
} }
// Update the shader's internal time
game_core
.resources
.pixel_shader
.set_shader_value(self.shader_time_var_location, draw_handle.get_time() as f32);
// Render the 2D context via the ripple shader // Render the 2D context via the ripple shader
{ {
let mut shader_context = let mut shader_context =
draw_handle.begin_shader_mode(&game_core.resources.pixel_shader); draw_handle.begin_shader_mode(&game_core.resources.pixel_shader);
// Blit the texture // Blit the texture
shader_context.draw_texture_rec( shader_context.draw_texture_pro(
&game_core.resources.shader_texture, &game_core.resources.shader_texture,
Rectangle { Rectangle {
x: 0.0, x: 0.0,
@ -257,7 +307,14 @@ impl Screen for InGameScreen {
width: game_core.resources.shader_texture.width() as f32, width: game_core.resources.shader_texture.width() as f32,
height: (game_core.resources.shader_texture.height() as f32) * -1.0, height: (game_core.resources.shader_texture.height() as f32) * -1.0,
}, },
Rectangle {
x: -10.0,
y: -10.0,
width: win_width as f32 + 20.0,
height: win_height as f32 + 20.0,
},
Vector2::zero(), Vector2::zero(),
0.0,
Color::WHITE, Color::WHITE,
); );
} }
@ -273,9 +330,14 @@ impl Screen for InGameScreen {
return Some(GameState::GameEnd); return Some(GameState::GameEnd);
} }
if game_core.world.end_position.distance_to(game_core.player.position) <= 70.0{ if game_core
return Some(GameState::WinGame); .world
} .end_position
.distance_to(game_core.player.position)
<= 70.0
{
return Some(GameState::WinGame);
}
return None; return None;
} }

View File

@ -125,7 +125,7 @@ impl Screen for PauseMenuScreen {
draw_handle.draw_text( draw_handle.draw_text(
"Credits:\n\t- @ewpratten\n\t- @rsninja722\n\t- @wm-c\n\t- @catarinaburghi", "Credits:\n\t- @ewpratten\n\t- @rsninja722\n\t- @wm-c\n\t- @catarinaburghi",
(win_width / 2) - (SCREEN_PANEL_SIZE.x as i32 / 2) + 10, (win_width / 2) - (SCREEN_PANEL_SIZE.x as i32 / 2) + 10,
(win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 120, (win_height / 2) - (SCREEN_PANEL_SIZE.y as i32 / 2) + 170,
20, 20,
Color::BLACK, Color::BLACK,
); );

View File

@ -11,7 +11,16 @@ mod world;
use gamecore::{GameCore, GameProgress, GameState}; use gamecore::{GameCore, GameProgress, GameState};
use lib::{utils::profiler::GameProfiler, wrappers::audio::player::AudioPlayer}; use lib::{utils::profiler::GameProfiler, wrappers::audio::player::AudioPlayer};
use log::info; use log::info;
use logic::{gameend::GameEndScreen, ingame::InGameScreen, loadingscreen::LoadingScreen, mainmenu::MainMenuScreen, pausemenu::PauseMenuScreen, screen::Screen, shop::ShopScreen, winscreen::{self, WinScreen}}; use logic::{
gameend::GameEndScreen,
ingame::InGameScreen,
loadingscreen::LoadingScreen,
mainmenu::MainMenuScreen,
pausemenu::PauseMenuScreen,
screen::Screen,
shop::ShopScreen,
winscreen::{self, WinScreen},
};
use raylib::prelude::*; use raylib::prelude::*;
use world::{load_world_colliders, World}; use world::{load_world_colliders, World};
@ -69,10 +78,13 @@ fn main() {
let mut loading_screen = LoadingScreen::new(); let mut loading_screen = LoadingScreen::new();
let mut main_menu_screen = MainMenuScreen::new(); let mut main_menu_screen = MainMenuScreen::new();
let mut pause_menu_screen = PauseMenuScreen::new(); let mut pause_menu_screen = PauseMenuScreen::new();
let mut ingame_screen = InGameScreen::new(); let mut ingame_screen;
unsafe {
ingame_screen = InGameScreen::new(&game_core);
}
let mut game_end_screen = GameEndScreen::new(); let mut game_end_screen = GameEndScreen::new();
let mut shop_screen = ShopScreen::new(); let mut shop_screen = ShopScreen::new();
let mut win_screen = WinScreen::new(); let mut win_screen = WinScreen::new();
// Main rendering loop // Main rendering loop
while !raylib.window_should_close() { while !raylib.window_should_close() {
@ -117,12 +129,12 @@ fn main() {
&mut audio_system, &mut audio_system,
&mut game_core, &mut game_core,
), ),
GameState::WinGame => win_screen.render( GameState::WinGame => win_screen.render(
&mut draw_handle, &mut draw_handle,
&raylib_thread, &raylib_thread,
&mut audio_system, &mut audio_system,
&mut game_core, &mut game_core,
) ),
}; };
// If needed, update the global state // If needed, update the global state

View File

@ -32,6 +32,10 @@ pub struct GlobalResources {
// Darkness layer // Darkness layer
pub darkness_overlay: Texture2D, pub darkness_overlay: Texture2D,
// Backgrounds
pub background_front: Texture2D,
pub background_back: Texture2D,
// Shop & items // Shop & items
pub shop_background: Texture2D, pub shop_background: Texture2D,
@ -167,6 +171,14 @@ impl GlobalResources {
&thread, &thread,
&Image::load_image("./assets/img/map/darkness.png")?, &Image::load_image("./assets/img/map/darkness.png")?,
)?, )?,
background_front: raylib.load_texture_from_image(
&thread,
&Image::load_image("./assets/img/map/backFront.png")?,
)?,
background_back: raylib.load_texture_from_image(
&thread,
&Image::load_image("./assets/img/map/backBack.png")?,
)?,
shop_background: raylib.load_texture_from_image( shop_background: raylib.load_texture_from_image(
&thread, &thread,
&Image::load_image("./assets/img/map/shopHighRes.png")?, &Image::load_image("./assets/img/map/shopHighRes.png")?,