-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
50 lines (38 loc) · 1.05 KB
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Raylib_cs;
using System.Numerics;
class Player: ObjectPosition{
int MovementSpeed;
public Rectangle thePlayer;
int Size;
public Player(): base()
{
Size = 30;
MovementSpeed = 4;
thePlayer.x = 390;
thePlayer.y = 420;
thePlayer.width = Size;
thePlayer.height = Size;
Position.X = thePlayer.x;
Position.Y = thePlayer.y;
}
public void Move()
{
if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT)) {
Position.X += MovementSpeed;
}
if (Raylib.IsKeyDown(KeyboardKey.KEY_LEFT)) {
Position.X -= MovementSpeed;
}
// if (Raylib.IsKeyDown(KeyboardKey.KEY_UP)) {
// Position.Y -= MovementSpeed;
// }
// if (Raylib.IsKeyDown(KeyboardKey.KEY_DOWN)) {
// Position.Y += MovementSpeed;
// }
thePlayer.x = Position.X;
}
public override void Draw()
{
Raylib.DrawRectangleLines((int)Position.X, (int)Position.Y, Size, Size, playerColor);
}
}