private void wander(ref short X_indx, ref short Y_indx) { //Are we going to run into anyone? if (rnd.NextDouble() * 55 > 52) { onBehavior = 2; } if (onBehavior == 2) { angle = (short)(angle + (rnd.NextDouble() * 6 - 3)); if (angle > 359) { angle = 1; } else if (angle < 1) { angle = 359; } if (rnd.NextDouble() * 55 > 35) { onBehavior = 1; } } if (testCol(X_indx, Y_indx, angle)) { //If there is another life form in our dirrection //change our angle and try to go around on the next cycle. angle = (short)(angle + ((type % 2) - 1) * 3); //even numbered types of life will turn left, odd will turn right. if (angle > 359) { angle = 1; } if (angle < 1) { angle = 359; } OuterSpace.msgbox.pushmsgs("Animal Collision!"); return; } // Adjust the displacement from index. deltaX = deltaX + OuterSpace.moveX[angle] * speed; deltaY = deltaY + OuterSpace.moveY[angle] * speed; // Adjust our screen position. sX = sX + OuterSpace.moveX[angle] * speed; sY = sY + OuterSpace.moveY[angle] * speed; // If we've moved more then 1, adjust our pointer, which was passed by refrence. // and adjust our lifemap array, shuffle memory locations around. if (Math.Abs(deltaX) > 1 | Math.Abs(deltaY) > 1) { //Make sure we are not going out of bounds. //when we adjust our array position. MathFunctions.location ifOut = new MathFunctions.location(); ifOut.x = (int)X_indx + deltaX / 1; ifOut.y = (int)Y_indx + deltaY / 1; ifOut = MathFunctions.outOfBounds(ifOut.x, ifOut.y, 0, 0, OuterSpace.thisPlanet.PlanetMaps.BigMapX, OuterSpace.thisPlanet.PlanetMaps.BigMapY, angle, false); OuterSpace.thisPlanet.lifemap[(int)ifOut.x, (int)ifOut.y] = null; OuterSpace.thisPlanet.lifemap[(int)ifOut.x, (int)ifOut.y] = new lifeforms(); //Create a new one OuterSpace.thisPlanet.lifemap[(int)ifOut.x, (int)ifOut.y] = OuterSpace.thisPlanet.lifemap[X_indx, Y_indx]; //Assign the old OuterSpace.thisPlanet.lifemap[X_indx, Y_indx] = new lifeforms(); OuterSpace.thisPlanet.lifemap[X_indx, Y_indx].type = 0; OuterSpace.thisPlanet.lifemap[X_indx, Y_indx].sX = 0; OuterSpace.thisPlanet.lifemap[X_indx, Y_indx].sY = 0; OuterSpace.thisPlanet.lifemap[(int)ifOut.x, (int)ifOut.y].angle = ifOut.angle; //Update the pointers and the deltas with their new values. X_indx = (short)ifOut.x; deltaX = deltaX - (int)deltaX / 1; Y_indx = (short)ifOut.y; deltaY = deltaY - (int)deltaY / 1; } }
private void drawScaleLines() { int x; int x1; int y; int y1; //Draw the scale lines. //Verticle first, then horizontal. aLine.Width = 1; aLineVectors[0].X = mapArea[0].X; aLineVectors[0].Y = mapArea[0].Y; aLineVectors[1].Y = mapArea[1].Y; aLineVectors[1].X = mapArea[0].X; aLine.Draw(aLineVectors, Color.White); aLineVectors[0].Y = mapArea[1].Y; aLineVectors[1].X = mapArea[1].X; aLine.Draw(aLineVectors, Color.White); // Draw the horozontal hash marks for (y = 0; y <= 249; y += 50) { aLineVectors[0].X = mapArea[0].X; aLineVectors[0].Y = MathFunctions.scaleValue(y, 250, 0, mapArea[1].Y, mapArea[0].Y); aLineVectors[1].Y = aLineVectors[0].Y; aLineVectors[1].X = mapArea[0].X + 20; aLine.Draw(aLineVectors, Color.Red); // Biggers ones every 50 for (y1 = 0; y1 <= 50; y1 += 10) { aLineVectors[0].X = mapArea[0].X; aLineVectors[0].Y = MathFunctions.scaleValue(y + y1, 250, 0, mapArea[1].Y, mapArea[0].Y); aLineVectors[1].Y = aLineVectors[0].Y; aLineVectors[1].X = mapArea[0].X + 9; aLine.Draw(aLineVectors, Color.White); //Smaller ones every 10 } } // Draw the verticle hash marks for (x = 0; x <= 249; x += 50) { aLineVectors[0].Y = mapArea[1].Y; aLineVectors[0].X = MathFunctions.scaleValue(x, 250, 0, mapArea[1].X, mapArea[0].X); aLineVectors[1].Y = mapArea[1].Y - 20; aLineVectors[1].X = aLineVectors[0].X; aLine.Draw(aLineVectors, Color.Red); for (x1 = 0; x1 <= 50; x1 += 10) { aLineVectors[0].Y = mapArea[1].Y; aLineVectors[0].X = MathFunctions.scaleValue(x + x1, 250, 0, mapArea[1].X, mapArea[0].X); aLineVectors[1].Y = mapArea[1].Y - 9; aLineVectors[1].X = aLineVectors[0].X; aLine.Draw(aLineVectors, Color.White); } } resizeButton.Draw(mapArea[0].X, mapArea[1].Y, resizeButton.sourceFrame[0], 0, resizeButtonColor); }