Compare commits

..

1 Commits

Author SHA1 Message Date
4cc42512fb parallax background, character art, pixel art, veg terrain 2026-07-13 15:42:13 -04:00
50 changed files with 169 additions and 1029 deletions

105
Readme.md Normal file
View File

@ -0,0 +1,105 @@
Week 4 - Environment
1. Create a second terrain for vegetation
Learn to use the tilemap layer to easily add vegetation to your level.
* Add a terrain to your terrain set zero
* Import and atlas your graphics (32x32)
* Paint terrain rules
2. Setting Display properties
Learn to set display properties to size the viewport and scale it.
Go to project settings:
Display>Window
Viewport Width 480
Viewport Height 270
This makes the viewport small, but we can now scale it up to the size we want to play at
Advanced settings: on
Window width override: 960
Window height override: 540
And finally how to handle the up-scaling
Stretch>Mode: viewport
aspect: keep
scale: 1.0
At this point you can control the scaling.
The closer the viewport setting is to the scaled size, the more of the
scene will be revealed.
You should add a camera to the player so that the viewport will show the area around them.
3. Creating a background
Create a "sky"
Create a color block the same size as your viewport (480x270)
Create a parallax2D > Add a child Sprite2D to it
Assign the graphic to be the sprite in Sprite2D
Offset the graphic in Sprite2D, 1/2 width, 1/2 height
In the parallax2D parent, set scroll scale to x:1.0 y:1.0
Repeat Size: x:480 y:270
Create a "midground" parallax2D
Scroll Scale x:1.05 y:1.0
Repeat Size x:480 y:0
Create a "foreground"
Scroll Scale x:1.1 y:1.0
Repeat Size x:480 y:0
Optional - Create a "front" parallax2D
4. Custom Graphics
Set up GIMP for creating custom pixel art
Make a background
Create a new document, set to the size of viewport (480x270)
Set up Canvas for Pixel Art
View > Show Grid
Image > Configure Grid
Spacing > 1 horizontal 1 vertical (pixels) > set foreground colour
Set up Tool for Pixel Art
Select "pencil" by click-hold on drawing tools
In tool options:
Size: 1.0
Hardness: 100
The pencil tool creates the hard edges we want in pixel art.
Saving your file as .xcf file will save your grid settings, but will not
automatically show the grid when you open the file. You will still need to
go to View > Show Grid
Turning Images into Pixel Art
When you bring in a reference image there is a good chance it will need to
have work done. A good way to get used to using reference images is to use
a silhoette image.
Get an image
Paste it as a new single layer
Scale it using the scaling tool
Use the colour picker tool to select the black
Make a new layer
Use the paint bucket tool to fill the selection (can now delete reference)
With the selection painted it will snap the paint to whole pixels, but
you will likely see some fuzzy edges because some of the pixels around edges
will be partially transparent.
You can use the colour picker tool set to "select by alpha". Now when you select
a transparent pixel, it will add all pixels with the same transparency to the
selection.
You can now use the paint bucket to fill the selection with an appropriate colour.
When done you can paint bucket the main colour (no selection) to flood-fill any
remaining partially transparent pixels.
Editing Pixel Art
You might want to customize your character art! Conveniently, your sprite sheets
are designed so that each limb of the character is composed of a consistent
colour in each frame.
This allows us to use the "colour selection" tool to select the limb in every frame.
And as above, the paint bucket can be used to fill the limb with an appropriate colour.
When complete, you can draw in anything else you like, though you will have to
do it for each cell. If you save it to your Godot project, it will overwrite
the graphics, and instantly show up in your game!
Scaling Pixel Art
Be aware that if you scale pixel art, there is a very high chance the edges will
become fuzzy and indistinct. This is because of "interpolation".
To avoid this problem, set the scaling tool to Interpolation - None.
Now when you scale your pixel art it will snap to the closes whole pixel,
maintaining the crisp edges.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b51p3mo2o7uxa"
path="res://.godot/imported/slime_purple.png-4674ec1226b290767ac60aef13cd0376.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/enemies/slime/slime_purple.png"
dest_files=["res://.godot/imported/slime_purple.png-4674ec1226b290767ac60aef13cd0376.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bhr2gp8fktmd7"
path="res://.godot/imported/foreground.png-3151a7c34530c015b33a4ea37acc5e2f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/environment/bg/foreground.png"
dest_files=["res://.godot/imported/foreground.png-3151a7c34530c015b33a4ea37acc5e2f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -2,7 +2,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dfikkb3kxl5vf"
uid="uid://b583o88duaqu"
path="res://.godot/imported/sky.png-86cc6f428916ab8e3e1824da6ccc3df5.ctex"
metadata={
"vram_texture": false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://er1mfomleylu"
path="res://.godot/imported/plane_512x512.png-d829dffdb6fbf8fcd999f98a3b97a20e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/environment/flavour/plane_512x512.png"
dest_files=["res://.godot/imported/plane_512x512.png-d829dffdb6fbf8fcd999f98a3b97a20e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bfhtipeqja1da"
path="res://.godot/imported/midground.png-03eab17df5ff63383933587ac063d6c8.ctex"
uid="uid://cn1qvqti2u0pk"
path="res://.godot/imported/mushroom_32x64.png-f773d82c5be18b26897c2ebfe3849a39.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/environment/bg/midground.png"
dest_files=["res://.godot/imported/midground.png-03eab17df5ff63383933587ac063d6c8.ctex"]
source_file="res://assets/environment/mushroom_32x64.png"
dest_files=["res://.godot/imported/mushroom_32x64.png-f773d82c5be18b26897c2ebfe3849a39.ctex"]
[params]

View File

Before

Width:  |  Height:  |  Size: 675 B

After

Width:  |  Height:  |  Size: 675 B

View File

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://djdtyvgn5noje"
path="res://.godot/imported/plane_02.png-8b33a4b74ab76c2899e86cb37ed79d24.ctex"
uid="uid://cj3we2brsknxh"
path="res://.godot/imported/veg_32x32.png-f547c76da23451f9a832bbe2fb852b32.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/source/plane_02.png"
dest_files=["res://.godot/imported/plane_02.png-8b33a4b74ab76c2899e86cb37ed79d24.ctex"]
source_file="res://assets/environment/veg_32x32.png"
dest_files=["res://.godot/imported/veg_32x32.png-f547c76da23451f9a832bbe2fb852b32.ctex"]
[params]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cewk7bgu5elop"
path="res://.godot/imported/mushroom_32x64.png-b1dbb217db4b1cc7fe723fa9cbf9622b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/environment/veggies/mushroom_32x64.png"
dest_files=["res://.godot/imported/mushroom_32x64.png-b1dbb217db4b1cc7fe723fa9cbf9622b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bcgol8iru1j5n"
path="res://.godot/imported/veg_32x32.png-1a23bbefe425ba5c243b7f4852257a1b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/environment/veggies/veg_32x32.png"
dest_files=["res://.godot/imported/veg_32x32.png-1a23bbefe425ba5c243b7f4852257a1b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://brsknqptomuux"
path="res://.godot/imported/coin.png-f4453cae0c71d6ed2110d4ba8123634d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/pickups/coin.png"
dest_files=["res://.godot/imported/coin.png-f4453cae0c71d6ed2110d4ba8123634d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://2ajlg788xas2"
path="res://.godot/imported/Player Death 64x64.png-19e98a15db451ac6dd6faaec1fd6a386.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player/dead/Player Death 64x64.png"
dest_files=["res://.godot/imported/Player Death 64x64.png-19e98a15db451ac6dd6faaec1fd6a386.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c7ike4q1xl2gy"
path="res://.godot/imported/Player Hurt 48x48.png-4f3bee63f7b077a423955d655b236738.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player/hurt/Player Hurt 48x48.png"
dest_files=["res://.godot/imported/Player Hurt 48x48.png-4f3bee63f7b077a423955d655b236738.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmobbopn07ooi"
path="res://.godot/imported/plane_00.png-715574c35ac58427959c768c95980a6f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/source/plane_00.png"
dest_files=["res://.godot/imported/plane_00.png-715574c35ac58427959c768c95980a6f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://74b6xr74ylk0"
path="res://.godot/imported/plane_01.png-78095a15e23617810bded5bfa5f5ebae.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/source/plane_01.png"
dest_files=["res://.godot/imported/plane_01.png-78095a15e23617810bded5bfa5f5ebae.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bh3jkggvx0spp"
path="res://.godot/imported/plane_03.png-511bd1045c45b614ee2bbad36f4dd30b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/source/plane_03.png"
dest_files=["res://.godot/imported/plane_03.png-511bd1045c45b614ee2bbad36f4dd30b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@ -15,14 +15,10 @@ run/main_scene="uid://ch6sfehmsskcs"
config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
Gamecontroller="*uid://dtv434qd1rfmu"
[display]
window/size/viewport_width=480
window/size/viewport_height=270
window/size/viewport_width=580
window/size/viewport_height=370
window/size/window_width_override=960
window/size/window_height_override=540
window/stretch/mode="viewport"

View File

@ -20,5 +20,4 @@ rotation = -3.1367095
scale = Vector2(0.07999989, 0.08039169)
texture = ExtResource("2_y25gk")
[connection signal="area_entered" from="." to="." method="_on_body_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,113 +0,0 @@
[gd_scene format=3 uid="uid://cfmbd0jdbrvd1"]
[ext_resource type="Script" uid="uid://d2sc7mlvheh7m" path="res://scripts/coin.gd" id="1_i64fm"]
[ext_resource type="Texture2D" uid="uid://brsknqptomuux" path="res://assets/pickups/coin.png" id="1_rwqht"]
[sub_resource type="CircleShape2D" id="CircleShape2D_i64fm"]
radius = 6.0
[sub_resource type="AtlasTexture" id="AtlasTexture_11l1o"]
atlas = ExtResource("1_rwqht")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_d14el"]
atlas = ExtResource("1_rwqht")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_1ikuy"]
atlas = ExtResource("1_rwqht")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_wnlwo"]
atlas = ExtResource("1_rwqht")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jig8b"]
atlas = ExtResource("1_rwqht")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_xmuha"]
atlas = ExtResource("1_rwqht")
region = Rect2(80, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kfxoj"]
atlas = ExtResource("1_rwqht")
region = Rect2(96, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jsmju"]
atlas = ExtResource("1_rwqht")
region = Rect2(112, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_s0mny"]
atlas = ExtResource("1_rwqht")
region = Rect2(128, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_7cc30"]
atlas = ExtResource("1_rwqht")
region = Rect2(144, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_rojmm"]
atlas = ExtResource("1_rwqht")
region = Rect2(160, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ls27i"]
atlas = ExtResource("1_rwqht")
region = Rect2(176, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_ssuvv"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_11l1o")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d14el")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1ikuy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wnlwo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jig8b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xmuha")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kfxoj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jsmju")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_s0mny")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7cc30")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rojmm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ls27i")
}],
"loop": true,
"name": &"default",
"speed": 12.0
}]
[node name="Coin" type="Area2D" unique_id=354461121]
script = ExtResource("1_i64fm")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=151276741]
shape = SubResource("CircleShape2D_i64fm")
debug_color = Color(0.6971114, 0.4832114, 0.29441354, 0.41960785)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=221062566]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_ssuvv")
autoplay = "default"
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,18 +1,14 @@
[gd_scene format=4 uid="uid://ch6sfehmsskcs"]
[ext_resource type="Texture2D" uid="uid://dfikkb3kxl5vf" path="res://assets/environment/bg/sky.png" id="2_0tnpc"]
[ext_resource type="Script" uid="uid://dtv434qd1rfmu" path="res://scripts/game.gd" id="1_lnu2h"]
[ext_resource type="Texture2D" uid="uid://b583o88duaqu" path="res://assets/environment/bg/sky.png" id="2_0tnpc"]
[ext_resource type="Script" uid="uid://b5c00ybml8rj" path="res://scripts/scene_manager.gd" id="2_lbhrr"]
[ext_resource type="Texture2D" uid="uid://b6fqvrq70n5al" path="res://assets/environment/Terrain (32x32).png" id="2_p57ef"]
[ext_resource type="Texture2D" uid="uid://bcgol8iru1j5n" path="res://assets/environment/veggies/veg_32x32.png" id="3_gee14"]
[ext_resource type="Texture2D" uid="uid://bfhtipeqja1da" path="res://assets/environment/bg/midground.png" id="3_vtaks"]
[ext_resource type="Texture2D" uid="uid://cewk7bgu5elop" path="res://assets/environment/veggies/mushroom_32x64.png" id="4_0tnpc"]
[ext_resource type="Texture2D" uid="uid://cn1qvqti2u0pk" path="res://assets/environment/mushroom_32x64.png" id="3_gee14"]
[ext_resource type="Texture2D" uid="uid://cj3we2brsknxh" path="res://assets/environment/veg_32x32.png" id="4_0tnpc"]
[ext_resource type="PackedScene" uid="uid://byl4bdrupii3k" path="res://scenes/player.tscn" id="4_iywne"]
[ext_resource type="Texture2D" uid="uid://bhr2gp8fktmd7" path="res://assets/environment/bg/foreground.png" id="4_kvpfn"]
[ext_resource type="Texture2D" uid="uid://er1mfomleylu" path="res://assets/environment/flavour/plane_512x512.png" id="5_dinhu"]
[ext_resource type="PackedScene" uid="uid://b6cmg0k8qjoxi" path="res://scenes/crate.tscn" id="5_iywne"]
[ext_resource type="PackedScene" uid="uid://b3hgbbmb0nohj" path="res://scenes/trigger.tscn" id="5_p57ef"]
[ext_resource type="PackedScene" uid="uid://cfmbd0jdbrvd1" path="res://scenes/coin.tscn" id="13_kvuet"]
[ext_resource type="PackedScene" uid="uid://b23q2ppkeamyh" path="res://scenes/slime.tscn" id="14_trtic"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u5sy4"]
texture = ExtResource("2_p57ef")
@ -374,18 +370,18 @@ texture = ExtResource("3_gee14")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
0:0/0/terrain_set = 0
0:0/0/terrain = 1
0:0/0/terrains_peering_bit/bottom_side = 1
0:1/0 = 0
0:1/0/terrain_set = 0
0:1/0/terrain = 1
0:1/0/terrains_peering_bit/top_side = 1
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kvpfn"]
texture = ExtResource("4_0tnpc")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
0:0/0/terrain_set = 0
0:0/0/terrains_peering_bit/bottom_side = 1
0:1/0 = 0
0:1/0/terrain_set = 0
0:1/0/terrain = 1
0:1/0/terrains_peering_bit/top_side = 1
0:0/0/terrain = 1
[sub_resource type="TileSet" id="TileSet_gee14"]
tile_size = Vector2i(32, 32)
@ -393,7 +389,7 @@ physics_layer_0/collision_layer = 1
terrain_set_0/mode = 0
terrain_set_0/terrain_0/name = "LeafyGreen"
terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1)
terrain_set_0/terrain_1/name = "Veg"
terrain_set_0/terrain_1/name = "Veg 1"
terrain_set_0/terrain_1/color = Color(0.5, 0.4375, 0.25, 1)
sources/0 = SubResource("TileSetAtlasSource_u5sy4")
sources/1 = SubResource("TileSetAtlasSource_vtaks")
@ -404,66 +400,40 @@ sources/2 = SubResource("TileSetAtlasSource_kvpfn")
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_iywne"]
[node name="Game" type="Node2D" unique_id=981419409]
script = ExtResource("1_lnu2h")
[node name="bg" type="Node2D" parent="." unique_id=2006279143]
[node name="Parallax2D" type="Parallax2D" parent="." unique_id=2081148083]
repeat_size = Vector2(580, 370)
[node name="sky" type="Parallax2D" parent="bg" unique_id=96096944]
repeat_size = Vector2(480, 270)
[node name="Sprite2D" type="Sprite2D" parent="bg/sky" unique_id=8390549]
[node name="Sprite2D" type="Sprite2D" parent="Parallax2D" unique_id=879239814]
texture = ExtResource("2_0tnpc")
offset = Vector2(240, 135)
[node name="midgfround" type="Parallax2D" parent="bg" unique_id=698172308]
scroll_scale = Vector2(1.05, 1)
repeat_size = Vector2(480, 0)
[node name="Sprite2D" type="Sprite2D" parent="bg/midgfround" unique_id=603045131]
texture_filter = 1
texture = ExtResource("3_vtaks")
centered = false
offset = Vector2(0, 200)
[node name="foreground" type="Parallax2D" parent="bg" unique_id=991647999]
scroll_scale = Vector2(1.1, 1)
repeat_size = Vector2(480, 0)
[node name="Sprite2D" type="Sprite2D" parent="bg/foreground" unique_id=1856428018]
texture_filter = 1
texture = ExtResource("4_kvpfn")
offset = Vector2(240, 330)
[node name="plane" type="Sprite2D" parent="bg" unique_id=2025512082]
texture_filter = 1
position = Vector2(944, 322)
texture = ExtResource("5_dinhu")
offset = Vector2(290, 185)
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=1253342998]
texture_filter = 1
tile_map_data = PackedByteArray("AAARAA0AAAAQAAQAAAARAAwAAAAPAAMAAAASAAwAAAABAAQAAAATAAwAAAAQAAQAAAATAAsAAAAEAAAAAAAUAAkAAAAAAAQAAAAVAAkAAAABAAQAAAAWAAkAAAACAAQAAAAXABEAAAAAAAQAAAAYABEAAAAQAAQAAAAYABAAAAAPAAMAAAAZABAAAAABAAQAAAAaABAAAAABAAQAAAAbABAAAAAQAAQAAAAbAA8AAAAEAAAAAAAbAAwAAAAAAAIAAAAbAAsAAAAAAAAAAAAcAAsAAAABAAAAAAAcAAwAAAABAAIAAAAdAAwAAAACAAIAAAAdAAsAAAAJAAMAAAAeAAsAAAACAAQAAAANAA0AAAAAAAQAAAAOAA0AAAABAAQAAAAPAA0AAAABAAQAAAAQAA0AAAABAAQAAAAKAA8AAAAAAAQAAAALAA8AAAABAAQAAAAMAA8AAAABAAQAAAANAA8AAAAKAAMAAAAOAA8AAAABAAAAAAAPAA8AAAABAAAAAAAQAA8AAAACAAAAAAAQABAAAAACAAEAAAAPABAAAAAGAAAAAAAOABAAAAAGAAAAAAANABAAAAAJAAEAAAANABEAAAAAAAIAAAAOABEAAAABAAIAAAAPABEAAAABAAIAAAAQABEAAAAJAAQAAAARABEAAAABAAQAAAASABEAAAAMAAQAAAASABAAAAAEAAAAAAATABEAAAACAAQAAAANAAwAAQAAAAAAAAAWAAgAAQAAAAAAAAAKAA4AAgAAAAEAAAAKAA0AAgAAAAAAAAA=")
tile_map_data = PackedByteArray("AAARAA0AAAAQAAQAAAARAAwAAAAPAAMAAAASAAwAAAABAAQAAAATAAwAAAAQAAQAAAATAAsAAAAEAAAAAAAUAAkAAAAAAAQAAAAVAAkAAAABAAQAAAAWAAkAAAACAAQAAAAXABEAAAAAAAQAAAAYABEAAAAQAAQAAAAYABAAAAAPAAMAAAAZABAAAAABAAQAAAAaABAAAAABAAQAAAAbABAAAAAQAAQAAAAbAA8AAAAEAAAAAAAbAAwAAAAAAAIAAAAbAAsAAAAAAAAAAAAcAAsAAAABAAAAAAAcAAwAAAABAAIAAAAdAAwAAAACAAIAAAAdAAsAAAAJAAMAAAAeAAsAAAACAAQAAAANAA0AAAAAAAQAAAAOAA0AAAABAAQAAAAPAA0AAAABAAQAAAAQAA0AAAABAAQAAAAKAA8AAAAAAAQAAAALAA8AAAABAAQAAAAMAA8AAAABAAQAAAANAA8AAAAKAAMAAAAOAA8AAAABAAAAAAAPAA8AAAABAAAAAAAQAA8AAAACAAAAAAAQABAAAAACAAEAAAAPABAAAAAGAAAAAAAOABAAAAAGAAAAAAANABAAAAAJAAEAAAANABEAAAAAAAIAAAAOABEAAAABAAIAAAAPABEAAAABAAIAAAAQABEAAAAJAAQAAAARABEAAAABAAQAAAASABEAAAAMAAQAAAASABAAAAAEAAAAAAATABEAAAACAAQAAAAbAA4AAgAAAAAAAAAbAAoAAQAAAAEAAAAbAAkAAQAAAAAAAAAKAA4AAQAAAAEAAAAKAA0AAQAAAAAAAAALAA4AAgAAAAAAAAAVAAgAAgAAAAAAAAA=")
tile_set = SubResource("TileSet_gee14")
[node name="SceneManager" type="Node2D" parent="." unique_id=323246552]
script = ExtResource("2_lbhrr")
[node name="Player" parent="." unique_id=2145223914 instance=ExtResource("4_iywne")]
position = Vector2(575, 368.00003)
position = Vector2(490, 380)
[node name="Crates" type="Node2D" parent="." unique_id=207771395]
[node name="Crate" parent="Crates" unique_id=1609374030 instance=ExtResource("5_iywne")]
position = Vector2(916, 337)
position = Vector2(951, 332.99997)
[node name="Crate3" parent="Crates" unique_id=249514132 instance=ExtResource("5_iywne")]
position = Vector2(690, 263)
position = Vector2(731, 340)
[node name="Crate2" parent="Crates" unique_id=1603366376 instance=ExtResource("5_iywne")]
position = Vector2(458, 355)
position = Vector2(558, 368)
[node name="Walls" type="Node2D" parent="." unique_id=80334518]
[node name="StaticBody2D" type="StaticBody2D" parent="Walls" unique_id=1863997109]
position = Vector2(1143, 277)
position = Vector2(553.00006, 401)
scale = Vector2(3.4000025, 1)
metadata/_edit_group_ = true
@ -479,7 +449,7 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_8cj0n")
[node name="StaticBody2D3" type="StaticBody2D" parent="Walls" unique_id=2089762008]
position = Vector2(1125, 128.00002)
position = Vector2(734.00006, 377)
scale = Vector2(3.4000025, 1)
metadata/_edit_group_ = true
@ -487,7 +457,7 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_8cj0n")
[node name="StaticBody2D2" type="StaticBody2D" parent="Walls" unique_id=2038269484]
position = Vector2(1160.0001, 202)
position = Vector2(681.00006, 398)
rotation = -0.7375178
scale = Vector2(3.4000025, 1)
metadata/_edit_group_ = true
@ -514,25 +484,6 @@ intent = "fan"
position = Vector2(953.99994, 442.99997)
intent = "teleport"
[node name="Coins" type="Node2D" parent="." unique_id=2040053188]
position = Vector2(459, 408)
[node name="Coin" parent="Coins" unique_id=354461121 instance=ExtResource("13_kvuet")]
[node name="Coin2" parent="Coins" unique_id=987971109 instance=ExtResource("13_kvuet")]
position = Vector2(116, -31)
[node name="Coin3" parent="Coins" unique_id=1071266659 instance=ExtResource("13_kvuet")]
position = Vector2(164, -65)
[node name="Enemies" type="Node2D" parent="." unique_id=998893132]
position = Vector2(484, 406)
[node name="Slime" parent="Enemies" unique_id=250926168 instance=ExtResource("14_trtic")]
[node name="Slime2" parent="Enemies" unique_id=777259292 instance=ExtResource("14_trtic")]
position = Vector2(-108, 65)
[connection signal="areaTriggerSignal" from="Triggers/Trigger" to="." method="_on_trigger"]
[connection signal="areaTriggerSignal" from="Triggers/Trigger2" to="." method="_on_trigger"]
[connection signal="areaTriggerSignal" from="Triggers/Trigger3" to="." method="_on_trigger"]

View File

@ -4,9 +4,7 @@
[ext_resource type="Texture2D" uid="uid://b1ai5l50rwv4u" path="res://assets/player/idle/Player Idle 48x48.png" id="2_g2els"]
[ext_resource type="Texture2D" uid="uid://dngnhx41kw3mw" path="res://assets/player/charging/Player Punch 64x64.png" id="2_qlg0r"]
[ext_resource type="Texture2D" uid="uid://cgyc5mlhrd472" path="res://assets/player/jump_fall/player jump 48x48.png" id="3_dqkch"]
[ext_resource type="Texture2D" uid="uid://2ajlg788xas2" path="res://assets/player/dead/Player Death 64x64.png" id="3_fjrip"]
[ext_resource type="Texture2D" uid="uid://di17x5ovjtvtt" path="res://assets/player/run/player run 48x48.png" id="3_qhqgy"]
[ext_resource type="Texture2D" uid="uid://c7ike4q1xl2gy" path="res://assets/player/hurt/Player Hurt 48x48.png" id="5_smehm"]
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
@ -14,66 +12,10 @@
atlas = ExtResource("2_qlg0r")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"]
atlas = ExtResource("3_fjrip")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"]
atlas = ExtResource("3_fjrip")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"]
atlas = ExtResource("3_fjrip")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"]
atlas = ExtResource("3_fjrip")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_gl8cc"]
atlas = ExtResource("3_fjrip")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_487ah"]
atlas = ExtResource("3_fjrip")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_md1ol"]
atlas = ExtResource("3_fjrip")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_bj30b"]
atlas = ExtResource("3_fjrip")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_jc3p3"]
atlas = ExtResource("3_fjrip")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_hax0n"]
atlas = ExtResource("3_fjrip")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
atlas = ExtResource("3_dqkch")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_t4otl"]
atlas = ExtResource("5_smehm")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"]
atlas = ExtResource("5_smehm")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"]
atlas = ExtResource("5_smehm")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_2dvfe"]
atlas = ExtResource("5_smehm")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
atlas = ExtResource("2_g2els")
region = Rect2(0, 0, 48, 48)
@ -178,41 +120,6 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_pf23h")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dt7fs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wqfne")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wnwbv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gl8cc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_487ah")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_md1ol")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bj30b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jc3p3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hax0n")
}],
"loop": false,
"name": &"dying",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_4ni07")
}],
"loop": false,
@ -221,23 +128,6 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_t4otl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j2b1d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_cs1tg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2dvfe")
}],
"loop": false,
"name": &"hurt",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qhqgy")
}, {
"duration": 1.0,
@ -342,19 +232,21 @@ target_position = Vector2(16.891893, 0)
target_position = Vector2(-17.56757, -0.67567575)
[node name="RightSpawn" type="Marker2D" parent="." unique_id=72314368]
position = Vector2(12.837839, -2.702703)
position = Vector2(12.837839, -8.1081085)
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=374152113]
position = Vector2(-12.837839, -2.7027035)
position = Vector2(-12.837839, -8.108109)
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=174634956]
texture_filter = 1
position = Vector2(0, -6.081082)
sprite_frames = SubResource("SpriteFrames_jej6c")
animation = &"dying"
animation = &"shoving"
autoplay = "idle"
frame = 2
frame_progress = 1.0
[node name="Camera2D" type="Camera2D" parent="." unique_id=839648774]
offset = Vector2(0, -60)
[node name="Camera2D" type="Camera2D" parent="." unique_id=144867956]
offset = Vector2(0, -50)
[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"]

View File

@ -1,74 +0,0 @@
[gd_scene format=3 uid="uid://b23q2ppkeamyh"]
[ext_resource type="Texture2D" uid="uid://b51p3mo2o7uxa" path="res://assets/enemies/slime/slime_purple.png" id="1_371uh"]
[ext_resource type="Script" uid="uid://d215jspbbgtq6" path="res://scripts/slime.gd" id="1_p2gj0"]
[sub_resource type="CircleShape2D" id="CircleShape2D_p2gj0"]
[sub_resource type="AtlasTexture" id="AtlasTexture_n6pvg"]
atlas = ExtResource("1_371uh")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_pjw23"]
atlas = ExtResource("1_371uh")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_2npkn"]
atlas = ExtResource("1_371uh")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_fd6lc"]
atlas = ExtResource("1_371uh")
region = Rect2(72, 24, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_gstla"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_n6pvg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pjw23")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2npkn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fd6lc")
}],
"loop": true,
"name": &"idle",
"speed": 12.0
}]
[node name="Slime" type="Area2D" unique_id=250926168 groups=["shootable"]]
script = ExtResource("1_p2gj0")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=588756743]
shape = SubResource("CircleShape2D_p2gj0")
debug_color = Color(0.83704245, 0.20573696, 0.8053471, 0.41960785)
[node name="SlimeGraphic" type="AnimatedSprite2D" parent="." unique_id=69804785]
texture_filter = 1
position = Vector2(0, -2)
sprite_frames = SubResource("SpriteFrames_gstla")
animation = &"idle"
autoplay = "idle"
frame = 1
frame_progress = 0.67487884
[node name="RightCast" type="RayCast2D" parent="." unique_id=18403424]
target_position = Vector2(16, 0)
[node name="RightDownCast" type="RayCast2D" parent="." unique_id=1848380842]
position = Vector2(9, 0)
target_position = Vector2(0, 16)
[node name="LeftDownCast" type="RayCast2D" parent="." unique_id=858346924]
position = Vector2(-10, 0)
target_position = Vector2(0, 16)
[node name="LeftCast" type="RayCast2D" parent="." unique_id=382510816]
target_position = Vector2(-16, 0)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -9,5 +9,5 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("shootable"):
if body is Crate:
bulletHitSignal.emit(body,self)

