diff --git a/Assets/Sprites/Bunny/bad_bunny_spritesheet.png b/Assets/Sprites/Bunny/bad_bunny_spritesheet.png new file mode 100644 index 0000000..dccef6d Binary files /dev/null and b/Assets/Sprites/Bunny/bad_bunny_spritesheet.png differ diff --git a/Assets/Sprites/EvilBunny/bunny_left.png.import b/Assets/Sprites/Bunny/bad_bunny_spritesheet.png.import similarity index 64% rename from Assets/Sprites/EvilBunny/bunny_left.png.import rename to Assets/Sprites/Bunny/bad_bunny_spritesheet.png.import index 61153c5..a8c77f8 100644 --- a/Assets/Sprites/EvilBunny/bunny_left.png.import +++ b/Assets/Sprites/Bunny/bad_bunny_spritesheet.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dbelgiv204e2b" -path="res://.godot/imported/bunny_left.png-78242bd12e7c1e446aa544882eb0c11c.ctex" +uid="uid://df2fluk0dlqar" +path="res://.godot/imported/bad_bunny_spritesheet.png-8145cd27d7de497a043aedfca5238e73.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/Sprites/EvilBunny/bunny_left.png" -dest_files=["res://.godot/imported/bunny_left.png-78242bd12e7c1e446aa544882eb0c11c.ctex"] +source_file="res://Assets/Sprites/Bunny/bad_bunny_spritesheet.png" +dest_files=["res://.godot/imported/bad_bunny_spritesheet.png-8145cd27d7de497a043aedfca5238e73.ctex"] [params] diff --git a/Assets/Sprites/Bunny/good_bunny_spritesheet.png b/Assets/Sprites/Bunny/good_bunny_spritesheet.png new file mode 100644 index 0000000..2b1b04c Binary files /dev/null and b/Assets/Sprites/Bunny/good_bunny_spritesheet.png differ diff --git a/Assets/Sprites/Bunny/good_bunny_spritesheet.png.import b/Assets/Sprites/Bunny/good_bunny_spritesheet.png.import new file mode 100644 index 0000000..ee82786 --- /dev/null +++ b/Assets/Sprites/Bunny/good_bunny_spritesheet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c54k7fn4fu42s" +path="res://.godot/imported/good_bunny_spritesheet.png-32ea29d3519f9bb76fce73fda32cc4c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Sprites/Bunny/good_bunny_spritesheet.png" +dest_files=["res://.godot/imported/good_bunny_spritesheet.png-32ea29d3519f9bb76fce73fda32cc4c7.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 diff --git a/Assets/Sprites/EvilBunny/bunny_down.png b/Assets/Sprites/EvilBunny/bunny_down.png deleted file mode 100644 index a80fdc6..0000000 Binary files a/Assets/Sprites/EvilBunny/bunny_down.png and /dev/null differ diff --git a/Assets/Sprites/EvilBunny/bunny_left.png b/Assets/Sprites/EvilBunny/bunny_left.png deleted file mode 100644 index 82ec294..0000000 Binary files a/Assets/Sprites/EvilBunny/bunny_left.png and /dev/null differ diff --git a/Assets/Sprites/EvilBunny/bunny_righ.png b/Assets/Sprites/EvilBunny/bunny_righ.png deleted file mode 100644 index f791943..0000000 Binary files a/Assets/Sprites/EvilBunny/bunny_righ.png and /dev/null differ diff --git a/Assets/Sprites/EvilBunny/bunny_up.png b/Assets/Sprites/EvilBunny/bunny_up.png deleted file mode 100644 index 57c361f..0000000 Binary files a/Assets/Sprites/EvilBunny/bunny_up.png and /dev/null differ diff --git a/Assets/Sprites/Jesus/jesus_down.ase b/Assets/Sprites/Jesus/jesus_down.ase new file mode 100644 index 0000000..a8f338a Binary files /dev/null and b/Assets/Sprites/Jesus/jesus_down.ase differ diff --git a/Assets/Sprites/Jesus/jesus_left.ase b/Assets/Sprites/Jesus/jesus_left.ase new file mode 100644 index 0000000..52e51f1 Binary files /dev/null and b/Assets/Sprites/Jesus/jesus_left.ase differ diff --git a/Assets/Sprites/Jesus/jesus_right.ase b/Assets/Sprites/Jesus/jesus_right.ase new file mode 100644 index 0000000..ed17a21 Binary files /dev/null and b/Assets/Sprites/Jesus/jesus_right.ase differ diff --git a/Assets/Sprites/Jesus/jesus_spritesheet.png b/Assets/Sprites/Jesus/jesus_spritesheet.png new file mode 100644 index 0000000..ab9a19d Binary files /dev/null and b/Assets/Sprites/Jesus/jesus_spritesheet.png differ diff --git a/Assets/Sprites/EvilBunny/bunny_down.png.import b/Assets/Sprites/Jesus/jesus_spritesheet.png.import similarity index 65% rename from Assets/Sprites/EvilBunny/bunny_down.png.import rename to Assets/Sprites/Jesus/jesus_spritesheet.png.import index 35c0d3c..8ccd198 100644 --- a/Assets/Sprites/EvilBunny/bunny_down.png.import +++ b/Assets/Sprites/Jesus/jesus_spritesheet.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://tv804qpxy44n" -path="res://.godot/imported/bunny_down.png-65e2d347963ef39987488ab06970e3b7.ctex" +uid="uid://db70wcy5ua3jd" +path="res://.godot/imported/jesus_spritesheet.png-2f2e431acd4617eba93529f5420694c6.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/Sprites/EvilBunny/bunny_down.png" -dest_files=["res://.godot/imported/bunny_down.png-65e2d347963ef39987488ab06970e3b7.ctex"] +source_file="res://Assets/Sprites/Jesus/jesus_spritesheet.png" +dest_files=["res://.godot/imported/jesus_spritesheet.png-2f2e431acd4617eba93529f5420694c6.ctex"] [params] diff --git a/Assets/Sprites/Jesus/jesus_up.ase b/Assets/Sprites/Jesus/jesus_up.ase new file mode 100644 index 0000000..bea1fda Binary files /dev/null and b/Assets/Sprites/Jesus/jesus_up.ase differ diff --git a/Assets/Sprites/crucefix.png b/Assets/Sprites/crucefix.png new file mode 100644 index 0000000..05c087a Binary files /dev/null and b/Assets/Sprites/crucefix.png differ diff --git a/Assets/Sprites/EvilBunny/bunny_up.png.import b/Assets/Sprites/crucefix.png.import similarity index 67% rename from Assets/Sprites/EvilBunny/bunny_up.png.import rename to Assets/Sprites/crucefix.png.import index 2bbcfab..544c570 100644 --- a/Assets/Sprites/EvilBunny/bunny_up.png.import +++ b/Assets/Sprites/crucefix.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://coyib2evn5o61" -path="res://.godot/imported/bunny_up.png-9db830aab18c79505e343895a04cf789.ctex" +uid="uid://c5jj6s5orw6mi" +path="res://.godot/imported/crucefix.png-cb219c7b600f79e2811b5e89faa1becb.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/Sprites/EvilBunny/bunny_up.png" -dest_files=["res://.godot/imported/bunny_up.png-9db830aab18c79505e343895a04cf789.ctex"] +source_file="res://Assets/Sprites/crucefix.png" +dest_files=["res://.godot/imported/crucefix.png-cb219c7b600f79e2811b5e89faa1becb.ctex"] [params] diff --git a/Prefabs/bunny.tscn b/Prefabs/bunny.tscn new file mode 100644 index 0000000..38a08f2 --- /dev/null +++ b/Prefabs/bunny.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=3 uid="uid://cpl4tllohhyel"] + +[ext_resource type="Script" path="res://Scripts/EntitySystem/Bunny.gd" id="1_1kj2b"] +[ext_resource type="Texture2D" uid="uid://df2fluk0dlqar" path="res://Assets/Sprites/Bunny/bad_bunny_spritesheet.png" id="2_v8p70"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_sedmr"] + +[node name="Bunny" type="CharacterBody2D"] +scale = Vector2(0.5, 0.5) +collision_layer = 4 +collision_mask = 11 +script = ExtResource("1_1kj2b") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_v8p70") +hframes = 5 +vframes = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_sedmr") diff --git a/Prefabs/projectile.tscn b/Prefabs/projectile.tscn new file mode 100644 index 0000000..ad78eed --- /dev/null +++ b/Prefabs/projectile.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=4 format=3 uid="uid://csxh42o8twxwn"] + +[ext_resource type="Script" path="res://Scripts/WeaponSystem/Projectile.gd" id="1_os652"] +[ext_resource type="Texture2D" uid="uid://c5jj6s5orw6mi" path="res://Assets/Sprites/crucefix.png" id="2_ibs3t"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ki5cp"] +radius = 8.57143 +height = 22.8571 + +[node name="Projectile" type="Area2D"] +scale = Vector2(0.5, 0.5) +collision_layer = 8 +collision_mask = 5 +script = ExtResource("1_os652") +map_collision_layer = 1 +bunny_collision_layer = 4 + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_ibs3t") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CapsuleShape2D_ki5cp") + +[connection signal="body_entered" from="." to="." method="_on_collision"] diff --git a/Scenes/Test.tscn b/Scenes/Test.tscn index 2febfb7..3895f10 100644 --- a/Scenes/Test.tscn +++ b/Scenes/Test.tscn @@ -1,10 +1,165 @@ -[gd_scene load_steps=2 format=3 uid="uid://da014wltujtna"] +[gd_scene load_steps=16 format=3 uid="uid://cd45icxf4gxpp"] -[ext_resource type="Texture2D" uid="uid://dynqs8dq175ty" path="res://Assets/Sprites/bunny_left.png" id="1_m0oli"] +[ext_resource type="TileSet" uid="uid://bj7uu2180mie3" path="res://Assets/Tileset.tres" id="1_s4utw"] +[ext_resource type="Script" path="res://Scripts/MapGenerator.gd" id="2_yhpwh"] +[ext_resource type="Script" path="res://Scripts/EntitySystem/BunnyGenerator.gd" id="3_dvklj"] +[ext_resource type="PackedScene" uid="uid://cpl4tllohhyel" path="res://Prefabs/bunny.tscn" id="4_0fyd5"] +[ext_resource type="Script" path="res://Scripts/PlayerController.gd" id="5_uv7bh"] +[ext_resource type="Texture2D" uid="uid://db70wcy5ua3jd" path="res://Assets/Sprites/Jesus/jesus_spritesheet.png" id="6_es2l8"] +[ext_resource type="Script" path="res://Scripts/WeaponSystem/WeaponController.gd" id="7_8kdie"] +[ext_resource type="PackedScene" uid="uid://csxh42o8twxwn" path="res://Prefabs/projectile.tscn" id="8_wx0kk"] -[node name="Node2D" type="Node2D"] +[sub_resource type="Animation" id="Animation_kdxam"] +resource_name = "Idle" +length = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} -[node name="BunnyLeft" type="Sprite2D" parent="."] -position = Vector2(582, 355) -scale = Vector2(6.25553, 5.92647) -texture = ExtResource("1_m0oli") +[sub_resource type="Animation" id="Animation_dwpep"] +resource_name = "MoveDown" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = false +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [0, 1, 2, 3, 4, 5, 6, 7] +} + +[sub_resource type="Animation" id="Animation_2jvl5"] +resource_name = "MoveLeft" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [24, 25, 26, 27, 28, 29, 30, 31] +} + +[sub_resource type="Animation" id="Animation_4ig1u"] +resource_name = "MoveRight" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [8, 9, 10, 11, 12, 13, 14, 15] +} + +[sub_resource type="Animation" id="Animation_pswkh"] +resource_name = "MoveUp" +length = 0.8 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [16, 17, 18, 19, 20, 21, 22, 23] +} + +[sub_resource type="Animation" id="Animation_o3hln"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Player Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_bi1h3"] +_data = { +"Idle": SubResource("Animation_kdxam"), +"MoveDown": SubResource("Animation_dwpep"), +"MoveLeft": SubResource("Animation_2jvl5"), +"MoveRight": SubResource("Animation_4ig1u"), +"MoveUp": SubResource("Animation_pswkh"), +"RESET": SubResource("Animation_o3hln") +} + +[node name="Player Movement" type="Node2D"] + +[node name="Map Generator" type="TileMap" parent="."] +tile_set = ExtResource("1_s4utw") +cell_quadrant_size = 32 +format = 2 +script = ExtResource("2_yhpwh") +start_area_corner_size = 3 + +[node name="Bunny Generator" type="Node" parent="."] +script = ExtResource("3_dvklj") +bunny_prefab = ExtResource("4_0fyd5") + +[node name="Player" type="CharacterBody2D" parent="." node_paths=PackedStringArray("animation_player")] +position = Vector2(960, 512) +collision_layer = 0 +script = ExtResource("5_uv7bh") +speed = 60 +animation_player = NodePath("Player Animator") + +[node name="Player Sprite" type="Sprite2D" parent="Player"] +position = Vector2(0, -20) +texture = ExtResource("6_es2l8") +hframes = 8 +vframes = 4 + +[node name="Player Collider" type="CollisionPolygon2D" parent="Player"] +polygon = PackedVector2Array(12, 32, -16, 32, -16, -24, 12, -24) + +[node name="Player Camera" type="Camera2D" parent="Player"] +zoom = Vector2(5, 5) +position_smoothing_enabled = true +drag_horizontal_enabled = true +drag_vertical_enabled = true +editor_draw_drag_margin = true + +[node name="Player Animator" type="AnimationPlayer" parent="Player"] +libraries = { +"": SubResource("AnimationLibrary_bi1h3") +} + +[node name="WeaponController" type="Node2D" parent="Player"] +position = Vector2(0, -16) +script = ExtResource("7_8kdie") +projectile_prefab = ExtResource("8_wx0kk") diff --git a/Scripts/EntitySystem/Bunny.gd b/Scripts/EntitySystem/Bunny.gd new file mode 100644 index 0000000..f5a3040 --- /dev/null +++ b/Scripts/EntitySystem/Bunny.gd @@ -0,0 +1,26 @@ +extends CharacterBody2D +class_name Bunny + +@export var health : int + +var team : int + +var on_death_callbacks : Array + +func damage(damage : int): + health -= damage + if(health <= 0): on_death() + pass + +func heal(health : int): + self.health += health + pass + +func on_death(): + for callback in on_death_callbacks: + callback.call(self) + pass + +func sub_on_death(callback : Callable): + on_death_callbacks.push_front(callback) + pass diff --git a/Scripts/EntitySystem/BunnyGenerator.gd b/Scripts/EntitySystem/BunnyGenerator.gd new file mode 100644 index 0000000..71bcc9f --- /dev/null +++ b/Scripts/EntitySystem/BunnyGenerator.gd @@ -0,0 +1,17 @@ +extends Node + +@export var bunny_prefab : Resource +@onready var BunnyPrefab : PackedScene = load(bunny_prefab.resource_path) + +func spawn_bunny(x : float, y : float, team : int, health : int) -> Bunny: + var bunny = BunnyPrefab.instantiate() + self.add_child(bunny) + bunny.global_position = Vector2(x,y) + bunny.health = health + bunny.team = team + return bunny + +func _ready(): + var bunny = spawn_bunny(960, 512, TEAM.EVIL, 3) + bunny.sub_on_death(func(bunny): bunny.queue_free()) + diff --git a/Scripts/EntitySystem/TEAM.gd b/Scripts/EntitySystem/TEAM.gd new file mode 100644 index 0000000..ff383b8 --- /dev/null +++ b/Scripts/EntitySystem/TEAM.gd @@ -0,0 +1,5 @@ +class_name TEAM +enum { + EVIL = 0, + GOOD = 1 +} diff --git a/Scripts/WeaponSystem/Projectile.gd b/Scripts/WeaponSystem/Projectile.gd new file mode 100644 index 0000000..96a7755 --- /dev/null +++ b/Scripts/WeaponSystem/Projectile.gd @@ -0,0 +1,27 @@ +extends Area2D + +@export var speed : float = 250.0 +@export var damage : int = 1 + +@export_flags_2d_physics var map_collision_layer : int +@export_flags_2d_physics var bunny_collision_layer : int + +func _process(delta): + self.translate(Vector2(cos(self.rotation), sin(self.rotation)) * speed * delta) + pass + +func _on_collision(body): + var collision_layer = null; + + if body.get_class() == "TileMap": + collision_layer = body.tile_set.get_physics_layer_collision_layer(0) + if(body.has_method("get_collision_layer")): + collision_layer = body.get_collision_layer() + + if collision_layer & map_collision_layer: + queue_free() + if collision_layer & bunny_collision_layer: + var bunny = body as Bunny + bunny.damage(damage) + queue_free() + pass diff --git a/Scripts/WeaponSystem/WeaponController.gd b/Scripts/WeaponSystem/WeaponController.gd new file mode 100644 index 0000000..f3b93ec --- /dev/null +++ b/Scripts/WeaponSystem/WeaponController.gd @@ -0,0 +1,22 @@ +extends Node2D + +@export var projectile_prefab : Resource +@onready var projectilePrefab : PackedScene = load(projectile_prefab.resource_path) + +func _process(delta): + rotate_to_pointer() + + if Input.is_action_just_pressed("attack"): + spawn_projectile(self.global_position, self.rotation, 100, 1) + pass + +func rotate_to_pointer(): + look_at(get_global_mouse_position()) + #TODO Implement Joystick Aiming + +func spawn_projectile(pos : Vector2, dir : float, speed: float, damage : int): + var projectile = projectilePrefab.instantiate() + projectile.global_position = pos + projectile.rotation = dir + get_tree().root.add_child(projectile) + pass