Some ToDos

This commit is contained in:
CreepyCrafter24 2019-10-05 17:49:56 +02:00
parent 35ecfcd98b
commit 6c8cdd2af2
16 changed files with 89 additions and 74 deletions

1
1/1.cs
View File

@ -59,6 +59,7 @@ namespace LaptopSimulator2015.Levels
public int installerProgressSteps => 500;
public Color backColor => Color.Black;
public string[] credits => new string[] { "Level1 Icon made by Oliver Scholtz from www.iconfinder.com" };
public bool isLowQuality => false;
List<Vector2> enemies;
List<Vector2> bullets;

2
2/2.cs
View File

@ -60,6 +60,8 @@ namespace LaptopSimulator2015.Levels
public int installerProgressSteps => 500;
public Color backColor => Color.Black;
public string[] credits => new string[] { "Level2 Icon made by Intel" };
public bool isLowQuality => false;
List<Vector2> enemies;
Vector2 player;
int lives;

38
3/3.cs
View File

@ -63,6 +63,7 @@ namespace LaptopSimulator2015.Levels
public int installerProgressSteps => 500;
public Color backColor => Color.Black;
public string[] credits => new string[] { "Level3 Icon made by NVidia" };
public bool isLowQuality => false;
Vector2 center;
Vector2 cannon;
@ -97,13 +98,14 @@ namespace LaptopSimulator2015.Levels
{
firing = false;
List<Vector2> targetsToRemove = new List<Vector2>();
Rect tr = new Rect(targ, new Vector2(power, power), true);
for (int i = 0; i < targets.Count; i++)
{
if (targets[i].distanceFromSquared(targ) <= Math.Pow(power + 10, 2))
if (targets[i].distanceToRectSquared(tr) <= 400)
targetsToRemove.Add(targets[i]);
}
targets = targets.Except(targetsToRemove.Distinct()).Distinct().ToList();
g.g.FillRectangle(new SolidBrush(Color.White), new Rectangle(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y - power / 2), Misc.d2i(power), Misc.d2i(power)));
g.DrawRectangle(tr, Color.White);
power = 10;
}
targ = new Vector2(center);
@ -113,9 +115,9 @@ namespace LaptopSimulator2015.Levels
if (Input.Down)
cannonL -= 100 / power;
if (Input.Right)
playerRot += 80 / power;
if (Input.Left)
playerRot -= 80 / power;
if (Input.Left)
playerRot += 80 / power;
while (playerRot > 360)
playerRot -= 360;
while (playerRot < 0)
@ -147,28 +149,28 @@ namespace LaptopSimulator2015.Levels
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{
//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.DrawRectangle(new RectangleF(center.toPointF(), new SizeF(10, 10)), Color.Green);
g.DrawLine(center, cannon, Color.Green, 5);
for (int i = 0; i < targets.Count; i++)
{
g.g.DrawEllipse(new Pen(new SolidBrush(Color.Red), 6), new RectangleF(Misc.d2f(targets[i].X - 10), Misc.d2f(targets[i].Y - 10), 20, 20));
g.g.DrawEllipse(new Pen(new SolidBrush(Color.White), 6), new RectangleF(Misc.d2f(targets[i].X - 7), Misc.d2f(targets[i].Y - 7), 14, 14));
g.g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Misc.d2f(targets[i].X - 3), Misc.d2f(targets[i].Y - 3), 6, 6));
g.g.DrawLine(new Pen(new SolidBrush(Color.Gray), 3), Misc.d2f(targets[i].X - 13), Misc.d2f(targets[i].Y - 15), Misc.d2f(targets[i].X + 13), Misc.d2f(targets[i].Y - 15));
g.g.DrawLine(new Pen(new SolidBrush(Color.Red), 3), Misc.d2f(targets[i].X - 13), Misc.d2f(targets[i].Y - 15), Misc.d2f(targets[i].X + ((((double)targets[i].Tag) * 0.2) - 12.9) + 0.1), Misc.d2f(targets[i].Y - 15));
g.DrawRectangle(new Rect(targets[i], new Vector2(20, 20), true), Color.AliceBlue);
g.g.DrawEllipse(new Pen(new SolidBrush(Color.Red), 6), new RectangleF(Misc.d2f(targets[i].X - 10), Misc.d2f(minigamePanel.Height - 10 - targets[i].Y), 20, 20));
g.g.DrawEllipse(new Pen(new SolidBrush(Color.White), 6), new RectangleF(Misc.d2f(targets[i].X - 7), Misc.d2f(minigamePanel.Height - 7 - targets[i].Y), 14, 14));
g.g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Misc.d2f(targets[i].X - 3), Misc.d2f(minigamePanel.Height - 3 - targets[i].Y), 6, 6));
g.DrawLine(new Vector2(targets[i].X - 13, targets[i].Y + 15), new Vector2(targets[i].X + 13, targets[i].Y + 15), Color.Gray, 3);
g.DrawLine(new Vector2(targets[i].X - 13, targets[i].Y + 15), new Vector2(targets[i].X + ((((double)targets[i].Tag) * 0.2) - 12.9) + 0.1, targets[i].Y + 15), Color.Red, 3);
}
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.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 - power / 2), Misc.d2i(targ.Y)), new PointF(Misc.d2i(targ.X + power / 2), Misc.d2i(targ.Y)));
g.DrawRectangle(new Rect(targ, new Vector2(power, power), true), Color.Green, filled: false);
g.DrawLine(targ + new Vector2(-power / 2, 0), targ + new Vector2(power / 2, 0), Color.Green, 1);
g.DrawLine(targ + new Vector2(0, -power / 2), targ + new Vector2(0, power / 2), Color.Green, 1);
}
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.DrawRectangle(new RectangleF(targ.toPointF(), new SizeF(5, 5)), Color.Green, transform: false);
g.DrawRectangle(new RectangleF(targ.toPointF(), new SizeF(5, 5)), Color.Green);
}
}
}

