|
 |
> Now, to me, that sounds like it's just going to build a bunch of
> boilerplate code for how the designers invesage a game would be
> structured, and if you want your game structured a different way you're
> going to have to waste time deleting the template stuff and rewritting it
> the way you want it.
Sorry but I never heard of anyone making a game that didn't have a "game
loop" and methods for rendering and methods for the game logic. Obviously
you are free to delete those and make your own, or just start from scratch.
They are just providing the most common structure, as most people will want
that anyway.
> Similarly, I obviously haven't written many games (currently at zero and
> counting), but I would have hoped that "initialising the system" would
> already be a fairly painless task. (Isn't this what we have libraries
> for?)
Sure, it's just the odd line here and there for creating a
GraphicsDeviceManager, a content loader object, a sprite/texture manager
object, method calls to clear and redraw the frame, that sort of thing. No
more than a handful of lines of code, but it's easier to have it done for
you in a nice structure than to have to start from scratch each time.
> I'm not quite sure what "build processors set up for graphics files,
> mashes, sound files etc" is supposed to mean.
So that you can go "Add to project..." and include a JPEG, PNG, WAV, MP3,
BMP, X (3D mesh) or whatever and at the build stage it will convert your
file into a format suitable/optimised for the game (eg mipmaps for the
textures). It saves you have to export all your data files in some specific
format just to get them to work with your API, the build processor just does
it seemlessly (obviously it detects if there has been an update or not).
> Well, yeah, there is always that. (Although not understanding C#,
> presumably none of it will make sense anyway...)
FYI here's the raw template code it gives you when you create a new game (it
looks better in the IDE than in plain text): Now maybe it's just me, but I
quite like it doing that automatically for me rather than having to
remember/type that all each time I want to mess about quickly with a little
graphics demo or whatever.
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 WindowsGame3
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before
starting to run.
/// This is where it can query for any required services and load
any non-graphic
/// related content. Calling base.Initialize will enumerate through
any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to
load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to
unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing
values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing
values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}
Post a reply to this message
|
 |