-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
052f3f0
commit 4fed514
Showing
14 changed files
with
669 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[gd_resource type="Resource" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://scenes/levels/LevelMetadata.gd" type="Script" id=1] | ||
|
||
[resource] | ||
script = ExtResource( 1 ) | ||
first_level_path = "res://scenes/levels/AdventureLand/Entrance.tscn" | ||
tags = [ "platformer" ] | ||
short_description = " " | ||
description = "Just a few levels to explore." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class_name Water | ||
extends Area2D | ||
|
||
#Warning: Although things can be in multiple water areas at the same time, do not allow | ||
# anything to be in water areas with different multipliers at the same time. | ||
# Strange things will happen. | ||
export var gravity_multiplier := 0.2 | ||
export var jump_multiplier := 0.5 | ||
|
||
const IN_WATER_GROUP := "in_water" | ||
const WATER_COUNT_META := "water_count" | ||
|
||
|
||
func _physics_process(_delta): | ||
var bodies := get_overlapping_bodies() | ||
for temp_body in bodies: | ||
var body : PhysicsBody2D = temp_body | ||
if "double_jump" in body: | ||
body.double_jump = true | ||
|
||
|
||
func _on_body_entered(body: Node): | ||
#This keeps a count of how many water areas a body is in. | ||
#This count is needed so physics work correctly when a body is touching multiple water areas. | ||
var old_water_count := 0 | ||
if body.has_meta(WATER_COUNT_META): | ||
old_water_count = body.get_meta(WATER_COUNT_META) | ||
body.set_meta(WATER_COUNT_META, old_water_count + 1) | ||
body.add_to_group(IN_WATER_GROUP) | ||
|
||
if old_water_count == 0: #The body was not in water already | ||
if "gravity" in body: | ||
body.gravity.strength *= gravity_multiplier | ||
if "jump_force" in body: | ||
body.jump_force *= jump_multiplier | ||
|
||
|
||
func _on_body_exited(body: Node): | ||
assert(body.has_meta(WATER_COUNT_META)) | ||
var old_water_count : int = body.get_meta(WATER_COUNT_META) | ||
body.set_meta(WATER_COUNT_META, old_water_count - 1) | ||
|
||
if old_water_count == 1: #The body just exited the last water area | ||
body.remove_from_group(IN_WATER_GROUP) | ||
if "gravity" in body: | ||
body.gravity.strength /= gravity_multiplier | ||
if "jump_force" in body: | ||
body.jump_force /= jump_multiplier | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tool | ||
extends Water | ||
|
||
export var size := Vector2(1024, 300) setget size_set | ||
export var color := Color(0.0, 0.3, 0.7, 0.5) setget color_set | ||
export var surface_color := Color(0.8, 0.8, 1.0, 0.7) setget surface_color_set | ||
export var surface := true setget surface_set | ||
|
||
|
||
var is_ready := false | ||
|
||
func _ready(): | ||
is_ready = true | ||
update_size() | ||
update_params() | ||
|
||
func size_set(value: Vector2): | ||
size = value | ||
if is_ready: #Make sure child nodes are loaded first | ||
update_size() | ||
|
||
func color_set(value): | ||
color = value | ||
if is_ready: #Make sure child nodes are loaded first | ||
update_params() | ||
|
||
func surface_color_set(value): | ||
surface_color = value | ||
if is_ready: #Make sure child nodes are loaded first | ||
update_params() | ||
|
||
func surface_set(value): | ||
surface = value | ||
if is_ready: #Make sure child nodes are loaded first | ||
update_params() | ||
|
||
|
||
func update_size(): | ||
$Display.scale = size | ||
$Display.position = size | ||
$CollisionShape2D.shape.extents = size / 2 | ||
$CollisionShape2D.position = size / 2 | ||
$Display.material.set_shader_param("size", size) | ||
|
||
|
||
func update_params(): | ||
$Display.material.set_shader_param("color", color) | ||
$Display.material.set_shader_param("surface_color", surface_color) | ||
$Display.material.set_shader_param("surface", surface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[gd_scene load_steps=6 format=2] | ||
|
||
[ext_resource path="res://scenes/platformer/environment/water/WaterBox.gd" type="Script" id=1] | ||
[ext_resource path="res://scenes/platformer/environment/water/water_shader.tres" type="Shader" id=2] | ||
[ext_resource path="res://textures/flatcolor.png" type="Texture" id=4] | ||
|
||
[sub_resource type="ShaderMaterial" id=1] | ||
resource_local_to_scene = true | ||
shader = ExtResource( 2 ) | ||
shader_param/size = Vector2( 1024, 300 ) | ||
shader_param/color = Color( 0, 0.301961, 0.701961, 0.501961 ) | ||
shader_param/surface_color = Color( 0.8, 0.8, 1, 0.701961 ) | ||
shader_param/surface = false | ||
shader_param/surface_depth = 64.0 | ||
|
||
[sub_resource type="RectangleShape2D" id=2] | ||
resource_local_to_scene = true | ||
extents = Vector2( 512, 150 ) | ||
|
||
[node name="WaterBox" type="Area2D"] | ||
collision_layer = 2 | ||
collision_mask = 72 | ||
space_override = 1 | ||
gravity = 0.2 | ||
linear_damp = 0.3 | ||
script = ExtResource( 1 ) | ||
color = Color( 0, 0.301961, 0.701961, 0.501961 ) | ||
surface_color = Color( 0.8, 0.8, 1, 0.701961 ) | ||
|
||
[node name="Display" type="Sprite" parent="."] | ||
material = SubResource( 1 ) | ||
position = Vector2( 1024, 300 ) | ||
scale = Vector2( 1024, 300 ) | ||
texture = ExtResource( 4 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
visible = false | ||
position = Vector2( 512, 150 ) | ||
shape = SubResource( 2 ) | ||
|
||
[connection signal="body_entered" from="." to="." method="_on_body_entered"] | ||
[connection signal="body_exited" from="." to="." method="_on_body_exited"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[gd_resource type="Shader" format=2] | ||
|
||
[resource] | ||
code = "shader_type canvas_item; | ||
|
||
uniform vec2 size; | ||
uniform vec4 color; | ||
uniform vec4 surface_color; | ||
uniform bool surface; | ||
|
||
uniform float surface_depth = 64.0; | ||
|
||
vec2 unscaled_uv(vec2 uv){ | ||
uv.x *= size.x; | ||
uv.y *= size.y; | ||
return uv; | ||
} | ||
|
||
float waviness(float x, float y){ | ||
return y - (10.0 * (sin((x / 100.0) + TIME) + 1.0)); | ||
} | ||
|
||
|
||
float get_surface_effect(vec2 uv){ | ||
if(surface == false){ | ||
return 0.0; | ||
} | ||
float x = unscaled_uv(uv).x; | ||
float y = unscaled_uv(uv).y; | ||
|
||
return smoothstep(surface_depth, 0, waviness(x, y)); | ||
} | ||
|
||
|
||
void fragment(){ | ||
float x = unscaled_uv(UV).x; | ||
float y = unscaled_uv(UV).y; | ||
|
||
COLOR = color; | ||
|
||
float surface_effect = get_surface_effect(UV); | ||
if(surface_effect == 1.0){ | ||
discard; | ||
} else { | ||
COLOR = mix(color, surface_color, surface_effect) | ||
} | ||
}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/sir_duckington.png-b5ace318f90fd81c218a8737e7ebb50c.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://sprites/NPCs/sir_duckington.png" | ||
dest_files=[ "res://.import/sir_duckington.png-b5ace318f90fd81c218a8737e7ebb50c.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=false | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
process/normal_map_invert_y=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=false | ||
svg/scale=1.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/flatcolor.png-264172cbb5ca60982552e47b75eea6cd.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://textures/flatcolor.png" | ||
dest_files=[ "res://.import/flatcolor.png-264172cbb5ca60982552e47b75eea6cd.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=false | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
process/normal_map_invert_y=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=false | ||
svg/scale=1.0 |
4fed514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://pr-653--little-mario.netlify.app
4fed514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://pr-654--little-mario.netlify.app