1 / 20

Ruminations on Sprites in Monogame

Ruminations on Sprites in Monogame. Martin Kellogg, definitely not Ph.D. Cunning Plan. Sprites are an abstraction of all graphical content Three kinds of coordinates: world, screen, and object We can manipulate sprites using linear algebra

joshwa
Télécharger la présentation

Ruminations on Sprites in Monogame

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ruminations on Sprites in Monogame Martin Kellogg, definitely not Ph.D.

  2. Cunning Plan • Sprites are an abstraction of all graphical content • Three kinds of coordinates: world, screen, and object • We can manipulate sprites using linear algebra • Some examples include translation, scaling, and rotation 2

  3. What is a Sprite? • Any graphical content • Either 2D or 3D • We’ll restrict ourselves to 2Dsprites 3

  4. Coordinates • We care about three coordinate systems: • Screen coordinates • World coordinates • Object coordinates 4

  5. Screen and world coordinates 5

  6. Object coordinates • Position of a pixel within an object 6

  7. What about Monogame? • Implemented through the SpriteBatch class • Three important methods: • Begin • Draw • End 7

  8. Back to front… • End() is easy – you call it when you’re finished drawing things! • Draw() is a touch more complex, but still simple. Three arguments: • The image to draw • The position at which to draw • A color to tint it (use Color.White most of the time) e.g. mySpriteBatch.Draw(background, Vector2.Zero, Color.White); 8

  9. Back to front (continued) • The Begin() method is the most complex • You can pass it a variety of parameters that control how everything is drawn • Or you can just pass it nothing (easiest and therefore most recommended choice) 9

  10. Trivia (Classics)! • This Roman general and statesman held the consulship for 59 BCE with Marcus Bibulus. Having completed the consulship, he held proconsular command in Gaul for nearly ten years before famously returning over the Rubicon river in January, 49. In later times his name was used as a title by the German Hohenzollern dynasty. 10

  11. And another (Games)… • Published in Japan in 2002 under the name Fuuin no tsurugi, this role-playing game follows a young noble of the Lycian League as he struggles to defend his homeland from the invasion of the neighboring kingdom of Bern. This noble, Roy, later went on to appear in an installment of a famous series of fighters directed by Masahiro Sakurai. 11

  12. Where to draw things? • This means using vectors • They can describe positions(from the origin) 12

  13. Transformations 2 2 • A function T: → • Examples include: • converting object to screen coordinates • translation • scale • rotation 13

  14. The Matrix and Vector2 classes • This is how we can apply transforms in Monogame • Make a Vector2 for your position • Apply matrix operations to the Vector2 14

  15. Translation • Translation is just a fancy way of saying movement • Equivalent to vector addition • Don’t need Matrix class 15

  16. Scaling • Changing the size of objects • = • Tread carefully: • Scaling is expensive • Scaling objects to make them larger can result in “jaggies” - pixelated images 16

  17. Rotation • Rotation around a fixed point • = • If you want to know why: gotoThornton_B; find(“APMA”); take(3080); 17

  18. A final note about transforms • As a general rule, most transforms are NOT commutative • Why? 18

  19. An example Rotate then TranslateTranslate then Rotate 19

  20. Wrap up • Your Physical prototypes are DUE in lab FRIDAY • Thanks for listening! • I’d really appreciate feedback on the lecture, so I set up this form. If y’all have a moment (it’s only two multiple choice questions and an optional free response) I’d appreciate it if you’d fill it out and let me know how I did! • Another way to get to the form: http://bit.ly/MAnk4i 20

More Related