Some minor polishing
This commit is contained in:
parent
f80fe9e644
commit
7c62a71358
81
1/1.cs
81
1/1.cs
|
@ -60,13 +60,13 @@ namespace LaptopSimulator2015.Levels
|
|||
public Panel desktopIcon { get; set; }
|
||||
|
||||
public int installerProgressSteps => 500;
|
||||
|
||||
List<Vector2> invadersAliens = new List<Vector2>();
|
||||
List<Vector2> invadersBullets = new List<Vector2>();
|
||||
Vector2 invadersPlayer;
|
||||
uint minigamePrevTime = 0;
|
||||
bool invadersCanShoot = true;
|
||||
double speedMod = 5;
|
||||
|
||||
List<Vector2> enemies;
|
||||
List<Vector2> bullets;
|
||||
Vector2 player;
|
||||
double speedMod;
|
||||
bool enemiesCanShoot;
|
||||
|
||||
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
|
||||
{
|
||||
|
@ -75,62 +75,62 @@ namespace LaptopSimulator2015.Levels
|
|||
try
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
for (int i = 0; i < invadersAliens.Count; i++)
|
||||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(invadersAliens[i].toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
|
||||
}
|
||||
for (int i = 0; i < invadersBullets.Count; i++)
|
||||
for (int i = 0; i < bullets.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(invadersBullets[i].toPoint(), new Size(5, 5)));
|
||||
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(bullets[i].toPoint(), new Size(5, 5)));
|
||||
}
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(invadersPlayer.toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
minigamePrevTime = minigameTime;
|
||||
if (random.Next(0, 100000) < minigameTime + 1300)
|
||||
invadersAliens.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
|
||||
for (int i = 0; i < invadersAliens.Count; i++)
|
||||
enemies.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
|
||||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
invadersAliens[i].X -= 1.2;
|
||||
if (invadersPlayer.distanceFromSquared(invadersAliens[i]) < 100 | invadersAliens[i].X < 0)
|
||||
enemies[i].X -= 1.2;
|
||||
if (player.distanceFromSquared(enemies[i]) < 100 | enemies[i].X < 0)
|
||||
{
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
}
|
||||
invadersCanShoot = invadersCanShoot | !Input.Action;
|
||||
List<Vector2> aliensToRemove = new List<Vector2>();
|
||||
enemiesCanShoot = enemiesCanShoot | !Input.Action;
|
||||
List<Vector2> enemiesToRemove = new List<Vector2>();
|
||||
List<Vector2> bulletsToRemove = new List<Vector2>();
|
||||
for (int i = 0; i < invadersBullets.Count; i++)
|
||||
for (int i = 0; i < bullets.Count; i++)
|
||||
{
|
||||
invadersBullets[i].X += 4;
|
||||
for (int j = 0; j < invadersAliens.Count; j++)
|
||||
bullets[i].X += 4;
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (invadersBullets[i].distanceFromSquared(invadersAliens[j] + new Vector2(2.5f, 2.5f)) < 56.25f)
|
||||
if (bullets[i].distanceFromSquared(enemies[j] + new Vector2(2.5f, 2.5f)) < 56.25f)
|
||||
{
|
||||
aliensToRemove.Add(invadersAliens[j]);
|
||||
bulletsToRemove.Add(invadersBullets[i]);
|
||||
enemiesToRemove.Add(enemies[j]);
|
||||
bulletsToRemove.Add(bullets[i]);
|
||||
}
|
||||
}
|
||||
if (invadersBullets[i].X > minigamePanel.Width)
|
||||
bulletsToRemove.Add(invadersBullets[i]);
|
||||
if (bullets[i].X > minigamePanel.Width)
|
||||
bulletsToRemove.Add(bullets[i]);
|
||||
}
|
||||
invadersAliens = invadersAliens.Except(aliensToRemove.Distinct()).Distinct().ToList();
|
||||
invadersBullets = invadersBullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
|
||||
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
|
||||
bullets = bullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
|
||||
speedMod += 0.1;
|
||||
speedMod = Math.Max(Math.Min(speedMod, 5), 1);
|
||||
if (Input.Up)
|
||||
invadersPlayer.Y -= speedMod;
|
||||
player.Y -= speedMod;
|
||||
if (Input.Left)
|
||||
invadersPlayer.X -= speedMod;
|
||||
player.X -= speedMod;
|
||||
if (Input.Down)
|
||||
invadersPlayer.Y += speedMod;
|
||||
player.Y += speedMod;
|
||||
if (Input.Right)
|
||||
invadersPlayer.X += speedMod;
|
||||
if (Input.Action & invadersCanShoot)
|
||||
player.X += speedMod;
|
||||
if (Input.Action & enemiesCanShoot)
|
||||
{
|
||||
invadersBullets.Add(new Vector2(0, 2.5) + invadersPlayer);
|
||||
invadersCanShoot = false;
|
||||
bullets.Add(new Vector2(0, 2.5) + player);
|
||||
enemiesCanShoot = false;
|
||||
speedMod--;
|
||||
}
|
||||
}
|
||||
|
@ -142,14 +142,13 @@ namespace LaptopSimulator2015.Levels
|
|||
|
||||
public void initGame(Graphics g, Panel minigamePanel, Timer minigameTimer)
|
||||
{
|
||||
invadersPlayer = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2);
|
||||
invadersPlayer.bounds_wrap = true;
|
||||
invadersPlayer.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
invadersAliens = new List<Vector2>();
|
||||
invadersBullets = new List<Vector2>();
|
||||
minigamePrevTime = 0;
|
||||
invadersCanShoot = true;
|
||||
enemies = new List<Vector2>();
|
||||
bullets = new List<Vector2>();
|
||||
speedMod = 5;
|
||||
enemiesCanShoot = true;
|
||||
player = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2);
|
||||
player.bounds_wrap = true;
|
||||
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
}
|
||||
}
|
||||
}
|
23
2/2.cs
23
2/2.cs
|
@ -61,10 +61,11 @@ namespace LaptopSimulator2015.Levels
|
|||
public Panel desktopIcon { get; set; }
|
||||
|
||||
public int installerProgressSteps => 500;
|
||||
List<Vector2> enemies = new List<Vector2>();
|
||||
Vector2 player;
|
||||
uint minigamePrevTime = 0;
|
||||
uint lives = 3;
|
||||
|
||||
List<Vector2> enemies;
|
||||
Vector2 player;
|
||||
int lives;
|
||||
|
||||
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
|
||||
{
|
||||
|
@ -75,7 +76,7 @@ namespace LaptopSimulator2015.Levels
|
|||
for (int i = 0; i < enemies.Count; i++)
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
g.DrawString(lives.ToString(), new Font("Tahoma", 7), Brushes.White, new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
Drawing.DrawSizedString(g, lives.ToString(), 7, (player + new PointF(5, 5)).toPointF(), Brushes.White, true);
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
|
@ -104,18 +105,18 @@ namespace LaptopSimulator2015.Levels
|
|||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
enemies[i].moveTowards(player, Math.Max(6, Math.Sqrt(minigameTime / 100 + 1)));
|
||||
if (player.distanceFromSquared(enemies[i]) < 100)
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (i != j && enemies[i].distanceFromSquared(enemies[j]) < 25 && !enemiesToRemove.Contains(enemies[j]))
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
}
|
||||
if (player.distanceFromSquared(enemies[i]) < 100 && !enemiesToRemove.Contains(enemies[i]))
|
||||
{
|
||||
lives--;
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
if (lives <= 0)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (i != j & enemies[i].distanceFromSquared(enemies[j]) < 25)
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
}
|
||||
}
|
||||
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
|
||||
}
|
||||
|
@ -127,10 +128,10 @@ namespace LaptopSimulator2015.Levels
|
|||
|
||||
public void initGame(Graphics g, Panel minigamePanel, Timer minigameTimer)
|
||||
{
|
||||
enemies = new List<Vector2>();
|
||||
player = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
player.bounds_wrap = true;
|
||||
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
enemies = new List<Vector2>();
|
||||
lives = 3;
|
||||
}
|
||||
}
|
||||
|
|
18
3/3.cs
18
3/3.cs
|
@ -62,16 +62,18 @@ namespace LaptopSimulator2015.Levels
|
|||
|
||||
public int installerProgressSteps => 500;
|
||||
uint minigamePrevTime = 0;
|
||||
|
||||
Vector2 center;
|
||||
Vector2 cannon;
|
||||
Vector2 targ;
|
||||
List<Vector2> targets = new List<Vector2>();
|
||||
List<Vector2> targets;
|
||||
Rectangle player => new Rectangle(center.toPoint().X - 5, center.toPoint().Y - 5, 10, 10);
|
||||
double playerRot = 0;
|
||||
double cannonL = 30;
|
||||
double power = 10;
|
||||
bool firing = false;
|
||||
uint lastTarget = 0;
|
||||
double playerRot;
|
||||
double cannonL;
|
||||
double power;
|
||||
bool firing;
|
||||
uint lastTarget;
|
||||
|
||||
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
|
||||
{
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
|
||||
|
@ -162,8 +164,8 @@ namespace LaptopSimulator2015.Levels
|
|||
public void initGame(Graphics g, Panel minigamePanel, Timer minigameTimer)
|
||||
{
|
||||
center = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
cannon = center;
|
||||
targ = center;
|
||||
cannon = new Vector2(center);
|
||||
targ = new Vector2(center);
|
||||
targets = new List<Vector2>();
|
||||
playerRot = 0;
|
||||
cannonL = 30;
|
||||
|
|
225
4/4.cs
225
4/4.cs
|
@ -56,13 +56,16 @@ namespace LaptopSimulator2015.Levels
|
|||
public Panel desktopIcon { get; set; }
|
||||
public int installerProgressSteps => 500;
|
||||
uint minigamePrevTime = 0;
|
||||
Random rnd = new Random();
|
||||
Vector2 player = new Vector2();
|
||||
Vector2 playerV = new Vector2();
|
||||
|
||||
Random rnd;
|
||||
Vector2 player;
|
||||
Vector2 playerV;
|
||||
double lazor;
|
||||
double lazorTime;
|
||||
double speed;
|
||||
int jmpj;
|
||||
List<Vector2> platforms = new List<Vector2>();
|
||||
bool wasOnPlatform;
|
||||
List<Vector2> platforms;
|
||||
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
|
||||
{
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
|
||||
|
@ -71,82 +74,89 @@ namespace LaptopSimulator2015.Levels
|
|||
{
|
||||
g.Clear(Color.Black);
|
||||
g.FillRectangle(new SolidBrush(Color.Green), player2rect());
|
||||
bool onPlatform = false;
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.White), plat2rect(i));
|
||||
onPlatform |= isOnPlatform(i);
|
||||
}
|
||||
if (lazorTime >= 0 && lazorTime <= 30)
|
||||
if (lazorTime >= 0 && lazorTime <= 80)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.DarkGray), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height - (float)Misc.map(0, 30, 0, minigamePanel.Height, lazorTime)));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height - (float)Misc.map(0, 80, 0, minigamePanel.Height, lazorTime)));
|
||||
}
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
g.FillRectangle(new SolidBrush(Color.White), plat2rect(i));
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
lazorTime -= minigameTime - minigamePrevTime;
|
||||
speed = Math.Min(minigameTime / 200d, 2) + 0.5;
|
||||
lazorTime -= Math.Min(minigameTime / 800, 2.5) + 0.5;
|
||||
minigamePrevTime = minigameTime;
|
||||
if (lazorTime <= 0)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 5, 0, 10, minigamePanel.Height));
|
||||
if (lazorTime <= -2)
|
||||
{
|
||||
lazorTime = 40;
|
||||
lazorTime = 100;
|
||||
lazor = player.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.X >= lazor - 5 && player.X <= lazor + 5)
|
||||
if (player.X > lazor - 10 && player.X < lazor + 10)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
}
|
||||
if (onPlatform)
|
||||
playerV.Y = Math.Min(playerV.Y, 0);
|
||||
else
|
||||
playerV.Y += 1;
|
||||
playerV.X /= 1.2f;
|
||||
if (onPlatform)
|
||||
jmpj = 10;
|
||||
else
|
||||
if (!Input.Up)
|
||||
jmpj = 0;
|
||||
if ((onPlatform || jmpj > 0) && Input.Up)
|
||||
{
|
||||
playerV.Y -= jmpj / 6d + 1.5;
|
||||
jmpj--;
|
||||
}
|
||||
double movementFactor = 15;
|
||||
if (onPlatform)
|
||||
movementFactor /= 4;
|
||||
if (Input.Left)
|
||||
playerV.X -= movementFactor;
|
||||
if (Input.Right)
|
||||
playerV.X += movementFactor;
|
||||
player.X += playerV.X;
|
||||
onPlatform = false;
|
||||
if (playerV.Y < 0)
|
||||
player.Y += playerV.Y;
|
||||
else
|
||||
for (int i = 0; i < playerV.Y / 2; i++)
|
||||
{
|
||||
for (int j = 0; j < platforms.Count; j++)
|
||||
onPlatform |= isOnPlatform(j);
|
||||
if (!onPlatform)
|
||||
player.Y += 2;
|
||||
}
|
||||
List<Vector2> platformsToRemove = new List<Vector2>();
|
||||
player.Y += speed;
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
platforms[i].Y += 1.7;
|
||||
platforms[i].Y += speed;
|
||||
if (platforms[i].Y > minigamePanel.Height)
|
||||
{
|
||||
platforms[i].Y = 0;
|
||||
platforms[i].X = rnd.Next(minigamePanel.Width);
|
||||
}
|
||||
}
|
||||
double movementFactor;
|
||||
if (wasOnPlatform)
|
||||
{
|
||||
movementFactor = 2;
|
||||
playerV.X *= 0.7;
|
||||
playerV.Y = Math.Min(playerV.Y, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
movementFactor = 5;
|
||||
playerV.X *= 0.9;
|
||||
playerV.Y += 1;
|
||||
}
|
||||
if (Input.Up)
|
||||
{
|
||||
if (wasOnPlatform || jmpj > 0)
|
||||
{
|
||||
playerV.Y -= jmpj / 6d + 1.5;
|
||||
jmpj--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wasOnPlatform)
|
||||
jmpj = 10;
|
||||
else
|
||||
jmpj = 0;
|
||||
}
|
||||
jmpj = Math.Max(0, jmpj);
|
||||
if (Input.Left)
|
||||
playerV.X -= movementFactor;
|
||||
if (Input.Right)
|
||||
playerV.X += movementFactor;
|
||||
player.X += playerV.X;
|
||||
if (playerV.Y < 0)
|
||||
player.Y += playerV.Y;
|
||||
else
|
||||
for (int i = 0; i < playerV.Y / 2; i++)
|
||||
{
|
||||
if (onPlatform)
|
||||
break;
|
||||
player.Y += 2;
|
||||
}
|
||||
if (player.Y > minigamePanel.Height)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
wasOnPlatform = onPlatform;
|
||||
}
|
||||
buffer.Render();
|
||||
buffer.Dispose();
|
||||
|
@ -156,80 +166,65 @@ namespace LaptopSimulator2015.Levels
|
|||
|
||||
public void initGame(Graphics g, Panel minigamePanel, Timer minigameTimer)
|
||||
{
|
||||
rnd = new Random();
|
||||
playerV = new Vector2();
|
||||
playerV.bounds = new Rectangle(-5, -20, 10, 40);
|
||||
playerV.bounds = new Rectangle(-10, -20, 20, 40);
|
||||
playerV.bounds_wrap = false;
|
||||
platforms = new List<Vector2>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
platforms.Add(new Vector2(rnd.Next(minigamePanel.Width), i * (minigamePanel.Height / 5)));
|
||||
player = new Vector2(platforms[0].X, -10);
|
||||
{
|
||||
platforms.Add(new Vector2(rnd.Next(minigamePanel.Width - 100) + 50, i * (minigamePanel.Height / 5)));
|
||||
}
|
||||
player = new Vector2(platforms[platforms.Count / 2].X, -10);
|
||||
player.bounds = new Rectangle(-5, 0, minigamePanel.Width + 10, 0);
|
||||
player.bounds_wrap = true;
|
||||
lazor = player.X;
|
||||
lazorTime = 50;
|
||||
lazorTime = 100;
|
||||
speed = 1;
|
||||
wasOnPlatform = true;
|
||||
}
|
||||
|
||||
bool onPlatform
|
||||
{
|
||||
get {
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
RectangleF rect = plat2rect(i);
|
||||
if (player.X < rect.X)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = (player - new PointF(rect.X, rect.Y)).magnitude;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = (player - new PointF(rect.X, rect.Y + rect.Height)).magnitude;
|
||||
else
|
||||
platforms[i].Tag = rect.X - player.X;
|
||||
}
|
||||
else if (player.X > rect.X + rect.Width)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = (player - new PointF(rect.X + rect.Width, rect.Y)).magnitude;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = (player - new PointF(rect.X + rect.Width, rect.Y + rect.Height)).magnitude;
|
||||
else
|
||||
platforms[i].Tag = player.X - rect.X + rect.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = rect.Y - player.Y;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = player.Y - (rect.Y + rect.Height);
|
||||
else
|
||||
platforms[i].Tag = 0d;
|
||||
}
|
||||
if (((double)platforms[i].Tag) <= 20 && RectangleF.Intersect(player2rect(), rect) != RectangleF.Empty && player.Y < platforms[i].Y - 8)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
RectangleF plat2rect(int platform) => new RectangleF((platforms[platform] - new Vector2(50, 5)).toPointF(), new SizeF(100, 10));
|
||||
RectangleF player2rect() => new RectangleF((player - new Vector2(5, 5)).toPointF(), new SizeF(10, 10));
|
||||
|
||||
bool isOnPlatform(int platform)
|
||||
{
|
||||
calcDist(platform);
|
||||
return ((double)platforms[platform].Tag) <= 20 && RectangleF.Intersect(player2rect(), plat2rect(platform)) != RectangleF.Empty && player.Y < platforms[platform].Y - 8;
|
||||
}
|
||||
|
||||
void calcDist(int platform)
|
||||
{
|
||||
RectangleF rect = plat2rect(platform);
|
||||
if (player.X < rect.X)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X, rect.Y);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X, rect.Y + rect.Height);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = rect.X - player.X;
|
||||
}
|
||||
}
|
||||
else if (player.X > rect.X + rect.Width)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X + rect.Width, rect.Y);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X + rect.Width, rect.Y + rect.Height);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = player.X - rect.X + rect.Width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
platforms[platform].Tag = rect.Y - player.Y;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
platforms[platform].Tag = player.Y - (rect.Y + rect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = 0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Drawing.cs" />
|
||||
<Compile Include="Input.cs" />
|
||||
<Compile Include="Level.cs" />
|
||||
<Compile Include="Misc.cs" />
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Base
|
||||
{
|
||||
public static class Drawing
|
||||
{
|
||||
public static void DrawSizedString(Graphics g, string s, int size, PointF location, Brush brush, bool isLocationCentered = false)
|
||||
{
|
||||
SmoothingMode tmpS = g.SmoothingMode;
|
||||
InterpolationMode tmpI = g.InterpolationMode;
|
||||
PixelOffsetMode tmpP = g.PixelOffsetMode;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString(s, new Font("Tahoma", size));
|
||||
RectangleF rectf;
|
||||
if (isLocationCentered)
|
||||
rectf = new RectangleF(location.X - sLen.Width / 2, location.Y - sLen.Height / 2, sLen.Width, sLen.Height);
|
||||
else
|
||||
rectf = new RectangleF(location, sLen);
|
||||
g.DrawString(s, new Font("Tahoma", size), brush, rectf);
|
||||
g.PixelOffsetMode = tmpP;
|
||||
g.InterpolationMode = tmpI;
|
||||
g.SmoothingMode = tmpS;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
@ -20,18 +20,34 @@ namespace Base
|
|||
{
|
||||
if (bounds_wrap)
|
||||
{
|
||||
if (bounds.X != 0 & bounds.Width < 0)
|
||||
throw new ArgumentException("bounds.Width must be greater than or equal to 0");
|
||||
while (bounds.X != 0 & x_unchecked > bounds.X + bounds.Width)
|
||||
x_unchecked -= bounds.Width;
|
||||
while (bounds.X != 0 & x_unchecked < bounds.X)
|
||||
x_unchecked += bounds.Width;
|
||||
if (bounds.Y != 0 & bounds.Height < 0)
|
||||
throw new ArgumentException("bounds.Height must be greater than or equal to 0");
|
||||
while (bounds.Y != 0 & y_unchecked > bounds.Y + bounds.Height)
|
||||
y_unchecked -= bounds.Height;
|
||||
while (bounds.Y != 0 & y_unchecked < bounds.Y)
|
||||
y_unchecked += bounds.Height;
|
||||
if (!(bounds.X == 0 && bounds.Width == 0))
|
||||
{
|
||||
if (bounds.Width == 0)
|
||||
x_unchecked = bounds.X;
|
||||
else
|
||||
{
|
||||
if (bounds.Width < 0)
|
||||
throw new ArgumentException("bounds.Width must be greater than or equal to 0");
|
||||
while (x_unchecked > bounds.X + bounds.Width)
|
||||
x_unchecked -= bounds.Width;
|
||||
while (x_unchecked < bounds.X)
|
||||
x_unchecked += bounds.Width;
|
||||
}
|
||||
}
|
||||
if (!(bounds.Y == 0 && bounds.Height == 0))
|
||||
{
|
||||
if (bounds.Height == 0)
|
||||
y_unchecked = bounds.Y;
|
||||
else
|
||||
{
|
||||
if (bounds.Height < 0)
|
||||
throw new ArgumentException("bounds.Height must be greater than or equal to 0");
|
||||
while (y_unchecked > bounds.Y + bounds.Height)
|
||||
y_unchecked -= bounds.Height;
|
||||
while (y_unchecked < bounds.Y)
|
||||
y_unchecked += bounds.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace LaptopSimulator2015
|
|||
this.optionsWindowIcon = new System.Windows.Forms.Panel();
|
||||
this.optionsWindowTitle = new System.Windows.Forms.Label();
|
||||
this.lsdEffectT = new System.Windows.Forms.Timer(this.components);
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.winMenuPanel.SuspendLayout();
|
||||
this.winTaskbar.SuspendLayout();
|
||||
this.winDesktop.SuspendLayout();
|
||||
|
@ -179,6 +180,7 @@ namespace LaptopSimulator2015
|
|||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.winTaskbar.BackColor = System.Drawing.Color.Navy;
|
||||
this.winTaskbar.Controls.Add(this.subsLabel);
|
||||
this.winTaskbar.Controls.Add(this.winTimeLabel);
|
||||
this.winTaskbar.Location = new System.Drawing.Point(30, 889);
|
||||
this.winTaskbar.Name = "winTaskbar";
|
||||
this.winTaskbar.Size = new System.Drawing.Size(1357, 30);
|
||||
|
@ -414,11 +416,11 @@ namespace LaptopSimulator2015
|
|||
this.winTimeLabel.AutoSize = true;
|
||||
this.winTimeLabel.BackColor = System.Drawing.Color.Navy;
|
||||
this.winTimeLabel.ForeColor = System.Drawing.Color.White;
|
||||
this.winTimeLabel.Location = new System.Drawing.Point(1344, 898);
|
||||
this.winTimeLabel.Location = new System.Drawing.Point(1305, 9);
|
||||
this.winTimeLabel.Name = "winTimeLabel";
|
||||
this.winTimeLabel.Size = new System.Drawing.Size(34, 13);
|
||||
this.winTimeLabel.Size = new System.Drawing.Size(49, 13);
|
||||
this.winTimeLabel.TabIndex = 0;
|
||||
this.winTimeLabel.Text = "00:00";
|
||||
this.winTimeLabel.Text = "00:00:00";
|
||||
//
|
||||
// winTimeTimer
|
||||
//
|
||||
|
@ -592,7 +594,6 @@ namespace LaptopSimulator2015
|
|||
this.Controls.Add(this.optionsWindow);
|
||||
this.Controls.Add(this.minigamePanel);
|
||||
this.Controls.Add(this.levelWindow);
|
||||
this.Controls.Add(this.winTimeLabel);
|
||||
this.Controls.Add(this.winMenuPanel);
|
||||
this.Controls.Add(this.winTaskbar);
|
||||
this.Controls.Add(this.winKey);
|
||||
|
@ -623,7 +624,6 @@ namespace LaptopSimulator2015
|
|||
this.optionsWindowHeader.ResumeLayout(false);
|
||||
this.optionsWindowHeader.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
@ -674,5 +674,6 @@ namespace LaptopSimulator2015
|
|||
private System.Windows.Forms.Label levelWindowHeaderExit;
|
||||
private System.Windows.Forms.Label optionsWindowHeaderExit;
|
||||
private System.Windows.Forms.Button optionsWindowReset;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
}
|
||||
}
|
|
@ -74,6 +74,7 @@ namespace LaptopSimulator2015
|
|||
if (!Directory.Exists("Levels"))
|
||||
Directory.CreateDirectory("Levels");
|
||||
InitializeComponent();
|
||||
toolTip.SetToolTip(options_2, strings.optionsWindowTitle);
|
||||
levelWindowContents.ItemSize = new Size(0, 1);
|
||||
optionsWindowLang.Text = Settings.lang.Name;
|
||||
Thread.CurrentThread.CurrentUICulture = Settings.lang;
|
||||
|
@ -89,7 +90,7 @@ namespace LaptopSimulator2015
|
|||
winMenuStart.Text = strings.winMenuStart;
|
||||
winMenuText.Text = strings.winMenuText;
|
||||
levelWindowTitle.Text = "";
|
||||
winTimeLabel.Text = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
|
||||
winTimeLabel.Text = DateTime.Now.ToString("hh:mm:ss", Settings.lang);
|
||||
fans = new SoundPlayer(Resources.fans);
|
||||
fans.PlayLooping();
|
||||
Control[] controls = getControls(ignore: new List<Control> { minigamePanel }).ToArray();
|
||||
|
@ -125,6 +126,7 @@ namespace LaptopSimulator2015
|
|||
tmp1.Size = new Size(46, 46);
|
||||
tmp1.Tag = i;
|
||||
tmp1.DoubleClick += (sender, e) => { level_Start((int)((Panel)sender).Tag); };
|
||||
toolTip.SetToolTip(tmp1, strings.lvPref + " " + (i + 1).ToString() + ": " + levels[i].installerHeader);
|
||||
|
||||
levels[i].desktopIcon.Controls.Add(tmp1);
|
||||
winDesktop.Controls.Add(levels[i].desktopIcon);
|
||||
|
@ -204,7 +206,7 @@ namespace LaptopSimulator2015
|
|||
|
||||
private void WinMenuStart_Click(object sender, EventArgs e) => mode = Mode.game;
|
||||
|
||||
private void WinTimeTimer_Tick(object sender, EventArgs e) => winTimeLabel.Text = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
|
||||
private void WinTimeTimer_Tick(object sender, EventArgs e) => winTimeLabel.Text = DateTime.Now.ToString("hh:mm:ss", Settings.lang);
|
||||
#endregion
|
||||
#region Level
|
||||
int levelInd = 0;
|
||||
|
@ -460,7 +462,7 @@ namespace LaptopSimulator2015
|
|||
optionsWindowLSD.Checked = false;
|
||||
try
|
||||
{
|
||||
if (MessageBox.Show("Are you SURE?\r\n(This will break EVERYTHING!)", "WARNING", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
if (MessageBox.Show(strings.optionsWindowLSDWarning, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
tmpoptionslsdcanchange = true;
|
||||
optionsWindowLSD.Checked = true;
|
||||
|
@ -512,12 +514,21 @@ namespace LaptopSimulator2015
|
|||
{
|
||||
if (MessageBox.Show(strings.resetWarning1, "", MessageBoxButtons.YesNo) == DialogResult.Yes && MessageBox.Show(strings.resetWarning2, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
Settings.wam = 0;
|
||||
Settings.lsd = false;
|
||||
Settings.subs = true;
|
||||
Settings.level = 1;
|
||||
Settings.Save();
|
||||
mode = Mode.game;
|
||||
File.Delete(Settings._xmlfile);
|
||||
winShouldClose = true;
|
||||
string ex = "";
|
||||
if (Application.ExecutablePath.Contains(" "))
|
||||
ex = "\"\" \"" + Application.ExecutablePath + "\"";
|
||||
else
|
||||
ex = Application.ExecutablePath;
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
Arguments = "/C timeout /t 2 /nobreak >nul & del \"" + Settings._xmlfile + "\" & start " + ex,
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
FileName = "cmd.exe"
|
||||
});
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -290,4 +290,7 @@
|
|||
<metadata name="lsdEffectT.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>462, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>566, 17</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -5,7 +5,7 @@ using System.Xml.Linq;
|
|||
|
||||
namespace LaptopSimulator2015 {
|
||||
public static class Settings {
|
||||
static string xmlfile;
|
||||
public static readonly string _xmlfile = Path.GetDirectoryName(Application.ExecutablePath) + @"\save.xml";
|
||||
public static void Save()
|
||||
{
|
||||
XElement xmldoc_temp = new XElement("save");
|
||||
|
@ -14,12 +14,11 @@ namespace LaptopSimulator2015 {
|
|||
xmldoc_temp.Add(new XElement("subs", subs));
|
||||
xmldoc_temp.Add(new XElement("level", level));
|
||||
xmldoc_temp.Add(new XElement("lang", lang));
|
||||
xmldoc_temp.Save(xmlfile);
|
||||
xmldoc_temp.Save(_xmlfile);
|
||||
}
|
||||
public static void Load()
|
||||
{
|
||||
xmlfile = Path.GetDirectoryName(Application.ExecutablePath) + @"\save.xml";
|
||||
if (!File.Exists(xmlfile))
|
||||
if (!File.Exists(_xmlfile))
|
||||
{
|
||||
XElement xmldoc_temp = new XElement("save");
|
||||
xmldoc_temp.Add(new XElement("wam", 10));
|
||||
|
@ -27,9 +26,9 @@ namespace LaptopSimulator2015 {
|
|||
xmldoc_temp.Add(new XElement("subs", true));
|
||||
xmldoc_temp.Add(new XElement("level", 1));
|
||||
xmldoc_temp.Add(new XElement("lang", CultureInfo.CurrentCulture));
|
||||
xmldoc_temp.Save(xmlfile);
|
||||
xmldoc_temp.Save(_xmlfile);
|
||||
}
|
||||
XElement xmldoc = XElement.Load(xmlfile);
|
||||
XElement xmldoc = XElement.Load(_xmlfile);
|
||||
wam = int.Parse(xmldoc.Element("wam").Value);
|
||||
lsd = bool.Parse(xmldoc.Element("lsd").Value);
|
||||
subs = bool.Parse(xmldoc.Element("subs").Value);
|
||||
|
|
|
@ -132,6 +132,15 @@ namespace LaptopSimulator2015 {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Level.
|
||||
/// </summary>
|
||||
internal static string lvPref {
|
||||
get {
|
||||
return ResourceManager.GetString("lvPref", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LSD Mode.
|
||||
/// </summary>
|
||||
|
@ -142,7 +151,16 @@ namespace LaptopSimulator2015 {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to PCOptimizerPro.
|
||||
/// Looks up a localized string similar to Are you SURE?\r\n(This will break EVERYTHING!).
|
||||
/// </summary>
|
||||
internal static string optionsWindowLSDWarning {
|
||||
get {
|
||||
return ResourceManager.GetString("optionsWindowLSDWarning", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Options.
|
||||
/// </summary>
|
||||
internal static string optionsWindowTitle {
|
||||
get {
|
||||
|
|
|
@ -141,9 +141,15 @@
|
|||
<data name="langWarning" xml:space="preserve">
|
||||
<value>WARNUNG: Wir empfehlen, das Spiel nach der Änderung neu zu starten. Neu starten?</value>
|
||||
</data>
|
||||
<data name="lvPref" xml:space="preserve">
|
||||
<value>Level</value>
|
||||
</data>
|
||||
<data name="optionsWindowLSD" xml:space="preserve">
|
||||
<value>LSD-Modus</value>
|
||||
</data>
|
||||
<data name="optionsWindowLSDWarning" xml:space="preserve">
|
||||
<value>Bist du dir sicher? (ALLES wird verbuggt werden!)</value>
|
||||
</data>
|
||||
<data name="optionsWindowTitle" xml:space="preserve">
|
||||
<value>Optionen</value>
|
||||
</data>
|
||||
|
|
|
@ -141,11 +141,17 @@
|
|||
<data name="langWarning" xml:space="preserve">
|
||||
<value>WARNING: We recommend you restart your game to apply these changes. Restart?</value>
|
||||
</data>
|
||||
<data name="lvPref" xml:space="preserve">
|
||||
<value>Level</value>
|
||||
</data>
|
||||
<data name="optionsWindowLSD" xml:space="preserve">
|
||||
<value>LSD Mode</value>
|
||||
</data>
|
||||
<data name="optionsWindowLSDWarning" xml:space="preserve">
|
||||
<value>Are you SURE?\r\n(This will break EVERYTHING!)</value>
|
||||
</data>
|
||||
<data name="optionsWindowTitle" xml:space="preserve">
|
||||
<value>PCOptimizerPro</value>
|
||||
<value>Options</value>
|
||||
</data>
|
||||
<data name="optionsWindowWam" xml:space="preserve">
|
||||
<value>Dedodated Wam</value>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
//
|
||||
this.minigameClockT.Enabled = true;
|
||||
this.minigameClockT.Interval = 17;
|
||||
this.minigameClockT.Tick += new System.EventHandler(this.Timer1_Tick);
|
||||
this.minigameClockT.Tick += new System.EventHandler(this.MinigameClockT_Tick);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Base;
|
||||
|
||||
|
@ -11,21 +11,44 @@ namespace SIT
|
|||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
List<Vector2> invadersAliens = new List<Vector2>();
|
||||
List<Vector2> invadersBullets = new List<Vector2>();
|
||||
Vector2 invadersPlayer;
|
||||
uint minigameTime = 0;
|
||||
uint minigamePrevTime = 0;
|
||||
double speedMod = 5;
|
||||
bool invadersCanShoot = true;
|
||||
#region FRMBD
|
||||
uint minigameTime;
|
||||
uint minigamePrevTime;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
invadersPlayer = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2);
|
||||
invadersPlayer.bounds_wrap = true;
|
||||
invadersPlayer.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
_initGame();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
private void MinigameClockT_Tick(object sender, EventArgs e)
|
||||
{
|
||||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void _initGame()
|
||||
{
|
||||
minigameTime = 0;
|
||||
minigamePrevTime = 0;
|
||||
initGame();
|
||||
}
|
||||
#endregion
|
||||
List<Vector2> enemies;
|
||||
List<Vector2> bullets;
|
||||
Vector2 player;
|
||||
double speedMod;
|
||||
bool enemiesCanShoot;
|
||||
private void initGame()
|
||||
{
|
||||
enemies = new List<Vector2>();
|
||||
bullets = new List<Vector2>();
|
||||
speedMod = 5;
|
||||
enemiesCanShoot = true;
|
||||
player = new Vector2(minigamePanel.Width / 4, minigamePanel.Height / 2);
|
||||
player.bounds_wrap = true;
|
||||
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
}
|
||||
|
||||
private void Panel1_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
@ -34,62 +57,62 @@ namespace SIT
|
|||
try
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
for (int i = 0; i < invadersAliens.Count; i++)
|
||||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(invadersAliens[i].toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
|
||||
}
|
||||
for (int i = 0; i < invadersBullets.Count; i++)
|
||||
for (int i = 0; i < bullets.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(invadersBullets[i].toPoint(), new Size(5, 5)));
|
||||
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(bullets[i].toPoint(), new Size(5, 5)));
|
||||
}
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(invadersPlayer.toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
minigamePrevTime = minigameTime;
|
||||
if (random.Next(0, 100000) < minigameTime + 1300)
|
||||
invadersAliens.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
|
||||
for (int i = 0; i < invadersAliens.Count; i++)
|
||||
enemies.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
|
||||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
invadersAliens[i].X -= 1.2;
|
||||
if (invadersPlayer.distanceFromSquared(invadersAliens[i]) < 100 | invadersAliens[i].X < 0)
|
||||
enemies[i].X -= 1.2;
|
||||
if (player.distanceFromSquared(enemies[i]) < 100 | enemies[i].X < 0)
|
||||
{
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
}
|
||||
invadersCanShoot = invadersCanShoot | !Input.Action;
|
||||
List<Vector2> aliensToRemove = new List<Vector2>();
|
||||
enemiesCanShoot = enemiesCanShoot | !Input.Action;
|
||||
List<Vector2> enemiesToRemove = new List<Vector2>();
|
||||
List<Vector2> bulletsToRemove = new List<Vector2>();
|
||||
for (int i = 0; i < invadersBullets.Count; i++)
|
||||
for (int i = 0; i < bullets.Count; i++)
|
||||
{
|
||||
invadersBullets[i].X += 4;
|
||||
for (int j = 0; j < invadersAliens.Count; j++)
|
||||
bullets[i].X += 4;
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (invadersBullets[i].distanceFromSquared(invadersAliens[j] + new Vector2(2.5f, 2.5f)) < 56.25f)
|
||||
if (bullets[i].distanceFromSquared(enemies[j] + new Vector2(2.5f, 2.5f)) < 56.25f)
|
||||
{
|
||||
aliensToRemove.Add(invadersAliens[j]);
|
||||
bulletsToRemove.Add(invadersBullets[i]);
|
||||
enemiesToRemove.Add(enemies[j]);
|
||||
bulletsToRemove.Add(bullets[i]);
|
||||
}
|
||||
}
|
||||
if (invadersBullets[i].X > minigamePanel.Width)
|
||||
bulletsToRemove.Add(invadersBullets[i]);
|
||||
if (bullets[i].X > minigamePanel.Width)
|
||||
bulletsToRemove.Add(bullets[i]);
|
||||
}
|
||||
invadersAliens = invadersAliens.Except(aliensToRemove.Distinct()).Distinct().ToList();
|
||||
invadersBullets = invadersBullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
|
||||
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
|
||||
bullets = bullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
|
||||
speedMod += 0.1;
|
||||
speedMod = Math.Max(Math.Min(speedMod, 5), 1);
|
||||
if (Input.Up)
|
||||
invadersPlayer.Y -= speedMod;
|
||||
player.Y -= speedMod;
|
||||
if (Input.Left)
|
||||
invadersPlayer.X -= speedMod;
|
||||
player.X -= speedMod;
|
||||
if (Input.Down)
|
||||
invadersPlayer.Y += speedMod;
|
||||
player.Y += speedMod;
|
||||
if (Input.Right)
|
||||
invadersPlayer.X += speedMod;
|
||||
if (Input.Action & invadersCanShoot)
|
||||
player.X += speedMod;
|
||||
if (Input.Action & enemiesCanShoot)
|
||||
{
|
||||
invadersBullets.Add(new Vector2(0, 2.5) + invadersPlayer);
|
||||
invadersCanShoot = false;
|
||||
bullets.Add(new Vector2(0, 2.5) + player);
|
||||
enemiesCanShoot = false;
|
||||
speedMod--;
|
||||
}
|
||||
}
|
||||
|
@ -99,16 +122,11 @@ namespace SIT
|
|||
catch (Exception ex) {
|
||||
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
|
||||
{
|
||||
minigameClockT.Enabled = false;
|
||||
g.Clear(Color.Red);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
|
||||
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
|
||||
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
|
||||
Drawing.DrawSizedString(g, "Lost.", 20, new PointF(minigamePanel.Width / 2, minigamePanel.Height / 2), Brushes.Black, true);
|
||||
buffer.Render();
|
||||
buffer.Dispose();
|
||||
Thread.Sleep(500);
|
||||
_initGame();
|
||||
}
|
||||
else
|
||||
#if DEBUG
|
||||
|
@ -118,13 +136,5 @@ namespace SIT
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Base;
|
||||
|
||||
|
@ -15,14 +12,12 @@ namespace lv2_t
|
|||
public partial class MainForm : Form
|
||||
{
|
||||
#region FRMBD
|
||||
uint minigameTime = 0;
|
||||
uint minigamePrevTime = 0;
|
||||
uint minigameTime;
|
||||
uint minigamePrevTime;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
player = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
player.bounds_wrap = true;
|
||||
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
_initGame();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
|
@ -31,10 +26,26 @@ namespace lv2_t
|
|||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void _initGame()
|
||||
{
|
||||
minigameTime = 0;
|
||||
minigamePrevTime = 0;
|
||||
initGame();
|
||||
}
|
||||
#endregion
|
||||
List<Vector2> enemies = new List<Vector2>();
|
||||
List<Vector2> enemies;
|
||||
Vector2 player;
|
||||
int lives = 3;
|
||||
int lives;
|
||||
private void initGame()
|
||||
{
|
||||
enemies = new List<Vector2>();
|
||||
player = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
player.bounds_wrap = true;
|
||||
player.bounds = new Rectangle(-10, -10, minigamePanel.Width + 10, minigamePanel.Height + 10);
|
||||
lives = 3;
|
||||
}
|
||||
|
||||
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
|
||||
|
@ -44,7 +55,7 @@ namespace lv2_t
|
|||
for (int i = 0; i < enemies.Count; i++)
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
|
||||
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
g.DrawString(lives.ToString(), new Font("Tahoma", 7), Brushes.White, new Rectangle(player.toPoint(), new Size(10, 10)));
|
||||
Drawing.DrawSizedString(g, lives.ToString(), 7, (player + new PointF(5, 5)).toPointF(), Brushes.White, true);
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
|
@ -73,18 +84,18 @@ namespace lv2_t
|
|||
for (int i = 0; i < enemies.Count; i++)
|
||||
{
|
||||
enemies[i].moveTowards(player, Math.Max(6, Math.Sqrt(minigameTime / 100 + 1)));
|
||||
if (player.distanceFromSquared(enemies[i]) < 100)
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (i != j && enemies[i].distanceFromSquared(enemies[j]) < 25 && !enemiesToRemove.Contains(enemies[j]))
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
}
|
||||
if (player.distanceFromSquared(enemies[i]) < 100 && !enemiesToRemove.Contains(enemies[i]))
|
||||
{
|
||||
lives--;
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
if (lives <= 0)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
for (int j = 0; j < enemies.Count; j++)
|
||||
{
|
||||
if (i != j & enemies[i].distanceFromSquared(enemies[j]) < 25)
|
||||
enemiesToRemove.Add(enemies[i]);
|
||||
}
|
||||
}
|
||||
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
|
||||
}
|
||||
|
@ -95,15 +106,11 @@ namespace lv2_t
|
|||
{
|
||||
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
|
||||
{
|
||||
minigameClockT.Enabled = false;
|
||||
g.Clear(Color.Red);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
|
||||
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
|
||||
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
|
||||
Drawing.DrawSizedString(g, "Lost.", 20, new PointF(minigamePanel.Width / 2, minigamePanel.Height / 2), Brushes.Black, true);
|
||||
buffer.Render();
|
||||
Thread.Sleep(500);
|
||||
_initGame();
|
||||
}
|
||||
else
|
||||
#if DEBUG
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Drawing;
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -15,13 +16,12 @@ namespace lv3_t
|
|||
public partial class MainForm : Form
|
||||
{
|
||||
#region FRMBD
|
||||
uint minigameTime = 0;
|
||||
uint minigamePrevTime = 0;
|
||||
uint minigameTime;
|
||||
uint minigamePrevTime;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
cannon = center;
|
||||
targ = center;
|
||||
_initGame();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
|
@ -30,17 +30,36 @@ namespace lv3_t
|
|||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void _initGame()
|
||||
{
|
||||
minigameTime = 0;
|
||||
minigamePrevTime = 0;
|
||||
initGame();
|
||||
}
|
||||
#endregion
|
||||
Vector2 center => new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
Vector2 center;
|
||||
Vector2 cannon;
|
||||
Vector2 targ;
|
||||
List<Vector2> targets = new List<Vector2>();
|
||||
List<Vector2> targets;
|
||||
Rectangle player => new Rectangle(center.toPoint().X - 5, center.toPoint().Y - 5, 10, 10);
|
||||
double playerRot = 0;
|
||||
double cannonL = 30;
|
||||
double power = 10;
|
||||
bool firing = false;
|
||||
uint lastTarget = 0;
|
||||
double playerRot;
|
||||
double cannonL;
|
||||
double power;
|
||||
bool firing;
|
||||
uint lastTarget;
|
||||
private void initGame()
|
||||
{
|
||||
center = new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
|
||||
cannon = new Vector2(center);
|
||||
targ = new Vector2(center);
|
||||
targets = new List<Vector2>();
|
||||
playerRot = 0;
|
||||
cannonL = 30;
|
||||
power = 10;
|
||||
firing = false;
|
||||
lastTarget = 0;
|
||||
}
|
||||
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
|
||||
|
@ -129,16 +148,11 @@ namespace lv3_t
|
|||
{
|
||||
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
|
||||
{
|
||||
minigameClockT.Enabled = false;
|
||||
g.Clear(Color.Red);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
|
||||
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
|
||||
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
|
||||
Drawing.DrawSizedString(g, "Lost.", 20, new PointF(minigamePanel.Width / 2, minigamePanel.Height / 2), Brushes.Black, true);
|
||||
buffer.Render();
|
||||
buffer.Dispose();
|
||||
Thread.Sleep(500);
|
||||
_initGame();
|
||||
}
|
||||
else
|
||||
#if DEBUG
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
using Base;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Base;
|
||||
|
||||
namespace lv4_t
|
||||
{
|
||||
|
@ -20,17 +16,7 @@ namespace lv4_t
|
|||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
playerV = new Vector2();
|
||||
playerV.bounds = new Rectangle(-5, -20, 10, 40);
|
||||
playerV.bounds_wrap = false;
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
platforms.Add(new Vector2(rnd.Next(minigamePanel.Width), i * (minigamePanel.Height / 5)));
|
||||
player = new Vector2(platforms[0].X, -10);
|
||||
player.bounds = new Rectangle(-5, 0, minigamePanel.Width + 10, 0);
|
||||
player.bounds_wrap = true;
|
||||
lazor = player.X;
|
||||
lazorTime = 50;
|
||||
_initGame();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
|
@ -39,15 +25,43 @@ namespace lv4_t
|
|||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void _initGame()
|
||||
{
|
||||
minigameTime = 0;
|
||||
minigamePrevTime = 0;
|
||||
initGame();
|
||||
}
|
||||
#endregion
|
||||
Random rnd = new Random();
|
||||
Vector2 player = new Vector2();
|
||||
Vector2 playerV = new Vector2();
|
||||
Random rnd;
|
||||
Vector2 player;
|
||||
Vector2 playerV;
|
||||
double lazor;
|
||||
double lazorTime;
|
||||
double speed;
|
||||
int jmpj;
|
||||
List<Vector2> platforms = new List<Vector2>();
|
||||
|
||||
bool wasOnPlatform;
|
||||
List<Vector2> platforms;
|
||||
private void initGame()
|
||||
{
|
||||
rnd = new Random();
|
||||
playerV = new Vector2();
|
||||
playerV.bounds = new Rectangle(-10, -20, 20, 40);
|
||||
playerV.bounds_wrap = false;
|
||||
platforms = new List<Vector2>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
platforms.Add(new Vector2(rnd.Next(minigamePanel.Width - 100) + 50, i * (minigamePanel.Height / 5)));
|
||||
}
|
||||
player = new Vector2(platforms[platforms.Count / 2].X, -10);
|
||||
player.bounds = new Rectangle(-5, 0, minigamePanel.Width + 10, 0);
|
||||
player.bounds_wrap = true;
|
||||
lazor = player.X;
|
||||
lazorTime = 100;
|
||||
speed = 1;
|
||||
wasOnPlatform = true;
|
||||
}
|
||||
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
|
||||
|
@ -56,98 +70,102 @@ namespace lv4_t
|
|||
{
|
||||
g.Clear(Color.Black);
|
||||
g.FillRectangle(new SolidBrush(Color.Green), player2rect());
|
||||
bool onPlatform = false;
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.White), plat2rect(i));
|
||||
onPlatform |= isOnPlatform(i);
|
||||
}
|
||||
if (lazorTime >= 0 && lazorTime <= 30)
|
||||
if (lazorTime >= 0 && lazorTime <= 80)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.DarkGray), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height - (float)Misc.map(0, 30, 0, minigamePanel.Height, lazorTime)));
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 1, 0, 2, minigamePanel.Height - (float)Misc.map(0, 80, 0, minigamePanel.Height, lazorTime)));
|
||||
}
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
g.FillRectangle(new SolidBrush(Color.White), plat2rect(i));
|
||||
Random random = new Random();
|
||||
if (minigameTime != minigamePrevTime)
|
||||
{
|
||||
lazorTime -= minigameTime - minigamePrevTime;
|
||||
speed = Math.Min(minigameTime / 200d, 2) + 0.5;
|
||||
lazorTime -= Math.Min(minigameTime / 800, 2.5) + 0.5;
|
||||
minigamePrevTime = minigameTime;
|
||||
if (lazorTime <= 0)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF((float)lazor - 5, 0, 10, minigamePanel.Height));
|
||||
if (lazorTime <= -2)
|
||||
{
|
||||
lazorTime = 40;
|
||||
lazorTime = 100;
|
||||
lazor = player.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.X >= lazor - 5 && player.X <= lazor + 5)
|
||||
if (player.X > lazor - 10 && player.X < lazor + 10)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
}
|
||||
}
|
||||
if (onPlatform)
|
||||
playerV.Y = Math.Min(playerV.Y, 0);
|
||||
else
|
||||
playerV.Y += 1;
|
||||
playerV.X /= 1.2f;
|
||||
if (onPlatform)
|
||||
jmpj = 10;
|
||||
else
|
||||
if (!Input.Up)
|
||||
jmpj = 0;
|
||||
if ((onPlatform || jmpj > 0) && Input.Up)
|
||||
{
|
||||
playerV.Y -= jmpj / 6d + 1.5;
|
||||
jmpj--;
|
||||
}
|
||||
double movementFactor = 15;
|
||||
if (onPlatform)
|
||||
movementFactor /= 4;
|
||||
if (Input.Left)
|
||||
playerV.X -= movementFactor;
|
||||
if (Input.Right)
|
||||
playerV.X += movementFactor;
|
||||
player.X += playerV.X;
|
||||
onPlatform = false;
|
||||
if (playerV.Y < 0)
|
||||
player.Y += playerV.Y;
|
||||
else
|
||||
for (int i = 0; i < playerV.Y / 2; i++)
|
||||
{
|
||||
for (int j = 0; j < platforms.Count; j++)
|
||||
onPlatform |= isOnPlatform(j);
|
||||
if (!onPlatform)
|
||||
player.Y += 2;
|
||||
}
|
||||
List<Vector2> platformsToRemove = new List<Vector2>();
|
||||
player.Y += speed;
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
platforms[i].Y += 1.7;
|
||||
platforms[i].Y += speed;
|
||||
if (platforms[i].Y > minigamePanel.Height)
|
||||
{
|
||||
platforms[i].Y = 0;
|
||||
platforms[i].X = rnd.Next(minigamePanel.Width);
|
||||
}
|
||||
}
|
||||
double movementFactor;
|
||||
if (wasOnPlatform)
|
||||
{
|
||||
movementFactor = 2;
|
||||
playerV.X *= 0.7;
|
||||
playerV.Y = Math.Min(playerV.Y, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
movementFactor = 5;
|
||||
playerV.X *= 0.9;
|
||||
playerV.Y += 1;
|
||||
}
|
||||
if (Input.Up)
|
||||
{
|
||||
if (wasOnPlatform || jmpj > 0)
|
||||
{
|
||||
playerV.Y -= jmpj / 6d + 1.5;
|
||||
jmpj--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wasOnPlatform)
|
||||
jmpj = 10;
|
||||
else
|
||||
jmpj = 0;
|
||||
}
|
||||
jmpj = Math.Max(0, jmpj);
|
||||
if (Input.Left)
|
||||
playerV.X -= movementFactor;
|
||||
if (Input.Right)
|
||||
playerV.X += movementFactor;
|
||||
player.X += playerV.X;
|
||||
if (playerV.Y < 0)
|
||||
player.Y += playerV.Y;
|
||||
else
|
||||
for (int i = 0; i < playerV.Y / 2; i++)
|
||||
{
|
||||
if (onPlatform)
|
||||
break;
|
||||
player.Y += 2;
|
||||
}
|
||||
if (player.Y > minigamePanel.Height)
|
||||
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
|
||||
wasOnPlatform = onPlatform;
|
||||
}
|
||||
buffer.Render();
|
||||
buffer.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
|
||||
{
|
||||
minigameClockT.Enabled = false;
|
||||
g.Clear(Color.Red);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
|
||||
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
|
||||
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
|
||||
Drawing.DrawSizedString(g, "Lost.", 20, new PointF(minigamePanel.Width / 2, minigamePanel.Height / 2), Brushes.Black, true);
|
||||
buffer.Render();
|
||||
Thread.Sleep(500);
|
||||
_initGame();
|
||||
}
|
||||
else
|
||||
#if DEBUG
|
||||
|
@ -157,68 +175,46 @@ namespace lv4_t
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool onPlatform
|
||||
{
|
||||
get {
|
||||
for (int i = 0; i < platforms.Count; i++)
|
||||
{
|
||||
RectangleF rect = plat2rect(i);
|
||||
if (player.X < rect.X)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = (player - new PointF(rect.X, rect.Y)).magnitude;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = (player - new PointF(rect.X, rect.Y + rect.Height)).magnitude;
|
||||
else
|
||||
platforms[i].Tag = rect.X - player.X;
|
||||
}
|
||||
else if (player.X > rect.X + rect.Width)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = (player - new PointF(rect.X + rect.Width, rect.Y)).magnitude;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = (player - new PointF(rect.X + rect.Width, rect.Y + rect.Height)).magnitude;
|
||||
else
|
||||
platforms[i].Tag = player.X - rect.X + rect.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
platforms[i].Tag = rect.Y - player.Y;
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
platforms[i].Tag = player.Y - (rect.Y + rect.Height);
|
||||
else
|
||||
platforms[i].Tag = 0d;
|
||||
}
|
||||
if (((double)platforms[i].Tag) <= 20 && RectangleF.Intersect(player2rect(), rect) != RectangleF.Empty && player.Y < platforms[i].Y - 8)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
RectangleF plat2rect(int platform) => new RectangleF((platforms[platform] - new Vector2(50, 5)).toPointF(), new SizeF(100, 10));
|
||||
RectangleF player2rect() => new RectangleF((player - new Vector2(5, 5)).toPointF(), new SizeF(10, 10));
|
||||
|
||||
bool isOnPlatform(int platform)
|
||||
{
|
||||
calcDist(platform);
|
||||
return ((double)platforms[platform].Tag) <= 20 && RectangleF.Intersect(player2rect(), plat2rect(platform)) != RectangleF.Empty && player.Y < platforms[platform].Y - 8;
|
||||
}
|
||||
|
||||
void calcDist(int platform)
|
||||
{
|
||||
RectangleF rect = plat2rect(platform);
|
||||
if (player.X < rect.X)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X, rect.Y);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X, rect.Y + rect.Height);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = rect.X - player.X;
|
||||
}
|
||||
}
|
||||
else if (player.X > rect.X + rect.Width)
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X + rect.Width, rect.Y);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
Vector2 diff = player - new Vector2(rect.X + rect.Width, rect.Y + rect.Height);
|
||||
platforms[platform].Tag = diff.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = player.X - rect.X + rect.Width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Y < rect.Y)
|
||||
{
|
||||
platforms[platform].Tag = rect.Y - player.Y;
|
||||
}
|
||||
else if (player.Y > rect.Y + rect.Height)
|
||||
{
|
||||
platforms[platform].Tag = player.Y - (rect.Y + rect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
platforms[platform].Tag = 0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Base;
|
||||
|
||||
|
@ -15,16 +12,32 @@ namespace lv_tst_base
|
|||
public partial class MainForm : Form
|
||||
{
|
||||
#region FRMBD
|
||||
uint minigameTime = 0;
|
||||
uint minigamePrevTime = 0;
|
||||
public MainForm() => InitializeComponent();
|
||||
uint minigameTime;
|
||||
uint minigamePrevTime;
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_initGame();
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
|
||||
private void MinigameClockT_Tick(object sender, EventArgs e)
|
||||
{
|
||||
minigameTime++;
|
||||
minigamePanel.Invalidate();
|
||||
}
|
||||
|
||||
private void _initGame()
|
||||
{
|
||||
minigameTime = 0;
|
||||
minigamePrevTime = 0;
|
||||
initGame();
|
||||
}
|
||||
#endregion
|
||||
private void initGame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
@ -46,15 +59,11 @@ namespace lv_tst_base
|
|||
{
|
||||
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
|
||||
{
|
||||
minigameClockT.Enabled = false;
|
||||
g.Clear(Color.Red);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
|
||||
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
|
||||
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
|
||||
Drawing.DrawSizedString(g, "Lost.", 20, new PointF(minigamePanel.Width / 2, minigamePanel.Height / 2), Brushes.Black, true);
|
||||
buffer.Render();
|
||||
Thread.Sleep(500);
|
||||
_initGame();
|
||||
}
|
||||
else
|
||||
#if DEBUG
|
||||
|
|
Reference in New Issue