Sunday, 27 March 2011
How to implement slopes!
Second video from my attempt to learn c++
This time I tried to implement slopes!
Something so trivial looking like slopes is actually pretty tricky task to do... my brain almost exploded till I finally figured it out how to do it :3
I googled and googled and found a way with an array thingy attached to each slope tile telling how much should push the hero upwards but that sounded like a pretty over-complicated way to make an array for each slope tile so I went my own way and simply calculated how far is my characted inside of the slope tile on X axis, then simply adjusted Y axis by the same amount :D ...it was working for 45 degree slopes, then for 22.5 ones I just divided that amount by 2
another byproduct with this method was that my heroine was snaped to the slopes like a magnet as soon as she entered the tile with a slope haha.. so I had to figure out the way how she can un-snap to be able to move freely and jump from the tiles and not be locked to it like a train to rails
I finally managed to solve that as well, there are still some issues and the slope tiles can't be touched from the bottom and from the sides or bad things will happen -_-
Only the 45 degree ones can be touched from the sides like you can see in the video in the top right part of the map.. and it took some huge effort to be able to do that, heh.. but my brain gave up on the rest xD
The whole code is almost 1000 lines by now