View File

@ -77,6 +77,7 @@ namespace LaptopSimulator2015.Goals
public Color backColor => Color.Black;
public string[] credits => new string[]{ "Testexetrisathlon Icon made by Freepik from www.flaticon.com" };
public bool isLowQuality => true;
public static int[,] grid = new int[23, 10];
public static int[,] droppedtetrominoeLocationGrid = new int[23, 10];
@ -203,11 +204,11 @@ namespace LaptopSimulator2015.Goals
if (grid[y, x] == 1 | droppedtetrominoeLocationGrid[y, x] == 1)
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.DrawLine(new Point(0, (y + 1) * 10), new Point(10 * 10, (y + 1) * 10), Color.DarkGray, 1, false);
}
for (int x = 0; x < 10; x++)
{
g.g.DrawLine(new Pen(Color.DarkGray), new Point((x + 1) * 10, 0), new Point((x + 1) * 10, 23 * 10));
g.DrawLine(new Point((x + 1) * 10, 0), new Point((x + 1) * 10, 23 * 10), Color.DarkGray, 1, false);
}
g.DrawSizedString("Level " + level, 10, new PointF(150, 10), Brushes.White, false);
g.DrawSizedString("Score " + score, 10, new PointF(150, 30), Brushes.White, false);

1
4/4.cs
View File

@ -56,6 +56,7 @@ namespace LaptopSimulator2015.Levels
public Panel desktopIcon { get; set; }
public int installerProgressSteps => 500;
public Color backColor => Color.Black;
public bool isLowQuality => false;
public string[] credits => new string[] { "Level4 Icon made by Microsoft" };
Random rnd;

View File