View File

@ -1,7 +0,0 @@
class_name Coin extends Area2D
signal coinCollectedSignal(body,coin)
func _on_body_entered(body: Node2D) -> void:
if body is Player:
print("you hit a coin")
coinCollectedSignal.emit(body,self)

View File

@ -1 +0,0 @@
uid://d2sc7mlvheh7m

View File

@ -2,33 +2,13 @@ class_name GameController extends Node2D
signal destroySignal(body)
signal fanTriggerSignal(body, fanDirection)
signal teleportTriggerSignal(body)
signal playerHurtSignal(playerHealth, maxHealth)
signal playerDeadSignal
var numberOfCrates = 2
var timeAvailable = 50
var totalCoinsCollected = 0
var timer = Timer.new()
var currentPlayerHealth = 100
var startingHealth = 100
var enemiesDict={}
var enemy:CharacterStats
var player:CharacterStats
func reset()->void:
print("GC reset")
currentPlayerHealth=player.startingHealth
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
get_window().grab_focus()
enemy = load("res://scripts/rscs/slimeStats.tres")
player = load("res://scripts/rscs/playerStats.tres")
add_child(timer)
timer.wait_time = 1
timer.one_shot = false
@ -40,7 +20,7 @@ func countdown()->void:
timeAvailable-=1
if timeAvailable<=0 and numberOfCrates>0:
print("LOOOOOSAH")
playerDeadSignal.emit()
get_tree().reload_current_scene()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
@ -51,8 +31,7 @@ func _on_trigger(body: Variant, trigger: Variant, intent:String) -> void:
print("GC knows trigger fired")
match intent:
"destroy":
if body is RigidBody2D:
destroySignal.emit(body)
destroySignal.emit(body)
"fan":
print("do a fan effect")
fanTriggerSignal.emit(body,Vector2(0,-1)*100*9)
@ -66,49 +45,13 @@ func crateTotal(howmany):
if numberOfCrates == 0:
print("YOU WON!!!")
get_tree().reload_current_scene()
func coinCollected(body,coin)->void:
totalCoinsCollected +=1
print("GC knows coin collected")
destroySignal.emit(coin)
func coinTotal(totalAmount)->void:
print("GC knows total coins "+str(totalAmount))
func bulletDamage(body, _bullet)->void:
if body.is_in_group("shootable"):
if body is Crate:
destroySignal.emit(body)
destroySignal.emit(_bullet)
if body is Slime:
enemiesDict[body]["health"] -= player.rangeDamage
if enemiesDict[body]["health"]<=0:
enemiesDict.erase(body)
destroySignal.emit(body)
destroySignal.emit(_bullet)
destroySignal.emit(body)
destroySignal.emit(_bullet)
func rocketDamage(body, rocket)->void:
if body.is_in_group("shootable"):
print("Rocket strikes target!")
destroySignal.emit(body)
func totalEnemies(numberOfEnemies)->void:
print("GC knows this many badguy: "+str(numberOfEnemies))
func slimeAttack(body,slime)->void:
print("GC knows slime attack "+str(enemiesDict[slime]["damage"]))
currentPlayerHealth -= enemiesDict[slime]["damage"]
if currentPlayerHealth>0:
#damage
print("player damaged")
playerHurtSignal.emit(currentPlayerHealth, startingHealth)
else:
#ded
print("player ded")
playerDeadSignal.emit()
func levelChange()->void:
get_tree().reload_current_scene()
func addEnemyToLevel(slime)->void:
var stats = {
"health": enemy.startingHealth,
"damage": enemy.meleeDamage
}
enemiesDict[slime]=stats

