Пример #1
0
        private List<Sprite> sprites = new List<Sprite>(); // List of sprites to draw

        #endregion Fields

        #region Constructors

        // Initialise the renderer
        public Renderer(Vector res, Vector screen)
        {
            // Figure out the ratio
            this.Resolution = res;
            this.ScreenSize = screen;

            double ratioX = (double)Resolution.x / (double)ScreenSize.y;
            double ratioY = (double)Resolution.y / (double)ScreenSize.y;
            // use whichever multiplier is smaller
            ratio = ratioX < ratioY ? ratioX : ratioY;

            // Create the Game Canvas for drawing sprites onto.
            canvas = new Bitmap(Convert.ToInt32(ScreenSize.x * ratio), Convert.ToInt32(ScreenSize.y * ratio));

            // Set up the graphic configs for the renderer
            fg = Graphics.FromImage(canvas);
            fg.InterpolationMode = InterpolationMode.HighQualityBicubic;
            fg.SmoothingMode = SmoothingMode.HighQuality;
            fg.PixelOffsetMode = PixelOffsetMode.HighQuality;
            fg.CompositingQuality = CompositingQuality.HighQuality;
        }
Пример #2
0
 // Set the Resolution
 public static void SetResolution(Vector r)
 {
     Resolution = r;
 }
Пример #3
0
 // Update the screen size
 public void UpdateScreenSize(Vector s)
 {
     this.ScreenSize = s;
 }
Пример #4
0
 // Constructor that defines the sprite as a rectangle
 public Sprite(int x, int y, int w, int h)
 {
     this.position = new Vector(x, y);
     this.size = new Vector(w, h);
     this.shape = true;
 }
Пример #5
0
        private bool shape = false; // Boolean to define if the sprite is just a rectangle

        #endregion Fields

        #region Constructors

        // Constructor that defines the sprite as an image
        public Sprite(Bitmap img, int x, int y)
        {
            this.img = img;
            this.position = new Vector(x, y);
            this.size = new Vector(img.Width, img.Height);
        }