]> Dogcows Code - chaz/carfire/blob - CarFire/CarFire/CarFire/Display.cs
Partially working display
[chaz/carfire] / CarFire / CarFire / CarFire / Display.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
9
10 namespace CarFire
11 {
12 public class Display
13 {
14 List<Projectile> mProjectiles = new List<Projectile>();
15 List<Character> mCharacters = new List<Character>();
16 Map mMap;
17 public Display()
18 {
19 /*
20 mMap = aMap;
21 mCharacters = characters;
22 */
23 }
24
25 /// <summary>
26 /// LoadContent will be called once per game and is the place to load
27 /// all of your content.
28 /// </summary>
29 public void LoadContent(ContentManager contentManager)
30 {
31 Texture2D everything = contentManager.Load<Texture2D>("cs");
32 mMap = contentManager.Load<Map>("Maps/stable");
33 Map.DefaultTile = contentManager.Load<Texture2D>("default");
34 mMap.CenterCell = new Vector2(5,5);
35 //List<object> entities = mMap.GetAllEntities();
36 mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300));
37 // TODO: use this.Content to load your game content here
38 }
39
40 /// <summary>
41 /// UnloadContent will be called once per game and is the place to unload
42 /// all content.
43 /// </summary>
44 public void UnloadContent()
45 {
46 // TODO: Unload any non ContentManager content here
47 }
48
49 /// <summary>
50 /// Allows the game to run logic such as updating the world,
51 /// checking for collisions, gathering input, and playing audio.
52 /// </summary>
53 /// <param name="gameTime">Provides a snapshot of timing values.</param>
54 public void Update(TimeSpan timespan)
55 {
56
57 foreach (Projectile projectile in mProjectiles)
58 {
59 projectile.Update(timespan);
60 }
61 //Check for collisons
62 foreach (Character character in mCharacters)
63 {
64 foreach (Projectile projectile in mProjectiles)
65 {
66 if (projectile.GridX == character.GridX && projectile.GridY == character.GridY)
67 {
68 //Debug - not sure if you can remove while doing for each
69 //Alternative - while loop, and decrement projectile counter if projectile is removed.
70 mProjectiles.Remove(projectile);
71 character.Health -= projectile.Damage;
72 }
73 }
74 }
75 }
76
77 /// <summary>
78 /// This is called when the game should draw itself.
79 /// </summary>
80 /// <param name="gameTime">Provides a snapshot of timing values.</param>
81 public void Draw(SpriteBatch spriteBatch)
82 {
83 mMap.Draw(spriteBatch);
84 foreach(Projectile projectile in mProjectiles)
85 {
86 projectile.Draw(spriteBatch);
87
88 }
89 foreach(Character character in mCharacters)
90 {
91 character.Draw(spriteBatch);
92 }
93
94
95 }
96 }
97 }
98
This page took 0.034658 seconds and 4 git commands to generate.