• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Ogame Laravel LARAGAME

Status
Not open for further replies.
Initiate Mage
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)

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:
Skilled Illusionist
Joined
Feb 26, 2013
Messages
346
Reaction score
57
I am atm learning laravel aswell so maybe someday ill get into it
 
Status
Not open for further replies.