Vector-based grphics - is Monogame the way to go?

I’m thinking of building an ‘Asteroids’ clone game, which of course, requires vector like graphics.
On that basis, I just need line drawing primitives.
Are these supported in Monogame? I’ve had a look in the documentation, but nothing is jumping out at me…

Monogame it self doesn’t do primitives, but they are 3rd party libraries that allows you to do them in monogame. I’ve pasted in some links I have, that might help. The 4th one is a thread on the subject. I don’t use Monogame Extended so not sure if primitives were ever implemented into it.

http://rbwhitaker.wikidot.com/primitives-tutorials

https://bitbucket.org/C3/2d-xna-primitives/wiki/Home

Ha neat, I was the other guy on that Primitives2D project. Man, that was a while ago. It’s nice people are getting some use out of it :slight_smile:

Looking back, I’m not a fan of the statically created Texture2D, but it was just so damn convenient. Making it into an extension method on SpriteBatch was something John figured out and that made it even more convenient.

Be warned if you use that though… lines are based on a rotated, stretched pixel sprite. This doesn’t give you any real control over the end-caps or joins between line segments. If you’re interested, a while back I came up with an alternative approach using line geometry. It makes clean joins between line segments by building triangles, but it uses polygon rendering instead of a SpriteBatch.

If this is something that interests you, I can post the basic XNA library, but it was only developed as an experiment so you’d have some work to do in order to port it to MonoGame and to adapt it to your own code. Let me know :slight_smile:

Hey mate,

We do have primitives in MonoGame.Extended. It was originally ported from the Primitives2D project (with permission of course). I believe we’ve fixed a couple of minor bugs along the way.

I agree with @Trinith, extension methods on the SpriteBatch are convenient because you can just use it whenever you want. Very good for debugging issues. The statically created Texture2D is not ideal and rotated lines are not perfect.

We’re working on MonoGame.Extended 2.0 these days. Improving the primitive drawing code is something I’ve got on the to-do list.

In the meantime, feel free to borrow any of the code you want out of our library.

1 Like