Posts Tagged ‘silverlight’

How to create a silverlight xna game (using silverarcade)

Monday, March 1st, 2010

Also, useful if you want to convert your existing XNA game to a silverlight app.

The silverarcade libraries help you keep most of you existing XNA code intact. I’ll assume that you are using Visual Studio and have all the proper Silverlight SDK stuff installed (if you haven’t, good luck. It took me way too long to figure that out. Maybe I will post details if I ever recover).

I typed up these instructions after my first conversion and have followed them to get few of my own games converted. So hopefully they will help you, too:

  • In Visual Studio, Choose new project > Silverlight > Silverlight Application. Click NO to the prompt about “Host as a new web site”
  • Open MainPage.xaml and add the following the <UserControl> tag as an atribute:
    xmlns:game="clr-namespace:[your project name here]"
  • In MainPage.xaml, Add the following to the <Grid> contents:
        <game:Game2D x:Name="Game1"/>
  • Right click on project name in Solution Explorer > add > class…
    Call the class Game2D.cs
  • In Game2D.cs, replace the “using…” lines with:
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using SilverArcade.SilverSprite;
        using SilverArcade.SilverSprite.Audio;
        using SilverArcade.SilverSprite.Content;
        using SilverArcade.SilverSprite.GamerServices;
        using SilverArcade.SilverSprite.Graphics;
        using SilverArcade.SilverSprite.Input;
        using SilverArcade.SilverSprite.Media;
        using SilverArcade.SilverSprite.Storage;
        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;
  • In Game2D.cs, replace the class declaration with:
        public class Game2D : SilverArcade.SilverSprite.Game
  • In Game2D.cs, Add global variables:
            GraphicsDeviceManager graphics;
            SpriteBatch spriteBatch;
  • In Game2D.cs, add constructor:
            public Game2D()
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                graphics.PreferredBackBufferWidth = 1000;
                graphics.PreferredBackBufferHeight = 600;
  • In Game2D.cs, Add initialize method:
            protected override void Initialize()
                // TODO: Add your initialization logic here
  • In Game2D.cs, Add loadcontent method:
            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
  • In Game2D.cs, Add unloadcontent method:
            protected override void UnloadContent()
                // TODO: Unload any non ContentManager content here
  • In Game2D.cs, Add update method:
            protected override void Update(GameTime gameTime)
                // Allows the game to exit
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                // TODO: Add your update logic here
  • In Game2D.cs, Add draw method:
            protected override void Draw(GameTime gameTime)
  • Add silversprite.dll to project by right clicking on references and add existing item and choose your silversprite.dll (probably put this in debug or release folder or wherever).

Important notes:

When adding content you must click each image file/etc. and go to properties and change Build action to Content.

.wav files are not allowed as silversprite audio, must use mp3 or wav

Don’t need graphics.applyChanges() line when requesting preferred size

Super Transformation wins G4LI Game Design Challenge 2009

Friday, December 18th, 2009

super transformation menu screen shot

Super Transformation won the grand prize ($1000) tonight at the Games for Leaning Institute’s Game Design Challenge 2009. Fellow designers Murphy Stein, Yongming Hong and I are super excited about the honor. It was a fun night seeing the competition and letting people play our game. Almost better than winning the competition was seeing a young boy get so into our game that his father had to pull him away from it. We also got to show our game at the Fall 2009 NYU Computer Science Department Showcase.

Play Super Transformation in your browser right now with Silverlight

Super Transformation (new Silverlight/XNA game)

Sunday, December 13th, 2009

super transformation help screen

Super Transformation is a new in-browser XNA/Silverlight game written by Murphy Stein, Alec Jacobson and Yongming Hong with music by Midicent. The player draws gestures with the mouse to drop transformation portals into a 2D world. The player must use these portals to navigate to each level’s exit door.

We submitted this game to the Games 4 Learning Institute Game Design Challenge 2009.

Super Transformation aims to teach 2D transformations as they appear on the New York State 8th grade Standardized Math Test. Through demonstration and experimentation in the first few levels of Super Transformation, players become aware of the effects of simple horizontal and vertical reflection and clockwise and counter-clockwise rotation. In later levels — as the game play becomes more challenging — the understanding of and familiarity with these transformations builds. Players reinforce their own learning because 2D transformation (aka the learning task) is not only built
into the gameplay, it is the gameplay.

This game uses animations I posted earlier: dude and worm.

Play it now!
Leave suggestions etc. below this post.

New erutnevdAtxeT story arcs added

Wednesday, November 18th, 2009

new erutnevdatxet story arcs

I’ve added some new story arcs to erutnevdAtxeT, the backwards text adventure game I’ve posted recently. Check it out and see if you can get to the beginning of the game. Or try to find all different causality pasts. I’ve added a “refresh” or “reveal the future you just chose feature” (just hold SPACE) to help keep track of your current arc as you play.

Still hoping to convert this to an in browser silverlight app sometime…