Variables
SET MUTATIONPOINT · clone · mutationcount · mutationpointx · mutationpointy
SET MUTATIONPOINT
Move one point of a shape, or add one past its end. This authors the shape, so a behavior driving it ends.
SET MUTATIONPOINT shape, index, at
set_mutationpoint(shape, index, at)
Parameters
- shape AS ARRAY - The shape: a
MUTATION. - index AS NUMBER - Which point, from 0.
- at AS COORDINATE - Where it goes:
(x, y).
Example
SCREEN 320, 240
triangle = MUTATION((0, 0), (50, 0), (25, 43))
SET MUTATIONPOINT triangle, 2, (25, 30)
PRINT mutationpointx(triangle, 2), mutationpointy(triangle, 2)
Notes
It’s also the function set_mutationpoint, for when you want what it gives back.
clone
Returns a deep, independent copy of a value. Crash BASIC arrays and objects are reference types: ‘b = a’ makes b an ALIAS of a (they share storage), so mutating one is seen through the other. CLONE(a) breaks that link, recursively duplicating nested arrays and objects so later mutations never bleed across. For scalars (Integer/Float/String) there is no shared storage, so CLONE just returns an equal value.
clone(value)
Parameters
- value - Any value. Arrays and Objects are deep-copied (recursively); scalars pass through unchanged.
Example
SCREEN 320, 240
original = {hp: 10, items: ["key"]}
copy = clone(original)
PUSH copy.items, "map"
PRINT LEN(original.items), LEN(copy.items)
mutationcount
Returns the number of points in a MUTATION variable. Returns 0 if the variable is not a mutation or is empty. Reading is non-destructive: a mutation driven by a behavior can be read as often as you like and keeps running. It is WRITING it (SET MUTATIONPOINT, re-assignment) that ends the behavior.
mutationcount(mutation)
Parameters
- mutation - MUTATION variable or variable name
Example
SCREEN 320, 240
shape = MUTATION((0, 0), (10, 0), (5, 8))
PRINT mutationcount(shape)
mutationpointx
Returns the X coordinate of a point in a MUTATION variable at the specified index. Returns 0 if the index is out of bounds or the variable is not a mutation. Reading is non-destructive: a mutation driven by a behavior can be read as often as you like and keeps running. It is WRITING it (SET MUTATIONPOINT, re-assignment) that ends the behavior.
mutationpointx(mutation, index)
Parameters
- mutation - MUTATION variable or variable name
- index - Zero-based index of the point
Example
SCREEN 320, 240
shape = MUTATION((0, 0), (10, 0), (5, 8))
FOR i = 0 ... mutationcount(shape) - 1
PRINT mutationpointx(shape, i)
END FOR
PRINT mutationpointx(shape, 99)
mutationpointy
Returns the Y coordinate of a point in a MUTATION variable at the specified index. Returns 0 if the index is out of bounds or the variable is not a mutation. Reading is non-destructive: a mutation driven by a behavior can be read as often as you like and keeps running. It is WRITING it (SET MUTATIONPOINT, re-assignment) that ends the behavior.
mutationpointy(mutation, index)
Parameters
- mutation - MUTATION variable or variable name
- index - Zero-based index of the point
Example
SCREEN 320, 240
shape = MUTATION((0, 0), (10, 0), (5, 8))
FOR i = 0 ... mutationcount(shape) - 1
PRINT mutationpointy(shape, i)
END FOR