vendredi 18 décembre 2020

How to make a tuple give a random new tuple?

I am trying to take a position (a,b) and via the code receive a random new position (a,b).. I am having great trouble implementing the code and what I got is by far my best try..

type Teleport (a,b) = 
    inherit Item (a, b, ' ', Color.White, Color.White)
    override this.FullyOccupy() = true
    override this.InteractWith (p: Player) =
        let mutable posX = p.X
        let mutable posY = p.Y
        let rand = System.Random()
        posX <- rand.Next()
        posY <- rand.Next()

Can someone maybe explain why it is not working?

It is supposed to work as a teleporter in a game, where if the player moves to the first (a,b) should be transported to a new (random) (a,b) position. Thanks!




Aucun commentaire:

Enregistrer un commentaire