I am trying to make platformer engine c# windows forms, so I am trying it out with super Mario tilesheet I found on the Internet. I cropped every picture I need its own tile object. When I draw it as it is It is alright. Because it is 16x16 picture I added scale factor. When I try to scale it picture gets transparent right and bottom edge.
Does anyone know the reason for it? I do scaling in the draw method. I have tried all similar results I found. Thanks in advance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace PlatformerRunner
{
class Tile
{
public int id;
public int width;
public int height;
public bool solid;
public String name;
public Bitmap image;
public Tile(int id, int width, int height, bool solid, String name, Bitmap image)
{
this.id = id;
this.width = width;
this.height = height;
this.solid = solid;
this.name = name;
this.image = image;
}
internal void draw(Graphics g, int x, int y)
{
int s = Game.scale;
g.DrawImage(new Bitmap(image, width * s, height * s), x * width * s, y * width * s);
}
}
}
This is game structure that draws every tile. background just goes from (0,0) to (width,height)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace PlatformerRunner
{
enum GameStructureType
{
BACKGROUND,
PLATFORM,
BUILDING,
PORTAL
}
class GameStructure
{
public int id;
public int x;
public int y;
public int width;
public int height;
public Tile tile;
public GameStructureType type;
public GameStructure(int id, int x, int y, int width, int height, Tile tile, GameStructureType type)
{
this.id = id;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.tile = tile;
this.type = type;
}
public void draw(Graphics g)
{
for (int i = x; i < x + width; i++ )
{
for (int j = y; j < y+height; j++)
{
tile.draw(g,i,j);
}
}
}
}
}