commit 43433bb405f7f5c4897999549b4b7549c6e9d896 Author: MasterGordon Date: Mon Oct 3 23:13:19 2022 +0200 first commit diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..91d637a --- /dev/null +++ b/Program.cs @@ -0,0 +1,6 @@ +// See https://aka.ms/new-console-template for more information + +var window = new Window("Hello World!", 800, 600); +var renderer = new Renderer(window); +var scene = new Scene(renderer); +scene.Run(); diff --git a/bin/Debug/net6.0/SDL2-CS.dll b/bin/Debug/net6.0/SDL2-CS.dll new file mode 100755 index 0000000..b18dc39 Binary files /dev/null and b/bin/Debug/net6.0/SDL2-CS.dll differ diff --git a/bin/Debug/net6.0/dotnet-console b/bin/Debug/net6.0/dotnet-console new file mode 100755 index 0000000..960eb3c Binary files /dev/null and b/bin/Debug/net6.0/dotnet-console differ diff --git a/bin/Debug/net6.0/dotnet-console.deps.json b/bin/Debug/net6.0/dotnet-console.deps.json new file mode 100644 index 0000000..23618d4 --- /dev/null +++ b/bin/Debug/net6.0/dotnet-console.deps.json @@ -0,0 +1,78 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v6.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v6.0": { + "dotnet-console/1.0.0": { + "dependencies": { + "ppy.SDL2-CS": "1.0.596-alpha" + }, + "runtime": { + "dotnet-console.dll": {} + } + }, + "ppy.SDL2-CS/1.0.596-alpha": { + "runtime": { + "lib/netstandard2.0/SDL2-CS.dll": { + "assemblyVersion": "0.0.0.0", + "fileVersion": "0.0.0.0" + } + }, + "runtimeTargets": { + "runtimes/linux-x64/native/libSDL2.so": { + "rid": "linux-x64", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/linux-x86/native/libSDL2.so": { + "rid": "linux-x86", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/osx-arm64/native/libSDL2.dylib": { + "rid": "osx-arm64", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/osx-x64/native/libSDL2.dylib": { + "rid": "osx-x64", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/win-arm64/native/SDL2.dll": { + "rid": "win-arm64", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/win-x64/native/SDL2.dll": { + "rid": "win-x64", + "assetType": "native", + "fileVersion": "0.0.0.0" + }, + "runtimes/win-x86/native/SDL2.dll": { + "rid": "win-x86", + "assetType": "native", + "fileVersion": "0.0.0.0" + } + } + } + } + }, + "libraries": { + "dotnet-console/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "ppy.SDL2-CS/1.0.596-alpha": { + "type": "package", + "serviceable": true, + "sha512": "sha512-yzIdTCjPp9le6J16WyG4py8frdwUTcsnqpGnuAk7Za2pvXGPmvVAiQBrdnFS58l2S6bS8AFNIG3uOSRQrMo1nQ==", + "path": "ppy.sdl2-cs/1.0.596-alpha", + "hashPath": "ppy.sdl2-cs.1.0.596-alpha.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net6.0/dotnet-console.dll b/bin/Debug/net6.0/dotnet-console.dll new file mode 100644 index 0000000..33ca584 Binary files /dev/null and b/bin/Debug/net6.0/dotnet-console.dll differ diff --git a/bin/Debug/net6.0/dotnet-console.dll.config b/bin/Debug/net6.0/dotnet-console.dll.config new file mode 100755 index 0000000..5ad7430 --- /dev/null +++ b/bin/Debug/net6.0/dotnet-console.dll.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/bin/Debug/net6.0/dotnet-console.pdb b/bin/Debug/net6.0/dotnet-console.pdb new file mode 100644 index 0000000..53f8f2e Binary files /dev/null and b/bin/Debug/net6.0/dotnet-console.pdb differ diff --git a/bin/Debug/net6.0/dotnet-console.runtimeconfig.json b/bin/Debug/net6.0/dotnet-console.runtimeconfig.json new file mode 100644 index 0000000..4986d16 --- /dev/null +++ b/bin/Debug/net6.0/dotnet-console.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net6.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "6.0.0" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net6.0/runtimes/linux-x64/native/libSDL2.so b/bin/Debug/net6.0/runtimes/linux-x64/native/libSDL2.so new file mode 100755 index 0000000..85f6ef7 Binary files /dev/null and b/bin/Debug/net6.0/runtimes/linux-x64/native/libSDL2.so differ diff --git a/bin/Debug/net6.0/runtimes/linux-x86/native/libSDL2.so b/bin/Debug/net6.0/runtimes/linux-x86/native/libSDL2.so new file mode 100755 index 0000000..047cfe4 Binary files /dev/null and b/bin/Debug/net6.0/runtimes/linux-x86/native/libSDL2.so differ diff --git a/bin/Debug/net6.0/runtimes/osx-arm64/native/libSDL2.dylib b/bin/Debug/net6.0/runtimes/osx-arm64/native/libSDL2.dylib new file mode 100755 index 0000000..27fcd08 Binary files /dev/null and b/bin/Debug/net6.0/runtimes/osx-arm64/native/libSDL2.dylib differ diff --git a/bin/Debug/net6.0/runtimes/osx-x64/native/libSDL2.dylib b/bin/Debug/net6.0/runtimes/osx-x64/native/libSDL2.dylib new file mode 100755 index 0000000..6aa068a Binary files /dev/null and b/bin/Debug/net6.0/runtimes/osx-x64/native/libSDL2.dylib differ diff --git a/bin/Debug/net6.0/runtimes/win-arm64/native/SDL2.dll b/bin/Debug/net6.0/runtimes/win-arm64/native/SDL2.dll new file mode 100755 index 0000000..10cd504 Binary files /dev/null and b/bin/Debug/net6.0/runtimes/win-arm64/native/SDL2.dll differ diff --git a/bin/Debug/net6.0/runtimes/win-x64/native/SDL2.dll b/bin/Debug/net6.0/runtimes/win-x64/native/SDL2.dll new file mode 100755 index 0000000..3ce73db Binary files /dev/null and b/bin/Debug/net6.0/runtimes/win-x64/native/SDL2.dll differ diff --git a/bin/Debug/net6.0/runtimes/win-x86/native/SDL2.dll b/bin/Debug/net6.0/runtimes/win-x86/native/SDL2.dll new file mode 100755 index 0000000..0e6a38c Binary files /dev/null and b/bin/Debug/net6.0/runtimes/win-x86/native/SDL2.dll differ diff --git a/dotnet-console.csproj b/dotnet-console.csproj new file mode 100644 index 0000000..c033c20 --- /dev/null +++ b/dotnet-console.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + dotnet_console + enable + enable + + + + + + + diff --git a/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs b/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs new file mode 100644 index 0000000..f795be5 --- /dev/null +++ b/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] diff --git a/obj/Debug/net6.0/apphost b/obj/Debug/net6.0/apphost new file mode 100755 index 0000000..960eb3c Binary files /dev/null and b/obj/Debug/net6.0/apphost differ diff --git a/obj/Debug/net6.0/dotnet-console.AssemblyInfo.cs b/obj/Debug/net6.0/dotnet-console.AssemblyInfo.cs new file mode 100644 index 0000000..95cf628 --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("dotnet-console")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("dotnet-console")] +[assembly: System.Reflection.AssemblyTitleAttribute("dotnet-console")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net6.0/dotnet-console.AssemblyInfoInputs.cache b/obj/Debug/net6.0/dotnet-console.AssemblyInfoInputs.cache new file mode 100644 index 0000000..81780a6 --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +5a44bd4435b7014cf09d126ef56021bc8e8fc082 diff --git a/obj/Debug/net6.0/dotnet-console.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net6.0/dotnet-console.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..f470fcd --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,10 @@ +is_global = true +build_property.TargetFramework = net6.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = dotnet_console +build_property.ProjectDir = /home/gordon/git/dotnet-console/ diff --git a/obj/Debug/net6.0/dotnet-console.GlobalUsings.g.cs b/obj/Debug/net6.0/dotnet-console.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net6.0/dotnet-console.assets.cache b/obj/Debug/net6.0/dotnet-console.assets.cache new file mode 100644 index 0000000..dd0ea61 Binary files /dev/null and b/obj/Debug/net6.0/dotnet-console.assets.cache differ diff --git a/obj/Debug/net6.0/dotnet-console.csproj.AssemblyReference.cache b/obj/Debug/net6.0/dotnet-console.csproj.AssemblyReference.cache new file mode 100644 index 0000000..0dcd7b2 Binary files /dev/null and b/obj/Debug/net6.0/dotnet-console.csproj.AssemblyReference.cache differ diff --git a/obj/Debug/net6.0/dotnet-console.csproj.CopyComplete b/obj/Debug/net6.0/dotnet-console.csproj.CopyComplete new file mode 100644 index 0000000..e69de29 diff --git a/obj/Debug/net6.0/dotnet-console.csproj.CoreCompileInputs.cache b/obj/Debug/net6.0/dotnet-console.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..bf9bfef --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +1430158ffd0195d00b80893ad9906b7cccc4512f diff --git a/obj/Debug/net6.0/dotnet-console.csproj.FileListAbsolute.txt b/obj/Debug/net6.0/dotnet-console.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..980cf0b --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.csproj.FileListAbsolute.txt @@ -0,0 +1,25 @@ +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console.deps.json +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console.runtimeconfig.json +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console.dll +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console.pdb +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.csproj.AssemblyReference.cache +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.GeneratedMSBuildEditorConfig.editorconfig +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.AssemblyInfoInputs.cache +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.AssemblyInfo.cs +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.csproj.CoreCompileInputs.cache +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.dll +/home/gordon/git/dotnet-console/obj/Debug/net6.0/refint/dotnet-console.dll +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.pdb +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.genruntimeconfig.cache +/home/gordon/git/dotnet-console/obj/Debug/net6.0/ref/dotnet-console.dll +/home/gordon/git/dotnet-console/bin/Debug/net6.0/dotnet-console.dll.config +/home/gordon/git/dotnet-console/bin/Debug/net6.0/SDL2-CS.dll +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/linux-x64/native/libSDL2.so +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/linux-x86/native/libSDL2.so +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/osx-arm64/native/libSDL2.dylib +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/osx-x64/native/libSDL2.dylib +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/win-arm64/native/SDL2.dll +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/win-x64/native/SDL2.dll +/home/gordon/git/dotnet-console/bin/Debug/net6.0/runtimes/win-x86/native/SDL2.dll +/home/gordon/git/dotnet-console/obj/Debug/net6.0/dotnet-console.csproj.CopyComplete diff --git a/obj/Debug/net6.0/dotnet-console.dll b/obj/Debug/net6.0/dotnet-console.dll new file mode 100644 index 0000000..33ca584 Binary files /dev/null and b/obj/Debug/net6.0/dotnet-console.dll differ diff --git a/obj/Debug/net6.0/dotnet-console.genruntimeconfig.cache b/obj/Debug/net6.0/dotnet-console.genruntimeconfig.cache new file mode 100644 index 0000000..d4375e3 --- /dev/null +++ b/obj/Debug/net6.0/dotnet-console.genruntimeconfig.cache @@ -0,0 +1 @@ +6e47d573ce23f499195def0267a82bede4ac78dc diff --git a/obj/Debug/net6.0/dotnet-console.pdb b/obj/Debug/net6.0/dotnet-console.pdb new file mode 100644 index 0000000..53f8f2e Binary files /dev/null and b/obj/Debug/net6.0/dotnet-console.pdb differ diff --git a/obj/Debug/net6.0/ref/dotnet-console.dll b/obj/Debug/net6.0/ref/dotnet-console.dll new file mode 100644 index 0000000..242a5d4 Binary files /dev/null and b/obj/Debug/net6.0/ref/dotnet-console.dll differ diff --git a/obj/Debug/net6.0/refint/dotnet-console.dll b/obj/Debug/net6.0/refint/dotnet-console.dll new file mode 100644 index 0000000..242a5d4 Binary files /dev/null and b/obj/Debug/net6.0/refint/dotnet-console.dll differ diff --git a/obj/dotnet-console.csproj.nuget.dgspec.json b/obj/dotnet-console.csproj.nuget.dgspec.json new file mode 100644 index 0000000..083b36f --- /dev/null +++ b/obj/dotnet-console.csproj.nuget.dgspec.json @@ -0,0 +1,73 @@ +{ + "format": 1, + "restore": { + "/home/gordon/git/dotnet-console/dotnet-console.csproj": {} + }, + "projects": { + "/home/gordon/git/dotnet-console/dotnet-console.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-console/dotnet-console.csproj", + "projectName": "dotnet-console", + "projectPath": "/home/gordon/git/dotnet-console/dotnet-console.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-console/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "dependencies": { + "ppy.SDL2-CS": { + "target": "Package", + "version": "[1.0.596-alpha, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/obj/dotnet-console.csproj.nuget.g.props b/obj/dotnet-console.csproj.nuget.g.props new file mode 100644 index 0000000..be02131 --- /dev/null +++ b/obj/dotnet-console.csproj.nuget.g.props @@ -0,0 +1,25 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /home/gordon/.nuget/packages/ + /home/gordon/.nuget/packages/ + PackageReference + 6.3.0 + + + + + + + ppy.SDL2-CS + 1.0.596-alpha + Content + false + False + app.config + + + \ No newline at end of file diff --git a/obj/dotnet-console.csproj.nuget.g.targets b/obj/dotnet-console.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/obj/dotnet-console.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json new file mode 100644 index 0000000..20197c2 --- /dev/null +++ b/obj/project.assets.json @@ -0,0 +1,149 @@ +{ + "version": 3, + "targets": { + "net6.0": { + "ppy.SDL2-CS/1.0.596-alpha": { + "type": "package", + "compile": { + "lib/netstandard2.0/SDL2-CS.dll": {} + }, + "runtime": { + "lib/netstandard2.0/SDL2-CS.dll": {} + }, + "contentFiles": { + "contentFiles/any/netstandard2.0/app.config": { + "buildAction": "Content", + "codeLanguage": "any", + "copyToOutput": false + } + }, + "runtimeTargets": { + "runtimes/linux-x64/native/libSDL2.so": { + "assetType": "native", + "rid": "linux-x64" + }, + "runtimes/linux-x86/native/libSDL2.so": { + "assetType": "native", + "rid": "linux-x86" + }, + "runtimes/osx-arm64/native/libSDL2.dylib": { + "assetType": "native", + "rid": "osx-arm64" + }, + "runtimes/osx-x64/native/libSDL2.dylib": { + "assetType": "native", + "rid": "osx-x64" + }, + "runtimes/win-arm64/native/SDL2.dll": { + "assetType": "native", + "rid": "win-arm64" + }, + "runtimes/win-x64/native/SDL2.dll": { + "assetType": "native", + "rid": "win-x64" + }, + "runtimes/win-x86/native/SDL2.dll": { + "assetType": "native", + "rid": "win-x86" + } + } + } + } + }, + "libraries": { + "ppy.SDL2-CS/1.0.596-alpha": { + "sha512": "yzIdTCjPp9le6J16WyG4py8frdwUTcsnqpGnuAk7Za2pvXGPmvVAiQBrdnFS58l2S6bS8AFNIG3uOSRQrMo1nQ==", + "type": "package", + "path": "ppy.sdl2-cs/1.0.596-alpha", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "content/app.config", + "contentFiles/any/netstandard2.0/app.config", + "lib/netstandard2.0/SDL2-CS.dll", + "ppy.sdl2-cs.1.0.596-alpha.nupkg.sha512", + "ppy.sdl2-cs.nuspec", + "runtimes/linux-x64/native/libSDL2.so", + "runtimes/linux-x86/native/libSDL2.so", + "runtimes/osx-arm64/native/libSDL2.dylib", + "runtimes/osx-x64/native/libSDL2.dylib", + "runtimes/win-arm64/native/SDL2.dll", + "runtimes/win-x64/native/SDL2.dll", + "runtimes/win-x86/native/SDL2.dll" + ] + } + }, + "projectFileDependencyGroups": { + "net6.0": [ + "ppy.SDL2-CS >= 1.0.596-alpha" + ] + }, + "packageFolders": { + "/home/gordon/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/home/gordon/git/dotnet-console/dotnet-console.csproj", + "projectName": "dotnet-console", + "projectPath": "/home/gordon/git/dotnet-console/dotnet-console.csproj", + "packagesPath": "/home/gordon/.nuget/packages/", + "outputPath": "/home/gordon/git/dotnet-console/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/home/gordon/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "dependencies": { + "ppy.SDL2-CS": { + "target": "Package", + "version": "[1.0.596-alpha, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "downloadDependencies": [ + { + "name": "Microsoft.AspNetCore.App.Ref", + "version": "[6.0.9, 6.0.9]" + } + ], + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/6.0.401/RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache new file mode 100644 index 0000000..3f13829 --- /dev/null +++ b/obj/project.nuget.cache @@ -0,0 +1,11 @@ +{ + "version": 2, + "dgSpecHash": "Z+HnQHJqEH3pQORn3oK/9WhS17M4sshlWSQ2haefUhu7xmUXe4i6NFbFXNMZCMcHlSu1wQ2wELP7qH7RGQ0Smw==", + "success": true, + "projectFilePath": "/home/gordon/git/dotnet-console/dotnet-console.csproj", + "expectedPackageFiles": [ + "/home/gordon/.nuget/packages/ppy.sdl2-cs/1.0.596-alpha/ppy.sdl2-cs.1.0.596-alpha.nupkg.sha512", + "/home/gordon/.nuget/packages/microsoft.aspnetcore.app.ref/6.0.9/microsoft.aspnetcore.app.ref.6.0.9.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file diff --git a/src/Scene.cs b/src/Scene.cs new file mode 100644 index 0000000..68181f6 --- /dev/null +++ b/src/Scene.cs @@ -0,0 +1,139 @@ +using static SDL2.SDL; + +class Scene +{ + public const int SCREEN_WIDTH = 800; + public const int SCREEN_HEIGHT = 600; + private Ship ship; + private Renderer renderer; + private static Scene? instance; + + public HashSet Shots; + public HashSet Asteroids; + public int Score = 0; + public int Level = 1; + + public Scene(Renderer renderer) + { + this.ship = new Ship(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + this.Shots = new HashSet(); + this.Asteroids = new HashSet(); + this.renderer = renderer; + instance = this; + } + + public int Run() + { + + double dx = 0; + DateTime start = DateTime.Now; + SpawnAsteroids(Level + 3); + while (true) + { + start = DateTime.Now; + pollEvents(); + + var entities = new List(); + entities.Add(ship); + entities.AddRange(Shots); + entities.AddRange(Asteroids); + + var keyState = new KeyState(); + renderer.Clear(); + + foreach (var entity in entities) + { + if (entity is Logic) + { + ((Logic)entity).Update(keyState, dx); + } + if (entity is Renderable) + { + ((Renderable)entity).Render(renderer, dx); + } + } + + if (Asteroids.Count == 0) + { + Level++; + SpawnAsteroids(Level + 3); + } + + renderer.Present(); + DateTime end = DateTime.Now; + dx = (end - start).TotalSeconds; + } + } + + public void SpawnAsteroids(int count) + { + for (int i = 0; i < count; i++) + { + SpawnAsteroid(); + } + } + + public void SpawnAsteroid() + { + var edge = new Random().Next(0, 4); + var x = 0; + var y = 0; + switch (edge) + { + case 0: + x = 0; + y = new Random().Next(0, SCREEN_HEIGHT); + break; + case 1: + x = SCREEN_WIDTH; + y = new Random().Next(0, SCREEN_HEIGHT); + break; + case 2: + x = new Random().Next(0, SCREEN_WIDTH); + y = 0; + break; + case 3: + x = new Random().Next(0, SCREEN_WIDTH); + y = SCREEN_HEIGHT; + break; + } + Asteroids.Add(new Asteroid(x, y, new Random().Next(0, 200) / 100.0 * Math.PI, Size.Large)); + } + + public void Loose() + { + Console.WriteLine("You loose!"); + Environment.Exit(0); + } + + private void pollEvents() + { + SDL_Event e; + while (SDL_PollEvent(out e) != 0) + { + if (e.type == SDL_EventType.SDL_QUIT) + { + System.Environment.Exit(0); + } + if (e.type == SDL_EventType.SDL_KEYDOWN) + { + if (e.key.keysym.sym == SDL_Keycode.SDLK_ESCAPE) + { + System.Environment.Exit(0); + } + } + } + } + + public static Scene Instance + { + get + { + if (instance == null) + { + throw new Exception("Scene not initialized"); + } + return instance; + } + } +} diff --git a/src/engine/KeyState.cs b/src/engine/KeyState.cs new file mode 100644 index 0000000..15032f0 --- /dev/null +++ b/src/engine/KeyState.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using static SDL2.SDL; + +class KeyState +{ + private byte[] keys; + + public KeyState() + { + var origArray = SDL_GetKeyboardState(out var arraySize); + this.keys = new byte[arraySize]; + Marshal.Copy(origArray, keys, 0, arraySize); + } + + public bool isPressed(SDL_Keycode keycode) + { + byte scanCode = (byte)SDL_GetScancodeFromKey(keycode); + return (this.keys[scanCode] == 1); + } +} diff --git a/src/engine/Renderer.cs b/src/engine/Renderer.cs new file mode 100644 index 0000000..907888f --- /dev/null +++ b/src/engine/Renderer.cs @@ -0,0 +1,55 @@ +using static SDL2.SDL; + +class Renderer +{ + IntPtr renderer; + + public Renderer(Window window) + { + this.renderer = SDL_CreateRenderer(window.GetWindow(), -1, SDL_RendererFlags.SDL_RENDERER_ACCELERATED); + } + + public void Clear() + { + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + } + + public void Present() + { + SDL_RenderPresent(renderer); + } + + public void DrawRect(double x, double y, int w, int h) + { + this.DrawRect((int)x, (int)y, w, h); + } + + public void DrawRect(int x, int y, int w, int h) + { + SDL_Rect rect = new SDL_Rect(); + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + + SDL_RenderFillRect(renderer, ref rect); + } + + public void DrawLines(double[][] points) + { + SDL_Point[] sdlPoints = new SDL_Point[points.Length]; + for (int i = 0; i < points.Length; i++) + { + sdlPoints[i].x = (int)points[i][0]; + sdlPoints[i].y = (int)points[i][1]; + } + + SDL_RenderDrawLines(renderer, sdlPoints, points.Length); + } + + public void setColor(int r, int g, int b, int a = 255) + { + SDL_SetRenderDrawColor(renderer, (byte)r, (byte)g, (byte)b, (byte)a); + } +} diff --git a/src/engine/Window.cs b/src/engine/Window.cs new file mode 100644 index 0000000..6131b6e --- /dev/null +++ b/src/engine/Window.cs @@ -0,0 +1,26 @@ +using static SDL2.SDL; + +class Window +{ + IntPtr window; + + public Window(string title, int w, int h) + { + window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WindowFlags.SDL_WINDOW_VULKAN); + } + + public Window(string title, int x, int y, int w, int h, SDL_WindowFlags flags) + { + this.window = SDL_CreateWindow(title, x, y, w, h, flags); + } + + public void Dispose() + { + SDL_DestroyWindow(this.window); + } + + public IntPtr GetWindow() + { + return this.window; + } +} diff --git a/src/engine/interfaces/Logic.cs b/src/engine/interfaces/Logic.cs new file mode 100644 index 0000000..7db6d41 --- /dev/null +++ b/src/engine/interfaces/Logic.cs @@ -0,0 +1,4 @@ +interface Logic +{ + public void Update(KeyState keyState, double dx); +} diff --git a/src/engine/interfaces/Renderable.cs b/src/engine/interfaces/Renderable.cs new file mode 100644 index 0000000..7a0c1aa --- /dev/null +++ b/src/engine/interfaces/Renderable.cs @@ -0,0 +1,4 @@ +interface Renderable +{ + public void Render(Renderer renderer, double dx); +} diff --git a/src/engine/utils/Point.cs b/src/engine/utils/Point.cs new file mode 100644 index 0000000..585457e --- /dev/null +++ b/src/engine/utils/Point.cs @@ -0,0 +1,7 @@ +class Point +{ + public static double Distance(double x1, double y1, double x2, double y2) + { + return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2)); + } +} diff --git a/src/entities/Asteroid.cs b/src/entities/Asteroid.cs new file mode 100644 index 0000000..b000814 --- /dev/null +++ b/src/entities/Asteroid.cs @@ -0,0 +1,96 @@ +enum Size : int +{ + Large = 60, + Medium = 30, + Small = 20 +} + +class Asteroid : Renderable, Logic +{ + const double SPEED = 100; + private double dx, dy; + public double X, Y; + public Size Size; + private double[][] shape; + + public Asteroid(double x, double y, double rotation, Size size) + { + this.X = x; + this.Y = y; + this.Size = size; + dx = Math.Cos(rotation) * SPEED; + dy = Math.Sin(rotation) * SPEED; + var random = new Random(); + shape = new double[16][]; + for (int i = 0; i < shape.Length; i++) + { + var rad = i * Math.PI * 2 / shape.Length; + shape[i] = new double[2]; + shape[i][0] = Math.Cos(rad) * (0.5 + random.NextDouble() / 2) * (int)size / 2; + shape[i][1] = Math.Sin(rad) * (0.5 + random.NextDouble() / 2) * (int)size / 2; + } + } + + public void Render(Renderer renderer, double dx) + { + renderer.setColor(255, 255, 255); + // renderer.DrawRect(X - (int)Size / 2, Y - (int)Size / 2, (int)Size, (int)Size); + double[][] drawLines = new double[shape.Length + 1][]; + for (int i = 0; i < shape.Length; i++) + { + drawLines[i] = new double[2]; + drawLines[i][0] = shape[i][0] + X - (int)Size / 2; + drawLines[i][1] = shape[i][1] + Y - (int)Size / 2; + } + drawLines[drawLines.Length - 1] = new double[2]; + drawLines[drawLines.Length - 1][0] = shape[0][0] + X - (int)Size / 2; + drawLines[drawLines.Length - 1][1] = shape[0][1] + Y - (int)Size / 2; + renderer.DrawLines(drawLines); + } + + public void Update(KeyState keyState, double dx) + { + X += dx * this.dx; + Y += dx * this.dy; + this.X = this.X % Scene.SCREEN_WIDTH; + this.Y = this.Y % Scene.SCREEN_HEIGHT; + if (this.X < 0) + { + this.X += Scene.SCREEN_WIDTH; + } + if (this.Y < 0) + { + this.Y += Scene.SCREEN_HEIGHT; + } + + foreach (var shot in Scene.Instance.Shots) + { + if (Point.Distance(shot.X, shot.Y, X, Y) < (int)Size / 2) + { + shot.Destroy(); + this.Destroy(); + var rotation = Math.Atan2(Y - shot.Y, X - shot.X); + if (Size == Size.Large) + { + Scene.Instance.Asteroids.Add(new Asteroid(X, Y, rotation + Math.PI * 2, Size.Medium)); + Scene.Instance.Asteroids.Add(new Asteroid(X, Y, rotation + Math.PI * 2 * 0.3, Size.Medium)); + Scene.Instance.Asteroids.Add(new Asteroid(X, Y, rotation + Math.PI * 2 * 0.6, Size.Medium)); + } + if (Size == Size.Medium) + { + Scene.Instance.Asteroids.Add(new Asteroid(X, Y, rotation + Math.PI * 2 * 0.3, Size.Small)); + Scene.Instance.Asteroids.Add(new Asteroid(X, Y, rotation + Math.PI * 2 * 0.6, Size.Small)); + } + break; + } + } + } + + public void Destroy() + { + Scene.Instance.Score += (int)Size; + Scene.Instance.Asteroids.Remove(this); + Console.WriteLine("Asteroid destroyed"); + Console.WriteLine("Score: " + Scene.Instance.Score); + } +} diff --git a/src/entities/Ship.cs b/src/entities/Ship.cs new file mode 100644 index 0000000..deaf974 --- /dev/null +++ b/src/entities/Ship.cs @@ -0,0 +1,94 @@ +using static SDL2.SDL; + + +class Ship : Logic, Renderable +{ + const double SPEED = 0.3; + const double ROTATION_SPEED = 5; + + double rotation = 0; + bool thrust = false; + private double dx, dy = 0; + double x; + double y; + DateTime lastShot = DateTime.Now; + + public Ship(double x, double y) + { + this.x = x; + this.y = y; + } + + public void Update(KeyState keyState, double dt) + { + thrust = false; + if (keyState.isPressed(SDL_Keycode.SDLK_LEFT)) + { + rotation -= ROTATION_SPEED * dt; + } + if (keyState.isPressed(SDL_Keycode.SDLK_RIGHT)) + { + rotation += ROTATION_SPEED * dt; + } + if (keyState.isPressed(SDL_Keycode.SDLK_UP)) + { + thrust = true; + this.dx += Math.Cos(rotation) * SPEED * dt; + this.dy += Math.Sin(rotation) * SPEED * dt; + } + if (keyState.isPressed(SDL_Keycode.SDLK_SPACE) && (DateTime.Now - lastShot).TotalMilliseconds > 200) + { + lastShot = DateTime.Now; + var shot = new Shot(x, y, rotation); + Scene.Instance.Shots.Add(shot); + } + rotation = rotation % (2 * Math.PI); + if (rotation < 0) + { + rotation += 2 * Math.PI; + } + this.x += this.dx; + this.y += this.dy; + this.dx *= 0.9998; + this.dy *= 0.9998; + this.x = this.x % Scene.SCREEN_WIDTH; + this.y = this.y % Scene.SCREEN_HEIGHT; + if (this.x < 0) + { + this.x += Scene.SCREEN_WIDTH; + } + if (this.y < 0) + { + this.y += Scene.SCREEN_HEIGHT; + } + foreach (var asteroid in Scene.Instance.Asteroids) + { + if (Point.Distance(x, y, asteroid.X, asteroid.Y) < (int)asteroid.Size / 2) + { + Scene.Instance.Loose(); + } + } + } + + public void Render(Renderer renderer, double dx) + { + renderer.setColor(255, 255, 255); + renderer.DrawLines(new double[][] { + new double[]{x + Math.Cos(rotation) * 10, y + Math.Sin(rotation) * 10}, + new double[]{x + Math.Cos(rotation + Math.PI * 2 / 3) * 10, y + Math.Sin(rotation + Math.PI * 2 / 3) * 10}, + new double[]{x + Math.Cos(rotation + Math.PI * 4 / 3) * 10, y + Math.Sin(rotation + Math.PI * 4 / 3) * 10}, + new double[]{x + Math.Cos(rotation) * 10, y + Math.Sin(rotation) * 10} + }); + if (thrust) + { + renderer.setColor(255, 0, 0); + // Draw flame behind ship + renderer.DrawLines(new double[][] { + new double[]{x + Math.Cos(rotation + Math.PI * 2 / 3) * 10, y + Math.Sin(rotation + Math.PI * 2 / 3) * 10}, + new double[]{x + Math.Cos(rotation + Math.PI * 2 / 3) * 10 + Math.Cos(rotation + Math.PI) * 10, y + Math.Sin(rotation + Math.PI * 2 / 3) * 10 + Math.Sin(rotation + Math.PI) * 10}, + new double[]{x + Math.Cos(rotation + Math.PI * 4 / 3) * 10, y + Math.Sin(rotation + Math.PI * 4 / 3) * 10}, + new double[]{x + Math.Cos(rotation + Math.PI * 2 / 3) * 10, y + Math.Sin(rotation + Math.PI * 2 / 3) * 10} + }); + } + } +} diff --git a/src/entities/Shot.cs b/src/entities/Shot.cs new file mode 100644 index 0000000..2b9c014 --- /dev/null +++ b/src/entities/Shot.cs @@ -0,0 +1,35 @@ +class Shot : Renderable, Logic +{ + const double SPEED = 300; + private double dx, dy; + public double X, Y; + + public Shot(double x, double y, double rotation) + { + this.X = x; + this.Y = y; + dx = Math.Cos(rotation) * SPEED; + dy = Math.Sin(rotation) * SPEED; + } + + public void Render(Renderer renderer, double dx) + { + renderer.setColor(255, 255, 255); + renderer.DrawRect(X, Y, 2, 2); + } + + public void Update(KeyState keyState, double dx) + { + X += dx * this.dx; + Y += dx * this.dy; + if (X < 0 || X > Scene.SCREEN_WIDTH || Y < 0 || Y > Scene.SCREEN_HEIGHT) + { + Destroy(); + } + } + + public void Destroy() + { + Scene.Instance.Shots.Remove(this); + } +}