Some stuff

This commit is contained in:
CreepyCrafter24 2019-09-26 22:24:45 +02:00
parent 1fca2fe8d2
commit 21c3ba85db
17 changed files with 171 additions and 127 deletions

26
1/1.cs
View File

@ -54,13 +54,10 @@ namespace LaptopSimulator2015.Levels
} }
public int availableAfter => 1; public int availableAfter => 1;
public int gameClock => 17; public int gameClock => 17;
public Panel desktopIcon { get; set; } public Panel desktopIcon { get; set; }
public int installerProgressSteps => 500; public int installerProgressSteps => 500;
public Color backColor => Color.Black;
List<Vector2> enemies; List<Vector2> enemies;
List<Vector2> bullets; List<Vector2> bullets;
Vector2 player; Vector2 player;
@ -90,7 +87,7 @@ namespace LaptopSimulator2015.Levels
bullets[i].X += 4; bullets[i].X += 4;
for (int j = 0; j < enemies.Count; j++) for (int j = 0; j < enemies.Count; j++)
{ {
if (bullets[i].distanceFromSquared(enemies[j] + new Vector2(2.5f, 2.5f)) < 56.25f) if (bullets[i].distanceFromSquared(enemies[j]) < 56.25f)
{ {
enemiesToRemove.Add(enemies[j]); enemiesToRemove.Add(enemies[j]);
bulletsToRemove.Add(bullets[i]); bulletsToRemove.Add(bullets[i]);
@ -104,16 +101,16 @@ namespace LaptopSimulator2015.Levels
speedMod += 0.1; speedMod += 0.1;
speedMod = Math.Max(Math.Min(speedMod, 5), 1); speedMod = Math.Max(Math.Min(speedMod, 5), 1);
if (Input.Up) if (Input.Up)
player.Y -= speedMod; player.Y += speedMod;
if (Input.Left) if (Input.Left)
player.X -= speedMod; player.X -= speedMod;
if (Input.Down) if (Input.Down)
player.Y += speedMod; player.Y -= speedMod;
if (Input.Right) if (Input.Right)
player.X += speedMod; player.X += speedMod;
if (Input.Action & enemiesCanShoot) if (Input.Action & enemiesCanShoot)
{ {
bullets.Add(new Vector2(0, 2.5) + player); bullets.Add(new Vector2(player));
enemiesCanShoot = false; enemiesCanShoot = false;
speedMod--; speedMod--;
} }
@ -129,21 +126,16 @@ namespace LaptopSimulator2015.Levels
enemiesCanShoot = true; enemiesCanShoot = true;
player = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2); player = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2);
player.bounds_wrap = true; player.bounds_wrap = true;
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10); player.bounds = new Rectangle(-5, -5, minigamePanel.Width + 10, minigamePanel.Height + 10);
} }
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime) public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{ {
g.g.Clear(Color.Black);
for (int i = 0; i < enemies.Count; i++) for (int i = 0; i < enemies.Count; i++)
{ g.DrawRectangle(new RectangleF(enemies[i].toPointF(), new SizeF(10, 10)), Color.Red);
g.g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
}
for (int i = 0; i < bullets.Count; i++) for (int i = 0; i < bullets.Count; i++)
{ g.DrawRectangle(new RectangleF(bullets[i].toPointF(), new SizeF(5, 5)), Color.White);
g.g.FillRectangle(new SolidBrush(Color.White), new Rectangle(bullets[i].toPoint(), new Size(5, 5))); g.DrawRectangle(new RectangleF(player.toPointF(), new SizeF(10, 10)), Color.Green);
}
g.g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
} }
} }
} }

19
2/2.cs
View File

