urinal goes zoom

This commit is contained in:
Victor Turgeon 2023-01-15 13:01:14 -05:00
parent 3d1ef70baa
commit aac5728643
12 changed files with 246 additions and 24 deletions

View File

@ -4,7 +4,7 @@ extends CharacterBody2D
@export var ACCELERATION = 1000.0;
@export var FRICTION = 1500.0;
@export var HP = 100;
@export var DAMAGE = 34;
@export var DAMAGE = 10;
@export var COOLDOWN = 2;
@onready var raycast = $RayCast2D;

View File

@ -31,6 +31,7 @@ shape = SubResource("RectangleShape2D_47nt3")
target_position = Vector2(35, 0)
[node name="Line2D" type="Line2D" parent="RayCast2D"]
visible = false
points = PackedVector2Array(0, 0, 35, 0)
width = 5.0
default_color = Color(1, 0, 0, 0.392157)

59
Enemies/urinal_mimic.gd Normal file
View File

@ -0,0 +1,59 @@
extends CharacterBody2D
@export var MAX_SPEED = 500.0;
@export var ACCELERATION = 1000.0;
@export var FRICTION = 1500.0;
@export var HP = 1;
@export var DAMAGE = 25;
@export var COOLDOWN = 10;
@onready var raycast = $RayCast2D;
@onready var cooldown_timer = $CooldownTimer;
@onready var sprite = $AnimatedSprite2D;
var player = null;
var is_on_cooldown = false;
var attacking = false;
func _ready():
add_to_group("enemies");
func _physics_process(delta):
if player == null || !attacking:
return
var vec_to_player = player.global_position - global_position;
vec_to_player = vec_to_player.normalized();
raycast.rotation = atan2(vec_to_player.y,vec_to_player.x);
velocity = velocity.move_toward(vec_to_player * MAX_SPEED,ACCELERATION*delta);
move_and_slide();
if raycast.is_colliding():
var coll = raycast.get_collider();
if coll.name == "Player":
attack(coll);
func attack(collider):
collider.take_damage(DAMAGE);
kill()
func take_damage(damage):
HP = HP - damage;
if HP <= 0:
kill();
func kill():
queue_free();
func set_player(p):
player = p;
func _on_cooldown_timer_timeout():
is_on_cooldown = false;
func _on_area_2d_body_entered(body):
if body.name == "Player":
sprite.play("default");
func _on_animated_sprite_2d_animation_finished():
attacking = true;

103
Enemies/urinal_mimic.tscn Normal file
View File

