XNA and Windows Form

ok, this time I’ve focused my spare time on making Windows Forms and XNA cohesist.


I’ve created a small example of how to do that and pushed everything on GitHub as the last time  , you can find the repository here.

Basically you have to create everything by yourself, GraphicsDevice and ServicesContainer. Yeah, that can be a mess.

Oh and don’t forget to set PresentationParameters.IsFullScreen to false!

Hexagons! Hexagons everywhere!

I feel bored. Sometimes I feel so bored that I start walking around as if I were on a tiled map. And sometimes I like to switch from rectangular to hex-shaped tiles 😀

I’ve started working on a hex-based map renderer, just because, as I said. I’m bored.

Here’re the results so far:

Senza nome

And this is the tile texture:


I’m using XNA 4 (yeah I know, but that’s easy and I love to do everything by myself). Here’s part of the rendering code:

_hexTexture = this.Content.Load<Texture2D>("hex");
_hexOffset = new Vector2(_hexTexture.Width * 0.75f, -_hexTexture.Height * 0.5f);

var hexPos = Vector2.Zero;
for (int y = 0; y != 10; ++y)
 hexPos.Y = _hexTexture.Height * y * .5f;
 hexPos.X = _hexOffset.X * y;
for (int x = 0; x != 10; ++x)
 hexPos += _hexOffset;
 spriteBatch.Draw(_hexTexture, hexPos, Color.White);

Easy huh?

© 2019 Davide Guida

Theme by Anders NorenUp ↑