moved player raycast

This commit is contained in:
pennyrigate 2023-01-09 19:38:49 -05:00
parent bc5f2606a0
commit 416982d88e
20 changed files with 294 additions and 6 deletions

View file

@ -0,0 +1,3 @@
source_md5="e3faccac81a57b393e0b8825a7fd1a83"
dest_md5="de8e5d579635e1ee91db2d6b92c44407"

Binary file not shown.

View file

@ -1,3 +1,3 @@
source_md5="82f232cbd11bbebe6d1233db07f644d6" source_md5="f63c0b618e4029ab7db46130a39050bc"
dest_md5="5ae15f7f93ebb7667d6cf1268987bb99" dest_md5="5ae15f7f93ebb7667d6cf1268987bb99"

View file

@ -0,0 +1,3 @@
source_md5="fa736e12b5ad6e0b506c142da949c609"
dest_md5="7fb8e0d80191df521d68f774ae8d550d"

View file

@ -2,7 +2,7 @@
[ext_resource path="res://scripts/scaling.gd" type="Script" id=1] [ext_resource path="res://scripts/scaling.gd" type="Script" id=1]
[ext_resource path="res://graphics/borders/prideborder.png" type="Texture" id=2] [ext_resource path="res://graphics/borders/prideborder.png" type="Texture" id=2]
[ext_resource path="res://maps/map01.tscn" type="PackedScene" id=3] [ext_resource path="res://maps/cave.tscn" type="PackedScene" id=3]
[ext_resource path="res://scripts/crt.gdshader" type="Shader" id=4] [ext_resource path="res://scripts/crt.gdshader" type="Shader" id=4]
[sub_resource type="ShaderMaterial" id=1] [sub_resource type="ShaderMaterial" id=1]

BIN
graphics/enemy/snail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/snail.png-665b03ca99f23d92830cd36201ff3f05.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/enemy/snail.png"
dest_files=[ "res://.import/snail.png-665b03ca99f23d92830cd36201ff3f05.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=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 736 B

Before After
Before After

BIN
graphics/tiles/cave.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/cave.png-b16f6dab3533202eb4820e5dc612ba6f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/tiles/cave.png"
dest_files=[ "res://.import/cave.png-b16f6dab3533202eb4820e5dc612ba6f.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=true
svg/scale=1.0

54
maps/cave.tscn Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,41 @@
extends "res://objects/enemy/enemy.gd"
#How far to move
export var left_up_boundry = 0.0
export var right_down_boundry = 0.0
#Start direction
export var direction = 1
export var speed = 50
#Move horizontal or vertical
export(int, "Horizontal", "Vertical") var move_direction
export var flip_sprite = true
#Onreadys
onready var startpos = position
onready var sprite = $AnimatedSprite
func _physics_process(delta):
if move_direction == 0:
move_side_to_side(delta)
else: move_up_and_down(delta)
func move_side_to_side(delta):
#Move
position.x += direction * (speed * delta)
#Switch dir
if position.x >= startpos.x + (right_down_boundry * 8):
direction = -1
if flip_sprite == true: sprite.scale.x = -1
if position.x <= startpos.x + (-left_up_boundry * 8):
direction = 1
if flip_sprite == true: sprite.scale.x = 1
func move_up_and_down(delta):
#Move
position.y += direction * (speed * delta)
#Switch dir
if position.y >= startpos.y + (right_down_boundry * 8):
direction = -1
if flip_sprite == true: sprite.scale.y = 1
if position.y <= startpos.y + (-left_up_boundry * 8):
direction = 1
if flip_sprite == true: sprite.scale.y = -1

View file

@ -38,6 +38,7 @@ score_for_killing = 10
material = SubResource( 1 ) material = SubResource( 1 )
position = Vector2( 1, 3 ) position = Vector2( 1, 3 )
frames = SubResource( 4 ) frames = SubResource( 4 )
frame = 1
playing = true playing = true
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]

50
objects/enemy/snail.tscn Normal file
View file

@ -0,0 +1,50 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=1]
[ext_resource path="res://graphics/enemy/snail.png" type="Texture" id=2]
[ext_resource path="res://objects/enemy/enemy_move_sidesideupdown.gd" type="Script" id=3]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 1 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 12, 11 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 12, 0, 12, 11 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 4, 4 )
[node name="Snail" type="Node2D"]
script = ExtResource( 3 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = SubResource( 1 )
frames = SubResource( 4 )
frame = 1
playing = true
[node name="Area2D" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 0, 1 )
shape = SubResource( 5 )
[node name="RayCast2D" type="RayCast2D" parent="."]
cast_to = Vector2( 32, 0 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]

View file

@ -3,7 +3,7 @@
[ext_resource path="res://objects/ladder/ladder.gd" type="Script" id=1] [ext_resource path="res://objects/ladder/ladder.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 4 ) extents = Vector2( 8, 4 )
[node name="Ladder" type="Node2D"] [node name="Ladder" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )

View file

@ -238,7 +238,7 @@ func check_ladder():
#Start Climbing #Start Climbing
current_state = State.CLIMB current_state = State.CLIMB
#Move the raycast #Move the raycast
climb_ray.position.x = 4 * sprite.scale.x #climb_ray.position.x = 4 * sprite.scale.x
func die(): func die():
position = Game.respawn_point position = Game.respawn_point

View file

@ -627,8 +627,7 @@ position = Vector2( 0.5, 5 )
shape = SubResource( 39 ) shape = SubResource( 39 )
[node name="ClimbRay" type="RayCast2D" parent="."] [node name="ClimbRay" type="RayCast2D" parent="."]
visible = false position = Vector2( 0.5, 10 )
position = Vector2( 4, 10 )
enabled = true enabled = true
cast_to = Vector2( 0, -10 ) cast_to = Vector2( 0, -10 )
collision_mask = 4 collision_mask = 4

View file

@ -28,6 +28,10 @@ window/size/height=192
enabled=PoolStringArray( ) enabled=PoolStringArray( )
[global]
scene=false
[gui] [gui]
common/drop_mouse_on_gui_input_disabled=true common/drop_mouse_on_gui_input_disabled=true

63
tilesets/t_cave.tres Normal file
View file

@ -0,0 +1,63 @@
[gd_resource type="TileSet" load_steps=6 format=2]
[ext_resource path="res://graphics/tiles/cave.png" type="Texture" id=1]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 8, 6, 0, 6, 0, 0, 8, 0 )
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
[sub_resource type="ConvexPolygonShape2D" id=4]
points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
[resource]
0/name = "cave.png 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 32, 40 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 8, 8 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 1 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 4 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0