Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kaikimi

Pages: [1]
1
Graphics / Renderimage upside down?
« on: September 28, 2010, 08:43:07 pm »
Ah, yeah that fixed it, thanks for the help.

2
Graphics / Blurred image
« on: September 28, 2010, 06:13:17 pm »
SetSmooth(false) on every sf::Image.

I had the same "problem" too when staring out.

3
Graphics / Renderimage upside down?
« on: September 28, 2010, 04:10:07 pm »
I made a main buffer to render to in my game as a test and it seems to be drawing the renderimage upside down. Maybe I'm doing something wrong? here's my code. I'm using SFML.NET 2.0



MainGame.cs
Code: [Select]
using System;
using System.Collections.Generic;
using System.Timers;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace FrostFire
{
    class MainGame : Program
    {
        public MainRenderBuffer MainBuffer;

        public MainGame()
        {  
            Text NewText = new Text();
            NewText.Position = new Vector2(200, 200);
            NewText.Color = new Color(250, 100, 30);

            Text NewText2 = new Text();
            NewText2.Position = new Vector2(120, 210);
            NewText2.Color = new Color(110, 222, 30);

            //sort all the sprites by depth and draw them to a buffer
            this.MainBuffer = new MainRenderBuffer(base.MainWindow.Height, base.MainWindow.Width);
       
            while (MainWindow.IsOpened())
            {
                base.MainWindow.DispatchEvents();

                //clear the window so we have a fresh screen to work with
                base.MainWindow.Clear();

                //Do all the game update logic
                MainGame.MainGameStateLoop();

                //replace this with the depth drawing array
                NewText.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
                NewText2.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
                this.MainBuffer.RenderBufferImage.Draw(NewText);
                this.MainBuffer.RenderBufferImage.Draw(NewText2);

                //draw the main buffer image to the screen
                base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image));

                //display drawn buffer to the window
                base.MainWindow.Display();

                //clear the main buffer for the next frame.
                this.MainBuffer.RenderBufferImage.Clear();
            }
        }

        public static void MainGameStateLoop()
        {
            //switch statement for different room states (title, level, etc.)
        }

    }
}



renderbuffer.cs
Code: [Select]

using System;
using System.Collections.Generic;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace FrostFire
{
    class MainRenderBuffer
    {
        public uint Height, Width;
        public RenderImage RenderBufferImage;

        public MainRenderBuffer(uint Height, uint Width)
        {
            this.Height = Height;
            this.Width = Width;
            this.RenderBufferImage = new RenderImage(this.Width, this.Height);
            RenderBufferImage.Image.Smooth = false;

        }

    }
}

4
DotNet / blurry png and bmp sprite
« on: September 21, 2010, 08:23:28 pm »
Thanks, I didn't realize there was a property for that.

5
DotNet / blurry png and bmp sprite
« on: September 21, 2010, 05:41:26 pm »
I'm trying to learn SFML and I've made a small program that just displays a sprite. It seems the sprite is rather blurry though. The result is the same if i use a bmp or png.

here's a screenshot


here's my source
Program.cs
Code: [Select]
using System;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace SFMLTest
{
    class Program
    {
        public Player MyPlayer;

        static void OnClose(object Sender, EventArgs e)
        {
            RenderWindow Window = (RenderWindow)Sender;
            Window.Close();
        }

        static void Main(string[] args)
        {
            RenderWindow Window = new RenderWindow(new VideoMode(384,256),"Hello world!");
           
            Window.Closed += new EventHandler(OnClose);
            Window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            while(Window.IsOpened())
            {
                Window.DispatchEvents();
                Window.Clear();
               
                Player MyPlayer = new Player();
                Player.Initialize(MyPlayer);

                Sprite ImageToDraw = MyPlayer.Draw(MyPlayer);

                Window.Draw(ImageToDraw);

                Window.Display();
            }
        }

        static void OnKeyPressed(object Sender, KeyEventArgs e)
        {
            RenderWindow Window = (RenderWindow)Sender;
            if (e.Code == KeyCode.Escape)
                Window.Close();
        }
    }
}


Player.cs
Code: [Select]
using System;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace SFMLTest
{
    class Player
    {
        public int X,Y;
        public string ImagePath;

        public Player()
        {
        }

        public static void Initialize(Player Player)
        {
            Player.X = 100;
            Player.Y = 100;
            Player.ImagePath = "Images/TestImage.png";
        }

        public Sprite Draw(Player Player)
        {
            Sprite PlayerImage = new Sprite(new Image(Player.ImagePath));
            PlayerImage.Position = new Vector2(Player.X,Player.Y);
            return PlayerImage;
        }
    }
}

Pages: [1]
anything