Fixed some stuff (Drawing is now working, yay)

This commit is contained in:
CreepyCrafter24 2019-10-07 17:26:55 +02:00
parent 148c1f9b83
commit 1aebfb2ccf
6 changed files with 18 additions and 29 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
tmp/*
tmp1/*
tmp2/*
tmp3/*
# Created by https://www.gitignore.io/api/csharp,visualstudio
# Edit at https://www.gitignore.io/?templates=csharp,visualstudio

8
3/3.cs
View File

@ -101,17 +101,11 @@ namespace LaptopSimulator2015.Levels
Rect tr = new Rect(targ, new Vector2(power, power), true);
for (int i = 0; i < targets.Count; i++)
{
if (targets[i].distanceToRectSquared(tr) <= 676)
if (targets[i].distanceToRectSquared(tr) <= 400)
targetsToRemove.Add(targets[i]);
}
targets = targets.Except(targetsToRemove.Distinct()).Distinct().ToList();
g.DrawRectangle(tr, Color.White);
g.DrawSizedString("TL", 10, tr.topLeftPoint.toPointF(), Brushes.Yellow);
g.DrawSizedString("TR", 10, tr.topRightPoint.toPointF(), Brushes.Yellow);
g.DrawSizedString("BL", 10, tr.bottomLeftPoint.toPointF(), Brushes.Yellow);
g.DrawSizedString("BR", 10, tr.bottomRightPoint.toPointF(), Brushes.Yellow);
g.DrawSizedString("CT", 10, tr.Location.toPointF(), Brushes.Blue);
power = 10;
}
targ = new Vector2(center);

4
4/4.cs
View File

@ -176,7 +176,7 @@ namespace LaptopSimulator2015.Levels
for (int i = 0; i < platforms.Count; i++)
{
Rect rect = new Rect(platforms[i], new Vector2(100, 10), true);
if (player.distanceToRectSquared(rect) <= 20 && rect.doOverlap(new Rect(player, new Vector2(10, 10), true)) && platforms[i].Y + 11 > player.Y && player.Y > platforms[i].Y + 9)
if (rect.doOverlap(new Rect(player, new Vector2(10, 10), true)) && platforms[i].Y + 11 > player.Y && player.Y > platforms[i].Y + 9)
return true;
}
return false;
@ -192,8 +192,6 @@ namespace LaptopSimulator2015.Levels
Vector2 mp = new Vector2(lazor, m);
g.DrawLine(mp, new Vector2(lazor, 0), Color.DarkGray, 2);
g.DrawLine(new Vector2(lazor, minigamePanel.Height), mp, Color.Red, 2);
//g.DrawRectangle(new RectangleF((float)lazor, minigamePanel.Height / 2, 2, minigamePanel.Height), Color.DarkGray);
//g.DrawRectangle(new RectangleF((float)lazor, minigamePanel.Height - m / 2, 2, m), Color.Red);
}
for (int i = 0; i < platforms.Count; i++)
g.DrawRectangle(new Rect(platforms[i], new Vector2(100, 10), true), Color.White);

View File

@ -37,12 +37,12 @@ namespace Base
/// <summary>
/// Draw a string with the given size
/// </summary>
/// <param name="s">The string to draw</param>
/// <param name="text">The string to draw</param>
/// <param name="size">The font size of the string</param>
/// <param name="location">The location to draw the string at</param>
/// <param name="brush">The brush to draw the string with</param>
/// <param name="isLocationCentered">Set to true if you want to draw the string around instead of left-down from the location</param>
public void DrawSizedString(string s, int size, PointF location, Brush brush, bool transform = true, bool isLocationCentered = false)
/// <param name="centered">Set to true if you want to draw the string around instead of left-down from the location</param>
public void DrawSizedString(string text, int size, PointF location, Brush brush, bool transform = true, bool centered = false)
{
SmoothingMode tmpS = g.SmoothingMode;
InterpolationMode tmpI = g.InterpolationMode;
@ -55,13 +55,11 @@ namespace Base
g.CompositingQuality = CompositingQuality.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
Font f = new Font("Tahoma", size);
SizeF sLen = g.MeasureString(s, f);
RectangleF rectf = new RectangleF(location, sLen);
SizeF s = g.MeasureString(text, f);
RectangleF r = new RectangleF(centered ? new PointF(location.X - s.Width / 2, location.Y - s.Height / 2) : location, s);
if (transform)
rectf = w2s(rectf);
if (isLocationCentered)
rectf = new RectangleF(rectf.X - rectf.Width / 2, rectf.Y - rectf.Height / 2, rectf.Width, rectf.Height);
g.DrawString(s, f, brush, rectf);
r = w2s(r);
g.DrawString(text, f, brush, r);
g.PixelOffsetMode = tmpP;
g.CompositingQuality = tmpQ;
g.CompositingMode = tmpM;
@ -79,14 +77,12 @@ namespace Base
/// <param name="unfilledLineSize">The size of the lines used when not filling</param>
public void DrawRectangle(RectangleF rectangle, Color color, bool centered = true, bool transform = true, bool filled = true, float unfilledLineSize = 1)
{
RectangleF r = rectangle;
SizeF s = rectangle.Size;
PointF location = rectangle.Location;
RectangleF r = new RectangleF(centered ? new PointF(location.X - s.Width / 2, location.Y - s.Height / 2) : location, s);
if (transform)
r = w2s(r);
Brush b = new SolidBrush(color);
if (centered)
{
r = new RectangleF(new PointF(r.X - r.Width / 2, r.Y - r.Height / 2), r.Size);
}
if (filled)
g.FillRectangle(b, r);
else
@ -168,7 +164,7 @@ namespace Base
_g.Dispose();
}
public RectangleF w2s(RectangleF from) => new RectangleF(w2s(from.Location), from.Size);
public RectangleF w2s(RectangleF from) => new RectangleF(w2s(new PointF(from.Left, from.Bottom)), from.Size);
public PointF w2s(PointF from) => new PointF(from.X, targetSize.Height - from.Y);
}
}

View File

@ -30,7 +30,7 @@ namespace Base
if (centered)
{
this.X -= Width / 2;
this.Y += Height / 2;
this.Y -= Height / 2;
}
}

View File

@ -1,6 +1,3 @@
Fix Physics weirdness in Level 3
Fix Physics weirdness in Level 4 (dropping through ground)
Ideas for content:
- Goals:
- MS Word = Sentenz