Creating a game world... there's got to be a better way.
Posted: Mon Sep 03, 2007 9:41 am
I hate making mobs in my game. Do you know why? Because my code looks like this.
My world is like, 4000 x 3000. That's a LOT of stupid if statements, especially when not every spot produces a monster. (there's oceans, mountains, etc.)
So what I'm saying is... do you guys have any better ideas for this? I tried the Quantum Game Library, atleast for ideas, but that runs on java and real-time viewing of other players; mine's instanced, server-based, and no pretty effects.
I'm thinking maybe some sort of huge array where I could set a whole group of coords as mountains, and oceans. I just hate to work with giant rectangles being oceans, and players being technically able to move into the ocean, because I missed a coord somewhere.
I don't care how hard your solution is, but I'd prefer to stay in PHP's range.
Code: Select all
if ($x >= 780 && $x <= 820 && $y >= 1260 && $y <= 1290) // between neworsa and abrupt valley, little box
{
if ($randommob3 == 1)
{
$monster = 'Slime';
mysql_query("UPDATE explore SET mobname = '$monster' WHERE username = '$user'");
}
if ($randommob3 == 2)
{
$monster = 'Vicious Rabbit';
mysql_query("UPDATE explore SET mobname = '$monster' WHERE username = '$user'");
}
if ($randommob3 == 3)
{
$monster = 'Dire Wolf';
mysql_query("UPDATE explore SET mobname = '$monster' WHERE username = '$user'");
}
}So what I'm saying is... do you guys have any better ideas for this? I tried the Quantum Game Library, atleast for ideas, but that runs on java and real-time viewing of other players; mine's instanced, server-based, and no pretty effects.
I'm thinking maybe some sort of huge array where I could set a whole group of coords as mountains, and oceans. I just hate to work with giant rectangles being oceans, and players being technically able to move into the ocean, because I missed a coord somewhere.
I don't care how hard your solution is, but I'd prefer to stay in PHP's range.