@ -53,6 +53,12 @@
<Compile Include="Rect.cs" />
<Compile Include="Vector2.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CC-Functions\W32\W32.csproj">
<Project>{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}</Project>
<Name>W32</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Base
{
public class GraphicsWrapper : IDisposable
public sealed class GraphicsWrapper : IDisposable
{
BufferedGraphics _g;
Color backColor;
@ -127,7 +127,7 @@ namespace Base
/// <summary>
/// Render and dispose
/// </summary>
public virtual void Dispose()
public void Dispose()
{
g.Flush();
_g.Render();

View File

@ -1,4 +1,5 @@
using System;
using CC_Functions.W32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
@ -9,10 +10,8 @@ using System.Windows.Input;
namespace Base
{
public class Input
public static class Input
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern short GetKeyState(int keyCode);
/// <summary>
/// Check whether the Key is pressed
/// </summary>
@ -22,17 +21,11 @@ namespace Base
{
try
{
int state = 0;
short retVal = GetKeyState((int)key);
if ((retVal & 0x8000) == 0x8000)
state |= 1;
if ((retVal & 1) == 1)
state |= 2;
return 1 == (state & 1);
return KeyboardReader.IsKeyDown(key);
}
catch (Exception e1)
catch (Exception e)
{
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e1.ToString());
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e.ToString());
return false;
}
}

View File

@ -32,6 +32,14 @@ namespace LaptopSimulator2015
/// </summary>
int gameClock { get; }
/// <summary>
/// Color to be painted to the Background before calling the draw method
/// </summary>
Color backColor { get; }
/// <summary>
/// In what quality to draw the frames
/// </summary>
bool isLowQuality { get; }
/// <summary>
/// DO NOT CHANGE! INTERNAL USE ONLY!
/// </summary>
Panel desktopIcon { get; set; }
@ -58,10 +66,6 @@ namespace LaptopSimulator2015
/// <param name="minigameTimer">The timer used for scheduling frames</param>
/// <param name="minigameTime">The amount of total displayed frames</param>
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
{

View File

@ -12,16 +12,10 @@ namespace Base
/// <summary>
/// Create a rect from the provided data
/// </summary>
/// <param name="Location">Bottom-left point</param>
/// <param name="Size">Amount to extend top-right</param>
public Rect(Vector2 Location, Vector2 Size, bool centered = false)
{
this.Location = Location ?? throw new ArgumentNullException(nameof(Location));
this.Size = Size ?? throw new ArgumentNullException(nameof(Size));
this.centered = centered;
if (this.centered)
this.Location -= this.Size / 2;
}
/// <param name="Location">Position</param>
/// <param name="Size">Rect's size</param>
/// <param name="centered">Whether the Rect should be created top-right or around the Location</param>
public Rect(Vector2 Location, Vector2 Size, bool centered = false) : this(Location.X, Location.Y, Size.X, Size.Y, centered) { }
/// <summary>
/// Create a rect from the provided data
@ -30,13 +24,18 @@ namespace Base
/// <param name="Y">Y in world-coordinates</param>
/// <param name="Width">Width</param>
/// <param name="Height">Height</param>
/// <param name="centered">Whether the Rect should be created top-right or around the Location</param>
public Rect(double X, double Y, double Width, double Height, bool centered = false)
{
Location = new Vector2(X, Y);
Size = new Vector2(Width, Height);
this.centered = centered;
if (this.centered)
Location -= Size / 2;
{
//Location -= Size / 2;
Location.X -= Size.X / 2;
Location.Y += Size.Y / 2;
}
}
/// <summary>
@ -47,17 +46,18 @@ namespace Base
{
Location = rect.Location;
Size = rect.Size;
centered = rect.centered;
}
public Rect(Rectangle rect)
{
Location = new Vector2(rect.Location);
Size = new Vector2(rect.Size);
}
public Rect(RectangleF rect)
{
Location = new Vector2(rect.Location);
Size = new Vector2(rect.Size);
}
/// <summary>
/// Copies the Rect's data
/// </summary>
/// <param name="rect"></param>
public Rect(Rectangle rect) : this(rect.X, rect.Y, rect.Width, rect.Height, false) { }
/// <summary>
/// Copies the Rect's data
/// </summary>
/// <param name="rect"></param>
public Rect(RectangleF rect) : this(rect.X, rect.Y, rect.Width, rect.Height, false) { }
public double X
{

View File

@ -66,10 +66,10 @@ namespace LaptopSimulator2015
bool tmp__mode_uiv = false;
[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
public FakeDesktop()
{
@ -482,7 +482,7 @@ namespace LaptopSimulator2015
uint minigamePrevTime = 0;
private void InvadersPanel_Paint(object sender, PaintEventArgs e)
{
using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, levels[levelInd].backColor, new Rectangle(Point.Empty, minigamePanel.Size)))
using (GraphicsWrapper w = new GraphicsWrapper(e.Graphics, levels[levelInd].backColor, new Rectangle(Point.Empty, minigamePanel.Size), levels[levelInd].isLowQuality))
{
w.Clear();
levels[levelInd].draw(w, minigamePanel, minigameClockT, minigameTime);
@ -658,11 +658,14 @@ namespace LaptopSimulator2015
private void optionsWindowCredit_Click(object sender, EventArgs e)
{
string tmp = Path.GetTempFileName();
File.Move(tmp, Path.ChangeExtension(tmp, "txt"));
tmp = Path.ChangeExtension(tmp, "txt");
File.WriteAllLines(tmp, levels.SelectMany(s => s.credits).ToArray());
Process.Start(tmp).Exited += (object sender1, EventArgs e1) => { File.Delete(tmp); };
new Thread(() => {
string tmp = Path.GetTempFileName();
File.Move(tmp, Path.ChangeExtension(tmp, "txt"));
tmp = Path.ChangeExtension(tmp, "txt");
File.WriteAllLines(tmp, levels.SelectMany(s => s.credits).ToArray());
Process.Start(tmp).WaitForExit();
File.Delete(tmp);
}).Start();
}
bool devWindowMoving = false;
@ -706,9 +709,9 @@ namespace LaptopSimulator2015
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOMOVE = 0x0002;
const uint TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

View File

@ -15,6 +15,7 @@ namespace LaptopSimulator2015
class Program
{
public static Splash splash;
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();

View File

@ -32,7 +32,7 @@ namespace LevelTest
}
else
{
string[] tmp = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll").ToArray();
string[] tmp = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll" && Path.GetFileName(s) != "CC-Functions.W32.dll").ToArray();
if (tmp.Length == 0)
using (FolderBrowserDialog openFileDialog = new FolderBrowserDialog())
{
@ -42,7 +42,7 @@ namespace LevelTest
throw new Exception("Please select a folder");
}
}
Minigame[] levels = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll")
Minigame[] levels = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.AllDirectories).Where(s => Path.GetFileName(s) != "Base.dll" && Path.GetFileName(s) != "CC-Functions.W32.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();

View File

@ -1 +1,2 @@
Fully implement new graphics on Goal and Level 3
Implement drawing ellipses (Level 3)
Fix Physics weirdness in Level 3

BIN
tmp1/3g.dll Normal file

Binary file not shown.

BIN
tmp3/LevelTest.exe Normal file

Binary file not shown.