Init
This commit is contained in:
commit
00fc14559e
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.idea/
|
||||
deleteme/bin/
|
||||
deleteme/obj/
|
16
deleteme.sln
Normal file
16
deleteme.sln
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "deleteme", "deleteme\deleteme.csproj", "{77A9793C-2EDA-4510-8D1A-72AD4C575882}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{77A9793C-2EDA-4510-8D1A-72AD4C575882}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{77A9793C-2EDA-4510-8D1A-72AD4C575882}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{77A9793C-2EDA-4510-8D1A-72AD4C575882}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{77A9793C-2EDA-4510-8D1A-72AD4C575882}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
59
deleteme/Game.cs
Normal file
59
deleteme/Game.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System.Numerics;
|
||||
using Raylib_cs;
|
||||
|
||||
namespace deleteme;
|
||||
|
||||
public class Game
|
||||
{
|
||||
private Vector2 _playerPosition = Vector2.Zero;
|
||||
private float _speed = 0.5f;
|
||||
|
||||
|
||||
public Game()
|
||||
{
|
||||
Raylib.SetConfigFlags(ConfigFlags.ResizableWindow);
|
||||
Raylib.InitWindow(1280,720,"Raylib");
|
||||
|
||||
_playerPosition = new Vector2(Raylib.GetScreenWidth() / 2, Raylib.GetScreenHeight() / 2);
|
||||
|
||||
while (!Raylib.WindowShouldClose())
|
||||
{
|
||||
Update();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Raylib.BeginDrawing();
|
||||
Raylib.ClearBackground(new(10,0,30,255));
|
||||
|
||||
DrawPlayer();
|
||||
|
||||
Raylib.EndDrawing();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Input();
|
||||
}
|
||||
|
||||
private void Input()
|
||||
{
|
||||
Vector2 newPos = _playerPosition;
|
||||
|
||||
|
||||
if (Raylib.IsKeyDown(KeyboardKey.D) && newPos.X < Raylib.GetScreenWidth() - 16) newPos.X += _speed;
|
||||
if (Raylib.IsKeyDown(KeyboardKey.A) && newPos.X != 0) newPos.X -= _speed;
|
||||
|
||||
if (Raylib.IsKeyDown(KeyboardKey.W) && newPos.Y != 0) newPos.Y -= _speed;
|
||||
if (Raylib.IsKeyDown(KeyboardKey.S) && newPos.Y < Raylib.GetScreenHeight() - 16) newPos.Y += _speed;
|
||||
|
||||
_playerPosition = newPos;
|
||||
}
|
||||
|
||||
private void DrawPlayer()
|
||||
{
|
||||
Raylib.DrawRectangle((int)_playerPosition.X, (int)_playerPosition.Y, 16,16, Color.RayWhite);
|
||||
}
|
||||
}
|
3
deleteme/Program.cs
Normal file
3
deleteme/Program.cs
Normal file
@ -0,0 +1,3 @@
|
||||
using deleteme;
|
||||
|
||||
Game game = new Game();
|
14
deleteme/deleteme.csproj
Normal file
14
deleteme/deleteme.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Raylib-cs" Version="6.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user