Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
some help
#1
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.
Reply
#2
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(050);
     
$y rand(050);
   }
   elseif(
$position == "nw")
   {
    
$x rand(-500);
    
$y rand(050);
   }
   elseif(
$position == "sw")
   {
    
$x rand(-500);
    
$y rand(0, -50);
   }
   elseif(
$position == "se")
   {
    
$x rand(050);
    
$y rand(0, -50);
   }
   else  
// If random position
   
{
    
$x rand(-5050);
    
$y rand(-5050);
   }

create_village($x$y); 

I hope, I could helped you :')

Sorry for bad english Big Grin

so far
Yannici
Manchmal denke ich:
Reply
#3
@Yannici: Was, wenn dann aber schon alles voll ist da? Tongue

@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(01);
}
// 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
Reply
#4
@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.
Reply
#5
(02.07.2011, 10:30)sinner Wrote: what do you mean by "amount of villages" the number of villages already created?
Exactly. Wink
Reply
#6
(02.07.2011, 08:00)Molt Wrote: @Yannici: Was, wenn dann aber schon alles voll ist da? Tongue

Die Abfrage steckt dann in der Funktion create_village(); *HÖHÖHÖHÖ* Big Grin

so far
Yannici
Manchmal denke ich:
Reply




Users browsing this thread: 1 Guest(s)