@ -55,13 +55,10 @@ namespace LaptopSimulator2015.Levels
} }
public int availableAfter => 2; public int availableAfter => 2;
public int gameClock => 17; public int gameClock => 17;
public Panel desktopIcon { get; set; } public Panel desktopIcon { get; set; }
public int installerProgressSteps => 500; public int installerProgressSteps => 500;
public Color backColor => Color.Black;
List<Vector2> enemies; List<Vector2> enemies;
Vector2 player; Vector2 player;
int lives; int lives;
@ -84,11 +81,11 @@ namespace LaptopSimulator2015.Levels
enemies.Add(new Vector2(0, tst - minigamePanel.Width * 2 - minigamePanel.Height + 10)); enemies.Add(new Vector2(0, tst - minigamePanel.Width * 2 - minigamePanel.Height + 10));
} }
if (Input.Up) if (Input.Up)
player.Y -= 5; player.Y += 5;
if (Input.Left) if (Input.Left)
player.X -= 5; player.X -= 5;
if (Input.Down) if (Input.Down)
player.Y += 5; player.Y -= 5;
if (Input.Right) if (Input.Right)
player.X += 5; player.X += 5;
List<Vector2> enemiesToRemove = new List<Vector2>(); List<Vector2> enemiesToRemove = new List<Vector2>();
@ -118,16 +115,18 @@ namespace LaptopSimulator2015.Levels
enemies = new List<Vector2>(); enemies = new List<Vector2>();
player = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2); player = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
player.bounds_wrap = true; player.bounds_wrap = true;
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10); player.bounds = new Rectangle(-5, -5, minigamePanel.Width + 10, minigamePanel.Height + 10);
lives = 3; lives = 3;
} }
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime) public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{ {
for (int i = 0; i < enemies.Count; i++) for (int i = 0; i < enemies.Count; i++)
g.g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10))); //g.g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
g.g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10))); g.DrawRectangle(new RectangleF(enemies[i].toPointF(), new SizeF(10, 10)), Color.Red);
g.DrawSizedString(lives.ToString(), 7, (player + new PointF(5, 5)).toPointF(), Brushes.White, true); //g.g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
g.DrawRectangle(new RectangleF(player.toPointF(), new SizeF(10, 10)), Color.Green);
g.DrawSizedString(lives.ToString(), 7, player.toPointF(), Brushes.White, true, true);
} }
} }
} }

12
3/3.cs
View File

@ -61,12 +61,12 @@ namespace LaptopSimulator2015.Levels
public Panel desktopIcon { get; set; } public Panel desktopIcon { get; set; }
public int installerProgressSteps => 500; public int installerProgressSteps => 500;
public Color backColor => Color.Black;
Vector2 center; Vector2 center;
Vector2 cannon; Vector2 cannon;
Vector2 targ; Vector2 targ;
List<Vector2> targets; List<Vector2> targets;
Rectangle player => new Rectangle(center.toPoint().X - 5, center.toPoint().Y - 5, 10, 10);
double playerRot; double playerRot;
double cannonL; double cannonL;
double power; double power;
@ -146,8 +146,8 @@ namespace LaptopSimulator2015.Levels
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime) public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{ {
g.g.Clear(Color.Black); //g.g.FillRectangle(new SolidBrush(Color.Green), player);
g.g.FillRectangle(new SolidBrush(Color.Green), player); g.DrawRectangle(new RectangleF(center.toPointF(), new SizeF(10, 10)), Color.Green, transform:false);
g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 5), center.toPoint(), cannon.toPoint()); g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 5), center.toPoint(), cannon.toPoint());
for (int i = 0; i < targets.Count; i++) for (int i = 0; i < targets.Count; i++)
{ {
@ -159,13 +159,15 @@ namespace LaptopSimulator2015.Levels
} }
if (firing) if (firing)
{ {
g.g.DrawRectangle(new Pen(new SolidBrush(Color.Green), 1), new Rectangle(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y - power / 2), Misc.d2i(power), Misc.d2i(power))); //g.g.DrawRectangle(new Pen(new SolidBrush(Color.Green), 1), new Rectangle(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y - power / 2), Misc.d2i(power), Misc.d2i(power)));
g.DrawRectangle(new RectangleF(targ.toPointF(), new SizeF(Misc.d2f(power), Misc.d2f(power))), Color.Green, filled: false, transform: false);
g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y - power / 2)), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y + power / 2))); g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y - power / 2)), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y + power / 2)));
g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y)), new PointF(Misc.d2i(targ.X + power / 2), Misc.d2i(targ.Y))); g.g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y)), new PointF(Misc.d2i(targ.X + power / 2), Misc.d2i(targ.Y)));
} }
else else
{ {
g.g.FillRectangle(new SolidBrush(Color.Green), new RectangleF(Misc.d2f(targ.X - 2.5f), Misc.d2f(targ.Y - 2.5f), 5, 5)); //g.g.FillRectangle(new SolidBrush(Color.Green), new RectangleF(Misc.d2f(targ.X - 2.5f), Misc.d2f(targ.Y - 2.5f), 5, 5));
g.DrawRectangle(new RectangleF(targ.toPointF(), new SizeF(5, 5)), Color.Green, transform: false);
} }
} }
} }

15
3g/3.cs
View File

