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.


Topics - CodingDolphin

Pages: [1]
1
Graphics / How can i propper rezise my Background Image
« on: July 15, 2014, 07:47:51 am »
Good Morning Guy's,

i have a Problem i try to set my Background Image exactly too my Window Resolultion.

My Image Size is 1920,1080:

If i run the Game with a Desktop Resolution 1920,1080 everything is perfectly centered.

If i run now the Game with a Desktop Resolution 1600,900 the Image is always off and not centered i did try Transform, Scale everything i dont get centered im sure i do something wrong but it would be nice if you could give me a hint. (BTW. I use SFML.NET)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using SFML.Window;
using SFML.Graphics;
using SFML.Audio;

namespace BushRaider64
{
    class BushRaider
    {
        //ScreenManager und Render Window

        private ScreenManager screenManager;
        public RenderWindow renderWindow;
        private Sprite background;
        private SpriteFactory spriteFactory;

        //Camera

        View view;

        //GameTime

        private const double frames = 60;
        private const double timeStep = 1 / frames;
        private double timeBank;
        private Stopwatch timer;
        private TimeSpan deltaTime;

        public BushRaider()
        {
            //Window Initialisieren

            VideoMode video = new VideoMode();
            video = VideoMode.DesktopMode;

            //Debug Code

            foreach(VideoMode item in VideoMode.FullscreenModes)
            {
                Console.WriteLine(item.Width + " + " + item.Height + " + " + item.BitsPerPixel);
            }
            Console.WriteLine(VideoMode.DesktopMode.Width + " + " + VideoMode.DesktopMode.Height );


            renderWindow = new RenderWindow(video, "BushRaider",Styles.Default);
            renderWindow.SetVisible(true);
            renderWindow.SetVerticalSyncEnabled(true);
            renderWindow.Closed += new EventHandler(onClosed);

            //Test Sprite

            spriteFactory = new SpriteFactory();
            background = spriteFactory.createSprite(new IntRect(0, 0, (int)video.Width, (int)video.Height), "GameAssets/logo.png");


            //GameTime Initialisieren

            timer = new Stopwatch();
            deltaTime = new TimeSpan();
            timer.Start();

            //Camera

            view = new View(new FloatRect(0, 0, VideoMode.DesktopMode.Width, VideoMode.DesktopMode.Height));
            renderWindow.SetView(view);

            this.Update();

        }

        public void Update()
        {
            while(renderWindow.IsOpen())
            {
                timeBank += deltaTime.TotalSeconds;

                if (timeBank >= timeStep)
                {
                    timeBank -= timeStep;
                }

                renderWindow.DispatchEvents();
                this.Draw();
                renderWindow.Display();

                deltaTime = timer.Elapsed;
                timer.Restart();
            }
        }

        public void Draw()
        {
            renderWindow.Clear(Color.Blue);
            renderWindow.Draw(background);
        }

        public void onClosed(Object sender, EventArgs e)
        {
            renderWindow.Close();
        }
    }
}
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Window;
using SFML.Graphics;
using SFML.Audio;

namespace BushRaider64
{
    class SpriteFactory
    {
        public Sprite createSprite(IntRect rectangle, string fileName)
        {
            Texture texture = new Texture(fileName, rectangle);
            return new Sprite(texture, rectangle);
        }
    }
}
 

Thanks in Advance

Dolphin

2
General / Fixed TimeStep 1 Core nearly 100 %
« on: July 14, 2014, 10:12:35 am »
Dear Lady's and Gentlemen,

i have a Problem, i try to get a Fixed Timestep Loop running. I got it so far that it now has the same Framerate on 60 or 99999(and everything between).

If i use VSYNC the Programm need a whole Core to run this simple Program. --> http://snag.gy/kADOW.jpg

BUT

If i use SetMaxFrameRate(60) i use just 1 - 3 % of my CPU --> http://snag.gy/byQlA.jpg

Can somebody please tell me where is the Problem of my Code?

http://pastebin.com/5XtkgJDC

(click to show/hide)

Greetings

Dolphin

3
General discussions / Some Question's about SFML
« on: July 07, 2014, 03:02:33 pm »
Dear Lady's and Gentlemen,

i am very new too Programming and i currently work with C# and XNA / Monogame.

I have some Question's about SFML, can i use SFML efficient with C# as Main Language or will i miss some Features / encounter more Bug's / Performance Issue?

Are there any real Product's that are createt with this Combination? (You may have Project links?)

Do i find Tutorial's for this or will it be hard to get into it?

Thanks for reading hope you can help me  :)

Greetings

Dolphin

Pages: [1]
anything