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

15 comments:

  1. Damn, that's sounds really really complicated. I always wanted to attempt and learn C++ or Python or something, but it looks so daunting...

    ReplyDelete
  2. Could you please explain me what the main difference is between C, C+ and C++?

    ReplyDelete
  3. C and C++ are programming languages and C+ doesnt exist :)

    ReplyDelete
  4. seems like it will take practice to perfect... +1 follower

    ReplyDelete
  5. Great, i love it. Are you gonna release the source or the executable file?

    ReplyDelete
  6. c++ is a neat language, following :) check out my blogs to see if you like em!

    ReplyDelete
  7. Nice, I'm into programming as well

    ReplyDelete
  8. keep it up man. good luck! following.

    ReplyDelete
  9. c++ sounds soo complicated, but it looks really cool!

    ReplyDelete
  10. @dende there is a link for first release in the latest post if you want to give it a try...

    ReplyDelete
  11. This is informative, thanks.

    ReplyDelete