@ -33,13 +33,9 @@ namespace LaptopSimulator2015.Goals
} }
public int availableAfter => 0; public int availableAfter => 0;
public int gameClock => 300; public int gameClock => 300;
public Panel desktopIcon { get; set; } public Panel desktopIcon { get; set; }
public int playableAfter => 4; public int playableAfter => 4;
public string[] availableText public string[] availableText
{ {
get { get {
@ -79,7 +75,7 @@ namespace LaptopSimulator2015.Goals
} }
} }
public Color backColor => Color.Black;
public static int[,] grid = new int[23, 10]; public static int[,] grid = new int[23, 10];
public static int[,] droppedtetrominoeLocationGrid = new int[23, 10]; public static int[,] droppedtetrominoeLocationGrid = new int[23, 10];
public static bool isDropped = false; public static bool isDropped = false;
@ -198,13 +194,12 @@ namespace LaptopSimulator2015.Goals
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime) public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{ {
g.g.Clear(Color.Black);
for (int y = 0; y < 23; ++y) for (int y = 0; y < 23; ++y)
{ {
for (int x = 0; x < 10; x++) for (int x = 0; x < 10; x++)
{ {
if (grid[y, x] == 1 | droppedtetrominoeLocationGrid[y, x] == 1) if (grid[y, x] == 1 | droppedtetrominoeLocationGrid[y, x] == 1)
g.g.FillRectangle(Brushes.White, new Rectangle(x * 10, y * 10, 10, 10)); g.DrawRectangle(new RectangleF(x * 10, y * 10, 10, 10), Color.White, false, false);
} }
g.g.DrawLine(new Pen(Color.DarkGray), new Point(0, (y + 1) * 10), new Point(10 * 10, (y + 1) * 10)); g.g.DrawLine(new Pen(Color.DarkGray), new Point(0, (y + 1) * 10), new Point(10 * 10, (y + 1) * 10));
} }
@ -212,9 +207,9 @@ namespace LaptopSimulator2015.Goals
{ {
g.g.DrawLine(new Pen(Color.DarkGray), new Point((x + 1) * 10, 0), new Point((x + 1) * 10, 23 * 10)); g.g.DrawLine(new Pen(Color.DarkGray), new Point((x + 1) * 10, 0), new Point((x + 1) * 10, 23 * 10));
} }
g.DrawSizedString("Level " + level, 10, new PointF(150, 10), Brushes.White); g.DrawSizedString("Level " + level, 10, new PointF(150, 10), Brushes.White, false);
g.DrawSizedString("Score " + score, 10, new PointF(150, 30), Brushes.White); g.DrawSizedString("Score " + score, 10, new PointF(150, 30), Brushes.White, false);
g.DrawSizedString("LinesCleared " + linesCleared, 10, new PointF(150, 50), Brushes.White); g.DrawSizedString("LinesCleared " + linesCleared, 10, new PointF(150, 50), Brushes.White, false);
} }
public class Tetrominoe public class Tetrominoe

39
4/4.cs
View File

