fuelscen butn

This commit is contained in:
zoe 2021-12-04 16:14:06 +01:00
parent 612cb6652b
commit 570ad5f640
6 changed files with 100 additions and 12 deletions

View file

@ -0,0 +1,6 @@
extends Button
func _on_FullscreenButton_pressed() -> void:
OS.window_fullscreen = !OS.window_fullscreen

View file

@ -1,7 +1,21 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://World/Plant.tscn" type="PackedScene" id=1] [ext_resource path="res://World/Plant.tscn" type="PackedScene" id=1]
[ext_resource path="res://World/FullscreenButton.gd" type="Script" id=2]
[node name="Main" type="Node2D"] [node name="Main" type="Node2D"]
[node name="Plant" parent="." instance=ExtResource( 1 )] [node name="Plant" parent="." instance=ExtResource( 1 )]
[node name="FullscreenButton" type="Button" parent="."]
margin_left = 171.0
margin_top = 122.0
margin_right = 254.0
margin_bottom = 142.0
text = "fuelscren :)"
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="FullscreenButton" to="FullscreenButton" method="_on_FullscreenButton_pressed"]

View file

@ -1,8 +1,20 @@
extends ColorRect extends ColorRect
var empty = true var active = false
var position = Vector2() var position = Vector2()
var age = 0
export var lighter_green = Color("#91e369") export var colors = [
export var light_green = Color("#56c157") Color("#00ffffff"),
export var medium_green = Color("#46a65c") Color("#91e369"),
export var dark_green = Color("#358859") Color("#56c157"),
Color("#46a65c"),
Color("#358859")]
func age_up():
if !(age >= 4):
age += 1
color = colors[age]
active = true
func _ready() -> void:
color = colors[age]

View file

@ -1,9 +1,15 @@
extends Node2D extends Node2D
export var size = Vector2(128, 144) export var size = Vector2()
# 2 dimensional array y and x # 2 dimensional array y and x
var pixels_x = [] var pixels_x = []
var active = []
var rng
func _ready(): func _ready():
randomize()
rng = RandomNumberGenerator.new()
size.x = ProjectSettings.get_setting("display/window/size/width") / 2
size.y = ProjectSettings.get_setting("display/window/size/height")
call_deferred("spawn_pixels") call_deferred("spawn_pixels")
call_deferred("plant_seed") call_deferred("plant_seed")
@ -24,8 +30,24 @@ func spawn_pixels():
pixels_x.append(pixels_y) pixels_x.append(pixels_y)
func plant_seed(): func plant_seed():
var rect = pixels_x[size.x / 2][size.y - 8] var plant_seed = pixels_x[size.x / 2][size.y - 8]
rect.color = rect.light_green plant_seed.active = true
active.append(plant_seed)
func grow(): func grow():
pass if (randi() % 2) == 1:
new_pixel(active[active.size() - 1])
else:
new_pixel(active[randi() % active.size()])
func new_pixel(original_pixel):
var var_x = rng.randi_range(-1, 1)
var var_y = rng.randi_range(-1, 0)
var new_position = Vector2(original_pixel.position)
new_position.x = clamp(new_position.x + var_x, 0, pixels_x.size() - 1)
new_position.y = clamp(new_position.y + var_y, 0, pixels_x[new_position.x].size() - 1)
var new_pixel = pixels_x[new_position.x][new_position.y]
if !new_pixel.active:
active.append(new_pixel)
new_pixel.age_up()

View file

@ -6,7 +6,7 @@
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
wait_time = 0.25 wait_time = 0.001
autostart = true autostart = true
[connection signal="timeout" from="Timer" to="." method="grow"] [connection signal="timeout" from="Timer" to="." method="grow"]

34
export_presets.cfg Normal file
View file

@ -0,0 +1,34 @@
[preset.0]
name="HTML5"
platform="HTML5"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../plantGame/Untitled Plant Game.html"
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
variant/export_type=0
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color( 0, 0, 0, 1 )