Develop games using silverlight


















NET developer to get their teeth into as it is. The introduction of Silverlight 2, though, changes this position considerably. Silverlight 2 brings RIA development to the. NET developer, enabling you to leverage your existing skills and experience. All in all, this means that RIA development is now something that you can freely participate in without having to go through a lengthy re-skilling process.

One of the more interesting sub-genres of RIA is the Web-based game, and Silverlight 2 is a very capable platform for writing these games. So in this article I want to share with you a dozen or so tips that will help you to get started writing Web-based games. Web-based games deploy in the browser, requiring little or no client installation; they often have rudimentary graphics, tinny soundtracks and simplistic game play — expect no Far Cry or World of WarCraft here — but they are nevertheless often highly addictive.

Their main appeal is the sense of immediacy about them that enables you to get into the game and start enjoying yourself straight away, without waiting for long installations to complete, which means that you can find yourself wasting an hour or two without realising it.

When all is said and done, though, the key to a successful Web-based game is that it installs quickly and is fun to play. Save my name, email, and website in this browser for the next time I comment.

Please click on the following link to open the newsletter signup page: Ghacks Newsletter Sign up. Ghacks is a technology news blog that was founded in by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers. Search for:. Martin Brinkmann. Microsoft Silverlight supports ends October 12, here is what you need to know. Related content Skype teases "next version", promises all browser support, forgets Firefox icon.

Never enter Microsoft account passwords again with the new passwordless account feature. Microsoft Start: news and interests expanded to the Web and Apps.

Microsoft Office for Windows and Mac will be released later this year. Microsoft increases OneDrive's maximum file size to Gigabytes. Microsoft Windows Security Updates January overview. Previous Post: « Never enter Microsoft account passwords again with the new passwordless account feature Next Post: « Skype teases "next version", promises all browser support, forgets Firefox icon. Comments Dumbledalf said on September 16, at am. Silverlight never stood a chance against Flash.

Anonymous said on September 16, at am. The demo can also be found on a separate page. In previous years the conference has included presentations in the following tracks. I am not sure if all of these tracks will be presented in July, but I know for certain that they have decided to expand its focus and include a Casual Gaming track highlighting some of the cool new games done in Silverlight.

Watching Microsoft Popfly evolve has been incredibly exciting for me. With its Silverlight-based drag-and-drop capabilities, Popfly has been a fun and easy way to build and share mashups, gadgets, Web pages, and applications. Popfly has won the hearts and minds of many, many people as evidenced by a lot of favorable press coverage and awards.

Today, I am excited to announce the alpha of the Popfly Game Creator. The Silverlight-based Game Creator is a very rich and yet very simple way to create all sorts of casual games without having to write a single line of code.

Whether it is a space shooting game, a racing game or a maze, the extremely friendly and interactive UI guides you, the user, to express your creativity. You can start with a known collection of game templates that are already built in and customize and share them, or start with a fresh idea and a clean canvas and build your own game. Read more Microsoft's Popfly team is rushing to finish a major addition to its mash up maker so it can do demonstrations at the Maker Faire in San Mateo, Calif.

I got a quick demo earlier this week and I hope the product is ready in time, because it's a great new service, and just perfect for the audience the Maker Faire draws. The new feature: an environment for building casual games think Solitaire, not Half-Life , called Game Creator There are several templates with generic titles to start from personal favorite: "Badly built wall" or users can create their own games from scratch using a scripting system and a built-in, and entertaining, library of graphics and sounds.

Popfly Game Creator Alpha is available today, and it's a brand new tool for building 2D games in Silverlight that requires zero programming to build games. How easy is it to build games?

Well in this interview Adam Nathan builds three games from scratch including - A Space invaders clone - - A 2D car game that plays like "snake" - - A 2D side scroller with a Ninja fighting rocket chickens This helps avoid the frustration that can occur if the main input to the game is the keyboard, and some other element in the browser has retained focus.

At this point, the Click handler for the button will also typically engage your main game engine, whatever that might be. Writing a game loop The vast majority of games are based around a game loop. As its name suggests, this is a loop that runs for the duration of the game or at least a level within the game , performing tasks such as responding to player input; moving sprites around the game; detecting collisions; and updating the score.

Figure 3 highlights some of these tasks. Silverlight has a very similar threading model to Windows Forms and WPF, which ensures that keyboard and mouse events, among others, are handled by a single UI thread. Additionally, any update to a UI element technically anything deriving from DispatcherObject must also occur on that same UI thread. It also precludes you from running a game loop on a background thread, as this would require cross-thread marshalling to update the visual elements, which would in turn be incredibly slow.

So the next tip in writing games in Silverlight is on writing game loops that are driven by timers. In other words, you move all the pieces a little bit, check for collisions and handle input whenever the timer ticks.

The important thing here is to choose the correct type of timer, which in the case of Silverlight is the DispatcherTimer. DispatcherTimer is a thread-affinity aware timer, which raises its Tick event based on an interval that you specify , on the UI thread. FromMilliseconds 10 ; loopTimer. This makes it very simple to manage the creation and removal of items, such as the explosions and incoming missiles, in the code as it has direct access to the root Canvas element which is the placeholder for everything that is displayed on screen.

You might choose to use greater levels of separation, especially if the game logic becomes complex. In SilverCommand, a GameLevel object is created and shown by the main game engine for each level, so the Loaded event is raised once per level. This pattern of creating a new object for each level makes state management much simpler within the game, even if the game is essentially repetitive in structure, as is the case with SilverCommand or Space Invaders, Pac Man and a host of other games.

Notice that RunGameLoop merely instantiates and starts the DispatcherTimer: there is no more to it than that. The end-of-level situation arises sooner or later depending on how wisely the player launches their defensive missiles wisely. In the case of SilverCommand, this is done by pressing the buttons Z, X and C for the left, centre and right missile bases respectively. Handling the keyboard Choosing how to handle the keyboard is a critical part of any Silverlight game.

Consider the two games in Figure 4. Figure 4: How you handle the keyboard is crucial In the Silverlight Breakout game, the bat should move and continue to move while the user holds down a key perhaps Z for left and X for right.

Instead, the user should press and release the relevant key to fire a missile. The Windows SDK has APIs that let you query the precise state of the keyboard at any time, as well as providing various keyboard events. Unfortunately, the only option in Silverlight is to handle the KeyDown and KeyUp events that are raised whenever the user presses and holds or releases a key. Understanding the KeyDown and KeyUp events The KeyDown event is raised whenever the user presses a key, which is what you would expect.

If the user continues to hold down that key then KeyDown will continue to be raised on a regular basis. They KeyUp event is raised, of course, when they release the key. There is one thing to be aware of, though. If the user presses a second key whilst holding down the first key, then all KeyDown events for the first key stop. This behaviour is shown in Figure 5. Figure 5: Pressing and holding multiple keys This makes it quite difficult to introduce diagonal movement into your game, as this is often achieved by holding and pressing two keys at once.

Tip 6: Basing an action on a KeyUp event In the case of SilverCommand, I wanted the user to press and release the key to launch a missile. This is, of course, straightforward to accomplish by ignoring the KeyDown events completely.



0コメント

  • 1000 / 1000