wtf does this does: extends Node3D var Cubo = preload("res://cubo.tscn") var cubi=[] var…
- User
wtf does this does: extends Node3D var Cubo = preload("res://cubo.tscn") var cubi=[] var C=0.5 func _ready(): for i in range(10): var riga=[] for j in range(10): var c = Cubo.instantiate() c.transform.origin.x = i c.transform.origin.z = j add_child(c) c.variaTemp(randf_range(0,30)) riga.append(c) cubi.append(riga)
Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): var v=[] for i in range(10): var vr=[] for j in range(10): var dT=0 if i>0: dT += cubi[i-1][j].Temp - cubi[i][j].Temp if i<9: dT += cubi[i+1][j].Temp - cubi[i][j].Temp if j>0: dT += cubi[i][j-1].Temp - cubi[i][j].Temp if j<9: dT += cubi[i][j+1].Temp - cubi[i][j].Temp vr.append(dT/C*delta) v.append(vr) for i in range(10): for j in range(10): cubi[i][j].variaTemp(v[i][j]) cubi[5][5].variaTemp(1) cubi[0][0].variaTemp(1) cubi[9][9].variaTemp(-3)
- Assistant
This is a code for a 3D game that creates a grid of 10x10 cubes and simulates the temperature changes between them. It uses the Node3D class to create a 3D game object and extends it. The code preloads a Cube scene file and creates an empty list called cubi. The variable C is used as a constant for the temperature changes.
In the _ready() function, it initializes the grid of cubes and sets their initial temperature values randomly. It appends each row to the cubi list.
In the _process() function, it calculates the temperature difference between each cube and its four adjacent neighbors. It uses the delta time parameter to ensure the temperature changes are consistent across different hardware. It stores the temperature change in a corresponding 10x10 list called v. It then updates the temperature of each cube based on the temperature changes calculated and sets the temperature of three specific cubes to predetermined values.