I'm stuck i have no idea how to do it help plz!

not sure what code i need to upload so i put it all in.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace ParachuteGame
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
TruckClass TruckObject;
Vector2 planeVelocity = new Vector2(-8f, 0f);
Texture2D planeTexture;
Vector2 planePosition = new Vector2(300f, 1f);
ParachuteClass spawnObject;
BirdClass[] birdObject;
int birdCount = 4;
Random rand = new Random();
private SpriteEffects planeflip;
private SpriteFont font;
private int score = 0;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreferredBackBufferHeight = 700;
graphics.PreferredBackBufferWidth = 1000;
}
protected override void Initialize()
{
TruckObject = new TruckClass(TruckClass.Texture, new Vector2(300f, 600f), new Vector2(-10f, 0f), Color.White);
birdObject = new BirdClass[birdCount];
for (int index = 0; index < birdCount; index++)
{
byte r = (byte)rand.Next(64, 256); // red
byte g = (byte)rand.Next(64, 256); // green
byte b = (byte)rand.Next(64, 256); // blue
Color tempColor = new Color(r, g, B)/>;
birdObject[index] = new BirdClass(BirdClass.Texture, new Vector2(rand.Next(300, 300), rand.Next(300, 300)), new Vector2(rand.Next(-5, -3), rand.Next(-5,-3)), tempColor);
}
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
TruckClass.Texture = Content.Load<Texture2D>("Sprites\\Truck");
TruckClass.GraphicsViewport = graphics.GraphicsDevice.Viewport;
ParachuteClass.Texture = Content.Load<Texture2D>("Sprites\\Parachute1");
ParachuteClass.GraphicsViewport = graphics.GraphicsDevice.Viewport;
planeTexture = Content.Load<Texture2D>("Sprites\\Plane");
BirdClass.Texture = Content.Load<Texture2D>("Sprites\\Bird");
BirdClass.GraphicsViewport = graphics.GraphicsDevice.Viewport;
font = Content.Load<SpriteFont>("Score");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
TruckObject.Update();
foreach (BirdClass Bird in birdObject)
{
Bird.Update();
if (ParachuteClass.spawn == true)
{
Rectangle parachuteRectangle = new Rectangle((int)spawnObject.Position.X, (int)spawnObject.Position.Y, ParachuteClass.Texture.Width, ParachuteClass.Texture.Height);
Rectangle truckRectangle = new Rectangle((int)TruckObject.Position.X, (int)TruckObject.Position.Y, TruckClass.Texture.Width, TruckClass.Texture.Height);
Rectangle birdRectangle = new Rectangle((int)Bird.Position.X, (int)Bird.Position.Y, BirdClass.Texture.Width, BirdClass.Texture.Height);
if (parachuteRectangle.Intersects(truckRectangle))
{
score += 10;
ParachuteClass.spawn = false;
}
if (parachuteRectangle.Intersects(birdRectangle))
{
score -= 5;
ParachuteClass.spawn = false;
}
}
}
KeyboardState keyboardState = Keyboard.GetState();
if (ParachuteClass.spawn == false)
{
if (keyboardState.IsKeyDown(Keys.Space))
{
Vector2 spawnPosition = planePosition;
spawnObject = new ParachuteClass(ParachuteClass.Texture, spawnPosition);
ParachuteClass.spawn = true;
}
}
if (ParachuteClass.spawn)
{
spawnObject.MovingSpawn();
}
planePosition = planePosition + planeVelocity;
if (planePosition.X < 0)
{
planeVelocity.X = -planeVelocity.X;
planePosition.X = planePosition.X + planeVelocity.X;
this.planeflip = SpriteEffects.FlipHorizontally;
}
else if (planePosition.X > graphics.GraphicsDevice.Viewport.Width - planeTexture.Width)
{
planeVelocity.X = -planeVelocity.X;
planePosition.X = planePosition.X + planeVelocity.X;
this.planeflip = SpriteEffects.None;
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
spriteBatch.Begin();
TruckObject.Draw(spriteBatch);
spriteBatch.Draw(planeTexture, planePosition, null, Color.White, 0.0f, new Vector2(0, 0), 1.0f, this.planeflip, 0.0f);
if (ParachuteClass.spawn)
{
spawnObject.Draw(spriteBatch);
}
foreach (BirdClass Bird in birdObject)
{
Bird.Draw(spriteBatch);
}
spriteBatch.DrawString(font, "Score: " + score, new Vector2(1, 1), Color.Black);
spriteBatch.End();
base.Draw(gameTime);
}
}
}

New Topic/Question
Reply


MultiQuote




|