diff --git a/ConsoleGameLib/ConsoleGameLib.csproj b/ConsoleGameLib/ConsoleGameLib.csproj index e7a1fc2..b133b32 100644 --- a/ConsoleGameLib/ConsoleGameLib.csproj +++ b/ConsoleGameLib/ConsoleGameLib.csproj @@ -55,7 +55,13 @@ + + + + + + + \ No newline at end of file diff --git a/PhysicsPlatformer/Program.cs b/PhysicsPlatformer/Program.cs new file mode 100644 index 0000000..f3c19e9 --- /dev/null +++ b/PhysicsPlatformer/Program.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ConsoleGameLib.CoreTypes; +using ConsoleGameLib.PhysicsTypes; +using ConsoleGameLib; +using System.Threading; + + +namespace PhysicsPlatformer +{ + class Program + { + + static void Main(string[] args) + { + PhysicsWorld world = new PhysicsWorld(); + List points = new List(); + + Console.CursorVisible = false; + + + + world.GravitationalAcceleration = 1; + + world.LinearDragCalculationInterval = 1; + + UserControlledPoint userPoint = new UserControlledPoint(true,new Point(0,36),true,ConsoleColor.Blue,world); + + userPoint.UpDistance = 0; + userPoint.RightDistance = 0; + userPoint.LeftDistance = 0; + + userPoint.OnLegalRight += UserPoint_OnLegalRight; + + userPoint.OnLegalLeft += UserPoint_OnLegalLeft; + + + userPoint.OnLegalUp += UserPoint_OnLegalUp; + + world.GravityCalculationInterval = 1; + + + userPoint.MoveUpKey = ConsoleKey.Spacebar; + userPoint.CanMoveDown = false; + + Random rand = new Random(); + + + for (int i = 0; i < 15; i++) + { + points.Add(new PhysicsPoint(false,new Point(i,35),true,ConsoleColor.Green,world)); + } + Point tempPos = new Point(15,35); + + for (int j = 0; j < 10; j++) + { + + int length = rand.Next(1, 10); + + tempPos.Y += rand.Next(0, 2); + tempPos.X += rand.Next(1, 3); + + for (int i = 0; i < length; i++) + { + points.Add(new PhysicsPoint(false, new Point(tempPos.X, tempPos.Y), true, ConsoleColor.Green, world)); + tempPos.X++; + } + } + /*for (int j = 0; j < 10; j++) + { + + int length = rand.Next(1, 10); + + tempPos.Y += rand.Next(-1, 1); + tempPos.X += rand.Next(1, 3); + + for (int i = 0; i < length; i++) + { + points.Add(new PhysicsPoint(false, new Point(tempPos.X, tempPos.Y), true, ConsoleColor.Green, world)); + tempPos.X++; + } + }*/ + + world.UserPoint = userPoint; + world.Contents = points; + + while(true) + { + + //world.PhysicsCamera.DrawReferencePosition = new Point(/*world.UserPoint.Position.X - 3, 27*/0,0); + + world.Update(); + + world.Draw(); + + if (userPoint.Position.Y <= 10) + { + userPoint.Position = new Point(0,36); + } + + + + Thread.Sleep(50); + + + + + } + + } + + private static void UserPoint_OnLegalLeft(object sender, EventArgs e) + { + ((UserControlledPoint)sender).Velocity.X-= 1; + } + + private static void UserPoint_OnLegalRight(object sender, EventArgs e) + { + ((UserControlledPoint)sender).Velocity.X+= 1; + } + + private static void UserPoint_OnLegalUp(object sender, EventArgs e) + { + UserControlledPoint sendPoint = (UserControlledPoint)sender; + if (sendPoint.World.Contents.ContainsPoint(new Point(sendPoint.Position.X, sendPoint.Position.Y - 1)) && sendPoint.Velocity.Y == 0) + { + sendPoint.Velocity.Y += 3; + } + } + } +} diff --git a/PhysicsPlatformer/Properties/AssemblyInfo.cs b/PhysicsPlatformer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b4d82b6 --- /dev/null +++ b/PhysicsPlatformer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PhysicsPlatformer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysicsPlatformer")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("344cceed-00a2-4244-a6a7-222b5139117d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]