-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupProjectiles.cs
45 lines (39 loc) · 1.52 KB
/
upProjectiles.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
using System;
using System.Windows.Forms;
using System.Drawing;
namespace RobotGame
{
public class upProjectiles
{
public int upProjectileLeftCoordinate { get; set; }
public int upProjectileTopCoordinate { get; set; }
public int upProjectilePower = 30;
private PictureBox upProjectileElement = new PictureBox();
private Timer upProjectileClock = new Timer();
public void startJump(Form form)
{
upProjectileElement.Size = new Size(10, 10);
upProjectileElement.Name = "UpProjectileName";
upProjectileElement.Tag = "UpProjectileTag";
upProjectileElement.Left = upProjectileLeftCoordinate;
upProjectileElement.Top = upProjectileTopCoordinate;
upProjectileElement.BringToFront();
form.Controls.Add(upProjectileElement);
upProjectileClock.Interval = upProjectilePower;
upProjectileClock.Tick += new EventHandler(launchProjectilesToNavigate);
upProjectileClock.Start();
}
private void launchProjectilesToNavigate(object sender, EventArgs e)
{
upProjectileElement.Top -= upProjectilePower;
if(upProjectileElement.Top < 10 || upProjectileElement.Top > 830)
{
upProjectileClock.Stop();
upProjectileElement.Dispose();
upProjectileClock.Dispose();
upProjectileElement = null;
upProjectileClock = null;
}
}
}
}