The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I am trying to make a version of carykh's 'evolvio' in Godot engine.
I need to add params that change over time or when interacted with

how can I do this?

example for the script:

var max_food = 10
var food = max_food
var fertility = 10

func _procces(delta):
    food += fertility * delta
    clamp(food, 0, max_food)
Godot version 3.2
in Engine by (36 points)

1 Answer

0 votes

You need to have a world state.

I created a Node2D scene with a TileSet with a TileSet image. Mine has 12 tiles.

I set one tile every _process randomly

extends Node2D

onready var tiles:TileMap = $TileMap

var world_width:int = 100
var world_height:int = 100

var world_state:PoolIntArray

func _ready():
    world_state = PoolIntArray()
    world_state.resize(world_width * world_height)

func _process(delta):
    # Select a random cell
    var x:int = randi() % world_width
    var y:int = randi() % world_height
    var food:int = randi() % 12
    # Change world state
    world_state[x + y * world_height] = food

    tiles.set_cell(x, y, world_state[x + y * world_height])

Hope this answers your question.

by (646 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.