Hello, as I go through various books and practicing I'm writing my own little space simulator app for fun and to reinforce the stuff i'm learning. Problem is now I've done something wrong. My space map is backwards. I'm using x and y coordinates and using nested loops to draw the map based on the user's current location. currently when using the charts command in flight it spits out a nice map, but when you set a course of new x and y, throttle up and movement begins, moving towards the new course reveals that the map is backwards. x and y are reversed as well as moving toward positive course goes in the down or back direction. Not sure what I messed up. Please help!
Its a bit of code so i'm linking to pastebin, hope thats okay.
Thanks GuestGulkan. I'll try to fiddle with that and see if it fixes the issue. Hopefully it will also fix the reverse direction as well as the x and y being swapped. I'll report back.
DevonRevenge I've not seen Elite. Just looked it up. Pretty cool. I was mostly inspired to start messing around, learning more C++ and developing thanks to another pioneer, Chris Roberts (Wing Commander) and his new game Star Citizen. Day job is Network engineer, and I do cloud computing architecture and such as well.. so while C++ isn't part of my day to day, it wouldn't hurt long run.. and would open up more doors.
GuestGulkan: Thanks a bunch, You were right on the money, flipping the loop worked great for getting X and Y reversed, then i just had to modify the location referenced map stuff to draw the correct amount of lines. I had tried flipping the values, but not the entire loop. So now its:
Movement along X is also working great, movement towards negative goes to the left, positive goes towards the right. Y however is flipped.. and I understand why, its incrementing from top to bottom. so positive goes down as it advances from where it starts drawing. Understanding it is one thing, but I'm not sure how to fix it. It needs to be more like the standard 4 quadrant algebra graph.
I like to use Row & Col rather i & j. It is easy to get the right way around because you remember that Rows are Y, and Cols are X.
Also, it will save you from doing this one day:
Using Row & Col, this won't happen because it would rather unlikely for you to do this:
I have seen exactly this happen before, someone had 200 lines of code full of i's & j's - no one could see the problem. I suggested doing a find replace - changing them to Row & Col. The error became much easier to spot visually. Even better, one is unlikely to make the error in the first place.
After some tinkering I figured out the backwards Y coords and rather than positively incrementing it rewrote it to do the opposite... works :) I also added the y and x just to show the proper axis label to confirm it was working properly.