Flashlight and basic character controls
This commit is contained in:
parent
70d322e276
commit
3832a05c1b
16 changed files with 258 additions and 4 deletions
13
.idea/.idea.1bit-game-jam/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.1bit-game-jam/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/projectSettingsUpdater.xml
|
||||
/contentModel.xml
|
||||
/.idea.1bit-game-jam.iml
|
||||
/modules.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
4
.idea/.idea.1bit-game-jam/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.1bit-game-jam/.idea/encodings.xml
generated
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
8
.idea/.idea.1bit-game-jam/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.1bit-game-jam/.idea/indexLayout.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
6
.idea/.idea.1bit-game-jam/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.1bit-game-jam/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
7
1bit-game-jam.csproj
Normal file
7
1bit-game-jam.csproj
Normal file
|
@ -0,0 +1,7 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.1.1">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<RootNamespace>bitgamejam</RootNamespace>
|
||||
</PropertyGroup>
|
||||
</Project>
|
19
1bit-game-jam.sln
Normal file
19
1bit-game-jam.sln
Normal file
|
@ -0,0 +1,19 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "1bit-game-jam", "1bit-game-jam.csproj", "{C33BED68-271C-4720-9764-1F965577E38A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||
{C33BED68-271C-4720-9764-1F965577E38A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -1,11 +1,13 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bhulqhxesd5gc"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bhulqhxesd5gc"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Player.cs" id="1_1vpun"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://cfdng3tdv65p6" path="res://sprites/player/player.tres" id="1_8jl58"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5hhj3"]
|
||||
size = Vector2(15, 15)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_1vpun")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0.5, 7.5)
|
||||
|
|
|
@ -12,10 +12,26 @@ config_version=5
|
|||
|
||||
config/name="1bit-game-jam"
|
||||
run/main_scene="res://scenes/main_scene.tscn"
|
||||
config/features=PackedStringArray("4.1", "Mobile")
|
||||
config/features=PackedStringArray("4.1", "C#", "Mobile")
|
||||
boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1)
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=256
|
||||
window/size/viewport_height=192
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="1bit-game-jam"
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_render/layer_1="Dark World"
|
||||
2d_render/layer_2="Light World"
|
||||
2d_render/layer_3="UI"
|
||||
|
||||
[rendering]
|
||||
|
||||
textures/canvas_textures/default_texture_filter=0
|
||||
|
@ -23,5 +39,7 @@ renderer/rendering_method="mobile"
|
|||
textures/lossless_compression/force_png=true
|
||||
textures/default_filters/anisotropic_filtering_level=0
|
||||
anti_aliasing/screen_space_roughness_limiter/enabled=false
|
||||
environment/glow/upscale_mode=0
|
||||
environment/defaults/default_clear_color=Color(0, 0, 0, 1)
|
||||
2d/snap/snap_2d_transforms_to_pixel=true
|
||||
2d/snap/snap_2d_vertices_to_pixel=true
|
||||
|
|
|
@ -1,5 +1,49 @@
|
|||
[gd_scene format=3 uid="uid://dhn7yt46fyac8"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dhn7yt46fyac8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bhulqhxesd5gc" path="res://prefabs/player.tscn" id="1_65a7v"]
|
||||
[ext_resource type="Texture2D" uid="uid://py6qiu3rm7cu" path="res://sprites/brickwall.png" id="2_edqdh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dlbl6d4yghvht" path="res://sprites/mask.png" id="3_8o315"]
|
||||
[ext_resource type="Material" uid="uid://xuvxq5hy1dt" path="res://shaders/light_shader_material.tres" id="4_ro05e"]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_wg1ao"]
|
||||
light_mode = 2
|
||||
|
||||
[node name="Root" type="Node2D"]
|
||||
|
||||
[node name="DarkCamera2D" type="Camera2D" parent="."]
|
||||
[node name="Player" parent="." node_paths=PackedStringArray("FlashlightUI", "FlashlightWorld") instance=ExtResource("1_65a7v")]
|
||||
position = Vector2(19, 4)
|
||||
FlashlightUI = NodePath("../CanvasLayer/FlashlightUI")
|
||||
FlashlightWorld = NodePath("../Camera2D/PointLight2D")
|
||||
|
||||
[node name="TestWall" type="Sprite2D" parent="."]
|
||||
light_mask = 2
|
||||
material = SubResource("CanvasItemMaterial_wg1ao")
|
||||
position = Vector2(-108, -74)
|
||||
texture = ExtResource("2_edqdh")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="FlashlightUI" type="Sprite2D" parent="CanvasLayer"]
|
||||
clip_children = 1
|
||||
texture = ExtResource("3_8o315")
|
||||
|
||||
[node name="InvertRect" type="ColorRect" parent="CanvasLayer/FlashlightUI"]
|
||||
material = ExtResource("4_ro05e")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -32.0
|
||||
offset_top = -32.0
|
||||
offset_right = -32.0
|
||||
offset_bottom = -32.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
|
||||
[node name="PointLight2D" type="PointLight2D" parent="Camera2D"]
|
||||
energy = 16.0
|
||||
blend_mode = 2
|
||||
range_item_cull_mask = 2
|
||||
texture = ExtResource("3_8o315")
|
||||
|
|
52
scripts/Player.cs
Normal file
52
scripts/Player.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Player : CharacterBody2D
|
||||
{
|
||||
[Export] public Node2D FlashlightUI;
|
||||
[Export] public Node2D FlashlightWorld;
|
||||
|
||||
[Export] public const float Speed = 50.0f;
|
||||
|
||||
protected AnimatedSprite2D Sprite;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
Sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Vector2 velocity = Velocity;
|
||||
|
||||
// Get the input direction and handle the movement/deceleration.
|
||||
// As good practice, you should replace UI actions with custom gameplay actions.
|
||||
Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down");
|
||||
if (direction != Vector2.Zero)
|
||||
{
|
||||
velocity.X = direction.X * Speed;
|
||||
velocity.Y = direction.Y * Speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
|
||||
velocity.Y = Mathf.MoveToward(Velocity.Y, 0, Speed);
|
||||
}
|
||||
|
||||
Velocity = velocity;
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
base._Input(@event);
|
||||
|
||||
if (@event is InputEventMouseMotion eventMouseMotion)
|
||||
{
|
||||
FlashlightUI.Position = eventMouseMotion.Position;
|
||||
FlashlightWorld.Position = eventMouseMotion.Position - new Vector2(128F, 96F);
|
||||
}
|
||||
}
|
||||
}
|
7
shaders/light_shader.gdshader
Normal file
7
shaders/light_shader.gdshader
Normal file
|
@ -0,0 +1,7 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
|
||||
|
||||
void fragment() {
|
||||
COLOR = vec4(vec3(1,1,1) - texture(screen_texture, SCREEN_UV).rgb, 1);
|
||||
}
|
6
shaders/light_shader_material.tres
Normal file
6
shaders/light_shader_material.tres
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://xuvxq5hy1dt"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/light_shader.gdshader" id="1_o757w"]
|
||||
|
||||
[resource]
|
||||
shader = ExtResource("1_o757w")
|
BIN
sprites/mask.png
Normal file
BIN
sprites/mask.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 807 B |
34
sprites/mask.png.import
Normal file
34
sprites/mask.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dlbl6d4yghvht"
|
||||
path="res://.godot/imported/mask.png-5403fce0f0c69d7184a2784f953221c8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/mask.png"
|
||||
dest_files=["res://.godot/imported/mask.png-5403fce0f0c69d7184a2784f953221c8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
sprites/mask_inv.png
Normal file
BIN
sprites/mask_inv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
34
sprites/mask_inv.png.import
Normal file
34
sprites/mask_inv.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cxnd43vcss7rm"
|
||||
path="res://.godot/imported/mask_inv.png-8ac95d87dd1b42a71c6dd5d5cfce4783.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/mask_inv.png"
|
||||
dest_files=["res://.godot/imported/mask_inv.png-8ac95d87dd1b42a71c6dd5d5cfce4783.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
Loading…
Add table
Reference in a new issue