-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaddle.cs
More file actions
57 lines (45 loc) · 1.28 KB
/
Paddle.cs
File metadata and controls
57 lines (45 loc) · 1.28 KB
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
51
52
53
54
55
56
57
using Raylib_cs;
namespace RaylibGame1
{
internal class Paddle
{
public int PosX { get; set; }
public int PosY { get; set; }
public int Acceleration { get; set; }
public KeyboardKey UpKey { get; set; }
public KeyboardKey DownKey { get; set; }
public int Speed = 0;
public Paddle(int posX, int posY, int acceleration, KeyboardKey upKey, KeyboardKey downKey)
{
this.PosX = posX;
this.PosY = posY;
this.Acceleration = acceleration;
this.UpKey = upKey;
this.DownKey = downKey;
}
public void Update()
{
PosY += Speed;
if (Speed > 0)
{
Speed -= Acceleration / 2;
}
if (Speed < 0)
{
Speed += Acceleration / 2;
}
if (Raylib.IsKeyDown(UpKey))
{
Speed -= Acceleration;
}
if (Raylib.IsKeyDown(DownKey))
{
Speed += Acceleration;
}
}
public void Render(int x, int y)
{
Raylib.DrawRectangle(x, y, 10, 40, Color.White);
}
}
}