Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS 4730 Ruminations on Sprites in Monogame Martin Kellogg, definitely not Ph.D."— Presentation transcript:

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

2 CS 4730 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 CS 4730 What is a Sprite? Any graphical content 3 Either 2D or 3D We’ll restrict ourselves to 2D sprites

4 CS 4730 Coordinates We care about three coordinate systems: –Screen coordinates –World coordinates –Object coordinates 4

5 CS 4730 Screen and world coordinates 5

6 CS 4730 Object coordinates Position of a pixel within an object 6

7 CS 4730 What about Monogame? Implemented through the SpriteBatch class Three important methods: –Begin –Draw –End 7

8 CS 4730 Back to front… End() is easy – you call it when you’re finished drawing things! 8 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);

9 CS 4730 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 CS 4730 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 CS 4730 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 CS 4730 Where to draw things? This means using vectors They can describe positions (from the origin) 12

13 CS 4730 Transformations A function T: → Examples include: –converting object to screen coordinates –translation –scale –rotation 13 22

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

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

16 CS 4730 Scaling 16

17 CS 4730 Rotation 17

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

19 CS 4730 An example Rotate then TranslateTranslate then Rotate 19

20 CS 4730 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!this form Another way to get to the form: http://bit.ly/MAnk4i 20


Download ppt "CS 4730 Ruminations on Sprites in Monogame Martin Kellogg, definitely not Ph.D."

Similar presentations


Ads by Google