-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrap.cs
52 lines (46 loc) · 1.55 KB
/
Trap.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using System.Drawing;
namespace BlappyFirb
{
class Trap
{
public int XPosition;
public int UpperPosition { get; private set; }
public int DownPosition { get; private set; }
public Image UpperTrap { get; private set; }
public Image DownTrap { get; private set; }
Random rand;
public Trap(int difficulty)
{
rand = new Random();
UpperTrap = new Image();
DownTrap = new Image();
var gap = difficulty == 0 ? 150 : difficulty == 1 ? 100 : difficulty == 2 ? 80 : 150;
XPosition = 900;
UpperPosition = rand.Next(-200, -20);
UpperTrap.Source = new BitmapImage(new Uri("C:/assets/pipe.png"));
UpperTrap.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);
UpperTrap.RenderTransform = new RotateTransform(180);
UpperTrap.Width = 80;
UpperTrap.Height = 350;
UpperTrap.Stretch = Stretch.Fill;
DownPosition = UpperPosition + 300 + gap;
DownTrap.Source = new BitmapImage(new Uri("C:/assets/pipe.png"));
DownTrap.Width = 80;
DownTrap.Height = 350;
UpperTrap.Stretch = Stretch.Fill;
}
public void Move()
{
XPosition -= 5;
}
}
}