-
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
1 parent
64ad019
commit dc5a766
Showing
9 changed files
with
311 additions
and
138 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (console)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
"program": "${workspaceFolder}/ConwaysGameOfLife/bin/Debug/net5.0/ConwaysGameOfLife.dll", | ||
"cwd": "${workspaceFolder}/ConwaysGameOfLife/", | ||
"args": [], | ||
"console": "internalConsole", | ||
"stopAtEntry": false | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "clean", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"clean", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile", | ||
}, | ||
{ | ||
"label": "restore", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"restore", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"-property:GenerateFullPaths=true", | ||
"-consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish windows", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"-c", | ||
"Release", | ||
"-r", | ||
"win-x64", | ||
"-o", | ||
"bin/Windows x64", | ||
"--no-self-contained", | ||
"-p:PublishSingleFile=true", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"-property:GenerateFullPaths=true", | ||
"-consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish linux", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"-c", | ||
"Release", | ||
"-r", | ||
"linux-x64", | ||
"-o", | ||
"bin/Linux x64", | ||
"--no-self-contained", | ||
"-p:PublishSingleFile=true", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"-property:GenerateFullPaths=true", | ||
"-consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish macos", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"-c", | ||
"Release", | ||
"-r", | ||
"osx-x64", | ||
"-o", | ||
"bin/MacOS x64", | ||
"--no-self-contained", | ||
"-p:PublishSingleFile=true", | ||
"${workspaceFolder}/${workspaceFolderBasename}/${workspaceFolderBasename}.csproj", | ||
"-property:GenerateFullPaths=true", | ||
"-consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Input; | ||
|
||
namespace ConwaysGameOfLife | ||
{ | ||
public class Camera | ||
{ | ||
public Vector2 Position { get; private set; } | ||
public Vector2 Origin { get; private set; } | ||
public float Zoom { get; private set; } = 1; | ||
public Matrix Matrix { get; private set; } | ||
public Matrix InverseMatrix { get; private set; } | ||
|
||
private MouseState oldMouse; | ||
|
||
public void Update(GameTime time) | ||
{ | ||
var mouse = Mouse.GetState(); | ||
|
||
if (mouse.MiddleButton == ButtonState.Pressed) | ||
{ | ||
Point pos = mouse.Position - oldMouse.Position; | ||
Position += new Vector2(pos.X, pos.Y) * 30 / (Zoom * 0.5f) * (float)time.ElapsedGameTime.TotalSeconds; | ||
} | ||
|
||
int scrollDelta = mouse.ScrollWheelValue - oldMouse.ScrollWheelValue; | ||
|
||
if (scrollDelta < 0) | ||
{ | ||
Zoom /= 2; | ||
if (Zoom < 0.0125f) | ||
{ | ||
Zoom = 0.0125f; | ||
} | ||
} | ||
else if (scrollDelta > 0) | ||
{ | ||
Zoom *= 2; | ||
if (Zoom > 4) | ||
{ | ||
Zoom = 4; | ||
} | ||
} | ||
|
||
Matrix = Matrix.CreateTranslation(Position.X, Position.Y, 0) * Matrix.CreateScale(Zoom) * Matrix.CreateTranslation(Origin.X, Origin.Y, 0); | ||
InverseMatrix = Matrix.Invert(Matrix); | ||
oldMouse = mouse; | ||
} | ||
|
||
public void Resize(int width, int height) | ||
{ | ||
Origin = new Vector2(width / 2f, height / 2f); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.