I'm making a platform game with a tilemap, and I've set up the wall sprites with addWallSprites.
How can I check on collisions with them?
I was thinking if I could assign them a sprite class I could use if collision['other']:isa(Wall) , but I'm not sure how to assign them to a class without assigning the whole tilemap.
I need to check for collisions to tell when the player is on ground (for example) and when a projectile his a wall etc.
To be honest I have a real hard time understanding Level 1-1's code. I learn better following tutorials than dissecting other games.
I can see it does class-based collision checking for coins and enemies. Walls I believe are on their own tilemap layer (which is different to how I'm set up). It seems to for loop through the tilemap and sets a variable (isWall=true) to each tile.
I don't know how to reference the table where addWallSprites adds the list of collidable tiles.
I've written this code to check if player is standing on a wall. It's in the Player:update function.
local onGround = false
for index, _sprite in ipairs (walls) do
if self.y+(self.height/2) == _sprite.y - (_sprite.height/2) and self.x >= _sprite.x-(_sprite.width/2) and self.x <= _sprite.x+(_sprite.width/2) then
onGround = true
end
end```