This commit is contained in:
2024-11-21 22:05:04 -06:00
commit 00fc14559e
5 changed files with 95 additions and 0 deletions

59
deleteme/Game.cs Normal file
View 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
View File

@@ -0,0 +1,3 @@
using deleteme;
Game game = new Game();

14
deleteme/deleteme.csproj Normal file
View 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>