-
Notifications
You must be signed in to change notification settings - Fork 0
/
Platform.cs
80 lines (62 loc) · 2.49 KB
/
Platform.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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace PlatformerProject
{
class Platform : Collidable
{
/// <summary>
/// This class is going to be used to hold all of the current platforms on the screen.
/// It will have placement, size of the platforms, and will also store the image for it's respective
/// platform
///</summary>
// This will be the image that we need to draw
Texture2D picture;
// This will be the position where it will be drawn
public Vector2 position;
// The width and the height, in order to calculate hitbox
public int width, height;
// The rectancle surrounding the object, will be used for collision
public Rectangle hitbox;
// The batch, will be used to draw!
SpriteBatch batch;
//The scale we wish for the platform to be drawn
float scale;
public Platform(Texture2D picture, Vector2 position, SpriteBatch batch, float scale)
{
this.picture = picture; // The picture to be drawn
this.position = position; // The position to where it will be drawn
this.width = (int)(picture.Width * scale); // Width of the picture
this.height = (int)(picture.Height * scale); //Height of the sprite
hitbox = new Rectangle((int)position.X, (int)position.Y, (int)this.width, (int)this.height); //This hitbox is the rectangle that is surrounding the sprite
this.batch = batch; // Getting the batch so that we can draw in this funtion
this.scale = scale; // In case we need to scale (in example, for the floor).
}
public void drawNoCol()
{
hitbox = new Rectangle((int)position.X, (int)position.Y, (int)this.width, (int)this.height);
batch.Draw(picture, position, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
}
public Vector2 getPosition()
{
return position;
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public Rectangle getHitbox()
{
return hitbox;
}
public void setWidth(int width)
{
this.width = width;
//picture.Bounds.Width = width;
}
}
}