Prof. Kostas Anagnostou from Ionian University has created an excellent 6 part tutorial covering the creation of the classic Arkanoid game for the PC using XNA framework. Here are the links for the tutorial Permanent link to Δημιουργώντας το Arkanoid μέρος 1ο
Permanent link to Arkanoid μέρος 2ο
Permanent link to Arkanoid- Game State Management
Permanent link to Arkanoid- Game State Management μέρος 2ο
Permanent link to Arkanoid- Σχεδιασμός πίστας
Permanent link to Arkanoid- Game over!
You can also find the complete tutorial packaged in a pdf document in StudentGuru e-learning page. All the tutorials are written in Greek but you can certainly use a translation platform such as Microsoft Translator to read them. Reminder: You can download tools for creating Windows Phone applications (Silverlight) and games (XNA) for free by visiting http://developer.windowsphone.com
Given his kind permission, I decided to port the game to Windows Phone 7. I have to admit that porting was rather easy, given the fact that XNA framework has minor differences comparing PC/XBOX engine to Windows Phone. Initially, something that one has to pay attention to is the screen sizes. In Windows, the screen size (resolution) is the one the user has chosen. In Windows Phone 7, it’s 800 x 480. You can see it in the code Visual Studio creates for you // Pre-autoscale settings.
graphics.PreferredBackBufferWidth = 480;
graphics.PreferredBackBufferHeight = 800;The other thing I had to change in order for this to work in Windows Phone 7 was the player input. In the PC, you have the keyboard. In Windows Phone 7, you have a touch screen. One can easily “query” the touch screen for input using this simple line of code TouchCollection tc = TouchPanel.GetState();In this way, you get a collection of TouchLocation objects, with each one representing the point where the user touched the screen. So, we can query this collection and get information about each and every one point that the user touched the screen (hint: Windows Phone 7 devices will have capacitive 4-point multitouch screens). We are using the following code inside the UpdateWorld method (which gets called by the Update XNA method) to determine the paddle’s movement and placementpaddleSpeed = 10;
TouchCollection tc = TouchPanel.GetState();
if (tc.Count != 0)
{
TouchLocation tl = tc[0]; int distance = (int)tl.Position.X - (int)(paddle.X + paddle.Width / 2); paddleSpeed *= Math.Sign(distance); if (Math.Sign(distance) == previousPaddleDirectionSign)
{
paddleSpeed += Math.Sign(distance) * 5;
}
previousPaddleDirectionSign = (short)Math.Sign(distance);
if (Math.Abs(distance) >= 3)
paddle.X += paddleSpeed;
}OK, let’s decrypt it a bit. For starters, we initialize the variable paddleSpeed to 10. 10 pixels will be the minimum movement of the paddle, either left or right. Then, we get the collection of touch points, getting a reference to the first touch point (we assume that the user won’t touch the screen in more than one point. If he does, we ignore them). We declare a distance variable, which value is set to be equal to the difference between touch point’s X and the center X of the paddle (paddle.X + paddle.Width / 2). Consequently, if the user touches righter than the paddle’s center, distance will be a positive integer. Otherwise, it will be negative. Read more: Scenes From A Developer Memory
Permanent link to Arkanoid μέρος 2ο
Permanent link to Arkanoid- Game State Management
Permanent link to Arkanoid- Game State Management μέρος 2ο
Permanent link to Arkanoid- Σχεδιασμός πίστας
Permanent link to Arkanoid- Game over!
You can also find the complete tutorial packaged in a pdf document in StudentGuru e-learning page. All the tutorials are written in Greek but you can certainly use a translation platform such as Microsoft Translator to read them. Reminder: You can download tools for creating Windows Phone applications (Silverlight) and games (XNA) for free by visiting http://developer.windowsphone.com
Given his kind permission, I decided to port the game to Windows Phone 7. I have to admit that porting was rather easy, given the fact that XNA framework has minor differences comparing PC/XBOX engine to Windows Phone. Initially, something that one has to pay attention to is the screen sizes. In Windows, the screen size (resolution) is the one the user has chosen. In Windows Phone 7, it’s 800 x 480. You can see it in the code Visual Studio creates for you // Pre-autoscale settings.
graphics.PreferredBackBufferWidth = 480;
graphics.PreferredBackBufferHeight = 800;The other thing I had to change in order for this to work in Windows Phone 7 was the player input. In the PC, you have the keyboard. In Windows Phone 7, you have a touch screen. One can easily “query” the touch screen for input using this simple line of code TouchCollection tc = TouchPanel.GetState();In this way, you get a collection of TouchLocation objects, with each one representing the point where the user touched the screen. So, we can query this collection and get information about each and every one point that the user touched the screen (hint: Windows Phone 7 devices will have capacitive 4-point multitouch screens). We are using the following code inside the UpdateWorld method (which gets called by the Update XNA method) to determine the paddle’s movement and placementpaddleSpeed = 10;
TouchCollection tc = TouchPanel.GetState();
if (tc.Count != 0)
{
TouchLocation tl = tc[0]; int distance = (int)tl.Position.X - (int)(paddle.X + paddle.Width / 2); paddleSpeed *= Math.Sign(distance); if (Math.Sign(distance) == previousPaddleDirectionSign)
{
paddleSpeed += Math.Sign(distance) * 5;
}
previousPaddleDirectionSign = (short)Math.Sign(distance);
if (Math.Abs(distance) >= 3)
paddle.X += paddleSpeed;
}OK, let’s decrypt it a bit. For starters, we initialize the variable paddleSpeed to 10. 10 pixels will be the minimum movement of the paddle, either left or right. Then, we get the collection of touch points, getting a reference to the first touch point (we assume that the user won’t touch the screen in more than one point. If he does, we ignore them). We declare a distance variable, which value is set to be equal to the difference between touch point’s X and the center X of the paddle (paddle.X + paddle.Width / 2). Consequently, if the user touches righter than the paddle’s center, distance will be a positive integer. Otherwise, it will be negative. Read more: Scenes From A Developer Memory