- Joined
- Mar 25, 2008
- Messages
- 1
- Reaction score
- 0
Hello.
Just wanted to say that I am building ogame clone with Laravel framework. If anyone is interseted in development can contact me trough PM.
Planing to use
- Vue.js
- Stripe Card Payment
- Live notifications...
- Responsive design
Here I am posting example code (PlanetCreator.php class)
And here you hame some images. It will use Xterium design:
https://drive.google.com/open?id=0B3j4DVOHBvGza0hyVU43cGhKWXZtQ0laaW5IVTU5YUxoaEJB
Just wanted to say that I am building ogame clone with Laravel framework. If anyone is interseted in development can contact me trough PM.
Planing to use
- Vue.js
- Stripe Card Payment
- Live notifications...
- Responsive design
Here I am posting example code (PlanetCreator.php class)
PHP:
/**
* Calculate planet diameter.
*
* [USER=850422]return[/USER] int
*/
public function calculatePlanetDiameter()
{
return (int)floor(1000 * sqrt($this->calculatePlanetMaxFields()));
}
/**
* Calculate galaxy, system, planet.
*/
private function calculatePlanetCoordinates()
{
//Get last set positions.
$lastSetGalaxy = settings('last_galaxy_position');
$lastSetSystem = settings('last_system_position');
$lastSetPlanet = settings('last_planet_position');
//If counter is bigger that max galaxy, return counter to 1.
if ($lastSetGalaxy > settings('max_galaxy')) {
$lastSetGalaxy = 1;
}
//If counter is bigger that max systems, return counter to 1.
if ($lastSetSystem > settings('max_systems')) {
$lastSetSystem = 1;
}
//Do while position is not free.
do {
$position = mt_rand(round(settings('max_planets') * 0.2), round(settings('max_planets') * 0.8));
if ($lastSetPlanet < 3) {
$lastSetPlanet += 1;
} else {
if ($lastSetSystem >= settings('max_systems')) {
$lastSetSystem = 1;
if ($lastSetGalaxy >= settings('max_galaxy')) {
$lastSetGalaxy = 1;
} else {
$lastSetGalaxy += 1;
}
} else {
$lastSetSystem += 1;
}
}
//Check is position free?
$isPositionFree = (Planet::where('galaxy', $lastSetGalaxy)->where('system', $lastSetSystem)->where('planet', $position)->get()->count() > 1) ? $isPositionFree = false : $isPositionFree = true;
//Do loop, if position is found, stop.
} while ($isPositionFree === false);
//Position found, write them to variable.
$this->galaxy = $lastSetGalaxy;
$this->system = $lastSetSystem;
$this->planet = $position;
//Update last valid generated positons.
$this->updateLastSetPositions($lastSetGalaxy, $lastSetSystem, $position);
}
And here you hame some images. It will use Xterium design:
https://drive.google.com/open?id=0B3j4DVOHBvGza0hyVU43cGhKWXZtQ0laaW5IVTU5YUxoaEJB
Last edited by a moderator: