#Create factory method with function that edits properties

3 messages · Page 1 of 1 (latest)

vital sun
#
interface Blob {
    readonly Position: Point2D
    readonly Size: number
    readonly Speed: number
    Move: () => void
}

const createBlob = () => ({
    Position: createRandomPoint2D(-50, 50),
    Size: randominRange(0, 5),
    
    // Moves blob in random direction.
    Move: () => {
        const direction = Math.floor(Math.random() * 4);
    }
})

How am I able to get the position of my blob in the Move function?

#

this.property doesnt seem to work.

vital sun
#

$close