-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhysics.cs
More file actions
82 lines (75 loc) · 3.22 KB
/
Physics.cs
File metadata and controls
82 lines (75 loc) · 3.22 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
76
77
78
79
80
81
82
using System.Windows.Forms;
namespace FirstGame
{
class Physics
{
public bool IsCollide(Player player, MapChanges map, Label scoreLabel)
{
var isColliding = false;
if ((player.ballX / 20) + player.directionX > MapChanges.mapWidth - 1 || (player.ballX / 20) + player.directionX < 0)
{
player.directionX *= -1;
isColliding = true;
}
if ((player.ballY / 20) + player.directionY < 0)
{
player.directionY *= -1;
isColliding = true;
}
if (map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] != 0)
{
var addScore = false;
isColliding = true;
if (map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] > 10 && map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] < 99)
{
map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] = 0;
map.map[(player.ballY / 20) + player.directionY, (player.ballX / 20) - 1] = 0;
addScore = true;
}
else if (map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] < 9)
{
map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] = 0;
map.map[(player.ballY / 20) + player.directionY, (player.ballX / 20) + 1] = 0;
addScore = true;
}
if (addScore)
{
player.score += 50;
if (player.score % 300 == 0 && player.score > 0)
{
map.AddLine();
}
}
player.directionY *= -1;
}
if (map.map[player.ballY / 20, (player.ballX / 20) + player.directionX] != 0)
{
var addScore = false;
isColliding = true;
if (map.map[player.ballY / 20, (player.ballX / 20) + player.directionX] > 10 && map.map[(player.ballY / 20) + player.directionY, player.ballX / 20] < 99)
{
map.map[player.ballY / 20, (player.ballX / 20) + player.directionX] = 0;
map.map[player.ballY / 20, (player.ballX / 20) + player.directionX - 1] = 0;
addScore = true;
}
else if (map.map[player.ballY / 20, (player.ballX / 20) + player.directionX] < 9)
{
map.map[player.ballY / 20, (player.ballX / 20) + player.directionX] = 0;
map.map[player.ballY / 20, (player.ballX / 20) + player.directionX + 1] = 0;
addScore = true;
}
if (addScore)
{
player.score += 50;
if (player.score % 300 == 0 && player.score > 0)
{
map.AddLine();
}
}
player.directionX *= -1;
}
scoreLabel.Text = $"Счёт: {player.score}";
return isColliding;
}
}
}