The XNA challenge

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1565 Views - Last Post: 15 January 2010 - 10:35 AM Rate Topic: -----

#1 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

The XNA challenge

Posted 14 January 2010 - 07:28 PM

There are a lot of C# programmers here. I would like to ask you if you would mind giving the XNA challenge here on DIC a chance. You don't have to be an expert at game programming to do this. You don't even have to make a complete game. Just give it a try. I will definitely try some new things and make a couple entries into the challenge. Let's see what you can do.
Is This A Good Question/Topic? 0
  • +

Replies To: The XNA challenge

#2 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: The XNA challenge

Posted 14 January 2010 - 07:44 PM

I want to give it a shot but I suck at drawing so my game will look like a hairy ASS.
Was This Post Helpful? 0
  • +
  • -

#3 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 14 January 2010 - 07:55 PM

View Postpapuccino1, on 14 Jan, 2010 - 09:44 PM, said:

I want to give it a shot but I suck at drawing so my game will look like a hairy ASS.


Look in the game programming forum. There is a pinned thread with lots of resources for game programmers. There are sprites, 3D models, music, lots of things. You don't have to do something with graphics. You could try playing sound files, though you can't post a screen shot you could post a little code. We just want people to try this, not make a game that requires a multi-million dollar budget.
Was This Post Helpful? 0
  • +
  • -

#4 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: The XNA challenge

Posted 14 January 2010 - 08:17 PM

And here I was planning on making the next World of Warcraft killer. :D
Was This Post Helpful? 0
  • +
  • -

#5 MentalFloss   User is offline

  • .
  • member icon

Reputation: 584
  • View blog
  • Posts: 1,528
  • Joined: 02-September 09

Re: The XNA challenge

Posted 15 January 2010 - 01:01 AM

What's the XNA challenge?
Could you possibly edit your post to include a link of where to review it?

EDIT: I found the spot to view the challenge. It's pretty obvious so I feel dumb for posting the link request.

This post has been edited by MentalFloss: 15 January 2010 - 01:08 AM

Was This Post Helpful? 0
  • +
  • -

#6 KeyboardKowboy   User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 142
  • Joined: 15-December 08

Re: The XNA challenge

Posted 15 January 2010 - 07:23 AM

Quote

There are a lot of C# programmers here. I would like to ask you if you would mind giving the XNA challenge here on DIC a chance.


Hey Sixofeleven... I know that this is an XNA challenge, and a couple months ago I started looking into it. I decided to start with GDI+. I wanted to learn the basics of graphics routines and graphics objects and thought it would be best, at least for me, to start with GDI+. I have been working on a project on my own for a few weeks now, but it's all in GDI+.

I'd love to share what I've been working on, and as I continue to learn more, will be moving to XNA to better leverage the DirectX framework. Should I bother responding to the XNA challenge, even though I've only focused on GDI+?
Was This Post Helpful? 0
  • +
  • -

#7 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 15 January 2010 - 07:52 AM

I hope that you all will give XNA a try. There are a few tutorials that will get you started with the documentation that comes with XNA and there are lots of tutorial sites listed in the challenge topic. I'm sure if you have a basic understanding of C# you will have no problems with XNA. Like I mentioned, we are not looking for the next World of Warcraft here. We just want people to try it and look at something they haven't used before.

There are links to a lot of free Game Resources that you can use to try it out. There are also a lot of starter kits that you can experiment with on XNA Creators Club. There is also a set of video tutorials on XNA Creators Club to help you get started as well.

Quote

I'd love to share what I've been working on, and as I continue to learn more, will be moving to XNA to better leverage the DirectX framework. Should I bother responding to the XNA challenge, even though I've only focused on GDI+?


Yes, I would recommend trying it out, even if you've only worked with GDI+ so far. The framework is very easy to get started with and I'm sure you would be able to come up with something simple to explore XNA. You might find that you like it. :)
Was This Post Helpful? 0
  • +
  • -

#8 KeyboardKowboy   User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 142
  • Joined: 15-December 08

Re: The XNA challenge

Posted 15 January 2010 - 08:02 AM

Quote

Yes, I would recommend trying it out, even if you've only worked with GDI+ so far. The framework is very easy to get started with and I'm sure you would be able to come up with something simple to explore XNA. You might find that you like it.

Oh I'm sure I'll enjoy the XNA framework... it's just that I wanted to get a good feel for the main concepts before I jumped right in. I doubt I'll have the capacity to get anything done in XNA by the end of this week, which is why I asked if my GDI+ project should be posted. At any rate, when I do move to XNA, I'll be sure to post my projects and findings.

I also wanted to mention that I have leveraged the DirectX.AudioVideoPlayback library in my GDI+ project, which I'm using to play .mp3's within the project. Are you familiar with that library? I actually have a question concerning something.

This post has been edited by KeyboardKowboy: 15 January 2010 - 08:04 AM

Was This Post Helpful? 0
  • +
  • -

#9 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 15 January 2010 - 08:17 AM

If you understand C# using XNA will be a breeze. It removes a lot of the complexities out of game programming. I posted a challenge, in the XNA forum, for other XNA programmers to write a game over the weekend and I'm taking on that challenge as well. I'm not asking you to write an entire game here. Just create an XNA project and have fun moving a sprite around the screen with the keyboad. Try having it so that when the sprite reaches the edge of the screen it won't go off or you could have it wrap to the other side of the screen. Just that would be good enough. You could also try moving a sprite around the screen in code. Core has a great tutorial on moving a sprite around the screen with code. You should be able to whip something cool up with that.

http://www.dreaminco...wtopic83921.htm
Was This Post Helpful? 0
  • +
  • -

