Hi,
I'm currently writing a level designer for my 2D game*. To do so, I'm writing this using c# / WinForms. The editor is designed to look a bit like VS, ie. a set of tool boxes surrounding a central panel to show the various tiles and game objects. I've got this central panel as a custom control (inheriting directly from Control) using custom rendering. The development machine that I'm using is using a 27" 4k display and so I've set Windows up to use a text zoom of 150% to avoid killing my eyes.
Unfortunately, when I use my standard drawing code of (within the OnPaint override):
var location = new System.Drawing.Point(
offsetX + (tilePair.Key.X * tileLayer.TileSize.Width ),
offsetY + (tilePair.Key.Y * tileLayer.TileSize.Height ) );
var destRectangle = new Rectangle( location, tileLayer.TileSize );
if( pe.ClipRectangle.IntersectsWith( destRectangle ) )
{
pe.Graphics.DrawImage( tilePair.Value.Image,
destRectangle,
tilePair.Value.TileRectangle,
GraphicsUnit.Pixel );
}
The actual rendering is being done at 150% size of the destRectangle (~96 pixels vs. 64 that's expected).
This isn't necessarily a problem so long as I can source that scale factor in advance so I can ensure the appropriate resizing / layout code. Googling doesn't lead to much info on how to source this information and there's nothing obvious that I can find in intellisense as to give me pointers as to where to investigate further.
So... does anyone have either any ideas as to how to solve this or links to places where I can investigate this sort of issue.
Thanks in advance
Steve
*originally, I was using Tiled - which is rather good, but for various reasons I wanted to write my own. 1. so I can define custom objects with a fixed set of properties for level designers who aren't that technical to use and 2. to use it as a learning exercise around the command pattern.
↧