View File

@ -2,7 +2,6 @@ class_name Player extends CharacterBody2D
signal pushSignal(body, direction)
signal shootSignal(markerPosition, speed)
signal fireSignal(markerPosition, direction, speed)
signal deathAnimationCompleteSignal
@onready var right_cast: RayCast2D = $RightCast
@onready var left_cast: RayCast2D = $LeftCast
@onready var right_spawn: Marker2D = $RightSpawn
@ -20,24 +19,18 @@ const JUMP_VELOCITY = -400.0
enum FaceDirection {RIGHT,LEFT}
var facing:FaceDirection = FaceDirection.RIGHT
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING,CHARGING,SHOVING,HURT,DEAD}
enum PlayerStates {IDLE,RUNNING,JUMPING,FALLING,CHARGING,SHOVING}
var current_player_state:PlayerStates = PlayerStates.IDLE
var upJump:bool = false
func _physics_process(delta: float) -> void:
if current_player_state != PlayerStates.DEAD:
handle_input()
handle_input()
handle_movement(delta)
handle_states()
handle_animation()
move_and_slide()
handle_collisions()
func hurt(playerHealth,maxHealth)->void:
current_player_state = PlayerStates.HURT
func kill()->void:
current_player_state = PlayerStates.DEAD
func handle_input()->void:
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
@ -46,7 +39,7 @@ func handle_input()->void:
upJump = true
# Handle shove.
if Input.is_action_just_pressed("shove"):
print("I want to shove")
if pushRightEnabled and facing==FaceDirection.RIGHT:
current_player_state= PlayerStates.CHARGING
pushTimer = Time.get_ticks_msec()
@ -67,7 +60,7 @@ func handle_input()->void:
current_player_state = PlayerStates.SHOVING
#Handle Shoot Bullet
if Input.is_action_just_pressed("shoot"):
print("Ima shoot a bullet")
#marker postion, speed
match facing:
FaceDirection.RIGHT:
@ -76,7 +69,7 @@ func handle_input()->void:
shootSignal.emit(left_spawn.global_transform, -800)
#Handle fire rocket
if Input.is_action_just_pressed("fire"):
print("Ima fire rocket")
match facing:
FaceDirection.RIGHT:
fireSignal.emit(right_spawn.global_transform,Vector2(1,0), 800)
@ -102,7 +95,7 @@ func handle_movement(delta)->void:
velocity += get_gravity() * delta
func handle_collisions()->void:
if right_cast.is_colliding():
print("Right raycast collision")
var collider = right_cast.get_collider()
if collider is Node:
pushRightEnabled = true
@ -111,7 +104,7 @@ func handle_collisions()->void:
pushRightEnabled = false
if left_cast.is_colliding():
print("Left raycast collision")
var collider = left_cast.get_collider()
if collider is Node:
pushLeftEnabled = true
@ -155,10 +148,6 @@ func handle_animation()->void:
player_graphic.play("charging")
PlayerStates.SHOVING:
player_graphic.play("shoving")
PlayerStates.HURT:
player_graphic.play("hurt")
PlayerStates.DEAD:
player_graphic.play("dying")
func _on_animation_finished() -> void:
@ -167,7 +156,3 @@ func _on_animation_finished() -> void:
upJump = false
PlayerStates.SHOVING:
current_player_state = PlayerStates.IDLE
PlayerStates.HURT:
current_player_state = PlayerStates.IDLE
PlayerStates.DEAD:
deathAnimationCompleteSignal.emit()

