diff --git a/ProjectName.csproj b/ProjectName.csproj index 7407171..66626fe 100644 --- a/ProjectName.csproj +++ b/ProjectName.csproj @@ -1,32 +1,32 @@ - - Exe - net6.0 - ProjectName - false - false - 8.0 - ProjectName.Program - ProjectName - ProjectName - true - true - - + + Exe + net6.0 + ProjectName + false + false + 7.3 + ProjectName.Program + ProjectName + ProjectName + true + true + + - - - Always - - + + + Always + + - - $(DefaultItemExcludes);lib\**\* - + + $(DefaultItemExcludes);lib\**\* + - - - + + + - + diff --git a/README.md b/README.md index c60fc21..9fd5f5e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ NOTE: OSX is broken right now because I need to set up MoltenVK. - Project boilerplate code - VSCode build tasks -- VSCode debugger integration +- VSCode step debugger integration ## Requirements @@ -19,6 +19,7 @@ NOTE: OSX is broken right now because I need to set up MoltenVK. - [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) on Windows - [Visual Studio Code](https://code.visualstudio.com/) - [VSCode C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) +- [VSCode Omnisharp Extension](https://github.com/OmniSharp/omnisharp-vscode) ## Installation @@ -33,7 +34,7 @@ NOTE: OSX is broken right now because I need to set up MoltenVK. - Open the project directory in VSCode - Press Ctrl-Shift-B to open the build tasks menu - Tasks use .NET 6.0 to build and run -- Press F5 to build and debug +- Press F5 to build and run step debugger ## Acknowledgments diff --git a/install.sh b/install.sh index 3e4b90d..5c3cde4 100755 --- a/install.sh +++ b/install.sh @@ -12,22 +12,21 @@ readlinkf(){ perl -MCwd -e 'print Cwd::abs_path shift' "$1";} # Checks if git is installed function checkGit() { - git --version > /dev/null 2>&1 - if [ ! $? -eq 0 ]; then - echo >&2 "ERROR: Git is not installed. Please install git to download MoonWorks." - exit 1 - fi + git --version > /dev/null 2>&1 + if [ ! $? -eq 0 ]; then + echo >&2 "ERROR: Git is not installed. Please install git to download MoonWorks." + exit 1 + fi } # Pulls MoonWorks from github function pullMoonWorks() { - checkGit - cd lib - git submodule add https://gitea.moonside.games/MoonsideGames/MoonWorks.git - git checkout main - cd .. - echo "Updating to the latest release of MoonWorks..." + checkGit + cd lib + git submodule add https://gitea.moonside.games/MoonsideGames/MoonWorks.git + cd .. + echo "Updating to the latest release of MoonWorks..." git submodule update --init --recursive if [ $? -eq 0 ]; then echo "Finished updating!" @@ -40,54 +39,54 @@ function pullMoonWorks() # Downloads and extracts prepackaged archive of native libraries ("moonlibs") function getLibs() { - # Downloading - echo "Downloading latest moonlibs..." - curl http://moonside.games/files/moonlibs.tar.bz2 > "$MY_DIR/moonlibs.tar.bz2" - if [ $? -eq 0 ]; then - echo "Finished downloading!" - else - >&2 echo "ERROR: Unable to download successfully." - exit 1 - fi + # Downloading + echo "Downloading latest moonlibs..." + curl https://moonside.games/files/moonlibs.tar.bz2 > "$MY_DIR/moonlibs.tar.bz2" + if [ $? -eq 0 ]; then + echo "Finished downloading!" + else + >&2 echo "ERROR: Unable to download successfully." + exit 1 + fi - # Decompressing - echo "Decompressing moonlibs..." - mkdir -p "$MY_DIR" - tar xjC "$MY_DIR" -f "$MY_DIR"/moonlibs.tar.bz2 - if [ $? -eq 0 ]; then - echo "Finished decompressing!" - echo "" - rm "$MY_DIR"/moonlibs.tar.bz2 - else - >&2 echo "ERROR: Unable to decompress successfully." - exit 1 - fi + # Decompressing + echo "Decompressing moonlibs..." + mkdir -p "$MY_DIR" + tar -xvC "$MY_DIR"/moonlibs -f "$MY_DIR"/moonlibs.tar.bz2 + if [ $? -eq 0 ]; then + echo "Finished decompressing!" + echo "" + rm "$MY_DIR"/moonlibs.tar.bz2 + else + >&2 echo "ERROR: Unable to decompress successfully." + exit 1 + fi } -getLibs - read -p "Enter your project name or 'exit' to quit: " newProjectName if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then - exit 1 + exit 1 fi NEW_PROJECT_DIR="$MY_DIR/../$newProjectName" if [ -d "$NEW_PROJECT_DIR" ]; then - >&2 echo "ERROR: Directory already exists." + >&2 echo "ERROR: Project directory already exists." exit 1 fi +getLibs + # copy everything into new dir cp -R "$MY_DIR" "$NEW_PROJECT_DIR" cd "$NEW_PROJECT_DIR" files=(ProjectName.sln .gitignore ProjectName.csproj src/ProjectNameGame.cs src/Program.cs .vscode/tasks.json .vscode/launch.json) for file in "${files[@]}"; do - sed -i -e "s/ProjectName/$newProjectName/g" "./$file" - if [ "$(uname)" == "Darwin" ]; then - rm ./${file}-e - fi + sed -i -e "s/ProjectName/$newProjectName/g" "./$file" + if [ "$(uname)" == "Darwin" ]; then + rm ./${file}-e + fi done mv ./ProjectName.sln "./$newProjectName.sln" @@ -98,8 +97,6 @@ rm ./LICENSE rm -rf .git git init -git checkout -b main -git branch -D master mkdir lib pullMoonWorks @@ -109,7 +106,7 @@ dotnet sln ${newProjectName}.sln add lib/MoonWorks/MoonWorks.csproj echo "Project $newProjectName created at: " if [ "$(uname)" == "Darwin" ]; then - echo $(readlinkf $NEW_PROJECT_DIR) + echo $(readlinkf $NEW_PROJECT_DIR) else - echo $(readlink -f $NEW_PROJECT_DIR) + echo $(readlink -f $NEW_PROJECT_DIR) fi diff --git a/src/Program.cs b/src/Program.cs index 073db7f..0c1b12e 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -5,30 +5,37 @@ using MoonWorks; namespace ProjectName { - class Program - { - [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool SetDllDirectory(string lpPathName); + class Program + { + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetDllDirectory(string lpPathName); - static void Main(string[] args) - { - WindowCreateInfo windowCreateInfo = new WindowCreateInfo - { - WindowWidth = 1280, - WindowHeight = 720, - WindowTitle = "ProjectName", - ScreenMode = ScreenMode.Windowed - }; + static void Main(string[] args) + { + WindowCreateInfo windowCreateInfo = new WindowCreateInfo + { + WindowWidth = 1280, + WindowHeight = 720, + WindowTitle = "ProjectName", + ScreenMode = ScreenMode.Windowed + }; - ProjectNameGame game = new ProjectNameGame( - windowCreateInfo, - MoonWorks.Graphics.PresentMode.FIFORelaxed, - true - ); + FramerateSettings framerateSettings = new FramerateSettings + { + Mode = FramerateMode.Uncapped, + Cap = 60 + }; - game.Run(); - } - } + ProjectNameGame game = new ProjectNameGame( + windowCreateInfo, + MoonWorks.Graphics.PresentMode.FIFORelaxed, + framerateSettings, + true + ); + + game.Run(); + } + } } diff --git a/src/ProjectNameGame.cs b/src/ProjectNameGame.cs index 39b3539..461fb3d 100644 --- a/src/ProjectNameGame.cs +++ b/src/ProjectNameGame.cs @@ -3,41 +3,42 @@ using MoonWorks; namespace ProjectName { - class ProjectNameGame : Game - { - public ProjectNameGame( - WindowCreateInfo windowCreateInfo, - PresentMode presentMode, - bool debugMode - ) : base(windowCreateInfo, presentMode, 60, debugMode) - { - // Insert your game initialization logic here. - } + class ProjectNameGame : Game + { + public ProjectNameGame( + WindowCreateInfo windowCreateInfo, + PresentMode presentMode, + FramerateSettings framerateSettings, + bool debugMode + ) : base(windowCreateInfo, presentMode, framerateSettings, 60, debugMode) + { + // Insert your game initialization logic here. + } - protected override void Update(System.TimeSpan dt) - { - // Insert your game update logic here. - } + protected override void Update(System.TimeSpan dt) + { + // Insert your game update logic here. + } - protected override void Draw(System.TimeSpan dt, double alpha) - { - // Replace this with your own drawing code. + protected override void Draw(double alpha) + { + // Replace this with your own drawing code. - var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); + var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window); - commandBuffer.BeginRenderPass( + commandBuffer.BeginRenderPass( new ColorAttachmentInfo(swapchainTexture, Color.CornflowerBlue) - ); + ); commandBuffer.EndRenderPass(); - GraphicsDevice.Submit(commandBuffer); - } + GraphicsDevice.Submit(commandBuffer); + } - protected override void OnDestroy() + protected override void Destroy() { } - } + } }