mirror of
https://git.kittycat.homes/BatHeartTiger/untitled-plant-game.git
synced 2024-08-15 03:16:27 +00:00
all the things
This commit is contained in:
parent
ea85953f61
commit
612cb6652b
6 changed files with 36 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://World/Tree.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://World/Plant.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
|
|
||||||
[node name="Tree" parent="." instance=ExtResource( 1 )]
|
[node name="Plant" parent="." instance=ExtResource( 1 )]
|
||||||
|
|
8
World/Pixel.gd
Normal file
8
World/Pixel.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends ColorRect
|
||||||
|
var empty = true
|
||||||
|
var position = Vector2()
|
||||||
|
|
||||||
|
export var lighter_green = Color("#91e369")
|
||||||
|
export var light_green = Color("#56c157")
|
||||||
|
export var medium_green = Color("#46a65c")
|
||||||
|
export var dark_green = Color("#358859")
|
|
@ -1,9 +1,11 @@
|
||||||
[gd_scene format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://World/Pixel.gd" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Pixel" type="ColorRect"]
|
[node name="Pixel" type="ColorRect"]
|
||||||
margin_right = 1.0
|
margin_right = 1.0
|
||||||
margin_bottom = 1.0
|
margin_bottom = 1.0
|
||||||
color = Color( 0, 0, 0, 0 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,31 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
export var size = Vector2(128, 144)
|
export var size = Vector2(128, 144)
|
||||||
# 2 dimensional array y and x
|
# 2 dimensional array y and x
|
||||||
var pixels_y = []
|
var pixels_x = []
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
call_deferred("spawn_pixels")
|
call_deferred("spawn_pixels")
|
||||||
|
call_deferred("plant_seed")
|
||||||
|
|
||||||
func spawn_pixels():
|
func spawn_pixels():
|
||||||
for n in size.x:
|
for n in size.x:
|
||||||
var pixels_x = []
|
var pixels_y = []
|
||||||
for i in size.y:
|
for i in size.y:
|
||||||
var Main = get_tree().current_scene
|
var Main = get_tree().current_scene
|
||||||
var Pixel = preload("res://World/Pixel.tscn")
|
var Pixel = preload("res://World/Pixel.tscn")
|
||||||
var pixel = Pixel.instance()
|
var pixel = Pixel.instance()
|
||||||
# set position
|
# set position
|
||||||
pixel.rect_global_position = Vector2(n, i)
|
pixel.rect_global_position = Vector2(n, i)
|
||||||
|
pixel.position = Vector2(n, i)
|
||||||
# show in scene
|
# show in scene
|
||||||
Main.add_child(pixel)
|
Main.add_child(pixel)
|
||||||
# initilize array
|
# initilize array
|
||||||
pixels_y.append(pixel)
|
pixels_y.append(pixel)
|
||||||
pixels_x.append(pixels_y)
|
pixels_x.append(pixels_y)
|
||||||
|
|
||||||
|
func plant_seed():
|
||||||
|
var rect = pixels_x[size.x / 2][size.y - 8]
|
||||||
|
rect.color = rect.light_green
|
||||||
|
|
||||||
|
func grow():
|
||||||
|
pass
|
12
World/Plant.tscn
Normal file
12
World/Plant.tscn
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://World/Plant.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Plant" type="Node2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.25
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="grow"]
|
|
@ -1,6 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://World/Tree.gd" type="Script" id=2]
|
|
||||||
|
|
||||||
[node name="Tree" type="Node2D"]
|
|
||||||
script = ExtResource( 2 )
|
|
Loading…
Reference in a new issue