Ameba Ownd

アプリで簡単、無料ホームページ作成

Microsoft xna dersleri

2022.01.19 02:45




















Joel Spolsky even went so far as to say that using managed code was the only advance in programming methodologies that led to measureably increased productivity. Microsoft's stalwart Visual Basic, although often derided by "real programmers," used managed code, and it was famous for its ability to enable coders to create programs quickly.


However, interfacing between Visual Basic and DirectX was rather nasty and required a bunch of hacks that didn't always work as expected, nor did they allow the full functionality of DirectX to be accessed. There were other managed development solutions available, such as Java, but performance concerns and a lack of integration with game libraries such as DirectX meant that Java was never a significant force in game development.


This is not to say, however, that nobody is developing games in Java—there is a healthy Java game development community, and the cross-platform nature of the Java library has meant that the language has found considerable success on diverse hardware such as cell phones.


In the Windows and console world, however, there was no easy way to connect managed code and existing game development technologies, until a small team at Microsoft came up with the Managed DirectX platform, which was a set of libraries that glued together the.


NET development framework and DirectX itself. A couple of years back, I picked up a copy of Managed DirectX Graphics and Game Programming by Tom Miller, which contained sample code and tutorials that allowed a complete game programming novice to enter the world of 3D meshes, texture maps, sound and joysticks, and even special effects such as specular highlights and programmable shaders.


NET as well. Microsoft has taken this effort and expanded it tenfold to create the XNA development platform. Not only are all the Managed DirectX goodies present, but the entire build process has been optimized to make game development easier.


He says that he gets very mixed reaction from industry professionals upon hearing about XNA developments at Torpex games. The primary argument against XNA is usually around performance, but this is what most professional game developers also said about DirectX in the s. Back then, all PC games were running on DOS because it allowed game developers to tap directly into the hardware without any high-level operating system overhead. Virtually all PC games are running on Windows now.


So is history repeating itself? Developers got over their fear of Windows and adopted it as the PC gaming platform of the future. Will the benefits of managed code and XNA prevail over the shortcomings, just like they did for DirectX?


We were dragged into DirectX whether we wanted to be or not, as some video card manufacturers made it the only API by which we could program their cards. In talking to game developers at GDC about XNA, I got the impression that many of them associate managed code with interpreted code, like scripting languages, assuming that the former will perform as inefficiently as the latter.


Does the average game developer know the difference? It seems that many do not know that managed code is, in fact, compiled for native execution. Just as the reasons to go with a scripting language have to do with the benefits in other areas outweighing speed, we have to think of XNA in terms of whether the benefits in other areas outweigh the disadvantages.


So, there is a natural progression here where CPU time becomes more of a commodity as computing speed power marches ever onward, and developer time becomes more precious as game budgets get larger and larger.


There are many tools that allow you to write much better code and profile it much easier in. NET, but most [game developers] just do not know about it because they have not bothered to really try. NET yet.


And thankfully so! I think game developers would breathe a collective sigh of relief if they never had to debug a corrupted memory stack again! Not yet in any case. Many of the XNA doubters and naysayers claim that XNA is only fitting for casual games, or at most prototyping game ideas. Until game developers see more commercial XNA games and bigger examples of XNA games in various genres, like first-person shooters, action games, role-playing games, sports games, and others, the question will remain about the type of game that can be tackled efficiently with XNA.


But a killer puzzle game is still a hit game. Scale is not an indicator of quality. Again, what I have seen within the indie community is that they will make large and ambitious titles with pretty low-end tools. Microsoft also seems realistic about who these initial tools are for, but Mitchell is very confident about what can be achieved with XNA Game Studio Express.


The XNA Framework is really proving to be favored by a growing number of professional and indie game developers for Xbox LIVE Arcade games and rapid prototyping of new commercial game concepts.


We use middleware and unified systems for some titles or custom tiny engines for others-our main goal is flexibility and speed so we can take on a variety of challenges. C is useful in that we can get game play prototyping going while the technical specifics get worked out for the specific platform. Fristrom does not think XNA is just for prototyping. He does not consider Schizoid to be a casual game either. Terrano cautions against underestimating the value of prototyping though.


Austin would use C for commercial games, not just prototyping, provided that XNA Game Studio could also allow you to integrate native code calls as well, which it does not today. While it is possible to use the full. NET Framework 2. Casual games are those games we can pick-up and play for a few minutes on a console, portable device, computer or even in a Web browser as many casual games are Flash-based.


From Solitaire to Tetris , Sudoku and beyond, casual games have the widest and most diverse audience among gamers, and they are also the most probable to be played by non-gamers, hence the term casual gamer. But quick to play does not mean these games do not attract hardcore gamers too. Williams is quick to point out that XNA is not just for casual games. Mid-way through development of Torque X, without even having done the majority of our performance tuning and optimization, we had a fully shaderized, 3D level of Marble Blast Ultra up and running and performing well on XNA and Torque X.


