Page 1 of 1
Am I making it to complicated?
Posted: Tue Aug 03, 2010 2:56 am
by Hutch
In php if I have?
$spaceship1 = 1;
$spaceship2 = 2;
$spaceship3 = 3;
$spaceship4 = 4;
$ufo1 = 1;
$ufo2 = 2;
$ufo3 = 3;
$ufo4 = 4;
Now if $spaceship2 does damage against $ufo3 and does no damage against $ufo1, $ufo2, $ufo4 while all $ufo attack back on all spaceship.
Re: Am I making it to complicated?
Posted: Tue Aug 03, 2010 3:21 am
by Jackolantern
What are these numbers? What are you trying to do? You will need to give us a lot more information before we can help you.
Re: Am I making it to complicated?
Posted: Tue Aug 03, 2010 3:53 am
by Hutch
Yeah, sorry that was not much info.
would be like.
$playerspaceship1 = 1 * $playerinfo3['spaceship1'];
If I have 4 different types of spaceships and attack 4 different types of ufo's. I would like 1 spaceship to be strong against ufo while the other 3 spaceships have little or no damage to the ufo's. Those ufo's would also attack back when being attacked, Those ufo's would all be able to attack back at all spaceships. Even though only 1 of those spaceships would do damage all those spaceships would be attacking.
I would have to attack with all 4 spaceships though. The defender would have no choice than to defend with all 4 ufo's.
I have a lot to learn.
Re: Am I making it to complicated?
Posted: Tue Aug 03, 2010 4:46 am
by Jackolantern
You could store the spaceships in an
array to help keep the code clear and to prevent repeating the same kind of code over and over. That way, say you want to alter the value of each spaceship, instead of doing something like this:
Code: Select all
$spaceship1 = $spaceship1 + 1;
$spaceship2 = $spaceship2 + 1;
$spaceship3 = $spaceship3 + 1;
$spaceship4 = $spaceship4 + 1;
You could do something more like this:
Code: Select all
foreach ($spaceship as $unit) {
$unit += 1;
}
If you want to explain a bit more about your game, I could try to help you with more of the logic. Are these same spaceships always on the board? If they are, you could hardcode the logic for which spaceship is tougher against which UFO. If they are not, it would be a small bit more complicated.
Re: Am I making it to complicated?
Posted: Sat Aug 07, 2010 3:20 am
by Hutch
@Jack
I don't have a game so was just trying to learn some things that I would want to do. I have an idea about a space wargame, not that I have seen here though. I am just working on the tutorial and trying to build on that.
I changed some things up though. Have 4 spaceships, 4 ufos, 4 spacecraft, 4 alien ships.
spaceship1 is good against ufos but not good against spaceships, spacecraft or alien ships.
spaceship2 is good against spacecraft but not good against spaceship, ufo or alien ships.
Still want spaceship1 to do damage to the others but more damage to ufos.
different scenarios for different spaceships and different ufos and the other ships.
Players will be able to decide which ships, ufos, crafts they may want.