This is the continuation of the previous lecture, so we'll get all the way to actually drawing those teddy bear sprites in this lecture. So let's continue. Okay, so let's actually go down to draw and see if we can draw our teddy bear. So, I'll say draw teddy bears with the expectation that later on I'm going to draw all three of them. Okay. So it turns out that, the way we do this drawing thing is, we have the other field that we get for free, if you will, in our Game class, is the SpriteBatch. And the SpriteBatch is used to draw stuff. So the way we do this is we start or begin the SpriteBatch by calling its begin method. And if you look carefully at what this is telling us, what this IntelliSense is actually telling us is that all of the parameters or the arguments that we provide when we call the begin method are optional. So in fact, we have control over some of the characteristics of the way the SpriteBatch works, but we can simply provide no arguments and it will work in the default way. Well also, after we've drawn all our stuff, we'll do a spriteBatch.End. We'll call the end method of the SpriteBatch, so that it ends the SpriteBatch. And this is a really good time for you to go take an in-lecture quiz, so that you can guess if you have to. What, when stuff gets drawn. Okay, the answer is when we call sprite badge end. So it's a batch of sprites that get all sort of put into this set of things that should be drawn, and when we call sprite batch end is when we actually draw them. We could override this behavior if we choose to do so in our XNA game, but there's no need for us to do that right now. So I'm going to, for those of you who don't believe me, please believe me, I'm going to deliberately make a mistake here, because you may find that you make the same mistake. So I want to draw that first teddy bear. So I call the spriteBatch draw method. And it turns out that there are seven different ways that I can call the spriteBatch draw method, but I'm going to take the very first one here. So I start with a texture 2D and that's bear zero, that's the texture 2D that I had the content manager load for us. I've provided destination rectangle, which I've called Draw Rectangle zero. And I provide a color so I can, in fact, tint this if I choose to do so. But I want it to be drawn in it's actual original colors from image. So I'm going to pick white. I will tell you that I had a student who regularly gave me wheat tinted stuff because she got to the WH and hit tab, and it was always wheat colored, but white is what you want if you want it drawn in actual color. So at this point, you could reasonably expect that we're going to see something drawn when we run the program. And I press F5 And we don't see anything drawn, and we're very sad. But, that's what debugging is about and I was telling my wife earlier today, we were talking about debugging and I said well debugging is like solving a mystery. We gather some information and we form a hypothesis and we try to figure out what's going on. It's very exciting, and you better get excited like that because you'll debug okay, so how do we debug? Well, what I'm going to do, watch my cursor way over here. I left clicked in this gray column right here and I got this red ball. What this red ball is called is a break point. So when I run my code using F5, not ctrl+F5 because that just ignores break points. When I run my code using F5, it's going to execute the program until it gets to this break point, and then it will stop. And so that's good because then I can look at stuff to see if I can figure out what's going on. Okay, so I press F5 and it runs, and then it's got to the sprite point. And we can tell because it's all highlighted and the red ball has a little yellow arrow inside it. And so now we can look at some things and try to figure out what's going on. So the two possibilities, one much stronger than the other is that we don't have a sprite loaded. And we're pretty sure we do but we'll take a look to make sure or that our rectangle isn't the way that it should be. And it turns out that the problem is the rectangle isn't the way it should be. So we look at bear zero, I hover over it and you can see that there is in fact a texture 2D there, so okay that's great, it's not null, it got loaded. But when we look at the draw rectangle, look at x, y, width, and height. So we have this rectangle and this rectangle is a structure in XNA, and it has an x and a y location, the upper left corner of the rectangle, and it has a width, how many pixels wide it is, and it has a height, how high is it. So what we're saying is, we should draw this sprite inside a rectangle with zero width and zero height. And that's a really small rectangle there are no pixels to be drawn in width and no pixels to be drawn in height. So that's why we're not getting any output even though we expected it. So go to the in lecture quiz about the rectangle structure and then comeback so we can fix this. Great, so I've taken out the break point and I'm clicking debugging stop debugging. So we need to, up here where we loaded the teddy bear, we need to also build its draw rectangle. So DrawRectangle0 We're going to call a rectangle constructor just like we've seen as we construct instances of classes. Two overloads, I don't want to use this one because this just builds me a rectangle with zero, zero, zero, zero which is not helpful to me. If you click the down arrow, you can see that there's a different one. For which we can provide x, y, width, and height. So let's actually provide x, y. Let's say we'll put it at 150 and x, we'll put it at 100 and y. And for now, let's give it a width of a couple 100 and have a height of a couple hundred. So now we've created that rectangle so that when we run this thing, now we get a very scary output with a fat, big pixelated teddy bear that scares us. So in general, scaling is cool. If you want to like feed teddy bears and they get fat and fat until they explode which is a horrible, well, fun game, what we might want to do is draw our assets in their original size. And so instead of using 200 and 200 here If only there were a way, now that we've loaded this bear0 texture, if only there was a way, given a bear0 or a texture 2D object that we could find out that texture 2D's width and height. And of course there is, otherwise I wouldn't have built it up so much, so the bear0 dot, so object dot, let's access its property, let's access its width. And bear zero dot access it's height and so now when we F5 it draws that bear in it's actual size. So now that we've tested that to make sure that that works, I will add the rest of the teddy bears copying and pasting which you'll hear me complain about lots but we're going to do it right now because we don't know a better way. And you'll notice that we're getting some errors as we do this which will take care of soon. But basically I'm changing all this so it's going to handle all the teddy bears. Now, if I leave all these draw rectangles for the same x y, then they're all going to get drawn in the same place, so it will look like we only have one teddy bear. So let's change these a little bit. We'll just do a row of teddy bears, like so. Now these errors, if I hover over this, it says, the name of bear1 does not exist in the current context, which really means, I don't have a bear1 field. So I'll add those, I'll get it so it can compile and run again, I press F6 to compile, build succeeded, that's great, we're very excited, it compiled, and I press F5 to run it and I still only have one teddy bear, so I'm sad again However this is an easy fix. I did control end by the way to bang my way all the way down to the end here, just because we've only told it to draw one of the teddy bears. So let's tell it to draw all three of those teddy bears like so, when I run it we get that row of teddy bears that we hoped for. And you'll notice that I loaded all those teddy bears, or I actually loaded the content for the teddy bear and built the draw rectangles here in the load content method which is exactly where you would expect me to do it. So that's really it for today. So let's recap. We've learned about how to do some initial stuff. We've initialized by changing the resolution of our game. We loaded content so that we could bring in some texture 2D's. Some sprites for our 2D game and we did some drawing. And you know, that way we get to see some output from our game. The sad news is, we never used update, because our game world never changes. Which makes for a very boring game world. The good news is, that next lecture we'll actually have a game world that changes over time.