Skip to content

Collision problems #2692

Answered by Lzrs111
Lzrs111 asked this question in Q&A
Discussion options

You must be logged in to vote

I've figured it out, so here's some pseudocode for anyone interested:

class SomeClass extends Actor { 


  public update(engine: Engine) { 
     let bounds = engine.getWorldBounds()
        
     if (this.pos.x > bounds.right || this.pos.x < bounds.left {
        this.vel.x *=-1
    }
     
   if (this.pos.y > bounds.bottom || this.pos.y < bounds.top) { 
       this.vel.y *=-1   
   }

  }
}

Works on resize and there's no need to add any Wall actors or anything along those lines.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Lzrs111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant