This repository was archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cs
More file actions
75 lines (70 loc) · 1.92 KB
/
Copy pathPlayer.cs
File metadata and controls
75 lines (70 loc) · 1.92 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsAppMyGame
{
internal class Player
{
public int positionX;
public int positionY;
public float Health;
public int Coins;
public bool IsAlive;
public int MovesLeft;
public float Damage;
public float WeaponDamaged;
public float ArmorHealth;
public int Keys;
public bool OnBlocked;
public Image PlayerImage;
public Player(int x, int y)
{
this.positionX = x;
this.positionY = y;
this.Health = 50;
this.Coins = 0;
IsAlive = true;
this.MovesLeft = 1;
this.Damage = 10;
this.WeaponDamaged = 5;
this.ArmorHealth = 15;
this.Keys = 0;
this.PlayerImage = SpritesBody.Player;
}
public void Spawn(PaintEventArgs e)
{
Graphics graphics = e.Graphics;
graphics.DrawImage(PlayerImage, positionX, positionY, 100, 100);
}
public void MoveRight()
{
if (positionX < 700)
{
positionX += 100;
}
else { MessageBox.Show("You can't move right!"); }
}
public void MoveLeft()
{
if (positionX != 0)
{
positionX -= 100;
}
else { MessageBox.Show("You can't move left!"); }
}
public void MoveUp()
{
if (positionY > 0) { positionY -= 100; }
else { MessageBox.Show("You can't move up!"); }
}
public void MoveDown()
{
if (positionY < 700) { positionY += 100; }
else { MessageBox.Show("You can't move down!"); }
}
}
}