You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried using polymorph with js backend and I am getting incorrect behavior.
The example I am using is taken from simple physics example (see here for a document showing this behavior).
When the following code is compiled using nim js backend:
it starts with Pos (0, 0) instead of (1, 1) (and wrong velociy)
at each step neither move nor gravity are applied, only bounce is applied.
import polymorph
# Parse some types as components.register defaultCompOpts:
typePos=object
x, y: floatVel=object
x, y: floatGravity=object
strength: floatBounce=object# A dataless 'tag' component.makeSystem"move", [Pos, Vel]:
# Calculate basic movement.
all:
echo"move"
pos.x += vel.x
pos.y += vel.y
makeSystem"gravity", [Vel, Gravity]:
# Apply a gravity force to 'Vel'.
all:
vel.y -= gravity.strength
makeSystem"bounce", [Pos, Vel, Bounce]:
all:
# Correct 'Pos.y' to never goes below zero, enacting a simple bounce# to 'Vel.y' if this occurs.if pos.y <=0.0:
pos.y =0.0
vel.y =abs(vel.y) *0.5# Generate the framework and system procedures.makeEcsCommit"run"let
ball =newEntityWith(
Pos(x: 0.0, y: 0.0),
Vel(x: 1.0, y: 1.0),
Gravity(strength: 1.0),
Bounce()
)
for i in0..<4:
run()
echo ball
Here are the results in js console (truncated at the end):
The text was updated successfully, but these errors were encountered:
So the situation is not to bad if we just have to avoid +=. Not sure if this is something that could be considered a bug for js backend but in order to report it on nim issue tracker it might be useful to have a more minimal reproducible example (possibly that does not involve polymorph).
I guess for the moment we could leave this open for others to be aware.
I have tried using polymorph with js backend and I am getting incorrect behavior.
The example I am using is taken from simple physics example (see here for a document showing this behavior).
When the following code is compiled using nim js backend:
Here are the results in js console (truncated at the end):
The text was updated successfully, but these errors were encountered: