Compare commits

..

No commits in common. "536af82beb7b059dcf96ba12ce55d10066ae3eab" and "06eac128c28d7b0938a01e40704a616aabfa6d37" have entirely different histories.

2 changed files with 3 additions and 31 deletions

View File

@ -19,7 +19,7 @@ namespace SemiColinGames {
// The number of total triangles drawn is one less than the number of edge points. // The number of total triangles drawn is one less than the number of edge points.
readonly int[] indices = new int[(NUM_EDGE_VERTICES - 1) * 3]; readonly int[] indices = new int[(NUM_EDGE_VERTICES - 1) * 3];
Color color = Color.FromNonPremultiplied(new Vector4(1, 0, 0, 0.25f)); Color color = Color.FromNonPremultiplied(new Vector4(1, 0, 0, 0.5f));
public LinesOfSight(GraphicsDevice graphics) { public LinesOfSight(GraphicsDevice graphics) {
for (int i = 0; i < MAX_NPCS; i++) { for (int i = 0; i < MAX_NPCS; i++) {
@ -88,13 +88,11 @@ namespace SemiColinGames {
} }
} }
coneVertices[index][i + 1] = new VertexPositionColor( coneVertices[index][i + 1] = new VertexPositionColor(new Vector3(closestHit, 0), color);
new Vector3((int) closestHit.X, (int) closestHit.Y, 0), color);
} }
} }
public void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) { public void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
// Draw the cones themselves.
for (int i = 0; i < NUM_EDGE_VERTICES - 1; i++) { for (int i = 0; i < NUM_EDGE_VERTICES - 1; i++) {
indices[i * 3] = 0; indices[i * 3] = 0;
indices[i * 3 + 1] = i + 1; indices[i * 3 + 1] = i + 1;
@ -115,31 +113,6 @@ namespace SemiColinGames {
graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indices.Length / 3); graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indices.Length / 3);
} }
} }
// Draw the outlines of the cones.
for (int i = 0; i <= NUM_EDGE_VERTICES; i++) {
indices[i] = i;
}
indices[NUM_EDGE_VERTICES + 1] = 0;
for (int npcIndex = 0; npcIndex < MAX_NPCS; npcIndex++) {
if (!coneEnabled[npcIndex]) {
continue;
}
vertexBuffer.SetData(coneVertices[npcIndex]);
indexBuffer.SetData(indices);
graphics.SetVertexBuffer(vertexBuffer);
graphics.Indices = indexBuffer;
foreach (EffectPass pass in lightingEffect.CurrentTechnique.Passes) {
pass.Apply();
// TODO: just draw a single opaque outline.
for (int i = 0; i < 4; i++) {
graphics.DrawIndexedPrimitives(
PrimitiveType.LineStrip, 0, 0, NUM_EDGE_VERTICES + 1);
}
}
}
} }
} }
} }

View File

@ -26,9 +26,8 @@ namespace SemiColinGames {
public string Update(NPC npc, float modelTime, World world) { public string Update(NPC npc, float modelTime, World world) {
int moveSpeed = 120; int moveSpeed = 120;
int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime); int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime);
int testPoint = desiredX + 12 * npc.Facing;
// TODO: define the box modularly & correctly. // TODO: define the box modularly & correctly.
AABB npcBox = new AABB(new Vector2(testPoint, npc.Position.Y), new Vector2(1, 33)); AABB npcBox = new AABB(new Vector2(desiredX, npc.Position.Y), new Vector2(1, 33));
Debug.AddRect(npcBox, Color.Cyan); Debug.AddRect(npcBox, Color.Cyan);
bool foundBox = false; bool foundBox = false;
foreach (AABB box in world.CollisionTargets) { foreach (AABB box in world.CollisionTargets) {