Marble Blast Ultra , I think most anyone would agree, is one of the most technically sophisticated and largest scope games on Xbox LIVE Arcade, and goes well beyond any normal definition of a casual game. But before going too far on the question, we need to assess whether or not the casual game developers even care about XNA.


When you think about it, we were really in the right place at the right time-we happened to be starting a new game with a new engine just as XNA became available. Austin is not worried about whether or not the casual game community adopts XNA. Game categories continue to evolve and change. XNA has many possible uses, and it may not be right for some developers, but I think it can be very useful for others. At that point, it won't matter what casual game developers think, though I'm pretty sure by then they will see the value in putting their game in front of millions of console owners.


With XNA being a new game development platform and toolset, it remains to be seen how far developers can go with it. Are there game ideas that you cannot create with XNA? Fristrom remains open-minded. In just four days, the teams created a 3D action RPG Figure 3 , a 2D siege shooter, a side-scrolling adventure game, and an off-the-wall alien abduction game that incorporated voice commands. It still blows my mind that they were able to create those four amazing games in just four days! I can only imagine what the community will create when given four months as part of the Dream-Build-Play contest later this summer.


But for various reasons modern games can be demanding. Austin does not entirely agree that XNA can do everything. However, given that more and more work can be done on the GPU, even that is changing.


Other games such as massively multiplayer online role-playing games MMORPGs , like World of Warcraft, EverQuest 2 or Lord of the Rings Online , can be highly demanding in terms of networking needs when hundreds of thousands of players are playing the same game simultaneously. Latency-and server-induced delays aka lag can mean the difference between an enjoyable online experience and utter player frustration. But as I said, for years now, a large portion of the code of many massively multiplayer games has effectively been managed code written in script.


The number of games using. NET and C outside of their tools chain will definitely grow. At this point, I have used Lua, Python, Java, and a couple of custom solutions. It lets designers do first pass or sometimes final behavior programming, and makes it easier to easily add one-offs. And since the scripting language can be insulated from the rest of the server codebase, you can protect the game as a whole from runaway scripts.


The best solutions I have ever used have been the custom ones, perhaps because they are designed exactly for the task and do nothing else. Observe any gamer shopping for a new title in a store, and the moment they pick-up a game box, they immediately flip it to take a look at the in-game screenshots on the back of the box to assess what kind of graphics the game features.


Is Gears CPU bound? But how far can you push the graphics envelope with XNA? They can take full advantage of programmable pipelines and all the features in Direct3D as of DirectX 9.


Fristrom, on the other hand, has solid hands-on experience with XNA, thanks to Schizoid , and still has not found its graphics limitations. But creating a successful game does not always involve pushing the envelope in terms of next-generation graphics. While visuals create a strong first impression with players in a game, fun and innovative game play are what turns a game into a commercial hit. Case in point, highly successful franchises like Guitar Hero, Lego Star Wars , and Dance Dance Revolution do not owe their success to advanced graphics, but to their game play elements.


Could XNA have been used to create these games, or similar games, without sacrificing quality? So I have little doubt they could be accomplished [with XNA]. Again, we should not be distracted by the 3D models bouncing around in the background. Nintendo has done a good job of showing how that can work effectively. Indeed, the massive success of the Nintendo Wii so far has taught us that next-generation graphics and pushing the envelope technically are not necessarily the keys to success.


Players want game play innovations, games for everyone, and games that are just plain fun. Can XNA then help bring back innovation by lowering the entry-level bar thus welcoming new blood and fresh ideas? Leave the core technology problems to us and the XNA Framework.


Knowing how to use a stove does not make one a great chef, and the same goes for game development tools. I would agree that the Wii did bring back some innovative game ideas and especially the controllers are fun, but most gamers out there today still want their regular food. Just take a look at the most successful games today like World of Warcraft for PC or like Halo for the Xbox , which are not really innovative. Those game ideas have existed for a long time.


Those games have just better controls, better balancing, and better game play and have huge worlds. Beyond hobbyists and professionals, Microsoft has also been partnering with dozens of universities and game development institutes to bring XNA to the curriculum of future game developers.


While this technology isn't the silver bullet that will help to reverse that trend, it is being used by more than 80 universities globally as part of overhauling dated curriculum and lab environments. Additionally, to help these and other universities successfully adopt and integrate XNA Game Studio Express into their curriculum, we're investing even more resources towards creating an XNA Academic Program that will work with partners in the academic community to develop re-usable curriculum, game samples, lab exercises, textbooks, support resources, and more.


