From 8f1613ca0fab95fe837d9278e7829f70fb7bc934 Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 24 Apr 2017 02:23:37 +0200 Subject: That's it for today, Compo is gone but might make the Jam --- .gitignore | 2 + ...angle.png-81d9911a043b3b982b4bbd30d008317a.stex | Bin 0 -> 2963 bytes ...ngles.png-297de53c2012e22e0c9acb69bf5e0414.stex | Bin 0 -> 3544 bytes ...waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex | Bin 0 -> 4694 bytes assets/combinator.json | 20 +++ assets/events.json | 0 assets/howto.json | 10 ++ assets/incubator.json | 20 +++ assets/life.json | 20 +++ assets/shop.json | 123 +++++++++++--- assets/triangle.png | Bin 0 -> 2140 bytes assets/triangle.png.import | 20 +++ assets/triangle.svg | 108 ++++++++++++ assets/triangles.png | Bin 0 -> 2953 bytes assets/triangles.png.import | 20 +++ assets/triangles.svg | 43 +++++ assets/waves.png | Bin 0 -> 4068 bytes assets/waves.png.import | 20 +++ assets/waves.svg | 67 ++++++++ base.tscn | 23 +-- combinator.tscn | 14 +- combinator_panel.tscn | 6 +- export_presets.cfg | 2 +- gray_mat.tres | 7 +- hud.tscn | 181 +++++++++++++++------ incubator.tscn | 1 - ld38.godot | 6 +- out/html/index.html | 2 +- out/html/index.pck | Bin 288180 -> 454948 bytes out/html/indexfs.js | 2 +- scripts/base.gd | 13 +- scripts/builder.gd | 60 +++++++ scripts/combinator.gd | 21 +++ scripts/combinator_panel.gd | 72 +++++++- scripts/howto.gd | 15 ++ scripts/hud.gd | 51 +++--- scripts/items.gd | 53 +++++- scripts/messages.gd | 51 ++++++ scripts/multiverse_shop.gd | 33 ++-- scripts/player.gd | 25 ++- scripts/storage.gd | 66 +++----- scripts/template.gd | 30 ++++ scripts/template_combine.gd | 10 ++ scripts/template_incubate.gd | 4 + scripts/world.gd | 60 +++++-- world.tscn | 7 +- 46 files changed, 1067 insertions(+), 221 deletions(-) create mode 100644 .gitignore create mode 100644 .import/triangle.png-81d9911a043b3b982b4bbd30d008317a.stex create mode 100644 .import/triangles.png-297de53c2012e22e0c9acb69bf5e0414.stex create mode 100644 .import/waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex create mode 100644 assets/combinator.json create mode 100644 assets/events.json create mode 100644 assets/howto.json create mode 100644 assets/incubator.json create mode 100644 assets/life.json create mode 100644 assets/triangle.png create mode 100644 assets/triangle.png.import create mode 100644 assets/triangle.svg create mode 100644 assets/triangles.png create mode 100644 assets/triangles.png.import create mode 100644 assets/triangles.svg create mode 100644 assets/waves.png create mode 100644 assets/waves.png.import create mode 100644 assets/waves.svg create mode 100644 scripts/builder.gd create mode 100644 scripts/howto.gd create mode 100644 scripts/messages.gd create mode 100644 scripts/template.gd create mode 100644 scripts/template_combine.gd create mode 100644 scripts/template_incubate.gd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..311b276 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +out/linux/ +out/w64/ diff --git a/.import/triangle.png-81d9911a043b3b982b4bbd30d008317a.stex b/.import/triangle.png-81d9911a043b3b982b4bbd30d008317a.stex new file mode 100644 index 0000000..290358e Binary files /dev/null and b/.import/triangle.png-81d9911a043b3b982b4bbd30d008317a.stex differ diff --git a/.import/triangles.png-297de53c2012e22e0c9acb69bf5e0414.stex b/.import/triangles.png-297de53c2012e22e0c9acb69bf5e0414.stex new file mode 100644 index 0000000..f16fa85 Binary files /dev/null and b/.import/triangles.png-297de53c2012e22e0c9acb69bf5e0414.stex differ diff --git a/.import/waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex b/.import/waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex new file mode 100644 index 0000000..81676dd Binary files /dev/null and b/.import/waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex differ diff --git a/assets/combinator.json b/assets/combinator.json new file mode 100644 index 0000000..b4d41e0 --- /dev/null +++ b/assets/combinator.json @@ -0,0 +1,20 @@ +{ + "bases": [ + "Great, you have succesfully created a new planet! It has a mass of /mass/, it is mainly /type/.", + "Your new creation is ready master! A planet was created as you commanded. /mass_comment/ /type_comment/" + ], + "mass_comment": { + "very_small": "It's so tiny it's largest mountain almost covers it.", + "small": "A rather small planet.", + "medium": "", + "big": "", + "huge": "", + "yuge": "It is so YUGE! Something else must be small... Look at those hands. Are they small hands? And he referred to my hands, if they are small, something else must be small." + }, + "type_comment": { + "solid": "It is clearly solid, with a metallic core.", + "rock": "A rocky planet, like this one shouldn't get lost anywhere.", + "icy": "Consists largely of ice, which being a solid form of water, gives good chances to CHON based life forms.", + "gaseous": "Gaseous." + } +} diff --git a/assets/events.json b/assets/events.json new file mode 100644 index 0000000..e69de29 diff --git a/assets/howto.json b/assets/howto.json new file mode 100644 index 0000000..5705c81 --- /dev/null +++ b/assets/howto.json @@ -0,0 +1,10 @@ +{ + "title": "How it's Made: Planets", + "text": "The ultimate guide for any beginner but also experienced planet builder!\ +Covers all the bases, even the orthonormal ones.\ +\ +You definitely need some solid base, to create the planet's core, mantle and crust. If you want to have a chance at creating life, gaseous elements for your planet's atmosphere are a must have! You could also try to create a gaseous planet, or anything else really, if spaghetti monsters are your thing.\ +\ +Buy resources from the Multiverse shop, they have everything you will need to make a planet. Usually sold in batches of sextillion tons. +" +} diff --git a/assets/incubator.json b/assets/incubator.json new file mode 100644 index 0000000..568c1e8 --- /dev/null +++ b/assets/incubator.json @@ -0,0 +1,20 @@ +{ +"bases": [ + "" +] + +"misc": { + "schrodinger": [ + "Life on this planet possesses a weird property, even by Multiverse standards. It seems to be in a state between existing and not existing.", + "Cardboard boxes are a common occurence on this planet, everything seems to have them on. Oh god, even the molecules are in cardboard boxes!", + "" + ], + "trees": [ + "This planet is covered in trees full of solid rocket fuel. They grow to maturity, producing solid fuel in their trunks. When mature, they shed their branches apart from a few top, seed-bearing, ones and lift off, to seek another planet.", + "The smell of rocket fuel is very strong at the surface of the planet. It feels like it's evaporating from the trees.", + "" + ] +}, + + +} diff --git a/assets/life.json b/assets/life.json new file mode 100644 index 0000000..568c1e8 --- /dev/null +++ b/assets/life.json @@ -0,0 +1,20 @@ +{ +"bases": [ + "" +] + +"misc": { + "schrodinger": [ + "Life on this planet possesses a weird property, even by Multiverse standards. It seems to be in a state between existing and not existing.", + "Cardboard boxes are a common occurence on this planet, everything seems to have them on. Oh god, even the molecules are in cardboard boxes!", + "" + ], + "trees": [ + "This planet is covered in trees full of solid rocket fuel. They grow to maturity, producing solid fuel in their trunks. When mature, they shed their branches apart from a few top, seed-bearing, ones and lift off, to seek another planet.", + "The smell of rocket fuel is very strong at the surface of the planet. It feels like it's evaporating from the trees.", + "" + ] +}, + + +} diff --git a/assets/shop.json b/assets/shop.json index b50ee24..241bbd1 100644 --- a/assets/shop.json +++ b/assets/shop.json @@ -1,35 +1,103 @@ { - "1": [ + "solid": [ {"id": "low_planet_mat", "name": "Low-grade planetary material", "desc": "Buying this, you basically get bread crumbs from other recycled worlds.", - "cost": 10}, + "cost": 10, + "mass": 0.2, + "color": "#222034"}, {"id": "mid_planet_mat", "name": "Middle-grade planetary material", "desc": "While still recycled, it's previous owners didn't filter out all the good stuff.", - "cost": 30}, + "cost": 30, + "mass": 0.3, + "color": "#181910"}, {"id": "high_planet_mat", "name": "High-grade planetary material", "desc": "Made from worlds demolished to make way for a new hyperspatial express drive.", - "cost": 50}, + "cost": 50, + "mass": 0.4, + "color": "#151731"}, {"id": "top_planet_mat", "name": "Pristine planetary material", "desc": "Pretty much the only source of such high-quality planetary material comes from the underground. ", - "cost": 100}, + "cost": 100, + "mass": 0.5, + "color": "#321521"}, + {"id": "high_rad_mat", + "name": "Ionizing planetary material", + "desc": "", + "cost": 140, + "mass": 0.4, + "color": "#99e550"}, {"id": "low_inter_dust", "name": "Low-grade interplanetary dust", "desc": "Scraped of the bottom of some junkyard universe megaship, this really doesn't have much to offer.", - "cost": 20}, + "cost": 20, + "mass":0.3, + "color": "#323c39"}, {"id": "middle_inter_dust", "name": "Middle-grade interplanetary dust", "desc": "", - "cost": 40}, + "cost": 40, + "mass":0.4, + "color": "#3c3031"}, {"id": "high_inter_dust", "name": "High-grade interplanetary dust", - "desc": "Collected after a supernova, it contains many diverse elements.", - "cost": 80} + "desc": "Collected after a supernova, it contains many diverse solid and gaseous elements.", + "cost": 80, + "mass":0.5, + "color": "#453832"} ], - "2": [ + "gas": [ + {"id": "hydrogen", + "name": "Hydrogen", + "desc": "The most abundant element across the multi-verse, you can get it cheap.", + "cost": 5, + "mass": 0.1, + "volume": 1, + "color": "#202030"}, + {"id": "helium", + "name": "Helium", + "desc": "", + "cost": 10, + "mass": 0.1, + "volume": 1, + "color": "#202030"}, + {"id": "alpha_chlerixum", + "name": "Alpha Chlerixum", + "desc": "", + "cost": 15, + "mass": 0.1, + "volume": 1, + "color": "#451917"}, + {"id": "bllenerium", + "name": "Bllenerium", + "desc": "Extremely dense for a gas, in some universes it will definitely be considered a liquid.", + "cost": 20, + "mass": 0.5, + "volume": 1, + "color": "#101557"}, + {"id": "kataraxen", + "name": "Kataraxen", + "desc": "", + "cost": 25, + "mass": 0.1, + "volume": 1, + "color": "#075721"}, + {"id": "mystery_balloon", + "name": "Mystery balloon", + "desc": "It's just a small balloon, yet it is supposed to contain enough gases to fill out a whole planet's atmosphere?", + "cost": 30, + "mass": 0.1, + "volume": 1, + "color": "#152030"} + ], + "precursor": [ + {"id": "space_junk", + "name": "Space junk", + "desc": "", + "cost": 50}, {"id": "unknown_molecules", "name": "Unknown molecules", "desc": "The packaging looks leaky and the guarantee signs are all weird but you might take it for the price.", @@ -51,10 +119,10 @@ "desc": "", "cost": 500} ], - "3": [ + "life": [ {"id": "chon_life_1", "name": "CHON based life (level 1)", - "desc": "", + "desc": "The most common life forms among the multi-verse are CHON based, so you can get them in bulk.", "cost": 1000}, {"id": "chon_life_2", "name": "CHON based life (level 2)", @@ -64,17 +132,32 @@ "name": "Grey goo", "desc": "No one really told you what it is, they just sell it.", "cost": 2000}, + {"id": "plumbus", + "name": "Plumbus", + "desc": "Everyone has a plumbus in their home.\ +First they take the dingle bop and they smooth it out with a bunch of schleem.\ +The schleem is then repurposed for later batches.\ +They take the dingle bop and they push it through the grumbo, where the fleeb is rubbed against it.\ +It's important that the fleeb is rubbed, becasue the fleeb has all the fleeb juice.\ +Then, a schlami shows up, and he rubs it and spits on it.\ +They cut the fleeb. There's several hizzards in the way.\ +The blamfs rub against the chumbles, and the plubis, and grumbo are shaved away.\ +That leaves you with a regular old plumbus.", + "cost": 2500}, {"id": "cardboard_box", "name": "A cardboard box", "desc": "You might have heard some cat noises from the inside, although you can't be sure unless you open it.", - "cost": 3000} - ], - "other": [ - {"id": "planets_howto", - "name": "How it's Made: Planets", - "desc": "The ultimate guide for any beginner but also experienced planet builder!\ - Covers all the bases, even the orthonormal ones.", - "cost": 5} + "cost": 3000}, + {"id": "stage_trees", + "name": "A forest of weird trees", + "desc": "They seem oddly rocket shaped. They even have the inter-civilized safety markings.", + "cost": 3000}, + {"id": "spaghetti_monster", + "name": "A flying spaghetti monster", + "desc": "Hovering with barely audible noises of slurping sauce you are not even sure how it's legal to trade such a creature.", + "cost": 3500} ] } + + diff --git a/assets/triangle.png b/assets/triangle.png new file mode 100644 index 0000000..3127458 Binary files /dev/null and b/assets/triangle.png differ diff --git a/assets/triangle.png.import b/assets/triangle.png.import new file mode 100644 index 0000000..05bbde8 --- /dev/null +++ b/assets/triangle.png.import @@ -0,0 +1,20 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/triangle.png-81d9911a043b3b982b4bbd30d008317a.stex" + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=true +stream=false +size_limit=0 +detect_3d=true diff --git a/assets/triangle.svg b/assets/triangle.svg new file mode 100644 index 0000000..d09bc34 --- /dev/null +++ b/assets/triangle.svg @@ -0,0 +1,108 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/assets/triangles.png b/assets/triangles.png new file mode 100644 index 0000000..1b1829d Binary files /dev/null and b/assets/triangles.png differ diff --git a/assets/triangles.png.import b/assets/triangles.png.import new file mode 100644 index 0000000..d8872a2 --- /dev/null +++ b/assets/triangles.png.import @@ -0,0 +1,20 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/triangles.png-297de53c2012e22e0c9acb69bf5e0414.stex" + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=true +stream=false +size_limit=0 +detect_3d=true diff --git a/assets/triangles.svg b/assets/triangles.svg new file mode 100644 index 0000000..ce0edb5 --- /dev/null +++ b/assets/triangles.svg @@ -0,0 +1,43 @@ + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/assets/waves.png b/assets/waves.png new file mode 100644 index 0000000..4587446 Binary files /dev/null and b/assets/waves.png differ diff --git a/assets/waves.png.import b/assets/waves.png.import new file mode 100644 index 0000000..d34ace5 --- /dev/null +++ b/assets/waves.png.import @@ -0,0 +1,20 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/waves.png-eaf24c5101f895533f4d0df7d131e1c8.stex" + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=true +stream=false +size_limit=0 +detect_3d=true diff --git a/assets/waves.svg b/assets/waves.svg new file mode 100644 index 0000000..087c11e --- /dev/null +++ b/assets/waves.svg @@ -0,0 +1,67 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/base.tscn b/base.tscn index 14c7fd8..b34e738 100644 --- a/base.tscn +++ b/base.tscn @@ -1,12 +1,11 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://scripts/base.gd" type="Script" id=1] [ext_resource path="res://scripts/camera.gd" type="Script" id=2] -[ext_resource path="res://world.tscn" type="PackedScene" id=3] -[ext_resource path="res://incubator.tscn" type="PackedScene" id=4] -[ext_resource path="res://combinator.tscn" type="PackedScene" id=5] -[ext_resource path="res://hud.tscn" type="PackedScene" id=6] -[ext_resource path="res://player.tscn" type="PackedScene" id=7] +[ext_resource path="res://incubator.tscn" type="PackedScene" id=3] +[ext_resource path="res://combinator.tscn" type="PackedScene" id=4] +[ext_resource path="res://hud.tscn" type="PackedScene" id=5] +[ext_resource path="res://player.tscn" type="PackedScene" id=6] [sub_resource type="Animation" id=1] @@ -68,15 +67,11 @@ omni_attenuation = 1.0 omni_shadow_mode = 0 omni_shadow_detail = 1 -[node name="World" parent="." instance=ExtResource( 3 )] - -transform = Transform( 0.02, 0, 0, 0, 0.02, 0, 0, 0, 0.02, 0, 0, -2.81418 ) - -[node name="Incubator" parent="." instance=ExtResource( 4 )] +[node name="Incubator" parent="." instance=ExtResource( 3 )] transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, -5 ) -[node name="Combinator" parent="." instance=ExtResource( 5 )] +[node name="Combinator" parent="." instance=ExtResource( 4 )] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 0, 0 ) @@ -96,9 +91,9 @@ environment = null h_offset = 0.0 v_offset = 0.0 -[node name="HUD" parent="." instance=ExtResource( 6 )] +[node name="HUD" parent="." instance=ExtResource( 5 )] -[node name="Player" parent="." instance=ExtResource( 7 )] +[node name="Player" parent="." instance=ExtResource( 6 )] [node name="cmb2inc" type="Position3D" parent="."] diff --git a/combinator.tscn b/combinator.tscn index fb29e59..dd100e9 100644 --- a/combinator.tscn +++ b/combinator.tscn @@ -75,6 +75,10 @@ tracks/0/keys = { script = ExtResource( 2 ) +[node name="Cube" parent="."] + +material_override = ExtResource( 3 ) + [node name="StaticBody" type="StaticBody" parent="Cube"] input_ray_pickable = true @@ -135,7 +139,7 @@ size = Vector2( 400, 400 ) own_world = true world = null transparent_bg = false -msaa = 0 +msaa = 1 hdr = false disable_3d = false render_target_v_flip = true @@ -177,7 +181,7 @@ collision_mask = 1 [node name="Quad" type="Quad" parent="Area"] -transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0.955984, 0 ) +transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0.99, 0 ) layers = 1 material_override = SubResource( 4 ) cast_shadow = 1 @@ -205,7 +209,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.809103, 1.6303, -1.32872 ) [node name="point" type="Camera" parent="."] -transform = Transform( -3.09086e-08, -0.707107, 0.707107, -1.28028e-08, 0.707107, 0.707107, -1, 1.28028e-08, -3.09086e-08, 2.2, 3.5, 0 ) +transform = Transform( -2.45426e-08, -0.90859, 0.417688, -2.27357e-08, 0.417688, 0.90859, -1, 1.28028e-08, -3.09086e-08, 1.23998, 3.03074, 0 ) projection = 0 fov = 60.0 near = 0.1 @@ -219,10 +223,10 @@ v_offset = 0.0 [node name="bulb" type="OmniLight" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.17673, 2.26107, 1.77229 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.818578, 2.10295, -1.66632 ) layers = 1 light_color = Color( 1, 1, 1, 1 ) -light_energy = 4.0 +light_energy = 15.0 light_negative = false light_specular = 0.1 light_cull_mask = -1 diff --git a/combinator_panel.tscn b/combinator_panel.tscn index f7a46d7..db54e82 100644 --- a/combinator_panel.tscn +++ b/combinator_panel.tscn @@ -13,7 +13,7 @@ rect_clip_content = false mouse_filter = 0 script = ExtResource( 1 ) -[node name="Tree" type="Tree" parent="."] +[node name="tree" type="Tree" parent="."] margin_left = 10.0 margin_top = 10.0 @@ -55,7 +55,7 @@ flat = false margin_left = 350.0 margin_top = 20.0 -margin_right = 394.0 +margin_right = 396.0 margin_bottom = 193.0 rect_clip_content = false mouse_filter = 0 @@ -68,7 +68,7 @@ icon = ExtResource( 4 ) flat = false clip_text = true -[connection signal="gui_input" from="Tree" to="." method="_on_Tree_gui_input"] +[connection signal="gui_input" from="tree" to="." method="_on_Tree_gui_input"] [connection signal="pressed" from="add" to="." method="_on_add_pressed"] diff --git a/export_presets.cfg b/export_presets.cfg index 0f5ef08..0c75b90 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -13,7 +13,7 @@ runnable=true custom_template/debug="" custom_template/release="" html/head_include="" -options/memory_size=3 +options/memory_size=4 options/target=1 texture_format/etc=true texture_format/etc2=false diff --git a/gray_mat.tres b/gray_mat.tres index 88420a6..2800293 100644 --- a/gray_mat.tres +++ b/gray_mat.tres @@ -1,6 +1,4 @@ -[gd_resource type="SpatialMaterial" load_steps=2 format=2] - -[ext_resource path="res://assets/gray_tex.png" type="Texture" id=1] +[gd_resource type="SpatialMaterial" format=2] [resource] @@ -19,8 +17,7 @@ params_depth_draw_mode = 0 params_line_width = 1.0 params_point_size = 1.0 params_billboard_mode = 0 -albedo_color = Color( 0.507812, 0.474091, 0.474091, 1 ) -albedo_texture = ExtResource( 1 ) +albedo_color = Color( 0.519531, 0.485031, 0.485031, 1 ) specular_mode = 0 specular_color = Color( 0.0736863, 0, 0.0736863, 1 ) specular_metalness = 0.1 diff --git a/hud.tscn b/hud.tscn index f76ca3f..2d91118 100644 --- a/hud.tscn +++ b/hud.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://scripts/hud.gd" type="Script" id=1] [ext_resource path="res://scripts/multiverse_shop.gd" type="Script" id=2] [ext_resource path="res://scripts/storage.gd" type="Script" id=3] +[ext_resource path="res://scripts/howto.gd" type="Script" id=4] +[ext_resource path="res://scripts/messages.gd" type="Script" id=5] [node name="HUD" type="Node"] @@ -10,10 +12,10 @@ script = ExtResource( 1 ) [node name="ms_button" type="Button" parent="."] -margin_left = 620.0 -margin_top = 30.0 -margin_right = 752.0 -margin_bottom = 55.0 +margin_left = 5.0 +margin_top = 5.0 +margin_right = 137.0 +margin_bottom = 30.0 rect_clip_content = false hint_tooltip = "The best resources in the whole multi-verse!" mouse_filter = 0 @@ -26,6 +28,9 @@ flat = false [node name="ms" type="Control" parent="."] +visible = false +margin_left = -615.0 +margin_right = -615.0 rect_clip_content = false mouse_filter = 0 script = ExtResource( 2 ) @@ -33,9 +38,9 @@ script = ExtResource( 2 ) [node name="tabs" type="TabContainer" parent="ms"] margin_left = 620.0 -margin_top = 56.0 +margin_top = 31.0 margin_right = 893.0 -margin_bottom = 486.0 +margin_bottom = 459.0 rect_clip_content = false mouse_filter = 0 tab_align = 0 @@ -43,7 +48,6 @@ tabs_visible = true [node name="*" type="Tabs" parent="ms/tabs"] -editor/display_folded = true anchor_right = 1 anchor_bottom = 1 margin_left = 4.0 @@ -65,7 +69,6 @@ mouse_filter = 0 [node name="**" type="Tabs" parent="ms/tabs"] -editor/display_folded = true visible = false anchor_right = 1 anchor_bottom = 1 @@ -88,7 +91,6 @@ mouse_filter = 0 [node name="***" type="Tabs" parent="ms/tabs"] -editor/display_folded = true visible = false anchor_right = 1 anchor_bottom = 1 @@ -109,37 +111,31 @@ margin_right = 3.0 margin_bottom = 31.0 mouse_filter = 0 -[node name="other" type="Tabs" parent="ms/tabs"] +[node name="panel" type="Panel" parent="ms"] -editor/display_folded = true -visible = false -anchor_right = 1 -anchor_bottom = 1 -margin_left = 4.0 -margin_top = 32.0 -margin_right = 4.0 -margin_bottom = 4.0 +margin_left = 895.0 +margin_top = 55.0 +margin_right = 990.0 +margin_bottom = 460.0 rect_clip_content = false mouse_filter = 0 -[node name="items" type="Tree" parent="ms/tabs/other"] +[node name="Label" type="Label" parent="ms/panel"] anchor_right = 1 anchor_bottom = 1 -margin_left = 5.0 -margin_top = 5.0 -margin_right = 3.0 -margin_bottom = 31.0 -mouse_filter = 0 - -[node name="panel" type="Panel" parent="ms"] - -margin_left = 895.0 -margin_top = 80.0 -margin_right = 990.0 -margin_bottom = 485.0 +margin_left = -265.0 +margin_top = 375.0 +margin_right = 72.0 +margin_bottom = -1.0 +rect_scale = Vector2( 0.9, 0.9 ) rect_clip_content = false -mouse_filter = 0 +mouse_filter = 2 +size_flags_vertical = 0 +text = "Hint: mouse over an item for it's description." +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 [node name="buy" type="Button" parent="ms/panel"] @@ -160,10 +156,10 @@ flat = false [node name="storage_button" type="Button" parent="."] -margin_left = 755.0 -margin_top = 30.0 -margin_right = 814.0 -margin_bottom = 55.0 +margin_left = 757.0 +margin_top = 5.0 +margin_right = 816.0 +margin_bottom = 30.0 rect_clip_content = false mouse_filter = 0 toggle_mode = true @@ -175,7 +171,8 @@ flat = false [node name="storage" type="Control" parent="."] -visible = false +margin_left = 2.0 +margin_right = 2.0 rect_clip_content = false mouse_filter = 0 script = ExtResource( 3 ) @@ -183,9 +180,9 @@ script = ExtResource( 3 ) [node name="panel" type="Panel" parent="storage"] margin_left = 755.0 -margin_top = 55.0 -margin_right = 990.0 -margin_bottom = 485.0 +margin_top = 56.0 +margin_right = 1018.0 +margin_bottom = 460.0 rect_clip_content = false mouse_filter = 0 @@ -193,16 +190,16 @@ mouse_filter = 0 margin_left = 15.0 margin_top = 10.0 -margin_right = 220.0 -margin_bottom = 410.0 +margin_right = 252.0 +margin_bottom = 392.0 mouse_filter = 0 [node name="funds" type="PanelContainer" parent="."] -margin_left = 815.0 -margin_top = 28.0 -margin_right = 946.0 -margin_bottom = 57.0 +margin_left = 817.0 +margin_top = 3.0 +margin_right = 948.0 +margin_bottom = 32.0 rect_clip_content = false mouse_filter = 0 @@ -235,10 +232,100 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 +[node name="help_button" type="Button" parent="."] + +margin_left = 951.0 +margin_top = 5.0 +margin_right = 1020.0 +margin_bottom = 30.0 +rect_clip_content = false +mouse_filter = 0 +toggle_mode = true +enabled_focus_mode = 2 +shortcut = null +group = null +text = "HowTo" +flat = false + +[node name="help" type="Control" parent="."] + +margin_left = 2.0 +margin_right = 2.0 +rect_clip_content = false +mouse_filter = 0 +script = ExtResource( 4 ) + +[node name="panel" type="Panel" parent="help"] + +margin_left = 756.0 +margin_top = 56.0 +margin_right = 1018.0 +margin_bottom = 460.0 +rect_clip_content = false +mouse_filter = 0 + +[node name="text" type="RichTextLabel" parent="help/panel"] + +margin_left = 7.0 +margin_top = 8.0 +margin_right = 252.0 +margin_bottom = 394.0 +mouse_filter = 0 +bbcode_enabled = true +bbcode_text = "" +visible_characters = -1 + +[node name="messages" type="Control" parent="."] + +margin_left = 380.0 +margin_top = 10.0 +margin_right = 745.0 +margin_bottom = 460.0 +rect_clip_content = false +mouse_filter = 2 +size_flags_vertical = 0 +script = ExtResource( 5 ) + +[node name="combibator_button" type="Button" parent="."] + +margin_left = 5.0 +margin_top = 575.0 +margin_right = 91.0 +margin_bottom = 595.0 +rect_clip_content = false +mouse_filter = 0 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Combinator" +flat = false + +[node name="incubator_button" type="Button" parent="."] + +margin_left = 95.0 +margin_top = 575.0 +margin_right = 168.0 +margin_bottom = 595.0 +rect_clip_content = false +mouse_filter = 0 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Incubator" +flat = false + [connection signal="pressed" from="ms_button" to="." method="_on_ms_button_pressed"] [connection signal="pressed" from="ms/panel/buy" to="ms" method="_on_buy_pressed"] [connection signal="pressed" from="storage_button" to="." method="_on_storage_button_pressed"] +[connection signal="pressed" from="help_button" to="." method="_on_help_button_pressed"] + +[connection signal="pressed" from="combibator_button" to="." method="_on_combibator_button_pressed"] + +[connection signal="pressed" from="incubator_button" to="." method="_on_incubator_button_pressed"] + diff --git a/incubator.tscn b/incubator.tscn index 59f2e9d..0502071 100644 --- a/incubator.tscn +++ b/incubator.tscn @@ -374,7 +374,6 @@ script = ExtResource( 2 ) [node name="Cube" parent="."] -editor/display_folded = true material_override = ExtResource( 3 ) [node name="StaticBody" type="StaticBody" parent="Cube"] diff --git a/ld38.godot b/ld38.godot index 5f19ab0..d25ca70 100644 --- a/ld38.godot +++ b/ld38.godot @@ -1,7 +1,7 @@ config_version=3 [application] -name="World Factory^TM" +name="World Factory" main_scene="res://base.tscn" icon="res://icon.png" @@ -13,5 +13,7 @@ multithread/thread_rid_pool_prealloc=60 viewport/default_clear_color=Color( 0, 0, 0, 1 ) quality/msaa=1 -gles3/shadow_filter_mode=2 quality/hdr=false +threads/thread_model=2 +quality/anisotropic_filter_level=2.0 +reflections/high_quality_vct_gi=false diff --git a/out/html/index.html b/out/html/index.html index abd526e..36e1789 100644 --- a/out/html/index.html +++ b/out/html/index.html @@ -266,7 +266,7 @@ var module = { thisProgram: BASE_NAME, wasmBinaryFile: BASE_NAME + '.wasm', - TOTAL_MEMORY: 268435456, + TOTAL_MEMORY: 536870912, print: function print(text) { if (arguments.length > 1) { text = Array.prototype.slice.call(arguments).join(" "); diff --git a/out/html/index.pck b/out/html/index.pck index c426cc7..1be77f2 100644 Binary files a/out/html/index.pck and b/out/html/index.pck differ diff --git a/out/html/indexfs.js b/out/html/indexfs.js index d79a4a1..3d3a09f 100644 --- a/out/html/indexfs.js +++ b/out/html/indexfs.js @@ -8,7 +8,7 @@ if (!Module.expectedDataFileDownloads) { Module.expectedDataFileDownloads++; (function() { - const PACK_FILE_NAME = 'index.pck'; const PACK_FILE_SIZE = 288180; function fetchRemotePackage(packageName, callback, errback) { + const PACK_FILE_NAME = 'index.pck'; const PACK_FILE_SIZE = 454948; function fetchRemotePackage(packageName, callback, errback) { var xhr = new XMLHttpRequest(); xhr.open('GET', packageName, true); xhr.responseType = 'arraybuffer'; diff --git a/scripts/base.gd b/scripts/base.gd index 3d138d9..6b2bfd5 100644 --- a/scripts/base.gd +++ b/scripts/base.gd @@ -1,17 +1,15 @@ extends Node -var Game = preload("res://base.tscn") -var Wrld = preload("res://world.tscn") -var Incubator = preload("res://incubator.tscn") +const Wrld = preload("res://world.tscn") +const Builder = preload("res://scripts/builder.gd") var cam = null +var builder = null func _ready(): randomize() self.cam = get_node("Camera") - -func _process(delta): - pass + self.builder = Builder.new() func _input(event): if event.type == InputEvent.MOUSE_BUTTON: @@ -42,7 +40,8 @@ func _input(event): if s != null: get_node("Incubator").push_world(s) if event.scancode == KEY_N: - var w = Wrld.instance() + #var w = Wrld.instance() + var w = self.builder.combine(Vector3(0,0,0), []) w.set_scale(Vector3(0.02, 0.02, 0.02)) add_child(w) get_node("Incubator").push_world(w) diff --git a/scripts/builder.gd b/scripts/builder.gd new file mode 100644 index 0000000..9a43437 --- /dev/null +++ b/scripts/builder.gd @@ -0,0 +1,60 @@ +extends Object + +const Wrld = preload("res://world.tscn") +const Items = preload("res://scripts/items.gd") + +var items = null + +func _init(): + self.items = Items.new() + +func build(where): + var w = Wrld.instance() + w.set_scale(Vector3(0.02, 0.02, 0.02)) + w.set_translation(where) + return w + +func can_combine(materials): + var has_solid = false + var has_gas = false + for id in materials: + var category = self.items.category(id) + if category == "solid": + has_solid = true + if category == "gas": + has_gas = true + return has_solid and has_gas + +func combine(where, materials): + var w = build(where) + var mass = 0 + var volume = 0 + var color = Color(0.3,0.3,0.3) + var gas_mass = 0 + var gas_volume = 0 + var gas_color = Color(0.5,0.5,0.6,0.35) + + for mat in materials: + var item = self.items.get(mat) + var category = self.items.category(mat) + if category == "solid": + mass += item.data["mass"] + #volume += item.data["volume"] + var s = item.data["color"] + color = color.blend(Color(s)) + + if category == "gas": + gas_mass += item.data["mass"] + gas_volume += item.data["volume"] + var s = item.data["color"] + gas_color = gas_color.blend(Color(s)) + + w.materials = materials + w.mass = mass + w.volume = volume + w.color = color + w.gas_mass = gas_mass + w.gas_volume = gas_volume + w.gas_color = gas_color + w.call_deferred("build") + return w diff --git a/scripts/combinator.gd b/scripts/combinator.gd index 2bc7740..43ebe0b 100644 --- a/scripts/combinator.gd +++ b/scripts/combinator.gd @@ -1,11 +1,20 @@ extends Spatial +const Builder = preload("res://scripts/builder.gd") +const CombinatorTemplate = preload("res://scripts/template_combine.gd") + var prev_pos = null var panel = null +var world = null + +var templater = null +var builder = null func _ready(): get_node("Area/Quad").get_material_override().set_texture(SpatialMaterial.DIFFUSE_LAMBERT, get_node("Viewport").get_texture()) self.panel = get_node("Viewport/CombinatorPanel") + self.templater = CombinatorTemplate.new() + self.builder = Builder.new() set_process_input(true) func _on_Area_input_event( camera, event, click_pos, click_normal, shape_idx ): @@ -35,5 +44,17 @@ func _on_panel_input_event( camera, event, click_pos, click_normal, shape_idx ): if event.type == InputEvent.MOUSE_BUTTON and event.button_index == BUTTON_LEFT and event.is_pressed(): print("panel") get_node("animation").play("click") + var panel = get_node("Viewport/CombinatorPanel") + var ids = panel.get_ids() + var message = null + if ids != null and ids.size() > 0 and self.builder.can_combine(ids): + self.world = self.builder.combine(get_node("spawn").get_global_transform().origin, ids) + get_tree().get_root().get_node("Game").add_child(self.world) + panel.clear_all() + message = self.templater.template(self.world) + else: + message = "Cannot combine!" + get_tree().get_root().get_node("Game/HUD").display_message(message, 15) + \ No newline at end of file diff --git a/scripts/combinator_panel.gd b/scripts/combinator_panel.gd index c4822e8..65ba69b 100644 --- a/scripts/combinator_panel.gd +++ b/scripts/combinator_panel.gd @@ -1,10 +1,22 @@ extends Panel -var Items = preload("res://scripts/items.gd") +const Items = preload("res://scripts/items.gd") + var items = null +var tree func _ready(): self.items = Items.new() + self.tree = get_node("tree") + self.tree.create_item() + self.tree.set_columns(2) + self.tree.set_column_title(0, "Item") + self.tree.set_column_title(1, "Amount") + self.tree.set_column_titles_visible(true) + self.tree.set_column_expand(1, false) + self.tree.set_column_min_width(1,60) + self.tree.set_hide_root(true) + self.tree.set_select_mode(Tree.SELECT_ROW) set_process_input(true) func _input(event): @@ -14,8 +26,26 @@ func _on_Tree_gui_input( ev ): #print(ev) pass -func get_items(): - pass +func get_ids(): + var ids = [] + var root = self.tree.get_root() + if root == null: + return ids + var node = root.get_children() + while node != null: + ids.append(node.get_metadata(0)["id"]) + node = node.get_next() + return ids + +func clear_all(): + var root = self.tree.get_root() + if root == null: + return + var node = root.get_children() + while node != null: + root.remove_child(node) + node = node.get_next() + self.tree.update() func _on_add_pressed(): var player = get_tree().get_root().get_node("Game/Player") @@ -24,13 +54,37 @@ func _on_add_pressed(): print(player.storage) print(storage.get_selected()) - if player.has_item(storage.get_selected()): - print("has") - player.remove_item(storage.get_selected(), 1) + var item = storage.get_selected() + if item != null and player.has_item(item["id"]): + var itm = player.get_item(item["id"]) + player.remove_item(item["id"], 1) + var root = self.tree.get_root() + var line = itm.insert_in_tree(tree, root) + line.set_text(1, "1") func _on_remove_pressed(): - pass # replace with function body - + var player = get_tree().get_root().get_node("Game/Player") + var item = self.get_selected() + if item != null: + print(item) + var node = self.tree.get_selected() + node.deselect(0) + print(node) + var root = self.tree.get_root() + root.remove_child(node) + self.tree.update() + player.add_item(item["id"], 1) func _on_storage_pressed(): - get_tree().get_root().get_node("Game/HUD").popup_storage() + get_tree().get_root().get_node("Game/HUD").popup("storage") + +func get_selected(): + var root = self.tree.get_root() + if root == null: + return null + var itm = root.get_children() + while itm != null: + if itm.is_selected(0): + return itm.get_metadata(0) + itm = itm.get_next() + return null \ No newline at end of file diff --git a/scripts/howto.gd b/scripts/howto.gd new file mode 100644 index 0000000..1259174 --- /dev/null +++ b/scripts/howto.gd @@ -0,0 +1,15 @@ +extends Control + +var title +var text + +func _ready(): + var file = File.new() + file.open("res://assets/howto.json", File.READ) + var content = file.get_as_text() + file.close() + var data = parse_json(content) + self.title = data["title"] + self.text = data["text"] + get_node("panel/text").set_bbcode("[b]" + self.title + "[/b]\n\n" + self.text) + #get_node("panel/text").add_text(self.text) \ No newline at end of file diff --git a/scripts/hud.gd b/scripts/hud.gd index 80c58a0..dcf4c88 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -4,32 +4,41 @@ func _ready(): pass func _on_ms_button_pressed(): - var visible = get_node("ms").is_visible() - if visible: - get_node("ms").set_visible(false) - else: - popup_shop() + _toggle("ms") func _on_storage_button_pressed(): - var visible = get_node("storage").is_visible() - if visible: - get_node("storage").set_visible(false) - else: - popup_storage() + popup("storage") + +func _on_help_button_pressed(): + popup("help") -func _popup(which): - var tabs = ["ms", "storage"] - for tab in tabs: - get_node(tab).set_visible(tab == which) +func _toggle(which): + var visible = get_node(which).is_visible() + get_node(which).set_visible(!visible) -func popup_storage(): - _popup("storage") +func popup(which): + var tabs = ["storage", "help"] + for tab in tabs: + var vis = false + if tab == which: + vis = !get_node(tab).is_visible() + get_node(tab).set_visible(vis) -func popup_shop(): - _popup("ms") - func set_funds(cash): get_node("funds/cash").set_text(str(cash)) -func update_storage(storage): - get_node("storage").update_storage(storage) +func update_storage(id, amount): + get_node("storage").update_storage(id, amount) + +func display_message(message, time=5): + get_node("messages").display_message(message, time) + +func _on_combibator_button_pressed(): + var cam = get_tree().get_root().get_node("Game/Camera") + var combinator = get_tree().get_root().get_node("Game/Combinator") + cam.select(combinator, combinator.get_node("point")) + +func _on_incubator_button_pressed(): + var cam = get_tree().get_root().get_node("Game/Camera") + var incubator = get_tree().get_root().get_node("Game/Incubator") + cam.select(incubator, incubator.get_node("point")) diff --git a/scripts/items.gd b/scripts/items.gd index a6ca8be..e2a1106 100644 --- a/scripts/items.gd +++ b/scripts/items.gd @@ -1,5 +1,9 @@ extends Object +const icon_triangle = preload("res://assets/triangle.png") +const icon_waves = preload("res://assets/waves.png") +const icon_triangles = preload("res://assets/triangles.png") + var data = null func _init(): @@ -9,9 +13,54 @@ func _init(): file.close() self.data = parse_json(content) +class Item: + extends Object + + var data + var category + var icon + + func _init(category, data, icon): + self.category = category + self.data = data + self.icon = icon + + func id(): + return data["id"] + + func insert_in_tree(tree, parent=null): + var item = tree.create_item(parent) + item.set_text(0, data["name"]) + item.set_tooltip(0, data["desc"]) + item.set_metadata(0, data) + item.set_icon_max_width(0, 20) + if self.icon != null: + item.set_icon(0, self.icon) + return item + + func insert_in_shop(tree, parent=null): + var item = self.insert_in_tree(tree, parent) + item.set_text(1, str(data["cost"])) + +func _get_icon(category): + if category == "solid": + return self.icon_triangle + elif category == "gas": + return self.icon_waves + elif category == "precursor": + pass + elif category == "life": + return self.icon_triangles + func get(id): for cat in self.data.keys(): for item in self.data[cat]: if item["id"] == id: - return item - return null \ No newline at end of file + return Item.new(cat, item, self._get_icon(cat)) + return null + +func category(id): + for cat in self.data.keys(): + for item in self.data[cat]: + if item["id"] == id: + return cat \ No newline at end of file diff --git a/scripts/messages.gd b/scripts/messages.gd new file mode 100644 index 0000000..236ebd1 --- /dev/null +++ b/scripts/messages.gd @@ -0,0 +1,51 @@ +extends Control + +var count = 0 +var labels = [] +var runs = [] +var lengths = [] + +func _ready(): + set_process(true) + +func _process(delta): + var to_remove = [] + for i in range(count): + var run = runs[i] + var len = lengths[i] + var label = labels[i] + var far = run + delta + if far >= (3*len/4): + label.set_modulate(Color(1,1,1,0.3)) + elif far >= len/2: + label.set_modulate(Color(1,1,1,0.5)) + if far >= len: + to_remove.append(i) + else: + runs[i] += delta + for i in to_remove: + var label = labels[i] + remove_child(label) + label.queue_free() + labels.remove(i) + runs.remove(i) + lengths.remove(i) + count -= 1 + +func display_message(message, time): + var label = Label.new() + label.set_text(message) + add_child(label) + + if count > 0: + var offset = label.get_size().y + for i in range(count): + var lab = labels[i] + var lab_pos = lab.get_global_position() + lab_pos.y += offset + lab.set_global_position(lab_pos) + + labels.push_back(label) + runs.push_back(0) + lengths.push_back(time) + count+=1 \ No newline at end of file diff --git a/scripts/multiverse_shop.gd b/scripts/multiverse_shop.gd index 494ccd5..d4c32b0 100644 --- a/scripts/multiverse_shop.gd +++ b/scripts/multiverse_shop.gd @@ -1,16 +1,20 @@ extends Control -var Items = preload("res://scripts/items.gd") +const Items = preload("res://scripts/items.gd") func _ready(): - var map = {"1": get_node("tabs/*/items"), - "2": get_node("tabs/**/items"), - "3": get_node("tabs/***/items"), - "other": get_node("tabs/other/items")} + var map = {"solid": get_node("tabs/*/items"), + "gas": get_node("tabs/*/items"), + "precursor": get_node("tabs/**/items"), + "life": get_node("tabs/***/items")} var items = Items.new() for k in items.data.keys(): var tree = map[k] - var root = tree.create_item() + var root = null + if tree.get_root() == null: + root = tree.create_item() + else: + root = tree.get_root() tree.set_columns(2) tree.set_column_title(0, "Item") tree.set_column_title(1, "Cost") @@ -20,17 +24,10 @@ func _ready(): tree.set_hide_root(true) tree.set_select_mode(Tree.SELECT_ROW) for i in range(items.data[k].size()): - var item = items.data[k][i] - var itm = tree.create_item(root) - itm.set_text(0, item["name"]) - itm.set_text(1, str(item["cost"])) - itm.set_tooltip(0, item["desc"]) - itm.set_metadata(0, item) - itm.set_collapsed(true) - - var desc = tree.create_item(itm) - desc.set_text(0, item["desc"]) - desc.set_selectable(0, false) + var dict = items.data[k][i] + var id = dict["id"] + var item = items.get(id) + item.insert_in_shop(tree, root) func _on_buy_pressed(): var tab = get_node("tabs").get_current_tab_control() @@ -40,7 +37,7 @@ func _on_buy_pressed(): var item = itm.get_metadata(0) var player = get_tree().get_root().get_node("Game/Player") if player.cash >= item["cost"]: - player.add_item(item["id"], item, 1) + player.add_item(item["id"], 1) player.cash -= item["cost"] else: pass \ No newline at end of file diff --git a/scripts/player.gd b/scripts/player.gd index c8c40eb..746d2d9 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,11 +1,15 @@ extends Node +const Items = preload("res://scripts/items.gd") +var items + var cash = 1000 setget set_cash, get_cash var storage = {} +var inventory = {} func _ready(): + self.items = Items.new() _update_funds() - _update_storage() func get_cash(): return cash @@ -14,24 +18,33 @@ func set_cash(csh): cash = csh _update_funds() -func add_item(id, item, amount): +func add_item(id, amount): if storage.has(id): storage[id] += amount else: storage[id] = amount - _update_storage() + inventory[id] = items.get(id) + _update_storage(id, storage[id]) func has_item(id, amount=1): return storage.has(id) and storage[id] >= amount +func get_item(id): + return inventory[id] + +func get_item_count(id): + return storage[id] + func remove_item(id, amount): + print("remove", id, amount) if storage.has(id) and storage[id] >= amount: storage[id] -= amount - _update_storage() + print("new amount", storage[id]) + _update_storage(id, storage[id]) func _update_funds(): get_tree().get_root().get_node("Game/HUD").set_funds(cash) -func _update_storage(): - get_tree().get_root().get_node("Game/HUD").update_storage(storage) +func _update_storage(id, amount): + get_tree().get_root().get_node("Game/HUD").update_storage(id, amount) \ No newline at end of file diff --git a/scripts/storage.gd b/scripts/storage.gd index bbac5e2..dd7d10e 100644 --- a/scripts/storage.gd +++ b/scripts/storage.gd @@ -1,13 +1,10 @@ extends Control -var Items = preload("res://scripts/items.gd") - +const Items = preload("res://scripts/items.gd") var items -var storage = {} var tree func _ready(): - self.items = Items.new() self.tree = get_node("panel/items") self.tree.create_item() self.tree.set_columns(2) @@ -15,47 +12,36 @@ func _ready(): self.tree.set_column_title(1, "Amount") self.tree.set_column_titles_visible(true) self.tree.set_column_expand(1, false) - self.tree.set_column_min_width(1,50) + self.tree.set_column_min_width(1,60) self.tree.set_hide_root(true) self.tree.set_select_mode(Tree.SELECT_ROW) + self.items = Items.new() -func _update_item(id, amount): - var child = self.tree.get_root().get_children() - while child != null: - var meta = child.get_metadata(0) - if meta == id: - if amount == 0: - self.tree.get_root().remove_child(child) - else: - child.set_text(1, str(amount)) - return - child = child.get_next() - - -func _add_item(id, amount): - var root = self.tree.get_root() - var item = self.tree.create_item(root) - item.set_text(0, self.items.get(id)["name"]) - item.set_text(1, str(amount)) - item.set_metadata(0, id) - -func update_storage(update): - for k in update.keys(): - print("key: ", k) - if self.storage.has(k): - if self.storage[k] != update[k]: - _update_item(k, update[k]) - if update[k] == 0: - self.storage.erase(k) - else: - self.storage[k] = update[k] - else: - self.storage[k] = update[k] - _add_item(k, update[k]) - - func get_selected(): var itm = self.tree.get_selected() if itm != null and itm.is_selected(0): return itm.get_metadata(0) return null + +func update_storage(id, amount): + var root = self.tree.get_root() + if root == null: + return + var node = root.get_children() + while node != null: + var meta = node.get_metadata(0) + if meta["id"] == id: + break + node = node.get_next() + + if amount == 0: + if node != null: + root.remove_child(node) + self.tree.update() + else: + if node == null: + var item = items.get(id) + node = item.insert_in_tree(tree, root) + node.set_text(1, str(amount)) + + \ No newline at end of file diff --git a/scripts/template.gd b/scripts/template.gd new file mode 100644 index 0000000..6e1affc --- /dev/null +++ b/scripts/template.gd @@ -0,0 +1,30 @@ +extends Node + +var data = null +var regex = null + +func _init(path): + var file = File.new() + file.open(path, File.READ) + var content = file.get_as_text() + file.close() + self.data = parse_json(content) + self.regex = RegEx.new() + self.regex.compile("/(.*?)/") + +func replace_all(base, values): + var mtch = self.regex.search(base) + while mtch != null: + var key = mtch.get_string(1) + var replace = "" + if values.has(key): + var from = values[key] + if typeof(from) == TYPE_DICTIONARY: + replace = from[from.keys()[randi() % from.size()]] + elif typeof(from) == TYPE_ARRAY: + replace = from[randi() % from.size()] + else: + replace = str(from) + base = self.regex.sub(base, replace) + mtch = self.regex.search(base) + return base \ No newline at end of file diff --git a/scripts/template_combine.gd b/scripts/template_combine.gd new file mode 100644 index 0000000..9791703 --- /dev/null +++ b/scripts/template_combine.gd @@ -0,0 +1,10 @@ +extends "res://scripts/template.gd" + +var bases = null + +func _init().("res://assets/combinator.json"): + self.bases = self.data["bases"] + +func template(world): + var base = self.bases[randi() % self.bases.size()] + return self.replace_all(base, self.data) diff --git a/scripts/template_incubate.gd b/scripts/template_incubate.gd new file mode 100644 index 0000000..f5c834c --- /dev/null +++ b/scripts/template_incubate.gd @@ -0,0 +1,4 @@ +extends "res://scripts/template.gd" + +func _init().("res://assets/incubator.json"): + pass diff --git a/scripts/world.gd b/scripts/world.gd index c871e81..e040524 100644 --- a/scripts/world.gd +++ b/scripts/world.gd @@ -1,23 +1,41 @@ extends Spatial -const SIZE = 15 +export var SIZE = 15 + +const Cube = preload("res://mesh/cube.obj") +const GrayMat = preload("res://gray_mat.tres") +const GlassMat = preload("res://glass.tres") +const House = preload("res://house.tscn") +const Pine = preload("res://tree_pine.tscn") +const Oak = preload("res://tree_oak.tscn") + +var materials + +var mass +var volume +var color +var gas_mass +var gas_volume +var gas_color + +var material +var glass_material -var Cube = preload("res://mesh/cube.obj") -var House = preload("res://house.tscn") -var Pine = preload("res://tree_pine.tscn") -var Oak = preload("res://tree_oak.tscn") func _enter_tree(): - var pn = Pine.instance() - pn.translate(Vector3(2,1,2)) - add_child(pn) - var ok = Oak.instance() - ok.translate(Vector3(-2,1,2)) - add_child(ok) - var hs = House.instance() - hs.translate(Vector3(0,1,2)) - hs.rotate_y(PI/2) - add_child(hs) + pass +# var pn = Pine.instance() +# pn.translate(Vector3(2,1,2)) +# add_child(pn) +# var ok = Oak.instance() +# ok.translate(Vector3(-2,1,2)) +# add_child(ok) +# var hs = House.instance() +# hs.translate(Vector3(0,1,2)) +# hs.rotate_y(PI/2) +# add_child(hs) + +func build(): _make_ball(SIZE, Vector3(0,0,0)) func _make_ball(size, center): @@ -37,8 +55,19 @@ func _make_ball(size, center): count += 1 else: line_y.append(null) + + + self.material = GrayMat.duplicate(true) + self.material.set_albedo(self.color) + self.glass_material = GlassMat.duplicate(true) + self.glass_material.set_albedo(self.gas_color) + get_node("CoverOther/Icosphere").set_material_override(self.glass_material) + + for i in range(Cube.get_surface_count()): + Cube.surface_set_material(i, self.material) var multi = MultiMesh.new() multi.set_transform_format(MultiMesh.TRANSFORM_3D) + multi.set_color_format(MultiMesh.COLOR_FLOAT) multi.set_mesh(Cube) multi.set_instance_count(count) var i = 0 @@ -56,6 +85,7 @@ func _make_ball(size, center): var trans = Transform() trans = trans.translated(pos) multi.set_instance_transform(i, trans) + multi.set_instance_color(i, self.color) i += 1 var instance = MultiMeshInstance.new() instance.set_multimesh(multi) diff --git a/world.tscn b/world.tscn index 74971e8..aacaea6 100644 --- a/world.tscn +++ b/world.tscn @@ -10,17 +10,18 @@ radius = 15.0 [node name="World" type="Spatial"] script = ExtResource( 1 ) +SIZE = 15 [node name="spot" type="SpotLight" parent="."] transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 20, 0 ) layers = 1 -light_color = Color( 0.819993, 0.824219, 0.283325, 1 ) -light_energy = 2.0 +light_color = Color( 0.771148, 0.773438, 0.480377, 1 ) +light_energy = 1.5 light_negative = false light_specular = 0.5 light_cull_mask = -1 -shadow_enabled = true +shadow_enabled = false shadow_color = Color( 0, 0, 0, 1 ) shadow_bias = 1.0 shadow_contact = 0.0 -- cgit v1.2.3-70-g09d2