@ -0,0 +1,103 @@
[gd_scene load_steps=14 format=3 uid="uid://p7aa6t787b3d"]
[ext_resource type="Script" path="res://Enemies/urinal_mimic.gd" id="1_2ga4k"]
[ext_resource type="Texture2D" uid="uid://clw15m8cxj22p" path="res://Sprites/Urinol.png" id="2_3n7wy"]
[ext_resource type="Texture2D" uid="uid://t2d8ft40y5c0" path="res://Sprites/Urinol_MIMIC.png" id="3_fjxqr"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rqcqj"]
atlas = ExtResource("3_fjxqr")
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_hcf1j"]
atlas = ExtResource("3_fjxqr")
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_smam5"]
atlas = ExtResource("3_fjxqr")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_mvcd5"]
atlas = ExtResource("3_fjxqr")
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_uyisr"]
atlas = ExtResource("3_fjxqr")
region = Rect2(256, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_r27p5"]
atlas = ExtResource("3_fjxqr")
region = Rect2(320, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_qbor8"]
atlas = ExtResource("3_fjxqr")
region = Rect2(384, 0, 64, 64)
[sub_resource type="SpriteFrames" id="SpriteFrames_e70cb"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_3n7wy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rqcqj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hcf1j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_smam5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mvcd5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uyisr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r27p5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qbor8")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jn4wv"]
size = Vector2(23, 21)
[sub_resource type="CircleShape2D" id="CircleShape2D_0y76e"]
radius = 120.037
[node name="urinal_mimic" type="CharacterBody2D"]
script = ExtResource("1_2ga4k")
[node name="RayCast2D" type="RayCast2D" parent="."]
target_position = Vector2(30, 0)
[node name="Line2D" type="Line2D" parent="RayCast2D"]
visible = false
points = PackedVector2Array(0, 0, 30, 0)
width = 4.0
default_color = Color(0.752941, 0, 0, 1)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(0, 21)
frames = SubResource("SpriteFrames_e70cb")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.5, -0.5)
shape = SubResource("RectangleShape2D_jn4wv")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 2
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_0y76e")
[node name="CooldownTimer" type="Timer" parent="."]
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]

View File

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta">
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.12">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View File

@ -0,0 +1,7 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>GameJamVanier</RootNamespace>
</PropertyGroup>
</Project>

View File

@ -18,6 +18,8 @@ animations = [{
size = Vector2(40, 64)
[node name="Player" type="CharacterBody2D"]
collision_layer = 3
collision_mask = 3
script = ExtResource("1_mbyc2")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]

BIN
Sprites/Urinol.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

34
Sprites/Urinol.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clw15m8cxj22p"
path="res://.godot/imported/Urinol.png-3d48a5dd6a4ef8c95cb84ee41f232b9e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Urinol.png"
dest_files=["res://.godot/imported/Urinol.png-3d48a5dd6a4ef8c95cb84ee41f232b9e.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
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/Urinol_MIMIC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://t2d8ft40y5c0"
path="res://.godot/imported/Urinol_MIMIC.png-edbfaed3e6aa9e657a1159072b3b4576.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Urinol_MIMIC.png"
dest_files=["res://.godot/imported/Urinol_MIMIC.png-edbfaed3e6aa9e657a1159072b3b4576.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
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

View File

@ -2,9 +2,9 @@
[ext_resource type="PackedScene" uid="uid://xev8p1td1icx" path="res://Player/player.tscn" id="1_51g8b"]
[ext_resource type="Texture2D" uid="uid://d3y4rna66nylu" path="res://TileSets/Tiles Set GameJam.png" id="2_xwre6"]
[ext_resource type="PackedScene" uid="uid://c661br4lh30r8" path="res://Enemies/basic_enemy.tscn" id="3_e1d3p"]
[ext_resource type="PackedScene" uid="uid://bbg5x0apue0ei" path="res://PickableItems/pickable_t_shirt.tscn" id="4_5egyc"]
[ext_resource type="PackedScene" uid="uid://degce2jvx3sli" path="res://PickableItems/pickable_shoes.tscn" id="5_4b36u"]
[ext_resource type="PackedScene" uid="uid://p7aa6t787b3d" path="res://Enemies/urinal_mimic.tscn" id="5_sfqul"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_aemot"]
resource_name = "Test"
@ -140,29 +140,11 @@ position = Vector2(67.9902, 68.8737)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(409, 497, 687, 497, 687, 367, 1681, 367, 1683, 639, 1967, 643, 1963, 85, 415, 85)
[node name="BasicEnemy" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(843, 709)
[node name="BasicEnemy2" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(1555, 856)
[node name="BasicEnemy3" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(1034, 520)
[node name="BasicEnemy4" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(774, -108)
[node name="BasicEnemy5" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(1383, -193)
[node name="BasicEnemy6" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(948, 660)
[node name="BasicEnemy7" parent="." instance=ExtResource("3_e1d3p")]
position = Vector2(1322, 618)
[node name="pickable_t_shirt" parent="." instance=ExtResource("4_5egyc")]
position = Vector2(172, 127)
[node name="shoes" parent="." instance=ExtResource("5_4b36u")]
position = Vector2(51, 155)
[node name="urinal_mimic" parent="." instance=ExtResource("5_sfqul")]
position = Vector2(704, 372)