Thursday, June 12, 2008

Can't Call It Long

I started to convert everything over to a floating point coordinate system, to get rid of this "two layer" thing I was doing, trying to keep DK as a sorta overlay of the Real World, 'cause DK uses nice solid integers for everything (its a grid with 500 rows and columns), and the Real World uses the ultra-hideous latitude and longitude coordinate system, where the city of Chicago is at Negative 86.something longitude (or you could say West insteada Negative) and positive 41.something (or North insteada Positive), and Russia is like, Positive Long and Positive Lat, and Brazil is Negative Long and Negative Lat, and Australia is Positive Long and Negative Lat.

So the Earth map is a Cartesian plane with good ole 0.0 sitting in the water off the west coast of Africa, and four positive-negative pairing quadrants, where north and east is positive, -180 West to 0 to 180 East, and 90 North to 0 to -90 South.

That seems nice and everything at first but then you get into some problems with game programming.

Like, it makes Bounding Box logic (for sql queries and stuff) really complicated and messy looking.

And you gotta do special cases for anything near the Zero and 180 East-West switchovers.

And conversions between different programming syntax things are a total headache even without that junk (I was using "lat" and "long" as variable names, y'know, nicknames for "latitude and longitude" until I was politely reminded by the Robot that "long" was a keyword for a couple of the older programming languages, y'know, the hard way ahaha), especially if you wanna make something that's gonna work internationally (which I've been doing my best to keep up on 'cause I got a lotta buddies from all over and that's one of the coolest things about this stupid game heh).

Plus php and sql and javascript all got different sorts of floating point problems, and the fact that some of 'em are "type jugglers" doesn't help a whole lot either when you gotta do a lot of math with the junk, although its nice when you can keep things pristine as strings for as long as possible while they're getting passed around and then just parse 'em out however you want when you need 'em, I think of it like "freezing" and "unthawing" 'em ahaha.

Oh man I got so much work ahead of me now.

I'm thinking about tricks I could do to make the whole thing easier.

Like, not using floating point, or using "fake" floating point numbers that are really integers, and then converting 'em to something that looks like floating point my own way, so that I can always be sure they'll look right and match up.

And getting rid of the positive and negative junk with the map, in the background of the game where I mess with stuff, by adding 90 to north-south stuff, and 180 to east-west stuff, and then just switching it back when I display it to users.

But then there's still the problem of the Zero lines and the brand new 360 degree overlap thingie I woulda made heh.

Ugh ahaha.

And the DK code ain't helping, the way it checks to see if you are in a town is by checking to see if your characters latitude and longitude is equal to the latitude and longitude of the town, and that's a no-no with floating point numbers, even if you were doing something simple, which I'm not heh.

So I started to redo all that by making a "bounding box" around the towns, so I could do a "greater than less than" type of thing, instead of an "is equal to," and that's how I got into thinking about all this messy map stuff.

And now I'm just trying to think of whether I wanna switch to a totally different trick or just keep trying to make the floating point stuff work.

I like the floating point stuff, I don't really wanna have to play around with that, and the resolution of the google map shit is crazy awesome, like no map that's ever been used for a game, y'know, its the Game Map of the Gods, man, and the floating point shit actually works really good for that, 'cause it adapts to it.

Plus I gotta do a lot of trig and I don't even wanna think about inventing my own mathematical framework thingie so that I could do all that with integers.

If I could just keep the "floaters" in line it'd be great heh.

4 comments:

Jeffool said...

I've no knowledge of the Google Maps API... But can you get ahold of data used in the default map, instead of the photo-map? Instant bounding by checking to see if the color of the default map matches the blue they use for water?

A far reach, I know, but it'd make an excellent resource if you could. The same thing could be used to check for forests and roads (for faster travel,) too.

Ole Bald Angus the Monk said...

Oh man actually (even though you don't see it in the screenshots) I can switch between all the different mapping company thingies on the fly, like Yahoo maps and Virtual Earth and WMS and all this other junk beside "Google Satellite" (which is what I'm using in the pictures), including all the different stuff all those guys provide.

So folks who have a hard time using one thing or another (maybe because of graphics lag or internet lag or they just wanna use the cartoony-looking street maps for something or whatever) can switch between all that junk on the fly too.

And there's actually a really clean two-color map for checking water that's not from google, so that's not much of a problem (the only problem is that you MIGHT wanna get stuck at every river and puddle, and you MIGHT NOT, and the difference between those two things is a lot of programming that won't work out too well as a "control panel" kinda thingie for folks who don't program, so I just put that on the side for later, its something I'll have to play with before I see how well I can handle it to make it something that's cool and not annoying).

Y'know, I either need to be able to detect "bridges" on the map or I need to have only "really deep water count" or something like that for that to not totally suck.

If you think about how the Florida Keys are you'll see what I'm saying about how that'd be annoying if I can't detect the bridges heh.

As for the rest of it, I was gonna use this thing you can paint on the map with (while you are in the game) so admins can just paint down colors (and polygons and whatever) that determine "zones" and terrain and stuff.

That's all built-in to it already, you can even move the junk you paint down around and rotate it and shrink it and all that.

I'm not gonna get into "faster speeds for using roads" and collison detection with buildings, I mean, that'd be cool, and something I could play with later, after I get the basic thing finished, and there's even a couple ways I could think of to try to do it, since I got access to streetmaps that work as overlays, but that's something I can leave for when I can't think of anything else to do heh.

Anonymous said...

If you're still having problems with the 180/-180 border, you could try translating the map somewhere that puts that area entirely in the ocean. And then saying the world is flat.

Ole Bald Angus the Monk said...

Yah I'm just gonna keep trying to muscle my way through it "straight up" with floats and cheap tricks and special cases for all the weird crap, I've been making progress on that.

And at least then the thing will make sense to somebody else if they look at the code and it won't be all written backwards in invisible ink and shit.

Its kinda awesome to be able to use floats and all this luxury crap, the last time I did REAL game programming type crap was back in the Great Depression, and the dudes who made Quake woulda ripped my nuts off for being so sloppy, doing all this junk that slowed the old computers we had back then down heh.

"Dividing takes 80 clock cycles man!"

"Dude! Multiplying is 40!"

"Bit shifts are four! You should use bit shifts!"

"Awww quitcher Bitshifting!"

So as much as I crab this "aw who cares I got more muscle than I know what to do with, I need to slow this DOWN some more!" stuff is kinda like being a rich guy to me or something, its cool to be able to waste all this power.

I'm getting close to the end of the map crap for now, I'm just working out my initial setup for showing other players on your screen and junk (I say initial 'cause I won't trust that I'm not gonna have to redo it unless I see it working in action with lots of players), and then when I'm done with that, I gotta finish off all the "special case" and bounding box junk for the coast of Africa and stuff heh.

And after that I'm gonna go back to the super easy and fun part, fixing up the combat and web pages and crap that DON'T have to do with the map heh.

And I won't need to go back and work on the map until I'm ready to flesh out the Admin thing where you can paint down zones and terrain stuff.