@ -55,6 +55,7 @@ namespace LaptopSimulator2015.Levels
public int gameClock => 17; public int gameClock => 17;
public Panel desktopIcon { get; set; } public Panel desktopIcon { get; set; }
public int installerProgressSteps => 500; public int installerProgressSteps => 500;
public Color backColor => Color.Black;
Random rnd; Random rnd;
Vector2 player; Vector2 player;
@ -74,7 +75,7 @@ namespace LaptopSimulator2015.Levels
lazorTime -= Math.Min(minigameTime / 800, 2.5) + 0.5; lazorTime -= Math.Min(minigameTime / 800, 2.5) + 0.5;
if (lazorTime <= 0) if (lazorTime <= 0)
{ {
g.g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 5, 0, 10, minigamePanel.Height)); g.DrawRectangle(new RectangleF((float)lazor, minigamePanel.Height / 2, 10, minigamePanel.Height), Color.Red);
if (lazorTime <= -2) if (lazorTime <= -2)
{ {
lazorTime = 100; lazorTime = 100;
@ -86,13 +87,13 @@ namespace LaptopSimulator2015.Levels
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe")); throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
} }
} }
player.Y += speed; player.Y -= speed;
for (int i = 0; i < platforms.Count; i++) for (int i = 0; i < platforms.Count; i++)
{ {
platforms[i].Y += speed; platforms[i].Y -= speed;
if (platforms[i].Y > minigamePanel.Height) if (platforms[i].Y < 0)
{ {
platforms[i].Y = 0; platforms[i].Y = minigamePanel.Height;
platforms[i].X = rnd.Next(minigamePanel.Width); platforms[i].X = rnd.Next(minigamePanel.Width);
} }
} }
@ -101,19 +102,19 @@ namespace LaptopSimulator2015.Levels
{ {
movementFactor = 2; movementFactor = 2;
playerV.X *= 0.7; playerV.X *= 0.7;
playerV.Y = Math.Min(playerV.Y, 0); playerV.Y = Math.Max(playerV.Y, 0);
} }
else else
{ {
movementFactor = 5; movementFactor = 5;
playerV.X *= 0.9; playerV.X *= 0.9;
playerV.Y += 1; playerV.Y -= 1;
} }
if (Input.Up) if (Input.Up)
{ {
if (wasOnPlatform || jmpj > 0) if (wasOnPlatform || jmpj > 0)
{ {
playerV.Y -= jmpj / 6d + 1.5; playerV.Y += jmpj / 6d + 1.5;
jmpj--; jmpj--;
} }
} }
@ -130,16 +131,16 @@ namespace LaptopSimulator2015.Levels
if (Input.Right) if (Input.Right)
playerV.X += movementFactor; playerV.X += movementFactor;
player.X += playerV.X; player.X += playerV.X;
if (playerV.Y < 0) if (playerV.Y > 0)
player.Y += playerV.Y; player.Y += playerV.Y;
else else
for (int i = 0; i < playerV.Y / 2; i++) for (int i = 0; i < (-playerV.Y) / 2; i++)
{ {
if (onPlatform) if (onPlatform)
break; break;
player.Y += 2; player.Y -= 2;
} }
if (player.Y > minigamePanel.Height) if (player.Y < 0)
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe")); throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
wasOnPlatform = onPlatform; wasOnPlatform = onPlatform;
} }
@ -158,7 +159,7 @@ namespace LaptopSimulator2015.Levels
{ {
platforms.Add(new Vector2(rnd.Next(minigamePanel.Width - 100) + 50, i * (minigamePanel.Height / 5))); platforms.Add(new Vector2(rnd.Next(minigamePanel.Width - 100) + 50, i * (minigamePanel.Height / 5)));
} }
player = new Vector2(platforms[platforms.Count / 2].X, -10); player = new Vector2(platforms[platforms.Count / 2].X, minigamePanel.Height + 10);
player.bounds = new Rectangle(-5, 0, minigamePanel.Width + 10, 0); player.bounds = new Rectangle(-5, 0, minigamePanel.Width + 10, 0);
player.bounds_wrap = true; player.bounds_wrap = true;
lazor = player.X; lazor = player.X;
@ -200,7 +201,7 @@ namespace LaptopSimulator2015.Levels
else else
platforms[i].Tag = 0d; platforms[i].Tag = 0d;
} }
if (((double)platforms[i].Tag) <= 20 && RectangleF.Intersect(player2rect(), rect) != RectangleF.Empty && player.Y < platforms[i].Y - 8) if (((double)platforms[i].Tag) <= 20 && RectangleF.Intersect(player2rect(), rect) != RectangleF.Empty && player.Y > platforms[i].Y + 8)
return true; return true;
} }
return false; return false;
@ -211,15 +212,15 @@ namespace LaptopSimulator2015.Levels
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime) public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{ {
g.g.Clear(Color.Black); g.DrawRectangle(new RectangleF(player.toPointF(), new SizeF(10, 10)), Color.Green);
g.g.FillRectangle(new SolidBrush(Color.Green), player2rect());
if (lazorTime >= 0 && lazorTime <= 80) if (lazorTime >= 0 && lazorTime <= 80)
{ {
g.g.FillRectangle(new SolidBrush(Color.DarkGray), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height)); g.DrawRectangle(new RectangleF((float)lazor, minigamePanel.Height / 2, 2, minigamePanel.Height), Color.DarkGray);
g.g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height - (float)Misc.map(0, 80, 0, minigamePanel.Height, lazorTime))); float m = (float)Misc.map(0, 80, 0, minigamePanel.Height, lazorTime);
g.DrawRectangle(new RectangleF((float)lazor, minigamePanel.Height - m / 2, 2, m), Color.Red);
} }
for (int i = 0; i < platforms.Count; i++) for (int i = 0; i < platforms.Count; i++)
g.g.FillRectangle(new SolidBrush(Color.White), plat2rect(i)); g.DrawRectangle(new RectangleF(platforms[i].toPointF(), new SizeF(100, 10)), Color.White);
} }
} }
} }

