Jump to content
  • entries
    46
  • comments
    207
  • views
    39,719

Mutant Madness - Building placement part 2


AggrorJorn

1,888 views

 Share

Building selection

A little update on the building placement. You can scroll with your mousewheel to select a different tower.

I made the following code to cycle through the towers:

//Mouse wheel checking
		m = LE.MouseZ();
		if (prevM < m)
		{
			selectionID++;
			if (selectionID > 4)
			{
				selectionID = 0;
				Console.WriteLine("now 0");
			}
			SetNewCurrentTempTower();
		}
		else if (prevM > m)
		{
			selectionID--;
			if (selectionID < 0)
			{
				selectionID = 4;
				Console.WriteLine("now 4");
			}
			SetNewCurrentTempTower();
		}
       prevM = LE.MouseZ();

blogentry-45-0-79425000-1335054365.png

 

 

Range ring

Instead of creating a decal I thought it would be nice to display some rotating meshes to show the range of a tower. At the moment the meshes are not being adjusted by the terrain height but that is something on the to-do list. One thing I noticed was that the FPS dropped heavily when using this range ring. A loop was interfering with the process causing a lot of unnecessary instances being created.

blogentry-45-0-39127400-1335054359_thumb.png

 

 

Firing towers

I made a small beginning with the tower's firing mechanism. Towers are now able to lock on to a target if it is within range. The bunker and sniper tower are the only towers with a working firing mechanism. The canon and the flamer use rotation and have extra calculations for damage, rotation and area impact.

blogentry-45-0-93037800-1335054838_thumb.jpg

 Share

3 Comments


Recommended Comments

You can simplify your code quite a bit actually by using the mod operator... (Assuming it's C, which it looks like)

 

 

 

//Mouse wheel checking
m = LE.MouseZ();
int CurrentTowerCount = 5; //Every time you add a tower, increment this - this should actually have a higher scope visibility than just this function, otherwise it will keep resetting this value to 5 towers (0 through 4) every time it checks for mouse movement
if (prevM != m)
{
(selectionID += (prevM - m)) %= CurrentTowerCount; //If it's going the wrong way, swap the += for a -=
SetNewCurrentTempTower();
prevM = m;//I'm guessing you had this line as well...
}

  • Upvote 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...