Show More
Commit Description:
Add water tiles.
Commit Description:
Add water tiles.
File last commit:
Show/Diff file:
Action:
isometric-park-fna/Line.cs
80 lines | 2.4 KiB | text/x-csharp | CSharpLexer
Early working version (including all dependencies, lol).
r0 using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace isometricparkfna
{
public class Line
{
public static Texture2D PixelTexture;
public Line()
{
}
public static void drawLine(SpriteBatch batch, Vector2 start, Vector2 stop, Color color)
{
Add rudimentary tree drawing.
r2 drawLine(batch, start, stop, color, 0, 1);
Add parameter to Line for width.
r1 }
Add rudimentary tree drawing.
r2 public static void drawLine(SpriteBatch batch, Vector2 start, Vector2 stop, Color color, float depth)
{
drawLine(batch, start, stop, color, depth, 1);
}
public static void drawLine(SpriteBatch batch, Vector2 start, Vector2 stop, Color color, float depth, int width)
Add parameter to Line for width.
r1 {
Early working version (including all dependencies, lol).
r0 Vector2 line = stop - start;
float angle = (float)Math.Atan2((double)line.Y, (double) line.X);
Add parameter to Line for width.
r1 Rectangle rect = new Rectangle((int)start.X, (int)start.Y, (int)Math.Round(line.Length()), width);
Add rudimentary tree drawing.
r2 batch.Draw(Line.PixelTexture, rect, null, color, angle, new Vector2(0,0), SpriteEffects.None, depth);
Early working version (including all dependencies, lol).
r0
}
public static void initialize(GraphicsDevice graphics)
{
SpriteBatch spriteBatch = new SpriteBatch(graphics);
Line.PixelTexture = new Texture2D(graphics, 1, 1);
Line.PixelTexture.SetData<Color> (new Color[] { Color.White});
}
Limit lines to grid.
r8
public static Vector2 departurePoint(Vector2 start, Vector2 stop, float width, float height)
{
Change delta to be per-year
r224 if (MathUtils.BetweenExclusive(stop.X, 0, width ) && MathUtils.BetweenExclusive(stop.Y, 0, height)) {
Limit lines to grid.
r8 return stop;
}
float slope = (start.Y - stop.Y) / (start.X - stop.X);
float intercept = (start.Y - (slope * start.X));
Fix style.
r462 if (stop.X < 0) {
Limit lines to grid.
r8 float newY = slope * 0 + intercept;
return new Vector2(0, newY);
}
else if (stop.Y < 0)
{
float newX = intercept / slope;
return new Vector2(newX, 0);
}
Fix style.
r462
Limit lines to grid.
r8 else if (stop.Y > height)
{
float newX = (intercept + height) / slope;
return new Vector2(newX, height);
}
else if (stop.X > width)
{
float newY = slope * width + intercept;
return new Vector2(width, newY);
}
return stop;//TODO
}
Early working version (including all dependencies, lol).
r0 }
}