#10 poncho4all   User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,422
  • Joined: 15-July 09

Re: The XNA challenge

Posted 15 January 2010 - 08:26 AM

I am at the moment still reading some tutorials on XNA, since I have never used it before, I think that by tomorrow ill be uploading a game, thats if there is still some time
Was This Post Helpful? 0
  • +
  • -

#11 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 15 January 2010 - 08:30 AM

View Postponcho4all, on 15 Jan, 2010 - 10:26 AM, said:

I am at the moment still reading some tutorials on XNA, since I have never used it before, I think that by tomorrow ill be uploading a game, thats if there is still some time


That would be awesome! Even though the challenge was supposed to only last a week, we would love to see what people can come up with. The idea is to try it out and be able to say "I learned something new!" and not "Look at this amazing game I made." We just want people to expand their horizons.
Was This Post Helpful? 0
  • +
  • -

#12 KeyboardKowboy   User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 142
  • Joined: 15-December 08

Re: The XNA challenge

Posted 15 January 2010 - 08:37 AM

I have implemented a lot of collision detection algorithms within my GDI+ project already. The graphics objects change direction when they come into contact with other graphics objects, or with the edge of the 'game' field. Would it be difficult or time consuming to 'port' these GDI+ collision algorithms and rendering loops into XNA? Or would it almost be a total rewrite?
Was This Post Helpful? 0
  • +
  • -

#13 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 15 January 2010 - 08:54 AM

Not at all! You can do simple collision detection using rectangles to check for collision between objects. If you need to you can also check for collision between objects with transparency with out much difficulty, there is a series on XNA Creators Club on how to do collision detection.

I just wrote this. It is the code to keep a computer controlled object from going off the edges of the window.

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 SimpleMovement
{
	public class Game1 : Microsoft.Xna.Framework.Game
	{
		GraphicsDeviceManager graphics;
		SpriteBatch spriteBatch;
		Texture2D image;
		Rectangle position;
		Vector2 velocity;

		public Game1()
		{
			graphics = new GraphicsDeviceManager(this);
			Content.RootDirectory = "Content";
		}

		protected override void Initialize()
		{
			base.Initialize();
		}

		protected override void LoadContent()
		{
			// Create a new SpriteBatch, which can be used to draw textures.
			spriteBatch = new SpriteBatch(GraphicsDevice);

			image = Content.Load<Texture2D>("alien1");
			position = new Rectangle(0, 0, image.Width, image.Height);
			velocity = new Vector2(3, 3);
		}

		protected override void UnloadContent()
		{
		}

		protected override void Update(GameTime gameTime)
		{
			// Allows the game to exit
			if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
				this.Exit();
			position.X += (int)velocity.X;
			position.Y += (int)velocity.Y;
			if (position.X < 0)
			{
				position.X = 0;
				velocity.X *= -1;
			}
			if (position.Y < 0)
			{
				position.Y = 0;
				velocity.Y *= -1;
			}
			if (position.X + image.Width > window.ClientBounds.Width)
			{
				position.X = window.ClientBounds.Width - image.Width;
				velocity.X *= -1;
			}
			if (position.Y + image.Height > window.ClientBounds.Height)
			{
				position.Y = window.ClientBounds.Height - image.Height;
				velocity.Y *= -1;
			}
			base.Update(gameTime);
		}

		protected override void Draw(GameTime gameTime)
		{
			GraphicsDevice.Clear(Color.CornflowerBlue);

			spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
			spriteBatch.Draw(image, position, Color.White);
			spriteBatch.End();

			base.Draw(gameTime);
		}
	}
}


Was This Post Helpful? 0
  • +
  • -

#14 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: The XNA challenge

Posted 15 January 2010 - 09:11 AM

Here is a quick sample that I wrote to show how to move a sprite around the screen using the keyboard and not have it go off the edges of the screen. Check it out.

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 SimpleMovement
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Texture2D image;
        Rectangle position;
        Vector2 velocity;
        KeyboardState keyboardState;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            image = Content.Load<Texture2D>("alien1");
            position = new Rectangle(0, 0, image.Width, image.Height);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            keyboardState = Keyboard.GetState();

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            velocity = Vector2.Zero;

            if (keyboardState.IsKeyDown(Keys.Left))
                velocity.X -= 3;
            if (keyboardState.IsKeyDown(Keys.Right))
                velocity.X += 3;
            if (keyboardState.IsKeyDown(Keys.Up))
                velocity.Y -= 3;
            if (keyboardState.IsKeyDown(Keys.Down))
                velocity.Y += 3;

            position.X += (int)velocity.X;
            position.Y += (int)velocity.Y;
            if (position.X < 0)
            {
                position.X = 0;
                velocity.X *= -1;
            }
            if (position.Y < 0)
            {
                position.Y = 0;
                velocity.Y *= -1;
            }
            if (position.X + image.Width > window.ClientBounds.Width)
            {
                position.X = window.ClientBounds.Width - image.Width;
                velocity.X *= -1;
            }
            if (position.Y + image.Height > window.ClientBounds.Height)
            {
                position.Y = window.ClientBounds.Height - image.Height;
                velocity.Y *= -1;
            }
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(image, position, Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}


Was This Post Helpful? 0
  • +
  • -

#15 SwiftStriker00   User is offline

  • No idea why my code works
  • member icon

Reputation: 439
  • View blog
  • Posts: 1,617
  • Joined: 25-December 08

Re: The XNA challenge

Posted 15 January 2010 - 10:16 AM

I'll get on it this weekend my iteration is ending today so I've been busy @ work, too tired to program @ home. but I will get on it asap.

SixOfEleven I might steel that sprite moving code :P
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2