View File

@ -1,9 +0,0 @@
class_name CharacterStats extends Resource
@export var currentHealth := 100
@export var maxHealth := 150
@export var startingHealth:int = 100
#damage
@export var meleeDamage:int = 20
@export var rangeDamage:int = 15

View File

@ -1 +0,0 @@
uid://cye1467wwip7u

View File

@ -1,10 +0,0 @@
[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://dt55hoe718r1x"]
[ext_resource type="Script" uid="uid://cye1467wwip7u" path="res://scripts/rscs/characterstats.gd" id="1_sqkfu"]
[resource]
script = ExtResource("1_sqkfu")
maxHealth = 200
meleeDamage = 30
rangeDamage = 20
metadata/_custom_type_script = "uid://cye1467wwip7u"

View File

@ -1,11 +0,0 @@
[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://c0ghdtxe11f0"]
[ext_resource type="Script" uid="uid://cye1467wwip7u" path="res://scripts/rscs/characterstats.gd" id="1_ppipo"]
[resource]
script = ExtResource("1_ppipo")
currentHealth = 60
maxHealth = 80
startingHealth = 60
rangeDamage = 0
metadata/_custom_type_script = "uid://cye1467wwip7u"

View File

@ -1,10 +1,7 @@
extends Node2D
@onready var game: GameController = $".."
@onready var crates: Node2D = $"../Crates"
@onready var player: Player = $"../Player"
@onready var coin: Coin = $"../Coins/Coin"
@onready var coins: Node2D = $"../Coins"
@onready var enemies: Node2D = $"../Enemies"
var bullet = preload("res://scenes/bullet.tscn")
var rocket = preload("res://scenes/rocket.tscn")
@ -16,22 +13,15 @@ var totalAllowedRockets:int = 3
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Gamecontroller.reset()
#signals from the view
player.pushSignal.connect(pushTarget)
player.shootSignal.connect(makeBullet)
player.fireSignal.connect(makeRocket)
player.deathAnimationCompleteSignal.connect(Gamecontroller.levelChange)
#signals from the GameController
Gamecontroller.destroySignal.connect(destroy)
Gamecontroller.fanTriggerSignal.connect(pushTarget)
Gamecontroller.teleportTriggerSignal.connect(teleportTarget)
Gamecontroller.playerHurtSignal.connect(player.hurt)
Gamecontroller.playerDeadSignal.connect(player.kill)
#signals from pickups
coin.coinCollectedSignal.connect(Gamecontroller.coinCollected)
game.destroySignal.connect(destroy)
game.fanTriggerSignal.connect(pushTarget)
game.teleportTriggerSignal.connect(teleportTarget)
buildLevel()
@ -42,8 +32,6 @@ func _process(delta: float) -> void:
func buildLevel()->void:
#tell GC how many crates...
updateCrates()
updateCoins()
updateEnemies()
func updateCrates()->void:
var totalCrates = 0
@ -54,29 +42,8 @@ func updateCrates()->void:
obj.tree_exited.connect(updateCrates)
totalCrates +=1
Gamecontroller.crateTotal(totalCrates)
game.crateTotal(totalCrates)
func updateCoins()->void:
var totalCoins = 0
if coins:
for obj in coins.get_children():
if obj is Coin:
if not obj.tree_exited.is_connected(updateCoins):
obj.tree_exited.connect(updateCoins)
if not obj.coinCollectedSignal.is_connected(Gamecontroller.coinCollected):
obj.coinCollectedSignal.connect(Gamecontroller.coinCollected)
totalCoins +=1
Gamecontroller.coinTotal(totalCoins)
func updateEnemies()->void:
var totalEnemies = 0
if enemies:
for obj in enemies.get_children():
if obj is Slime:
Gamecontroller.addEnemyToLevel(obj)
obj.slimeDamageSignal.connect(Gamecontroller.slimeAttack)
totalEnemies +=1
Gamecontroller.totalEnemies(totalEnemies)
func pushTarget(body,pushDirection)->void:
if body is RigidBody2D:
body.apply_central_impulse(pushDirection)
@ -110,8 +77,8 @@ func bulletFactory()->Bullet:
#make a new bullet
myBullet = bullet.instantiate()
add_sibling(myBullet)
if not myBullet.bulletHitSignal.is_connected(Gamecontroller.bulletDamage):
myBullet.bulletHitSignal.connect(Gamecontroller.bulletDamage)
if not myBullet.bulletHitSignal.is_connected(game.bulletDamage):
myBullet.bulletHitSignal.connect(game.bulletDamage)
else:
myBullet = bulletArray.pop_back()
@ -138,6 +105,6 @@ func makeRocket(spawnPosition, direction, speed)->void:
print("make a rocket")
var myRocket:Rocket = rocketFactory()
myRocket.splodeSignal.connect(destroy)
myRocket.impactSignal.connect(Gamecontroller.rocketDamage)
myRocket.impactSignal.connect(game.rocketDamage)
myRocket.transform = spawnPosition
pushTarget(myRocket,direction*speed)

View File

@ -1,31 +0,0 @@
class_name Slime extends Area2D
@onready var right_cast: RayCast2D = $RightCast
@onready var right_down_cast: RayCast2D = $RightDownCast
@onready var left_down_cast: RayCast2D = $LeftDownCast
@onready var left_cast: RayCast2D = $LeftCast
@onready var slime_graphic: AnimatedSprite2D = $SlimeGraphic
signal slimeDamageSignal(body,slime)
@export var speed:int = 100
var direction = 1
func _process(delta: float) -> void:
if not right_down_cast.is_colliding():
direction =-1
slime_graphic.flip_h = true
if not left_down_cast.is_colliding():
direction = 1
slime_graphic.flip_h = false
if right_cast.is_colliding() && not right_cast.get_collider() is Player:
direction = -1
slime_graphic.flip_h = true
if left_cast.is_colliding() && not left_cast.get_collider() is Player:
direction = 1
slime_graphic.flip_h = false
position.x += direction*speed*delta
func _on_body_entered(body: Node2D) -> void:
if body is Player:
slimeDamageSignal.emit(body,self)

View File

@ -1 +0,0 @@
uid://d215jspbbgtq6