With support for the Xbox using a simple off-the shelf commercial console, XNA is well positioned to provide a cheap and efficient offering to game development faculties and academies looking to reach beyond PC gaming in preparing students for the gaming industry. The more people we can get excited about our industry and pursue careers as game developers, content creators, audio engineers, etc. Williams can certainly relate with students discovering console development through XNA, sharing some old dreams.


Not that this is bad for education, or anything. XNA still has a long way to go before it gets widely adopted by professionals, if it even does. If the gaming industry does not follow this path and a new horde of XNA-proficient game development grads start looking for jobs, are these developers then at risk of hurting their career before it even starts? Mitchell is not worried. This goes on and on.


In the end, any sharp programmer can pick up that low-level stuff over time. The skills you learn and knowledge you gain in a game development course are ideally higher-level. You need to be able to use them all to your best advantage, and roll with the needs of a particular project. Ultimately, XNA, managed code, and C are all just a fraction of the concepts students will be exposed to going through a current computer science or game design program.


So anything that gives them an onramp is good for the industry. Fristrom sees this as a positive move, and also offers advice to future game developers. Game developers are not at risk. Technology changes all the time and part of the challenge of being a game developer is you have to keep up.


That experience transcends platform or programming languages. Fristrom explains why his peers should follow his lead in embracing XNA for commercial game development. You get all the benefits from using the Common Language Runtime: faster build times, garbage collection, array bounds checking, pointers-free-code. Did I mention faster build times? Also, fewer bugs, more productivity. You get all the benefits from using a very parseable language-better refactoring tools and auto-completion.


All this stuff makes you happy. Happy programmers are productive programmers. Austin offers a practical example. What usually has been my bottleneck in the past is dealing with the infrastructure to create a windowed graphics application and support classes. With C , in a day I had a model viewer that read in from an external source, and had sliders to test out various parameters on a fairly complex system.


However, the larger the game studio is, the harder it will be for them to migrate to or even adopt XNA. Fristrom knows smaller studios have an advantage here. They can turn around faster, adopt new technologies more easily, and also attract the developers eager to pioneer new techniques and approaches.


C is just too slow! That opened a lot of eyes. Williams agrees with Fristrom and elaborates further. C was lambasted when people first started talking about using it in game development too!


Back in the day, it was assembly or death. But man, who wants to? If you look at non-game developers you see a strong shift towards. NET [that happened] in recent years. It took a couple of years too, but it is ridiculous how long it takes for game developers.


You have to fear the managed code; it may eat your family. There is no networking support in the XNA Framework on the Xbox yet but it is planned for a future update. With those boundaries in place, you can now add the code to adjust the direction and speed of the text as it moves around the screen. Whenever your text position exceeds either the X or Y boundaries, your speed is flipped between positive and negative and your position is adjusted accordingly. The last step is to look in the Draw method and change your DrawString method to use your new textXY variable, instead of the hardcoded 0,0 values, like so:.


With that, you're done with this set of changes, and your Game class should look like Listing 1. Hit F5 and give it a run. Adding a 2D sprite image to your game is as simple as right-clicking the Content folder in your Solution Explorer and picking Add Existing Item. Browse to the image you wish to use. For best results, grab a. PNG file with a transparent background, such as the soccerball.


After you add the image to your solution this article assumes that you'll be using the soccer ball image , add the following line of code at the class level, where you defined the SpriteFont :. A Texture2D type is used to store a two-dimensional graphic also known as a Sprite which you will pass to the Draw method of your SpriteBatch object. Now that you have a variable to hold it, load the image by adding the following line in your LoadContent method:.


This loads the image into your GPU and reloads it in the event of a device reset so it will be ready for use by your game. At this point, with the image loaded into your soccer ball variable, you're one line of code away from seeing it onscreen.


Add the following line to the Draw method, inside the spriteBatch block:. Remember that XNA draws from back to front by default, in the order the calls are made in the code.


Once again, you're ready to fire up your game. Hit the F5 key and sit back, marveling at the splendor of moving text and a static soccer ball competing for screen real estate. I've barely scratched the surface of what the SpriteBatch. Draw method is capable of, but in the next section, you'll tackle some additional functionality.


The SpriteBatch. Draw method has a number of overloads for handling things like rotation, image origin, source rectangle handy for slicing up those spritesheets into animations , and a lot more.


Take a look at this method signature:. It's a bit longer than the one you previously used, but there's a lot more functionality here. The first two parameters, texture and position, should look familiar. Next is an optional parameter: sourceRectangle , which allows you to draw a specific area of a larger texture such as a single cell of animation.


