Monday, July 6, 2009

Time to go to work

A&W unfortunately.

I spent almost six hours this morning trying to get the code to work. Nothing worked. I was about to post a long rant filled with hateful words when I realized I still had about 15 minutes. So I was messing around. Then it happened...progress.

Now I'm so very very close and I have to go to work. I hate that place.


The following is for future Tom so he doesn't forget what's going on, and for anyone who is interested.

So the main problem with scaling the level wasn't the scrolling portion. This was the main problem when Joe and I did the scrolling code for Jumpman. That was a different fix. I got the scrolling to work no matter how big I make the level. The problem is the collision. I'm starting to think this collision code sucks. It happens. My bad. The problem is that this collision code, unlike Jumpman's, takes the level.x and level.y into account when calculating it. This results in a different x and y position when the level is scaled. So after hours and hours and hours and hours and hours and hours and a few more hours of playing around with different formulas to get the numbers I need, I figured something out. Just a little bit of progress.

IMPORTANT: Right now without the scaling it takes the player's y and adds the level's y to get the number it needs. To do this properly when scaling I need to adjust the numbers. What I need to do is convert the level's y into the number it was originally before scaling it. This means I have to divide by how much I scaled it. Then I have to add the player's y. This would give me the number I need originally. However, this is not all. I finally realized in order to make this work correctly I need to bring it back to the scale that it currently is. This involves multiplying it by the scale.

I hope that made sense. If not here's the code:

( futureY + (level.y/level.scaleY) ) * level.scaleY

It's not working perfectly but I'm very close.

1 comment:

  1. It's funny what intentions of the past can bring forth in the future. I remember the horiba thoughts and hours and hours and hours spent on that code. Your explaination made sense to me, seeing that Jumpman kinda left off in that area. Either way, it's soundin' great buddy! Good luck!

    ReplyDelete