-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
102 lines (83 loc) · 2.94 KB
/
Form1.cs
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
namespace ThisAnim
{
public partial class frmGame : Form
{
int score = 0;
int vx = 2;
PictureBox[] rings = new PictureBox[4];
Panel[] panels = new Panel[2];
private SoundPlayer coinCollect;
private SoundPlayer ouch;
public frmGame()
{
InitializeComponent();
coinCollect = new SoundPlayer("coin.wav.wav");
ouch = new SoundPlayer("thud.wav");
}
private void tmrBlueOcto_Tick(object sender, EventArgs e)
{
// int flag = 0;
//Player starting from the begining
/* if (picBlueOcto.Left < 700)
{
picBlueOcto.Left += 1;
}
else flag = 1;
if (flag == 1)
picBlueOcto.Left = -100;
*/
picBlueOcto.Location = new Point(picBlueOcto.Location.X + vx, picBlueOcto.Location.Y);
for (int i = 0; i < 2; i++)
{
if (panels[i].Bounds.IntersectsWith(picBlueOcto.Bounds))
{
ouch.Play();
vx *= -1;
picBlueOcto.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}
}
Random random = new Random();
if (random.Next(10) % 2 == 0)
picBlueOcto.Location = new Point(picBlueOcto.Location.X, picBlueOcto.Location.Y + random.Next(5)+2);
else
picBlueOcto.Location = new Point(picBlueOcto.Location.X, picBlueOcto.Location.Y - random.Next(5));
}
private void frmGame_Load(object sender, EventArgs e)
{
rings[0] = picRing1;
rings[1] = picRing2;
rings[2] = picRing3;
rings[3] = picRing4;
tmrBlueOcto.Start();
panels[0] = panel1;
panels[1] = panel2;
}
private void tmrWindow_Tick(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
if (picBlueOcto.Bounds.IntersectsWith(rings[i].Bounds) && rings[i].Visible)
{
rings[i].Hide();
score += 1;
coinCollect.Play();
lblScore.Text = "Coins: " + score.ToString();
}
}
}
private void picBlueOcto_Click(object sender, EventArgs e)
{
picBlueOcto.Location = new Point(picBlueOcto.Location.X, picBlueOcto.Location.Y - 25);
}
}
}