add ooze movement

This commit is contained in:
fram3d 2024-06-09 17:51:43 +02:00
parent 3059cddacc
commit e7a3167e60
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
9 changed files with 121 additions and 30 deletions

View File

@ -1,12 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://NPCs/ooze.png" type="Texture" id=1]
[node name="Ooze" type="KinematicBody2D"]
[node name="ooze" type="Sprite" parent="."]
position = Vector2( -0.061738, 0.18198 )
texture = ExtResource( 1 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( 4.09251, -4.06066, 4.04832, 4.15946, -4.1276, 4.02687, -4.1718, -4.06066 )

View File

@ -2,7 +2,7 @@
[ext_resource path="res://NPCs/goblin.png" type="Texture" id=1]
[node name="Goblin" type="KinematicBody2D"]
[node name="goblin" type="KinematicBody2D"]
[node name="goblin" type="Sprite" parent="."]
position = Vector2( 0.380203, -0.127379 )

17
src/NPCs/moss.gd Normal file
View File

@ -0,0 +1,17 @@
extends Area2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@ -1,8 +1,13 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://NPCs/moss.png" type="Texture" id=1]
[ext_resource path="res://NPCs/moss.gd" type="Script" id=2]
[node name="Moss" type="StaticBody2D"]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5.3049, 5.46393 )
[node name="moss" type="Area2D"]
script = ExtResource( 2 )
[node name="moss" type="Sprite" parent="."]
position = Vector2( 0.110608, -0.127491 )
@ -10,3 +15,10 @@ texture = ExtResource( 1 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( -3.90663, -4.01647, -3.77405, 3.8501, 4.04832, 3.8059, 4.09251, -4.01647 )
[node name="Hitbox" type="Area2D" parent="."]
collision_layer = 2
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
shape = SubResource( 1 )

24
src/NPCs/ooze.gd Normal file
View File

@ -0,0 +1,24 @@
extends KinematicBody2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
pass

24
src/NPCs/ooze.tscn Normal file
View File

@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://NPCs/ooze.png" type="Texture" id=1]
[ext_resource path="res://NPCs/ooze.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4.91306, 4.99174 )
[node name="ooze" type="KinematicBody2D"]
script = ExtResource( 2 )
[node name="ooze" type="Sprite" parent="."]
position = Vector2( -0.061738, 0.18198 )
texture = ExtResource( 1 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( 4.09251, -4.06066, 4.04832, 4.15946, -4.1276, 4.02687, -4.1718, -4.06066 )
[node name="Hitbox" type="Area2D" parent="."]
collision_layer = 4
collision_mask = 2
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="Hitbox"]
shape = SubResource( 1 )

View File

@ -3,8 +3,8 @@
[ext_resource path="res://Tilesets/stone.png" type="Texture" id=1]
[ext_resource path="res://Tilesets/dirt.png" type="Texture" id=2]
[ext_resource path="res://Tilesets/water.png" type="Texture" id=3]
[ext_resource path="res://NPCs/Goblin.tscn" type="PackedScene" id=4]
[ext_resource path="res://NPCs/Ooze.tscn" type="PackedScene" id=5]
[ext_resource path="res://NPCs/goblin.tscn" type="PackedScene" id=4]
[ext_resource path="res://NPCs/ooze.tscn" type="PackedScene" id=5]
[ext_resource path="res://NPCs/moss.tscn" type="PackedScene" id=6]
[sub_resource type="ConvexPolygonShape2D" id=1]
@ -136,7 +136,6 @@ points = PoolVector2Array( 0, 0, 8, 0, 8, 8, 0, 8 )
[node name="World" type="Node2D"]
[node name="TileMap" type="TileMap" parent="."]
position = Vector2( 2, 0 )
tile_set = SubResource( 7 )
cell_size = Vector2( 8, 8 )
cell_quadrant_size = 8
@ -144,20 +143,23 @@ cell_custom_transform = Transform2D( 8, 0, 0, 8, 0, 0 )
format = 1
tile_data = PoolIntArray( 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 0, 4, 1, 0, 5, 1, 0, 6, 1, 0, 7, 1, 0, 8, 1, 0, 9, 1, 0, 65536, 1, 0, 65537, 0, 0, 65538, 0, 0, 65539, 0, 0, 65540, 2, 65537, 65541, 2, 65537, 65542, 2, 65537, 65543, 1, 0, 65544, 1, 0, 65545, 1, 0, 131072, 1, 0, 131073, 0, 0, 131074, 1, 0, 131075, 0, 0, 131076, 0, 0, 131077, 1, 0, 131078, 2, 65537, 131079, 1, 0, 131080, 1, 0, 131081, 1, 0, 196608, 1, 0, 196609, 0, 0, 196610, 1, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 2, 65537, 196615, 2, 65537, 196616, 2, 2, 196617, 1, 0, 262144, 1, 0, 262145, 0, 0, 262146, 1, 0, 262147, 0, 0, 262148, 0, 0, 262149, 1, 0, 262150, 2, 65536, 262151, 2, 65537, 262152, 2, 65538, 262153, 1, 0, 327680, 1, 0, 327681, 0, 0, 327682, 1, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 2, 65536, 327687, 2, 65537, 327688, 2, 65538, 327689, 1, 0, 393216, 1, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 2, 131072, 393223, 2, 131073, 393224, 2, 131074, 393225, 1, 0, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 0, 458756, 1, 0, 458757, 1, 0, 458758, 1, 0, 458759, 1, 0, 458760, 1, 0, 458761, 1, 0 )
[node name="Moss" parent="TileMap" instance=ExtResource( 6 )]
position = Vector2( 35.5938, 20.699 )
[node name="Moss2" parent="." instance=ExtResource( 6 )]
position = Vector2( 44, 44 )
[node name="Moss2" parent="TileMap" instance=ExtResource( 6 )]
position = Vector2( 44.5283, 44.7697 )
[node name="Moss" parent="." instance=ExtResource( 6 )]
position = Vector2( 37.5938, 20.699 )
[node name="Ooze" parent="TileMap" instance=ExtResource( 5 )]
position = Vector2( 27.8155, 44.3492 )
[node name="Moss3" parent="." instance=ExtResource( 6 )]
position = Vector2( 44, 52 )
[node name="Goblin" parent="TileMap" instance=ExtResource( 4 )]
position = Vector2( 13.9407, 21.5399 )
[node name="Ooze" parent="." instance=ExtResource( 5 )]
position = Vector2( 28, 44 )
[node name="Goblin2" parent="TileMap" instance=ExtResource( 4 )]
position = Vector2( 35.4887, 33.6278 )
[node name="Goblin" parent="." instance=ExtResource( 4 )]
position = Vector2( 12, 20 )
[node name="Ooze2" parent="TileMap" instance=ExtResource( 5 )]
position = Vector2( 35.3835, 52.6531 )
[node name="Goblin2" parent="." instance=ExtResource( 4 )]
position = Vector2( 28, 36 )
[node name="Ooze2" parent="." instance=ExtResource( 5 )]
position = Vector2( 36, 52 )

16
src/global.gd Normal file
View File

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -19,6 +19,10 @@ config/name="Fishtank"
run/main_scene="res://World.tscn"
config/icon="res://icon.png"
[autoload]
Global="*res://global.gd"
[display]
window/size/width=80
@ -29,6 +33,10 @@ window/size/test_width=1280
window/size/test_height=720
window/stretch/mode="2d"
[physics]
common/physics_fps=2
[rendering]
quality/driver/driver_name="GLES2"