important! programmer needed for our vg project :O
15 years ago
we need a programmer for our game, since our old programmer has fallen sick and will be in hospital for a while.
If you know how to code (possibly for xna,but other languages are ok too, i guess) and want to help us please let me or
gazpacho know, we have little time!
If you know how to code (possibly for xna,but other languages are ok too, i guess) and want to help us please let me or
gazpacho know, we have little time!
FA+

You have glasses, use 'em~
It's a Microsoft development environment for games for the PC, XBox 360, windows phone games, etc.
If you've programmed with Visual Studio, DirectX, and C++ you're pretty much set. You can use native DirectX calls with C++ but you can also use C# or even Visual Basic with available wrapper package. Obviously, there is a graphics component to the games so 3D (or maybe 2D) graphics experience would be a big help.
http://www.xnainfo.com/
http://creators.xna.com/en-US/
Adding Code
In this step, you will add the code that will move two graphics around the screen, detect when the graphics collide, and play a sound as a response. Look at the code that has been provided for you by default in the project. The framework of the application has been provided. The next steps will take you through the process of adding some variables, loading your graphic and sound assets in the LoadContent method, drawing your graphics on the screen in the Draw loop, and updating the graphics position and detecting a collision in the Update loop.
To add code:
1. Copy and paste the following variables into your Game1 class, placing them after the existing SpriteBatch spriteBatch variable. There are pairs of variables to track each graphic, its position, its speed, its height, and its width. There is also one variable to hold our sound effect. The two rectangles will be used to let us know when the sprites collide.
Texture2D texture1;
Texture2D texture2;
Vector2 spritePosition1;
Vector2 spritePosition2;
Vector2 spriteSpeed1 = new Vector2(50.0f, 50.0f);
Vector2 spriteSpeed2 = new Vector2(100.0f, 100.0f);
int sprite1Height;
int sprite1Width;
int sprite2Height;
int sprite2Width;
SoundEffect soundEffect;
Rectangle sprite1Rect;
Rectangle sprite2Rect;
2. Replace the LoadContent method with the following lines of code. This code will load the graphic twice. Later on, you can add a second graphic to the project so that you can have two different graphics bouncing about the screen. Each graphic is given an initial position on the screen and the height and width of each are calculated.
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
//Load the GameThumbnail graphic into a texture
texture1 = Content.Load<Texture2D>("GameThumbnail");
texture2 = Content.Load<Texture2D>("GameThumbnail");
//Load the Windows Ding sound into a sound effect
soundEffect = Content.Load<SoundEffect>("Windows Ding");
//Set the position of the first sprite to the top-left corner
spritePosition1.X = 0;
spritePosition1.Y = 0;
//Set the position of the second sprite to the bottom-right corner
spritePosition2.X = graphics.GraphicsDevice.Viewport.Width - texture1.Width;
spritePosition2.Y = graphics.GraphicsDevice.Viewport.Height - texture1.Height;
//Set the width and height for the sprites
sprite1Height = texture1.Bounds.Height;
sprite1Width = texture1.Bounds.Width;
sprite2Height = texture2.Bounds.Height;
sprite2Width = texture2.Bounds.Width;
//Set the initial positions for the collision rectangles
sprite1Rect = new Rectangle((int)spritePosition1.X, (int)spritePosition1.Y, sprite1Height, sprite1Width);
sprite2Rect = new Rectangle((int)spritePosition2.X, (int)spritePosition2.Y, sprite2Height, sprite2Width);
}
3. Replace the Draw method with the following lines of code. This code will draw each graphic on the screen at their current position. They are given a different BlendState so that they appear slightly different since this example uses the same graphic file for each sprite
protected override void Draw(GameTime gameTime)
{
//Clear the background color
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
// Draw the sprites.
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Opaque);
spriteBatch.Draw(texture1, spritePosition1, Color.White);
spriteBatch.Draw(texture2, spritePosition2, Color.Gray);
spriteBatch.End();
base.Draw(gameTime);
}
4. Replace the Update method with the following lines of code. The code also adds the UpdateSprite and CheckForCollision methods. The new code in the Update method will tell each sprite to update their position in the UpdateSprite method. The UpdateSprite method also checks to see if the sprite hits a side, and if it does, changes their direction. Finally, Update calls CheckForCollision which checks to see if the bounds of each graphic intersect with each other. If they do, a sound is played.
protected override void Update(GameTime gameTime)
{
// Tells the game to exit when the back button is pressed
if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
ButtonState.Pressed)
this.Exit();
// Move the sprite around.
UpdateSprite(gameTime, ref spritePosition1, ref spriteSpeed1);
UpdateSprite(gameTime, ref spritePosition2, ref spriteSpeed2);
//Check to see if the sprites collided
CheckForCollision();
base.Update(gameTime);
}
void UpdateSprite(GameTime gameTime, ref Vector2 spritePosition, ref Vector2 spriteSpeed)
{
// Move the sprite by speed, scaled by elapsed time.
spritePosition +=
spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
// Check to see if the sprite has passed the edge of the screen
// If so, change direction and place it at the edge of the screen
if (spritePosition.X > graphics.GraphicsDevice.Viewport.Width)
{
spriteSpeed.X *= -1;
spritePosition.X = graphics.GraphicsDevice.Viewport.Width;
}
else if (spritePosition.X < 0)
{
spriteSpeed.X *= -1;
spritePosition.X = 0;
}
if (spritePosition.Y > graphics.GraphicsDevice.Viewport.Height)
{
spriteSpeed.Y *= -1;
spritePosition.Y = graphics.GraphicsDevice.Viewport.Height;
}
else if (spritePosition.Y < 0)
{
spriteSpeed.Y *= -1;
spritePosition.Y = 0;
}
}
void CheckForCollision()
{
//Set the collision rects to the current position of the sprites
//The width and height data was set in LoadContent()
sprite1Rect.X = (int)spritePosition1.X;
sprite1Rect.Y = (int)spritePosition1.Y;
sprite2Rect.X = (int)spritePosition2.X;
sprite2Rect.Y = (int)spritePosition2.Y;
//If the sprites rectangles intersect, play the soundEffect
if(sprite1Rect.Intersects(sprite2Rect))
{
soundEffect.Play();
}
}
The application is now complete. This step will let you build, run, and debug the application.
To build and debug the application:
1. Build the solution by selecting the Debug | Build Solution menu command. The project should build without any errors in the Errors List window. If there are errors, review the steps above, correct any errors, and then build the solution again.
2. Run the application by selecting the Debug | Start Debugging menu command. This will open the emulator window and launch the application. Two graphics will bounce around the screen and play a sound when they are intersecting.