From 1e9336a11dbc7077c25573dcd75deb62800a061d Mon Sep 17 00:00:00 2001 From: Logan Date: Sun, 19 Jul 2020 23:45:39 -0500 Subject: [PATCH] Added Ogre --- ai/Enemy.gd | 28 ++---------------------- ai/ogre.gd | 36 +++++++++++++++++++++++++++++++ ai/ogre.tscn | 46 ++++++++++++++++++++++++++++++++++++++++ art/Ogre_Run.png | Bin 0 -> 1087 bytes art/Ogre_Run.png.import | 34 +++++++++++++++++++++++++++++ levels/test.tscn | 6 +++++- project.godot | 26 ++++++++--------------- ui/Inventory.tscn | 3 +++ 8 files changed, 135 insertions(+), 44 deletions(-) create mode 100644 ai/ogre.gd create mode 100644 ai/ogre.tscn create mode 100644 art/Ogre_Run.png create mode 100644 art/Ogre_Run.png.import diff --git a/ai/Enemy.gd b/ai/Enemy.gd index e93d003..72dc6b6 100644 --- a/ai/Enemy.gd +++ b/ai/Enemy.gd @@ -3,41 +3,17 @@ extends KinematicBody2D class_name Enemy var speed = 60 -var gravity =500 +var gravity = 500 var health = 5 const UP = Vector2(0, -1) var velocity = Vector2() func get_type(): - return "player" + return "enemy" func apply_gravity(delta, modifier = 1): velocity.y += gravity * delta * modifier -func _physics_process(_delta): - var dist = global_position.distance_to(Globals.player) - if Globals.player != null: - if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player": - velocity = Vector2(0, 0) - elif $RayCast2D2.get_collider() != null && $RayCast2D2.get_collider().has_method("get_type") and $RayCast2D2.get_collider().get_type() == "player": - velocity = Vector2(0, 0) - elif $RayCast2D3.get_collider() != null && $RayCast2D3.get_collider().has_method("get_type") and $RayCast2D3.get_collider().get_type() == "player": - velocity = Vector2(0, 0) - elif $RayCast2D4.get_collider() != null && $RayCast2D4.get_collider().has_method("get_type") and $RayCast2D4.get_collider().get_type() == "player": - velocity = Vector2(0, 0) - if dist <= 400: - velocity.x = position.direction_to(Globals.player).normalized().x - else: - velocity = Vector2(0, 0) - apply_gravity(_delta) - velocity.x *= speed - velocity = move_and_slide(velocity, UP) - - #FOR FLIPPING THE SPRITE RIGHT AND LEFT DEPENDING ON WHICH WAY THEY FACING - #if velocity.x > 0: - # $(Enemy Sprite).flip_h = false - #elif velocity.x < 0: - # $(Enemy Sprite).flip_h = true if is_on_wall() and is_on_floor(): velocity.y = -150 diff --git a/ai/ogre.gd b/ai/ogre.gd new file mode 100644 index 0000000..d756dc2 --- /dev/null +++ b/ai/ogre.gd @@ -0,0 +1,36 @@ +extends Enemy + +var contact_damage = 0.5 + +onready var Spr = $Sprite +onready var DamageCD = $DamageCD + +func _ready(): + speed = 100 + +func _physics_process(delta): + var player = Globals.player + var distance = global_position.distance_to(player) + + if distance <= 400: + if player.x > global_position.x: + Spr.flip_h = false + velocity.x = speed + elif player.x < global_position.x: + Spr.flip_h = true + velocity.x = -speed + + if not is_on_floor(): + velocity.y = 10 + + var collision = move_and_collide(velocity) + if collision != null: + on_impact(collision) + +func on_impact(collision): + if collision.collider.has_method("get_type") && collision.collider.get_type() == "player": + if DamageCD.is_stopped(): + var c = collision.collider + c.set_health(c.get_health() - contact_damage) + DamageCD.start() + diff --git a/ai/ogre.tscn b/ai/ogre.tscn new file mode 100644 index 0000000..07c3560 --- /dev/null +++ b/ai/ogre.tscn @@ -0,0 +1,46 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://ai/ogre.gd" type="Script" id=1] +[ext_resource path="res://art/Ogre_Run.png" type="Texture" id=2] + +[sub_resource type="CapsuleShape2D" id=1] +height = 4.0 + +[sub_resource type="Animation" id=2] +resource_name = "Run" +length = 0.35 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("Sprite:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.1, 0.2, 0.3 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 1, +"values": [ 0, 1, 2, 3 ] +} + +[node name="Ogre" type="KinematicBody2D"] +collision_layer = 4 +collision_mask = 2147483651 +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 0, -17 ) +texture = ExtResource( 2 ) +hframes = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 1, -12 ) +shape = SubResource( 1 ) + +[node name="DamageCD" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +autoplay = "Run" +anims/Run = SubResource( 2 ) diff --git a/art/Ogre_Run.png b/art/Ogre_Run.png new file mode 100644 index 0000000000000000000000000000000000000000..d42a2ffd674eb110743bd77c0a410b94de844b23 GIT binary patch literal 1087 zcmV-F1i<@=P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5dZ)S5dnW>Uy%R+1Jp@GK~!i%?U*r( z6hRP$=S;lx0z(s*3oew+j0Fu$1@SK!i-NJB7~fwI!PG#(*laO8P}ami!C=!fT6yEV zrR=M!sqX378yG)mx_5TEs;gdg&+Hy-x7+4F(_z+vEEbDh@ay&Zpc`H)vlN6vJbr(@ zdAB-j?k&%oS9iZpLX<0AKN}#%$@AlO3=ts4l$g~Hp%_vG>=1DF?CT_U$Seg(sVxSN z#1fm65`=+R3{6@p2!sH&#o)84MCi!~q9u!g@iV9)N;j-31fUqCM3gK+WH2d1f}~s&BU%NQCW}H#`wWUA4Hd&HCXEtb^ntvvn7B(o#AZm4 zv4h!HvhLqnHp`pG&Fb^t1X;ZOv?>-~#!^zSVL`?WW*_#^(+7BZ`lju{i$@RIUS2B| z1i+s>g1Ji~HnV>iA|ND%4WH$;q13idv2&q_B_Qz-07A$kD?+azB@4@$Gp2pqXNiI9 zY(%>j1-@j%H3%WaNWa%`k1R~Y;!v6BQK>*4E7~>OAK9K`+NW&*8#s=nk3MjJ&ap** zus`J3HFt;%C!To+ZrB2!NIDzW&CedHAZc}xTEXng zzO)UPjN2zS+WyJIJ8mDrD=d#xM4}#9X+V7Y(2}Upx83(;AJ7)Wh9JD|f%_uImGnc~ z(jU>TSw1cZk|qn(3}$Tmz!M~g9MMrEXC9)mC*!F?+0W6yyo*PcLL_7T4P z`03goGX_5$TpPPF}Q-rK-kx$#6IprvP+H* z`ao5(Nm1l_qR2V9b2VH+KwkxLL8Xg{R@e|9#CjRXv5on#BZnG5)6QQ>8mJ_lXC>F$Ingy)wk7nV#RFj=uoQ@bGe*n)1wn|FJQ}pV^8$$oV$DzI zMv@kxR1ne^lO$rdNRZM*3<(}{yWx&nf^@@wxEw*6<_~m}OYuPaC5Zq4002ovPDHLk FV1m73=q>;N literal 0 HcmV?d00001 diff --git a/art/Ogre_Run.png.import b/art/Ogre_Run.png.import new file mode 100644 index 0000000..a44b10f --- /dev/null +++ b/art/Ogre_Run.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Ogre_Run.png-54e4b25ca8cf84d68d9ee78aad2faaee.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/Ogre_Run.png" +dest_files=[ "res://.import/Ogre_Run.png-54e4b25ca8cf84d68d9ee78aad2faaee.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 +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/levels/test.tscn b/levels/test.tscn index 27c3693..a970ad0 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -1,12 +1,16 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2] +[ext_resource path="res://ai/ogre.tscn" type="PackedScene" id=3] [node name="Node2D" type="Node2D"] [node name="Player" parent="." instance=ExtResource( 1 )] position = Vector2( 60, 176 ) +[node name="Ogre" parent="." instance=ExtResource( 3 )] +position = Vector2( 252, 170 ) + [node name="TileMap" parent="." instance=ExtResource( 2 )] tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 131077, 131092, 0, 131083, 196608, 0, 65544, 196609, 0, 131083, 196627, 0, 65544, 196628, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 262163, 0, 65544, 262164, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 327699, 0, 65544, 327700, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 393235, 0, 65544, 393236, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 458771, 0, 65544, 458772, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 524307, 0, 65544, 524308, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589843, 0, 65544, 589844, 0, 131083, 655360, 0, 65544, 655361, 0, 131083, 655379, 0, 65544, 655380, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 65541, 720916, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196619 ) diff --git a/project.godot b/project.godot index b93e2ae..7773123 100644 --- a/project.godot +++ b/project.godot @@ -45,7 +45,7 @@ _global_script_class_icons={ [application] config/name="Gamejam" -run/main_scene="res://Title/Tilte.tscn" +run/main_scene="res://levels/test.tscn" config/icon="res://icon.png" [autoload] @@ -55,6 +55,10 @@ IconLoaderGithub="*res://addons/github-integration/scripts/IconLoaderGithub.gd" RestHandler="*res://addons/github-integration/scripts/RestHandler.gd" Globals="*res://script/globals.gd" +[debug] + +settings/fps/force_fps=60 + [display] window/size/width=320 @@ -90,47 +94,32 @@ texture={ "stream": false, "svg/scale": 1.0 } -wav={ -"compress/mode": 0, -"edit/loop": true, -"edit/normalize": false, -"edit/trim": false, -"force/8_bit": false, -"force/max_rate": false, -"force/max_rate_hz": 44100, -"force/mono": false -} [input] up={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) ] } down={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) ] } left={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) ] } right={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) ] } shoot={ "deadzone": 0.5, -"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) ] } inventory={ @@ -141,11 +130,14 @@ inventory={ [layer_names] +2d_render/layer_1="Player" 2d_physics/layer_1="Player" +2d_render/layer_2="World" 2d_physics/layer_2="World" 2d_physics/layer_3="Enemy" 2d_physics/layer_4="Projectiles" [rendering] +quality/driver/fallback_to_gles2=true environment/default_environment="res://default_env.tres" diff --git a/ui/Inventory.tscn b/ui/Inventory.tscn index 07f7db2..e4b32b0 100644 --- a/ui/Inventory.tscn +++ b/ui/Inventory.tscn @@ -175,6 +175,9 @@ margin_left = -22.0 margin_top = 35.0 margin_right = 23.0 margin_bottom = 55.0 +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="pressed" from="Inventory/Conduits/Conduit1" to="." method="_on_Conduit1_toggled"] [connection signal="pressed" from="Inventory/Conduits/Conduit2" to="." method="_on_Conduit2_toggled"] [connection signal="pressed" from="Inventory/Conduits/Conduit3" to="." method="_on_Conduit3_toggled"]