1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-21 23:34:21 +00:00

Start producing crops

This commit is contained in:
Steffo 2023-01-08 10:01:13 +01:00
parent 9f077b3711
commit b97916bedc
Signed by: steffo
GPG key ID: 6965406171929D01
6 changed files with 31 additions and 10 deletions

View file

@ -8,6 +8,10 @@ signal on_complete()
@onready var growth_timer: Timer = $GrowthTimer @onready var growth_timer: Timer = $GrowthTimer
@onready var sprout_mesh: MeshInstance3D = $Plant/Sprout @onready var sprout_mesh: MeshInstance3D = $Plant/Sprout
@onready var pop_sound: AudioStreamPlayer3D = $Pop @onready var pop_sound: AudioStreamPlayer3D = $Pop
@onready var producer: Node3D = $Producer
@export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn")
@export var debug_growth: bool = false @export var debug_growth: bool = false
@export var debug_growth_offset: float = 0.0; @export var debug_growth_offset: float = 0.0;
@ -15,6 +19,7 @@ signal on_complete()
func plant(): func plant():
if growth_timer.is_stopped(): if growth_timer.is_stopped():
growth_timer.start() growth_timer.start()
producer.produce_with_random_force()
emit_signal("on_planted") emit_signal("on_planted")

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://cf35yl04qtru3"] [gd_scene load_steps=8 format=3 uid="uid://cf35yl04qtru3"]
[ext_resource type="Script" path="res://island/CropTile.gd" id="1_7lls2"] [ext_resource type="Script" path="res://island/CropTile.gd" id="1_7lls2"]
[ext_resource type="Material" uid="uid://w0ipvdnh4l8s" path="res://island/CropMaterial.tres" id="2_1oajr"] [ext_resource type="Material" uid="uid://w0ipvdnh4l8s" path="res://island/CropMaterial.tres" id="2_1oajr"]
[ext_resource type="Script" path="res://island/Producer.gd" id="2_jejoo"]
[ext_resource type="AudioStream" uid="uid://lkftwgdun745" path="res://assets/pop.wav" id="3_gur2a"] [ext_resource type="AudioStream" uid="uid://lkftwgdun745" path="res://assets/pop.wav" id="3_gur2a"]
[ext_resource type="Script" path="res://island/Pop.gd" id="4_5e7wk"] [ext_resource type="Script" path="res://island/Pop.gd" id="4_5e7wk"]
@ -25,6 +26,10 @@ _surfaces = [{
[node name="CropTile" type="Node3D"] [node name="CropTile" type="Node3D"]
script = ExtResource("1_7lls2") script = ExtResource("1_7lls2")
[node name="Producer" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0.5)
script = ExtResource("2_jejoo")
[node name="Plant" type="Area3D" parent="."] [node name="Plant" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0.5) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0.5)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://bg88gc1w1gw5m"] [gd_scene load_steps=15 format=3 uid="uid://bg88gc1w1gw5m"]
[ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_agjfy"] [ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_agjfy"]
[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="1_w6ara"] [ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="1_w6ara"]
@ -9,7 +9,6 @@
[ext_resource type="PackedScene" uid="uid://bknwefv5ycc3u" path="res://island/PyramidSmolMesh.tscn" id="6_klmt8"] [ext_resource type="PackedScene" uid="uid://bknwefv5ycc3u" path="res://island/PyramidSmolMesh.tscn" id="6_klmt8"]
[ext_resource type="PackedScene" uid="uid://boxtb3trgcy8c" path="res://island/PillarMesh.tscn" id="7_grmwj"] [ext_resource type="PackedScene" uid="uid://boxtb3trgcy8c" path="res://island/PillarMesh.tscn" id="7_grmwj"]
[ext_resource type="PackedScene" uid="uid://cf35yl04qtru3" path="res://island/CropTile.tscn" id="8_4ooup"] [ext_resource type="PackedScene" uid="uid://cf35yl04qtru3" path="res://island/CropTile.tscn" id="8_4ooup"]
[ext_resource type="PackedScene" uid="uid://v7bv81krh12e" path="res://island/Pineapple.tscn" id="10_cvxfg"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"]
render_priority = 0 render_priority = 0
@ -96,8 +95,3 @@ debug_growth_offset = 0.5
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 8)
debug_growth = true debug_growth = true
debug_growth_offset = 0.6 debug_growth_offset = 0.6
[node name="Pineapple" parent="." instance=ExtResource("10_cvxfg")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 3, 31)
[editable path="Pineapple"]

View file

@ -19,7 +19,6 @@ func _physics_process(delta):
if captured: if captured:
var direction = player.position - parent.position var direction = player.position - parent.position
var force = direction.normalized() * force_multiplier * delta var force = direction.normalized() * force_multiplier * delta
force.y = abs(force.y)
parent.apply_force(force) parent.apply_force(force)

View file

@ -14,7 +14,7 @@ radius = 3.0
[node name="Pineapple" type="RigidBody3D"] [node name="Pineapple" type="RigidBody3D"]
collision_layer = 2 collision_layer = 2
lock_rotation = true lock_rotation = true
linear_damp = 3.0 linear_damp = 1.0
[node name="Shape" type="CollisionShape3D" parent="."] [node name="Shape" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.45, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.45, 0)

18
island/Producer.gd Normal file
View file

@ -0,0 +1,18 @@
extends Node3D
@export var produce_scene: PackedScene = preload("res://island/Pineapple.tscn")
var rng: RandomNumberGenerator
func _ready():
rng = RandomNumberGenerator.new()
rng.randomize()
func produce_with_random_force():
# TODO: Not sure it's a good idea attaching produce to the crop
var produce: RigidBody3D = produce_scene.instantiate()
add_child(produce)
produce.apply_impulse(Vector3.UP * rng.randf_range(15.0, 25.0))