View File

@ -11,16 +11,20 @@ namespace Base
public class GraphicsWrapper : IDisposable public class GraphicsWrapper : IDisposable
{ {
BufferedGraphics _g; BufferedGraphics _g;
Color backColor;
Rectangle targetSize;
public readonly Graphics g; public readonly Graphics g;
/// <summary> /// <summary>
/// Wrap the Graphics object with these excellent High-Quality functions /// Wrap the Graphics object with these excellent High-Quality functions
/// </summary> /// </summary>
/// <param name="g">The Graphics-object to wrap</param> /// <param name="g">The Graphics-object to wrap</param>
/// <param name="targetSize">The size of the device the Graphics are drawn to</param> /// <param name="targetSize">The size of the device the Graphics are drawn to</param>
public GraphicsWrapper(Graphics g, Rectangle targetSize) public GraphicsWrapper(Graphics g, Color backColor, Rectangle targetSize)
{ {
_g = BufferedGraphicsManager.Current.Allocate(g ?? throw new ArgumentNullException(nameof(g)), targetSize); _g = BufferedGraphicsManager.Current.Allocate(g ?? throw new ArgumentNullException(nameof(g)), targetSize);
this.g = _g.Graphics; this.g = _g.Graphics;
this.backColor = backColor;
this.targetSize = targetSize;
} }
/// <summary> /// <summary>
@ -31,7 +35,7 @@ namespace Base
/// <param name="location">The location to draw the string at</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="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> /// <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 isLocationCentered = false) public void DrawSizedString(string s, int size, PointF location, Brush brush, bool transform = true, bool isLocationCentered = false)
{ {
SmoothingMode tmpS = g.SmoothingMode; SmoothingMode tmpS = g.SmoothingMode;
InterpolationMode tmpI = g.InterpolationMode; InterpolationMode tmpI = g.InterpolationMode;
@ -40,17 +44,43 @@ namespace Base
g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality;
SizeF sLen = g.MeasureString(s, new Font("Tahoma", size)); SizeF sLen = g.MeasureString(s, new Font("Tahoma", size));
RectangleF rectf; RectangleF rectf = new RectangleF(location, sLen);
if (isLocationCentered) if (isLocationCentered)
rectf = new RectangleF(location.X - sLen.Width / 2, location.Y - sLen.Height / 2, sLen.Width, sLen.Height); rectf = new RectangleF(rectf.X - rectf.Width / 2, rectf.Y - rectf.Height / 2, rectf.Width, rectf.Height);
else if (transform)
rectf = new RectangleF(location, sLen); rectf = w2s(rectf);
g.DrawString(s, new Font("Tahoma", size), brush, rectf); g.DrawString(s, new Font("Tahoma", size), brush, rectf);
g.PixelOffsetMode = tmpP; g.PixelOffsetMode = tmpP;
g.InterpolationMode = tmpI; g.InterpolationMode = tmpI;
g.SmoothingMode = tmpS; g.SmoothingMode = tmpS;
} }
/// <summary>
/// Draws a rectangle
/// </summary>
/// <param name="rectangle">Use the PointF/SizeF Constructor as it is much more logical</param>
/// <param name="color">The color of the rectangle</param>
/// <param name="centered">Whether the rectangle should be drawn centered rather than down-left</param>
/// <param name="filled">Whether the rectangle should be filled</param>
/// <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, int unfilledLineSize = 1)
{
RectangleF r = rectangle;
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
g.DrawRectangle(new Pen(b, unfilledLineSize), new Rectangle(Misc.f2i(r.X), Misc.f2i(r.Y), Misc.f2i(r.Width), Misc.f2i(r.Height)));
}
public void Clear() => g.Clear(backColor);
public void Dispose() public void Dispose()
{ {
g.Flush(); g.Flush();
@ -58,5 +88,8 @@ namespace Base
g.Dispose(); g.Dispose();
_g.Dispose(); _g.Dispose();
} }
public RectangleF w2s(RectangleF from) => new RectangleF(w2s(from.Location), from.Size);
public PointF w2s(PointF from) => new PointF(from.X, targetSize.Height - from.Y);
} }
} }

View File

