Jump to content

Using FLOAT or INT For Grid


Usarjjaco

Recommended Posts

Hello Everyone,All players in my game start on a grid that is based off a real world location 4 digit latitude and 4 digit longitude. Here is the problem I found. I was going to just use INT for this but had a face plant moment when I realized that doing it with a 4 digit grid would in some instances mean a player could be at a real world grid like 104.2 and 10.42 at the same time. So I needed to have a decimal... easy.. or so I thought. I changed all grid values to be 3,2 FLOAT. However now when a player goes to move I cannot get it to move their position. I had it set up so they would move .01 in any given direction + .01 Latitude (North)- .01 Latitude (South)+ .01 Longitude (East)- .01 Longitude (West)But it will not add that amount to the value in the rows of the tables. Is there some way I need to specifically use FLOAT so that I can and and subtract to it using a value of less that 1? Thanks in advance!

Link to comment
Share on other sites

Your description is confusing and you didn't post a script. Sounds to me you can fix this by thinking outside the box a little. In this world of yours every numeric value means exactly what you want it to mean. If you can't use decimals like 104.2 and the lowest possible decimal place is in the 100 thousandths place then multiply the number by 100 and it will mean the same thing as you want it to. 104.2 = 10420 and 10.42 = 1042. The space from 1 to 2 might have been one virtual meter, but now it's one virtual centimeter (1 now means the same as the old .1). See what I'm saying?

Link to comment
Share on other sites

Yes I see what you are saying. The problem with that is we are aiming for making it as close to real GPS coordinates as possible. I'll post a script:

mysql_query("UPDATE survivors SET lat=lat + .01 WHERE username='{$uname}'");

That's an example of a line I'd try to execute, but it would not update the "lat" column accordingly.

Link to comment
Share on other sites

I tried with my own database. The status field is a float and I tried this query-"UPDATE tasks SET status = status + .01 WHERE id = 1"and it works fine13348870.jpg11590952.jpgSo what do you mean by "not update the 'lat' column accordingly"? You mean it updates funny or not at all? Also, why does your $uname variable have curly brackets around it? Is that the way it is in the database? Otherwise, that's what might be screwing it up.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...