You've seen the color parameter before in the previous example, but what you may not know is that you can use it to tint your sprite. Using Color. White actually means no tint at all. The next three parameters, rotation, origin, and scale, have a direct impact on how the image is rendered and will be the focus of the next enhancements to the Game project. The effect parameter accepts a SpriteEffects enumeration that allows you to flip your sprite vertically, horizontally, or neither.


You don't apply this value to the sprite unless you need to. Lastly, the depth parameter is used with sprite sorting, if you need to sort them in a manner other than back to front, in the order drawn in code. To make the soccer ball rotate, you will change the Draw method to use the signature described above, and pass in values to control the rotation and origin. In order to rotate the image, you need to know the point you are rotating around, which is stored in the origin variable.


This isn't just the rotation point though; origin dictates where to draw the image in relation to the supplied positional coordinates. By default, this is 0,0, which means that the top left corner is drawn at the position you specify. By changing it to the middle of the image, you're drawing the image with an offset. If this seems confusing, wait until you run the code.


We haven't changed the position value, but you'll notice the soccer ball is drawn further up and left than before, because of changing the origin. Lastly, the scale variable dictates the size to render the image in relation to the original size.


A value of 1. The original image was kind of big, so I've scaled it down by half. With those variables in place, the next step is to add this line of code to your LoadContent method. This code sets the rotation origin to the center of the image, as determined by dividing width and height by two. There are a few different ways to handle setting the origin. You can define it at the class level if you know the specific resolution of the image, but if you prefer to do it programmatically, you need to do it after loading the image, since you won't know the size until then.


To rotate the image, you'll need to add the following code to the Update method. You can put it before or after the code that moves your text, as long as it's before the call to base. Just like with moving the text, you rely on the GameTime class to provide a consistent and smooth animation.


A little bit of math to calculate the proper rotation degrees and you're done with the Update method. The last thing to do is change one line in the Draw method. Change the spriteBatch. Draw method to look like this:.


If you run the game at this point, you'll see a rotating soccer ball in the top left corner, and your text slowly gliding across the screen, just like in Figure 7. For a complete listing of how your Game class should look at this point, check out Listing 2. The final thing to cover in this article is what makes the difference between a game, and the world's most boring screensaver: the ability for your player s to provide input and see a direct effect in your game. If you take a look at the first two lines of the Update method, you'll see that you are already checking for two forms of input: from the Game Controller via the GamePad class and the Keyboard via the Keyboard class.


This piece of code checks to see if the Back button on the game controller being used by player one there's support for up to four players locally is pressed:. The Buttons collection contains a value for every button, bumper, stick and trigger on the controller.


The ButtonState enumeration contains two values: Pressed and Released. Since you can check for either state, per button, this gives you a lot of flexibility. The following piece of code gets the state of the keyboard to see what, if any, keys are pressed. In this case, you are checking for the Esc key. The IsKeyDown function checks the state of whichever member of the Keys enumeration you pass to it.


The Keys enumeration contains entries, and includes a number of special function keys to cover most keyboard configurations.


Not all input types are available on all devices. For example, there is no support for Touch or Mouse on the Xbox , and most phones don't support the GamePad. Your PC probably has Mouse support, but not necessarily Touch. With this, you now have enough to get started with MonoGame.


You've learned what you need to get, where to find it, how to set up, and you've stuck your toe in the code enough to put some text and images on screen, and read a little player input. All that's left is the game idea, and I bet you already have a million of those.


If you don't, here are some suggestions for additional learning opportunities. A lot of people try to go a little too big on their first game project. Start small. Tetris clones are a great way to learn the basic fundamentals of moving and rotating static, grid-based objects across the screen, and also covers basic collision detection and player input. Tower Defense games cover things like basic pathfinding AI, shooting trajectories, simple animation, and unit placement via touch or click.


Space Shooter games like Galaxian, Galaga, Zaxxon, and even Space Invaders teach about patterns, speed of movement, scrolling backgrounds and more. These are just some of the more simple ones, but even these have a lot more hidden complexity to them than you realize until you try to build one.


Just imagine what goes into building the next World of Warcraft clone. The message here is that there's a lot to learn from the classics. Don't be too proud to take a look at what others have done before you and learn from it.


Also, keep in mind that any of the tutorials and starter kits written for XNA should work with little or no modification in MonoGame. There's a wealth of information out there just waiting for you to tap into it. My Subscriber Account Advertise Write. Training Home State of. Staffing Home Looking for Staff? Looking for Work? Contact Us. Dark Kimbie. Published in:. Getting Started With MonoGame In this section, you'll learn what you need to download to set up your development environment for using MonoGame on the supported platforms.


The version you need to download and install depends on your operating system. If you're running Windows 8, get Express for Windows and if you're running an earlier operating system, like Windows 7, get Express for Windows Desktop.