Casual Game Design website
Today I came across an interesting website,
Casual Game Design. I reading the article about
coming up with game ideas right now at it's pretty good. Therefore I just thought I would post an little blog entry about this. I have also added the rss feed of the website to my blogroll.
Movement/control with Farseer Physics Engine 1.0.0.5 (Silverlight 2 beta 1)
In this sample you learn one way to capture keyboard inputs, react on them by applying force to an object and that way control the object in the game. Again this sample is a simplified version of the code from the original Farseer Physics Engine demo code.
You can download the source here.
And you can see the it running in your browser here.
Feel free to leave a comment if you got any questions.
Enjoy :)
PopTheBubble Hi-score code
NOTE: I'm so sorry I don't have a code parser on my blog at the moment. This means that the code doesn't look very good. I'm working on an codeparser, but just can't find a working one at the moment. So I desided to do the post, and then clean up the source code in it later.
In a comment to my blog post about PopTheBubble on silverlight.ne, Jason Schluter asked me for the code to the hi-score in the game. So here goes.
The hi-score actually works pretty simple. The game has a Service reference to a WebService, which lives on the web server ofcause (remember the game lives in the users browser). When the Hi-score UserControl is loaded in the Silverlight application (the game), calls a method called "GetScore" to retrieve the top-50 scores/players. When you type in your name and click submit, another method is called on the WebService to save your score. The score is persisted in an xml file on the server.
HiScore.xaml:
public partial class HiScore : UserControl
{
private int score;
private ServiceReference1.BubbleHiScoreSoapClient scoreClient;
public HiScore()
{
InitializeComponent();
score = 0;
//Hook up with WebService
scoreClient = new PopTheBubble.ServiceReference1.BubbleHiScoreSoapClient();
scoreClient.GetScoresCompleted += new EventHandler<PopTheBubble.ServiceReference1.GetScoresCompletedEventArgs>(scoreClient_GetScoresCompleted);
scoreClient.SaveScoreCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(scoreClient_SaveScoreCompleted);
}
public void UpdateScore()
{
scoreClient.GetScoresAsync();
}
public int Score
{
get { return this.score; }
set
{
hiScoreTextBlock.Text = "Your score: " + value;
this.score = value;
}
}
protected void scoreClient_SaveScoreCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
UpdateScore();
}
protected void scoreClient_GetScoresCompleted(object sender, PopTheBubble.ServiceReference1.GetScoresCompletedEventArgs e)
{
hiscoreDataGrid.ItemsSource = e.Result;
}
private void submitScoreButton_Click(object sender, RoutedEventArgs e)
{
if (!playerNameTextbox.Text.ToLower().Equals("type your name...") && playerNameTextbox.Text != "")
scoreClient.SaveScoreAsync(playerNameTextbox.Text, score);
}
}
HiScore.asmx
[WebMethod]
public void SaveScore(string name, int score)
{
//Saves the score into a xml file. Original code has been removed.
}
[WebMethod]
public List<HiScoreEntry> GetScores()
{
//Get the top-50 hiscores from the xml file. Original code has been removed.
}
As you can see it's pretty simple, but not very secure. You don't need to be a state-of-the-art hacker to figure out how to cheat here, but this was not my focus with this game. The code in the WebService is just normal C# code reading/writing from an xml file. Please post a comment if you have any questions.
Getting started with Farseer Physics Engine 1.0.0.5 (Silverlight 2 beta 1)
UPDATE: Please note that there is a new release of this for Silverlight Beta 2: Check it out here.
When you are doing game development you sometimes wants to spice up the game with some physics. To do this from scratch, you need to be pretty good at math and have a lot of spare time. Lucky for us Silverlight Game Developers, Jeff Weber from Farseer Games, created a little engine to help us out. It's called the Farseer Physics Engine.
Currently the latest release is 1.0.0.5 which supports Silverlight 2 beta 1. This is the release used in this sample.
Getting started
I am new to the Farseer engine myself, and have been looking on the internet for a, "Getting started with Farseer" tutorial, with out any luck. Therefore I desided to create my own. The release of the engine comes with some pretty nice demos, that shows you how to use the engine. The only problem is, that the code is pretty complex at first sight, which could make some people give up.
Therefore I have created this tiny project to show you how to make the engine run in the simplest form possible. The code should be pretty self-explaining. If you want to know alittle more about why the diffent things are done, you can read on Andy Beaulieu blog, which has a starting tutorial too. The only problem is thats it's for Silverlight 1.1 Alpha and therefore alittle outdated, but the basic things are the same as far as I can see.
(As I said, I'm new to the engine also, so this can maybe be done even more simpler. If you have some changes, please let me know. You can use the "Contact" here on the page and send me and email through that. Thanks in advance.)
You can download the source here.
And you can see the it running in your browser here.
I hope you have a better idea of how to get the engine to work after looking through the source code.
Happy coding!
Please note: The Silverlight 2 beta 1 currectly have a "region bug" when you position the elements. If you are running with US region settings, there should be no problem, but if you, like me, run with Danish Region settings, this sample will crash at first sight. So to be able to see/run this, you need to set your region settings to English (United States). This works for me.
PopTheBubble on silverlight.net
Some days ago a submitted my "PopTheBubble" game to Silverlight.net. I thought it would be a great source of inspiration, as this game is the outcome of a hands-on-lab tutorial from silverlight.net.
At the moment you can see it in the Silverlight.net Gallery
This has been my first "learning" project, both for learning Silverlight 2 but also learning alittle about game development in Silverlight 2. Learning/getting started projects like this normally doesn't have the most sweet code and structure, which is why I haven't published the source code for it.
My Projects page has been updated
A while ago I was talking with another game developer (Cameron) and was showing him some of the prototype games I have made over the last year and a half. As I was browsing through my "Projects" folder on my desktop, I discovered some old games that I almost forgot about.
Today I desided to put them on my site here. So please go to the "My Projects" site and start downloading.