Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun canWalkInto(pos : Vector2): Boolean {
- var localPosX: Int = (pos.x.toInt() - x * GameConstants.PIXEL_SIZE) / GameConstants.PIXEL_SIZE
- var localPosY: Int = (pos.y.toInt() - y * GameConstants.PIXEL_SIZE) / GameConstants.PIXEL_SIZE
- if (localPosX >= if (rot == 0 || rot == 2) def.shape.w - 1 else def.shape.h - 1)
- localPosX = if (rot == 0 || rot == 2) def.shape.w - 1 else def.shape.h - 1
- if (localPosY >= if (rot == 1 || rot == 3) def.shape.w - 1 else def.shape.h - 1)
- localPosY = if (rot == 1 || rot == 3) def.shape.w - 1 else def.shape.h - 1
- //Cases of < 0 will be handled by the "/" operation
- var internals = def.internalCollision
- if (internals.equals(""))
- return !def.isWall
- //rotations
- when (rot) {
- 0 -> return internals[localPosX + localPosY * def.shape.h] == 'a' // x, y
- 1 -> return internals[localPosY + (def.shape.w - localPosX - 1) * def.shape.w] == 'a' // y, -x
- 2 -> return internals[(def.shape.w - localPosX - 1) + (def.shape.h - localPosY - 1) * def.shape.h] == 'a' //-x, -y
- 3 -> return internals[(def.shape.h - localPosY - 1) + localPosX * def.shape.w] == 'a' // -y, x
- }
- return !def.isWall
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement