-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
clones/v1.osl
_clones = {}
def setupType(type) (
_clones[type] = []
)
def new(num, type, setup_obj) (
local object obj = {}
loop num (
obj = setup_obj
obj.main = obj.main.bind(obj)
_clones[type].append(obj)
)
)
def stepSim(type) (
local clones = _clones[type]
local i = 0
loop clones.len (
i ++
void clones[i].main()
)
)
my_program.osl
import "clones/v1.osl" from "packages" as "clones"
clones.setupType("coin")
clones.new(1, "coin", {
x: random(-100,100),
y: random(-100,100),
xv: 0,
yv: 0,
size: 0,
main: def() -> (
local pos_x = self.x
local pos_y = self.y
goto pos_x post_y
image assets.coin 10 10
if dist(pos_x, pos_y, player.x, player.y) < 200 (
local original_dir = direction
pointat player.x player.y
self.x += direction.sin() * 10
self.y += direction.cos() * 10
direction original_dir
)
)
})
mainloop:
clones.stepSim("coin")
Mistium
Metadata
Metadata
Assignees
Labels
No labels