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



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

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


Great!



[Please log in to post a comment]