@ -54,6 +54,10 @@ namespace LaptopSimulator2015
/// <param name="minigameTimer">The timer used for scheduling frames</param> /// <param name="minigameTimer">The timer used for scheduling frames</param>
/// <param name="minigameTime">The amount of total displayed frames</param> /// <param name="minigameTime">The amount of total displayed frames</param>
void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime); void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime);
/// <summary>
/// Color to be painted to the Background before calling the draw method
/// </summary>
Color backColor { get; }
} }
public interface Level : Minigame public interface Level : Minigame
{ {

View File

@ -9,6 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaptopSimulator2015", "Lapt
{8109040E-9D8D-43E7-A461-83475B2939C9} = {8109040E-9D8D-43E7-A461-83475B2939C9} {8109040E-9D8D-43E7-A461-83475B2939C9} = {8109040E-9D8D-43E7-A461-83475B2939C9}
{4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529} = {4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529} {4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529} = {4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529}
{048BCC52-64BA-452B-A3F6-3683F9049AFD} = {048BCC52-64BA-452B-A3F6-3683F9049AFD} {048BCC52-64BA-452B-A3F6-3683F9049AFD} = {048BCC52-64BA-452B-A3F6-3683F9049AFD}
{DFD89655-00A7-4DF8-8B2E-17F5BEFE5090} = {DFD89655-00A7-4DF8-8B2E-17F5BEFE5090}
{E61E2797-62B4-471C-ACBF-31EAB7C746CF} = {E61E2797-62B4-471C-ACBF-31EAB7C746CF} {E61E2797-62B4-471C-ACBF-31EAB7C746CF} = {E61E2797-62B4-471C-ACBF-31EAB7C746CF}
{DFA2FB97-D676-4B0D-B281-2685F85781EE} = {DFA2FB97-D676-4B0D-B281-2685F85781EE} {DFA2FB97-D676-4B0D-B281-2685F85781EE} = {DFA2FB97-D676-4B0D-B281-2685F85781EE}
{72BBB6B8-5DA3-4FF1-8FA6-75256637F931} = {72BBB6B8-5DA3-4FF1-8FA6-75256637F931} {72BBB6B8-5DA3-4FF1-8FA6-75256637F931} = {72BBB6B8-5DA3-4FF1-8FA6-75256637F931}
@ -28,8 +29,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3", "3\3.csproj", "{8109040
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "4", "4\4.csproj", "{4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "4", "4\4.csproj", "{4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{23D851A7-722E-416A-91F8-0C86349D5BF3}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Meta", "Meta", "{23D851A7-722E-416A-91F8-0C86349D5BF3}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
make.bat = make.bat
README.md = README.md
ToDo.txt = ToDo.txt ToDo.txt = ToDo.txt
EndProjectSection EndProjectSection
EndProject EndProject
@ -48,6 +52,13 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zzz_ShuffleChars", "zzz_ShuffleChars\zzz_ShuffleChars.csproj", "{5E10F1D0-0114-444A-B80E-975B5DC40D9F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "zzz_ShuffleChars", "zzz_ShuffleChars\zzz_ShuffleChars.csproj", "{5E10F1D0-0114-444A-B80E-975B5DC40D9F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LevelTest", "LevelTest\LevelTest.csproj", "{DFD89655-00A7-4DF8-8B2E-17F5BEFE5090}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LevelTest", "LevelTest\LevelTest.csproj", "{DFD89655-00A7-4DF8-8B2E-17F5BEFE5090}"
ProjectSection(ProjectDependencies) = postProject
{0965C803-49B2-4311-B62F-1E60DBD9185F} = {0965C803-49B2-4311-B62F-1E60DBD9185F}
{8109040E-9D8D-43E7-A461-83475B2939C9} = {8109040E-9D8D-43E7-A461-83475B2939C9}
{4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529} = {4AA1EF48-BC5E-4FE4-9B7D-BAE6D6AB9529}
{E61E2797-62B4-471C-ACBF-31EAB7C746CF} = {E61E2797-62B4-471C-ACBF-31EAB7C746CF}
{DFA2FB97-D676-4B0D-B281-2685F85781EE} = {DFA2FB97-D676-4B0D-B281-2685F85781EE}
EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -475,8 +475,9 @@ namespace LaptopSimulator2015
uint minigamePrevTime = 0; uint minigamePrevTime = 0;
private void InvadersPanel_Paint(object sender, PaintEventArgs e) private void InvadersPanel_Paint(object sender, PaintEventArgs e)
{ {
using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, new Rectangle(Point.Empty, minigamePanel.Size))) using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, levels[levelInd].backColor, new Rectangle(Point.Empty, minigamePanel.Size)))
{ {
w.Clear();
levels[levelInd].draw(w, minigamePanel, minigameClockT, minigameTime); levels[levelInd].draw(w, minigamePanel, minigameClockT, minigameTime);
if (minigameTime != minigamePrevTime) if (minigameTime != minigamePrevTime)
{ {

View File

@ -144,6 +144,9 @@ if not exist "$(TargetDir)Content\Glitches" mkdir "$(TargetDir)Content\Glitches"
if exist "$(SolutionDir)tmp2" copy $(SolutionDir)tmp2\* "$(TargetDir)Content\Glitches" if exist "$(SolutionDir)tmp2" copy $(SolutionDir)tmp2\* "$(TargetDir)Content\Glitches"
rmdir /s /q "$(SolutionDir)tmp2" rmdir /s /q "$(SolutionDir)tmp2"
if exist "$(SolutionDir)tmp3" copy $(SolutionDir)tmp3\* "$(TargetDir)"
rmdir /s /q "$(SolutionDir)tmp3"
del /q "$(TargetDir)save.xml"</PostBuildEvent> del /q "$(TargetDir)save.xml"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@ -46,7 +46,6 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(482, 262); this.ClientSize = new System.Drawing.Size(482, 262);
this.ControlBox = false;
this.Controls.Add(this.listBox1); this.Controls.Add(this.listBox1);
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;

View File

@ -13,10 +13,11 @@ namespace LevelTest
public partial class ArrayDialog : Form public partial class ArrayDialog : Form
{ {
public int returnIndex; public int returnIndex;
public ArrayDialog(string[] items) public ArrayDialog(string[] items, string title = "")
{ {
InitializeComponent(); InitializeComponent();
listBox1.Items.AddRange(items); listBox1.Items.AddRange(items);
Text = title;
} }
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -95,4 +95,8 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist "$(SolutionDir)tmp3" mkdir "$(SolutionDir)tmp3"
copy "$(TargetPath)" "$(SolutionDir)tmp3"</PostBuildEvent>
</PropertyGroup>
</Project> </Project>

View File

@ -31,7 +31,6 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.minigamePanel = new System.Windows.Forms.Panel(); this.minigamePanel = new System.Windows.Forms.Panel();
this.minigameClockT = new System.Windows.Forms.Timer(this.components); this.minigameClockT = new System.Windows.Forms.Timer(this.components);
this.closeButton = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// minigamePanel // minigamePanel
@ -50,28 +49,19 @@
this.minigameClockT.Interval = 17; this.minigameClockT.Interval = 17;
this.minigameClockT.Tick += new System.EventHandler(this.MinigameClockT_Tick); this.minigameClockT.Tick += new System.EventHandler(this.MinigameClockT_Tick);
// //
// closeButton
//
this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeButton.BackColor = System.Drawing.Color.Red;
this.closeButton.Location = new System.Drawing.Point(776, 2);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(23, 23);
this.closeButton.TabIndex = 0;
this.closeButton.Text = "X";
this.closeButton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.closeButton.Click += new System.EventHandler(this.CloseButton_Click);
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.closeButton);
this.Controls.Add(this.minigamePanel); this.Controls.Add(this.minigamePanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm"; this.Name = "MainForm";
this.ShowIcon = false;
this.Text = "Form1"; this.Text = "Form1";
this.TopMost = true;
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -79,7 +69,6 @@
#endregion #endregion
private System.Windows.Forms.Panel minigamePanel; private System.Windows.Forms.Panel minigamePanel;
private System.Windows.Forms.Timer minigameClockT; private System.Windows.Forms.Timer minigameClockT;
private System.Windows.Forms.Label closeButton;
} }
} }

View File

@ -17,14 +17,14 @@ namespace LevelTest
Minigame level; Minigame level;
public MainForm(Minigame game) public MainForm(Minigame game)
{ {
Misc.closeGameWindow = () => { level.initGame(minigamePanel, minigameClockT); };
level = game; level = game;
InitializeComponent(); InitializeComponent();
minigameClockT.Interval = level.gameClock; minigameClockT.Interval = level.gameClock;
Text = level.name; Text = level.name;
level.initGame(minigamePanel, minigameClockT); Misc.closeGameWindow.Invoke();
} }
private void CloseButton_Click(object sender, EventArgs e) => Application.Exit();
uint minigameTime; uint minigameTime;
uint minigamePrevTime; uint minigamePrevTime;
private void MinigameClockT_Tick(object sender, EventArgs e) private void MinigameClockT_Tick(object sender, EventArgs e)
@ -35,8 +35,9 @@ namespace LevelTest
private void MinigamePanel_Paint(object sender, PaintEventArgs e) private void MinigamePanel_Paint(object sender, PaintEventArgs e)
{ {
using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, new Rectangle(Point.Empty, minigamePanel.Size))) using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, level.backColor, new Rectangle(Point.Empty, minigamePanel.Size)))
{ {
w.Clear();
level.draw(w, minigamePanel, minigameClockT, minigameTime); level.draw(w, minigamePanel, minigameClockT, minigameTime);
if (minigameTime != minigamePrevTime) if (minigameTime != minigamePrevTime)
{ {

View File

@ -17,49 +17,56 @@ namespace LevelTest
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
Application.EnableVisualStyles(); try
Application.SetCompatibleTextRenderingDefault(false);
if (args != null && args.Length > 0)
{ {
if (Directory.Exists(args[0].Replace("\"", ""))) Application.EnableVisualStyles();
Directory.SetCurrentDirectory(args[0].Replace("\"", "")); Application.SetCompatibleTextRenderingDefault(false);
else if (File.Exists(args[0].Replace("\"", ""))) if (args != null && args.Length > 0)
Directory.SetCurrentDirectory(Path.GetDirectoryName(args[0].Replace("\"", ""))); {
if (Directory.Exists(args[0].Replace("\"", "")))
Directory.SetCurrentDirectory(args[0].Replace("\"", ""));
else if (File.Exists(args[0].Replace("\"", "")))
Directory.SetCurrentDirectory(Path.GetDirectoryName(args[0].Replace("\"", "")));
else
throw new Exception("Invalid argument");
}
else else
throw new Exception("Invalid argument"); {
} string[] tmp = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll").ToArray();
else if (tmp.Length == 0)
{ using (FolderBrowserDialog openFileDialog = new FolderBrowserDialog())
string[] tmp = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll").ToArray(); {
if (tmp.Length == 0) if (openFileDialog.ShowDialog() == DialogResult.OK)
using (FolderBrowserDialog openFileDialog = new FolderBrowserDialog()) Directory.SetCurrentDirectory(openFileDialog.SelectedPath);
else
throw new Exception("Please select a folder");
}
}
Minigame[] levels = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll")
.Select(s => Assembly.LoadFrom(s)).SelectMany(s => s.GetTypes()).Distinct()
.Where(p => typeof(Minigame).IsAssignableFrom(p)).Distinct().Except(new Type[] { typeof(Minigame), typeof(Level), typeof(Goal) })
.Select(s => (Minigame)Activator.CreateInstance(s)).OrderBy(lv => lv.availableAfter).ToArray();
Minigame level;
if (levels.Length == 0)
throw new Exception("No Levels found!");
else if (levels.Length == 1)
level = levels[0];
else
{
using (ArrayDialog dialog = new ArrayDialog(levels.Select(s => s.name).ToArray(), "Select a Minigame"))
{ {
if (openFileDialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
Directory.SetCurrentDirectory(openFileDialog.SelectedPath); level = levels[dialog.returnIndex];
else else
throw new Exception("Please select a folder"); throw new Exception("Please select a folder");
} }
}
Minigame[] levels = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll")
.Select(s => Assembly.LoadFrom(s)).SelectMany(s => s.GetTypes()).Distinct()
.Where(p => typeof(Minigame).IsAssignableFrom(p)).Distinct().Except(new Type[] { typeof(Minigame), typeof(Level), typeof(Goal) })
.Select(s => (Minigame)Activator.CreateInstance(s)).OrderBy(lv => lv.availableAfter).ToArray();
Minigame level;
if (levels.Length == 0)
throw new Exception("No Levels found!");
else if (levels.Length == 1)
level = levels[0];
else
{
using (ArrayDialog dialog = new ArrayDialog(levels.Select(s => s.name).ToArray()))
{
if (dialog.ShowDialog() == DialogResult.OK)
level = levels[dialog.returnIndex];
else
throw new Exception("Please select a folder");
} }
Application.Run(new MainForm(level));
}
catch (Exception e)
{
Console.WriteLine(e.Message);
} }
Application.Run(new MainForm(level));
} }
} }
} }

View File

@ -1,3 +1,5 @@
Centralize drawing, distance, screen/worldspace, central "Content"-Folder with depth, in-game level inspector Centralize distance functions
Fully implement new graphics on Goal and Level 3
Handle Subtitle-Exception
https://devblogs.nvidia.com/hybridizer-csharp/ (?) https://devblogs.nvidia.com/hybridizer-csharp/ (?)
OS Install as Tutoral OS Install as Tutorial