galo 2 rokov pred
rodič
commit
b7e02dffee
4 zmenil súbory, kde vykonal 96 pridanie a 56 odobranie
  1. 8 0
      Textures.gd
  2. 2 54
      enemie/monster.tscn
  3. 6 1
      enemiessprite.gd
  4. 80 1
      main.tscn

+ 8 - 0
Textures.gd

@@ -0,0 +1,8 @@
+extends Node
+
+var dict = {}
+
+func _ready():
+	for i in get_children():
+		dict[i.name] = i.get_texture()
+	pass # Replace with function body.

+ 2 - 54
enemie/monster.tscn

@@ -1,55 +1,3 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene format=2]
 
-[ext_resource path="res://art/Untitledcxz.png" type="Texture" id=1]
-
-[sub_resource type="AtlasTexture" id=1]
-atlas = ExtResource( 1 )
-region = Rect2( 0, 0, 112, 113 )
-
-[sub_resource type="AtlasTexture" id=2]
-atlas = ExtResource( 1 )
-region = Rect2( 112, 0, 112, 113 )
-
-[sub_resource type="AtlasTexture" id=3]
-atlas = ExtResource( 1 )
-region = Rect2( 224, 0, 112, 113 )
-
-[sub_resource type="AtlasTexture" id=4]
-atlas = ExtResource( 1 )
-region = Rect2( 336, 0, 112, 113 )
-
-[sub_resource type="SpriteFrames" id=5]
-animations = [ {
-"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ],
-"loop": true,
-"name": "goblin",
-"speed": 5.0
-} ]
-
-[sub_resource type="GDScript" id=6]
-script/source = "extends AnimatedSprite
-
-
-# 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():
-	speed_scale = rand_range(0.8,1.2)
-	pass # Replace with function body.
-
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-#	pass
-"
-
-[node name="monster" type="AnimatedSprite"]
-visible = false
-frames = SubResource( 5 )
-animation = "goblin"
-frame = 1
-playing = true
-script = SubResource( 6 )
+[node name="monster" type="Sprite"]

+ 6 - 1
enemiessprite.gd

@@ -9,7 +9,12 @@ var sprite = preload('res://enemie/monster.tscn')
 # Called when the node enters the scene tree for the first time.
 func _ready():
 	for i in 4096:
-		add_child(sprite.instance())
+		var add= sprite.instance()
+#		add.texture = get_node('../../Textures').dict['Goblin1']
+		var array = ['Goblin1','Goblin2','Goblin3','Goblin4']
+		array.shuffle()
+		add.texture = get_node('../../Textures').dict[array[0]]
+		add_child(add)
 	pass # Replace with function body.
 
 

+ 80 - 1
main.tscn

@@ -1,4 +1,4 @@
-[gd_scene load_steps=11 format=2]
+[gd_scene load_steps=18 format=2]
 
 [ext_resource path="res://Client.gd" type="Script" id=1]
 [ext_resource path="res://Server.gd" type="Script" id=2]
@@ -9,6 +9,32 @@
 [ext_resource path="res://enemiessprite.gd" type="Script" id=7]
 [ext_resource path="res://font/tiny.tres" type="DynamicFont" id=8]
 [ext_resource path="res://Debug.tscn" type="PackedScene" id=9]
+[ext_resource path="res://art/Untitledcxz.png" type="Texture" id=10]
+[ext_resource path="res://Textures.gd" type="Script" id=11]
+
+[sub_resource type="AtlasTexture" id=2]
+atlas = ExtResource( 10 )
+region = Rect2( 0, 0, 112, 113 )
+
+[sub_resource type="AtlasTexture" id=3]
+atlas = ExtResource( 10 )
+region = Rect2( 112, 0, 112, 113 )
+
+[sub_resource type="AtlasTexture" id=4]
+atlas = ExtResource( 10 )
+region = Rect2( 224, 0, 112, 113 )
+
+[sub_resource type="AtlasTexture" id=5]
+atlas = ExtResource( 10 )
+region = Rect2( 336, 0, 112, 113 )
+
+[sub_resource type="SpriteFrames" id=6]
+animations = [ {
+"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
+"loop": true,
+"name": "default",
+"speed": 5.0
+} ]
 
 [sub_resource type="GDScript" id=1]
 script/source = "extends Node
@@ -31,6 +57,59 @@ func _physics_process(delta):
 
 [node name="Node" type="Node"]
 
+[node name="Textures" type="Node" parent="."]
+script = ExtResource( 11 )
+
+[node name="Goblin1" type="Viewport" parent="Textures"]
+size = Vector2( 64, 64 )
+own_world = true
+transparent_bg = true
+render_target_v_flip = true
+
+[node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin1"]
+frames = SubResource( 6 )
+frame = 3
+playing = true
+offset = Vector2( 32, 32 )
+
+[node name="Goblin2" type="Viewport" parent="Textures"]
+size = Vector2( 64, 64 )
+own_world = true
+transparent_bg = true
+render_target_v_flip = true
+
+[node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin2"]
+frames = SubResource( 6 )
+frame = 2
+speed_scale = 0.8
+playing = true
+offset = Vector2( 32, 32 )
+
+[node name="Goblin3" type="Viewport" parent="Textures"]
+size = Vector2( 64, 64 )
+own_world = true
+transparent_bg = true
+render_target_v_flip = true
+
+[node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin3"]
+frames = SubResource( 6 )
+frame = 2
+speed_scale = 1.2
+playing = true
+offset = Vector2( 32, 32 )
+
+[node name="Goblin4" type="Viewport" parent="Textures"]
+size = Vector2( 64, 64 )
+own_world = true
+transparent_bg = true
+render_target_v_flip = true
+
+[node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin4"]
+frames = SubResource( 6 )
+speed_scale = 0.9
+playing = true
+offset = Vector2( 32, 32 )
+
 [node name="Server" type="Node" parent="."]
 script = ExtResource( 2 )
 database = NodePath("../Database")