-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBall.cs
More file actions
47 lines (40 loc) · 1.01 KB
/
Ball.cs
File metadata and controls
47 lines (40 loc) · 1.01 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
using Raylib_cs;
namespace RaylibGame1
{
class Ball
{
public int PosX { get; set; }
public int PosY { get; set; }
public int SpeedX { get; set; }
public int SpeedY { get; set; }
// Direction
public int DirX = 1;
public int DirY = 1;
public Ball(int posX, int posY, int speedX, int speedY)
{
this.PosX = posX;
this.PosY = posY;
this.SpeedX = speedX;
this.SpeedY = speedY;
}
public void Update()
{
PosX += SpeedX * DirX;
PosY += SpeedY * DirY;
}
public void Render(int x, int y)
{
Raylib.DrawRectangle(x, y, 10, 10, Color.White);
}
// reverse x direction
public void ChangeDirX()
{
DirX *= -1;
}
// reverse y direction
public void ChangeDirY()
{
DirY *= -1;
}
}
}