This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Phoenixfirewingz
committed
May 2, 2023
1 parent
25b912d
commit d0c92c5
Showing
28 changed files
with
1,360 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,83 @@ | ||
using SquareSmash.client; | ||
Client c = new(); | ||
c.Run(); | ||
Console.ReadLine(); | ||
using OpenTK.Graphics.ES30; | ||
using OpenTK.Windowing.Common; | ||
using OpenTK.Windowing.Desktop; | ||
using SquareSmash.objects; | ||
using SquareSmash.objects.components; | ||
using SquareSmash.renderer; | ||
|
||
namespace SquareSmash | ||
{ | ||
internal class Client : GameWindow | ||
{ | ||
public static readonly int Width = 720; | ||
public static readonly int Height = 640; | ||
private long PreviousTime { get; set; } | ||
public QuadBatchRenderer Renderer { get; private set; } | ||
public Paddle paddle; | ||
public Level level; | ||
/*private static readonly DebugProc DebugMessageDelegate = OnDebugMessage; | ||
private static void OnDebugMessage(DebugSource source,DebugType type,int id,DebugSeverity severity,int length,IntPtr pMessage,IntPtr pUserParam) | ||
{ | ||
string message = Marshal.PtrToStringAnsi(pMessage, length); | ||
Console.WriteLine("[{0} source={1} type={2} id={3}] {4}", severity, source, type, id, message); | ||
if (type == DebugType.DebugTypeError) | ||
throw new Exception(message); | ||
}*/ | ||
|
||
public Client() | ||
: base(GameWindowSettings.Default, new() | ||
{ | ||
Size = new(Width, Height), | ||
Title = "DISCout", | ||
Flags = ContextFlags.ForwardCompatible, | ||
MinimumSize = new(Width, Height), | ||
MaximumSize = new(Width, Height) | ||
}) | ||
{ | ||
//GL.DebugMessageCallback(DebugMessageDelegate, IntPtr.Zero); | ||
Renderer = new(); | ||
paddle = new(); | ||
level = new(); | ||
PreviousTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | ||
GL.ClearColor(0, 0, 0, 1); | ||
} | ||
public void LevelWon() | ||
{ | ||
level = new Level(); | ||
} | ||
|
||
protected override void OnUnload() | ||
{ | ||
Renderer.Flush(); | ||
base.OnUnload(); | ||
} | ||
|
||
protected override void OnUpdateFrame(FrameEventArgs args) | ||
{ | ||
base.OnUpdateFrame(args); | ||
long currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | ||
long DeltaTime = (currentTime - PreviousTime); | ||
PreviousTime = currentTime; | ||
paddle?.OnUpdate(this, DeltaTime); | ||
level?.OnUpdate(this, DeltaTime); | ||
} | ||
|
||
protected override void OnRenderFrame(FrameEventArgs args) | ||
{ | ||
base.OnRenderFrame(args); | ||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); | ||
paddle?.OnRendering(Renderer); | ||
level?.OnRendering(Renderer); | ||
Renderer.Flush(); | ||
SwapBuffers(); | ||
} | ||
} | ||
static class ProgramMain | ||
{ | ||
public static void Main() | ||
{ | ||
Client client = new(); | ||
client.Run(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.