Posts: 38
Threads: 9
Joined: Jul 2011
(This post was last modified: 02.07.2011, 12:27 by sinner.)
02.07.2011, 00:42
Hi there, I'm developing a game, it's still at a little script stage, hope that soon will get shape. Anyway, I have been studying the create_village function, and came exactly to no result. Can someone tip (pass) me some info on that ? A slight idea on how could it be made, because, I can't show up with any idea even after some researching on a x,y points onto a vertex circle on google. Tough, I still didn't manage to make any progress on that function, which is quite important. I'm asking the developers of this game, sure, if they want to give me a hand on that. I'm available via PM or Mail if you don't want to say the hints in this thread.
Cheers, Sinner.
Posts: 3'459
Threads: 57
Joined: Apr 2009
Reputation:
115
(This post was last modified: 02.07.2011, 01:55 by Yannici.)
02.07.2011, 01:52
I just little bit drunken, but I hope I understood your question anyway.
You have to get the position where the village should be create! (Like: Nord-East(ne), Nord-West (nw), South-West (sw), South-East (se)).
So if you get this information you can create a random number for the X and Y coordinates.
For example you got a map with coords between -50|50.
So the Script would be like this one:
PHP Code: $position = $_GET['position'];
if($position == "ne")
{
$x = rand(0, 50);
$y = rand(0, 50);
}
elseif($position == "nw")
{
$x = rand(-50, 0);
$y = rand(0, 50);
}
elseif($position == "sw")
{
$x = rand(-50, 0);
$y = rand(0, -50);
}
elseif($position == "se")
{
$x = rand(0, 50);
$y = rand(0, -50);
}
else // If random position
{
$x = rand(-50, 50);
$y = rand(-50, 50);
}
create_village($x, $y);
I hope, I could helped you :')
Sorry for bad english
so far
Yannici
Manchmal denke ich:
Posts: 2'493
Threads: 43
Joined: Mar 2010
Reputation:
87
(This post was last modified: 02.07.2011, 10:47 by Molt.)
02.07.2011, 08:00
@Yannici: Was, wenn dann aber schon alles voll ist da?
@Sinner:
Before I joined the TWLan Dev, I wrote a little script for myself and it looked similar to this:
PHP Code: // Given variables:
// $direction = direction in which the village should be created
// $villages = amount of villages
// Coord-System is like in Tribalwars
// So, the main idea is to find a circle where the village is created on
$radius = sqrt($villages);
if($direction == "nw" || $direction == "sw")
{
$x = rand(0, -1);
}
else
{
$x = rand(0, 1);
}
// Now we have a horizontal value and need the vertical one
$y = cos(asin($x));
// But it will always be positive, so we have to make another check
if($direction == "se" || $direction == "sw")
{
$y *= (-1);
}
// All we have to do now is multiply x and y with the radius and add the center coords of the map
$x *= $radius;
$y *= $radius;
$x += 500;
$y += 500;
$x = round($x);
$y = round($y);
// And then of course check if this coords are free ;)
Greetings
Molt
Posts: 38
Threads: 9
Joined: Jul 2011
(This post was last modified: 02.07.2011, 10:30 by sinner.)
02.07.2011, 10:30
@Molt, what do you mean by "amount of villages" the number of villages already created ? Though, I am a bit shamed because thats quite logical, too bad i never got in good relation with math algorithms.
Thanks again for this. Anyway, I have 2 more questions that are like an enigma for me at the moment, because they require mathematical attention, and i kind of suck at that. Hope for the best, i will get back with them as soon as possible, and thanks again for the patience and the help you gave me.
@Yannici, thanks for that too, you understood my needings, but i done it myself too and didn't helped much.
Posts: 2'493
Threads: 43
Joined: Mar 2010
Reputation:
87
(02.07.2011, 10:30)sinner Wrote: what do you mean by "amount of villages" the number of villages already created? Exactly.
Posts: 3'459
Threads: 57
Joined: Apr 2009
Reputation:
115
(02.07.2011, 08:00)Molt Wrote: @Yannici: Was, wenn dann aber schon alles voll ist da? 
Die Abfrage steckt dann in der Funktion create_village(); *HÖHÖHÖHÖ*
so far
Yannici
Manchmal denke ich:
|