Log In  

I implemented code for wall detection and now the player moves diagonally across the y-axis, rather than just straight up and down. What am I missing?

Sorry, this cartridge is not currently available.
by
Cart #45113 | 2017-10-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#45114 2017-10-11 11:17 ( Edited 2017-10-11 15:57)

In each of the elseif btn(...) blocks you're modifying the X value.

example :

elseif btn(3) then
        if(solid_tile(player.x,player.y+8+1) == false) then
                player.x += 1
        else player.y += 0.2
        end
        player.y += player.speed
        movey()
        player.flipv = false
end

To be honest, I don't understand this. Why are you adding 1 to player.x? Shouldn't it look more like this?

elseif btn(3) then
        if(solid_tile(player.x,player.y+8+1) == false) then
                player.y += player.speed
        end
        movey()
        player.flipv = false
end
P#45115 2017-10-11 11:29 ( Edited 2017-10-11 15:29)

That worked beautifully! Thank you. I am brand new to the world of coding, so I've just been Frankensteining a bunch of code. :-P

P#45116 2017-10-11 11:39 ( Edited 2017-10-11 15:42)

Great!

P#45117 2017-10-11 11:57 ( Edited 2017-10-11 15:57)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 13:06:11 | 0.007s | Q:17