XNA/C#

Epic Space Adventure | Machanics Down

So I have now made about 10 or so Classes to run differing aspects of the game. These range from asteroid movement and collision. Main ship movement and collision and enemy ship movement and collision. I have also made it so that the enemy ships shoot at the player and fly differing patterns. I have also added a title screen and a ugly “HUD” in the game as to show you your current score and lives left.

Basically the game is in working condition, but doesn’t get progressively harder and could last forever, theoretically. I must now come up with some sort of timer that will make the game get harder as your progress. Possibly add some sort of boss fight.

These are some of my other Ideas:

  • Other enemy types with differing styles of “bullets”
  • More asteroids as the game moves along
  • Differing paths that the enemies fly
  • Power ups for the ship

Anyways below is a screen capture of  that I have so far. I might in the near future add the source code and a down-loadable packet for those that want to “try” this mini game.

Image

 

UPDATE!

 Source Files for Epic Space Adventure

Advertisements

Epic Space Adventure | StarScape

So since I just started this blog, I thought it would be nice to post some code and maybe talk a little about the game I am working on currently. The game I am currently working on is sort of a learning/fun project. The idea is a standard “scrolling” outer space shooter. I have been working on this in C#, and using the XNA framework. As I am quite new to C# it is a change and the learning curve, at least for me is slower. First I developed the background starscape. I didn’t want it to look “real” so I first drew out some stars then threw them in photoshop. This gave me a cartoony/poopy look that I really didn’t like that much. So I decided to just make a randomizer of pixels that I would choose from. Since in C# and in the XNA framework white can be changed in colors  I decided that I would also randomize what colors would be picked with the help of online and some books I had been reading I came up with this code for the background randomizer.

class StarField
{

private List<Sprite> stars = new List<Sprite>();
private int screenWidth = 800;
private int screenHeight = 600;
private Random rand = new Random();
private Color[] colors = { Color.White, Color.Yellow,Color.Wheat, Color.WhiteSmoke,Color.SlateGray };

public StarField(int screenWidth, int screenHeight, int starCount,Vector2 starVelocity, Texture2D texture, Rectangle frameRectangle)
{
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;

for (int x = 0; x < starCount; x++)
{
//My Star Generator
stars.Add(new Sprite(new Vector2(rand.Next(0,screenWidth),rand.Next(0,screenHeight)),

texture,frameRectangle,starVelocity));
//My Star Color randomizer
Color starColor = colors[rand.Next(0, colors.Count())];
starColor *= (float)(rand.Next(30, 80)/ 100f);
stars[stars.Count() -1].TintColor= starColor;
}
}

public void Update(GameTime gameTime)
{

foreach (Sprite star in stars)
{
star.Update(gameTime);
if (star.Location.Y > screenHeight)
{
star.Location = new Vector2(rand.Next(0, screenWidth), 0);
}
}
}

public void Draw(SpriteBatch spriteBatch)
{
foreach (Sprite star in stars)
{
star.Draw(spriteBatch);
}
}

}

Sorry for the terrible formatting, I am working on getting my own domain and such so wordpress doesn’t allow me to use coding pluggins as of right now. So this will have to do. It’s readable.

Anyways, this is the coding of the whole class. Small but effective. Anyone have any improvement they would like to add?