-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWall.cs
More file actions
69 lines (59 loc) · 2.22 KB
/
Wall.cs
File metadata and controls
69 lines (59 loc) · 2.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
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using nkast.Aether.Physics2D.Dynamics;
using nkast.Aether.Physics2D.Dynamics.Contacts;
using Vector2 = nkast.Aether.Physics2D.Common.Vector2;
namespace PeggleAI
{
// Simple walls on the edges of the play area
public class Wall
{
// Textures are not necessary for this, but will remain commented in case I need to see the box for debugging
/*
private static Texture2D wallTexture;
private static Vector2 wallTextureSize;
private static Vector2 wallTextureOrigin;
private static Vector2 wallTextureScale;
*/
private Body wallBody;
private static Vector2 wallBodySize = new Vector2(0.25f, 10f);
private static float WALL_BOUNCINESS = 0.8f;
private static float WALL_FRICTION = 0.0f;
public Wall(float x, float y, World world)
{
Vector2 wallPosition = new Vector2(x, y);
// Create the wall fixture
wallBody = world.CreateBody(wallPosition, 0, BodyType.Static);
var wfixture = wallBody.CreateRectangle(wallBodySize.X, wallBodySize.Y, 1f, Vector2.Zero);
wfixture.Restitution = WALL_BOUNCINESS;
wfixture.Friction = WALL_FRICTION;
}
/*
public static void loadContent(Texture2D wallTexture)
{
Wall.wallTexture = wallTexture;
Wall.wallTextureSize = new Vector2(wallTexture.Width, wallTexture.Height);
Wall.wallTextureOrigin = wallTextureSize / 2f;
Wall.wallTextureScale = new Vector2(
wallBodySize.X / wallTextureSize.X,
wallBodySize.Y / wallTextureSize.Y
);
}
public void draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(
wallTexture,
LevelComponent.convertVec(wallBody.Position),
null,
Color.White,
wallBody.Rotation,
LevelComponent.convertVec(wallTextureOrigin),
LevelComponent.convertVec(wallTextureScale),
SpriteEffects.FlipVertically,
0f
);
}
*/
}
}