-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.cs
More file actions
42 lines (38 loc) · 1.08 KB
/
Enemy.cs
File metadata and controls
42 lines (38 loc) · 1.08 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
using Raylib_cs;
using System.Numerics;
namespace SharpAsteroids
{
public class Enemy
{
public Vector2 Pos => new Vector2(posX, posY);
public Rectangle Rec => new Rectangle(posX, posY, sizeX, sizeY);
public int SizeX => sizeX;
int sizeX = 15;
int sizeY = 15;
int posX;
int posY;
int speed = 3;
int axis;
public Enemy(int a, int x = 0, int y = 0 )
{
posX = x;
posY = y;
axis = a;
}
public void Update()
{
switch (axis) {
case 0: posX -= speed; break; //move left
case 1: posY -= speed; break; //move down
case 2: posX += speed; break; //move right
case 3: posY += speed; break; //move up
}
}
public void Draw()
{
Raylib.DrawRectangle(posX, posY, sizeX, sizeY, Color.ORANGE);
//if hitbox = circle:
//Raylib.DrawRectangle(posX - sizeX/2, posY - sizeY/2, sizeX, sizeY, Color.ORANGE);
}
}
}