I’m making a game but I cant Macke a wall
could you perhaps provide slightly more info as to what you are doing? it’d be really helpful to determine how we can help you make a wall of any sort.
like, are you making a platformer? car game? is there gravity?
Easy:
// wall default script
if(!project.walls)
project.walls = Object.create(null);
project.walls[this.uuid] = this;
// player update script
const lastX = this.x, lastY = this.y;
// movement...
const touchingAnything = Object.values(project.walls).filter(c => this.hits(c)).reduce((acc, cur) => cur || acc);
if(touchingAnything) {
this.x = lastX;
this.y = lastY;
This code does:
- Save the last ‘good’ position
- Movement code (you know how to do that)
- Calculate if touching anything
- If actually touching anything, revert to last ‘good’ position