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 - vipar

Pages: [1] 2
1
General / Re: Data Driven Design: The Journey
« on: July 25, 2013, 08:58:50 am »
I highly suggest you go and read Tank's article about the Component System (Part I / Part II) and the Message Bus and maybe even buy his eBook to support him, maybe he'll then write another awesome article soon? :P

Here are some bookmarks of mine, keep in mind, that I don't have any experience in that section and those are only resources I've bookmarked a year or more ago.

Okay. I will have a look at those!
I have already seen a slideshow with explanations from the guy who did the Dungeon Siege thing so maybe this is more in-depth. I also know of the Artemis Framework but I don't really get it so I thought I could learn some by doing it myself.

2
General / Data Driven Design: The Journey
« on: July 25, 2013, 12:01:11 am »
Hey guys!

I'd like to make this thread to dedicate what I learn about Data Driven Design (DDD for short) as I go along. This thread will also serve as a Questions thread to some of the, hopefully, more skilled people on these forums. It is done with the intention of learning and teaching at the same time.

I've written many applications in the past using Object Oriented Design (OOD for short). When I started looking into game programming it became apparent to me pretty fast that OOD just won't cut it. DDD is another way of making applications and it's a way I am not familiar with at all.
So I am starting from scratch trying to learn my way around DDD while making what I want.

My end-goal is to make a 2D Tile Engine, much the same as the one seen in A Link To The Past. Free Movement in all 8 directions, top-down, fighting and so on. This will take time and I am not going to become a wizard over night, I realize this.

So with that out of the way, lets start.
I've now read many articles on the subject of DDD. It seems that instead of using deep inheritance which discourages rapid change to the chain itself, you use Components and a flat structure which does not implement inheritance at all or at least, to a minimum. This is to reduce coupling and to make everything modular so you can plug-and-play what you want in the engine and game. You also focus on separating Logic from Data entirely. Finally you avoid hard-coding and also any game specific code so it's very reusable.

In my system I wanted to go for an Entity-System-Component (ESC for short) pattern. Every entity consist of component who each is just a bag of data. An Entity on it's own is nothing. Just an empty shell. No component have any behavior. The behavior is done in the Logic part since Components and Entities only act as Data.

For handling and managing entities and components there are Systems. Each System got it's own job and will be running Update() every frame. The EntitySystem will be making and removing entities. When an Entity is created it is given an ID expressed in an Integer. It also have all of it's Components given out to the respective ComponentSystems. Every frame of the game the EntitySystem calls Update() on all ComponentSystems which in return calls their Update() method as well, making everything update in a series rather than in a sequence (AAA, BBB, CCC instead of ABC,ABC,ABC).

Every Component implements the IComponent Interface so they can be grouped together in a List regardless of Component Type and every System implements the ISystem Interface so that the Update() method can be mandatory on all Systems should Expansion of the engine happen in the future.

Since this is a tile engine, some things will not be changed. There are Tiles which consists of a Vector2i for a Position and an Image which can be made into a Sprite at runtime seeing as Images can be saved while Textures in Sprites only exist temporarily. Levels consists of a 2D array of Tiles.

Here is a diagram of the design:

http://puu.sh/3KVcr.png

I would like to hear opinions on this approach.

3
DotNet / Re: Mismatch between processor architecture
« on: May 25, 2013, 03:44:29 pm »
I think he means like in Java for example.

You can add a documentation URL to the IDE and whenever you use a method or such IntelliSense shows you the documentation in the window for that element/method, instead of having to go to a website to find the documentation.

4
DotNet / Re: Embedding SFML into C#?
« on: May 24, 2013, 10:46:30 pm »
Because I am silly.

5
DotNet / Re: Embedding SFML into C#?
« on: May 24, 2013, 10:04:51 pm »
Oh I was just interested to know really.

The less the user needs to do the better :3

6
DotNet / Re: Embedding SFML into C#?
« on: May 24, 2013, 09:47:08 pm »
Hmm alright.

Would be so handy though =.=

7
Graphics / Re: Image.LoadFromFile fails?
« on: May 24, 2013, 09:29:37 pm »
I JUST had this issue in another thread. Quite literally.

The solution was to load the picture into Paint and save it again.
Or use another picture.

The reason it fails is because the picture most likely is 8-bit which is not supported. It needs to be at least 24 or 32.

8
DotNet / Embedding SFML into C#?
« on: May 24, 2013, 08:26:32 pm »
In C++ you can embed the Static Libraries into the application so you don't have to include them separately every time you make a new project in the output folder.

Is it possible to do the same in C#?

9
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 07:32:49 pm »
Weird. I can open it just fine.

I can open it fine in Window Photo Viewer, but SFML and Adobe PS CS5 do not like it for some reason.

But that error message did not show up at all. I looked through and through. Thanks though.

I saw it when I loaded it in C++ with a console application.

Strange.

I used another image like you said though, and it works. So thank you :)

10
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 05:24:26 pm »
Weird. I can open it just fine.

But okay I'll try another image. But that error message did not show up at all. I looked through and through. Thanks though.

11
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 05:15:00 pm »
Yes, it's a spritesheet I found randomly to try and render something.

13
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 04:38:53 pm »
I have tried to place it in all folders in the entire project.

I have also tried to give an absolute path. None of them works.
The picture is not corrupt either. I can open and edit the picture as I please.

14
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 04:17:49 pm »
Because I've tested it, and it works..?

The only problem there is with the first example is that it doesn't even load the sprite. Until that is solved, the rest won't really matter because there will be nothing to render.

15
Graphics / Re: Texture not Rendering on Screen
« on: May 24, 2013, 03:48:52 pm »
Now I've tried to construct an Image and Texture Object separately with the .NET binding instead.

Tells me it can't read my file. Can't load it. Just like in my C++ example.

void MainLoop()
        {
            Image sprite;
            //sprite = new Image("C:\\Users\\Vipar\\Dekstop\\sprite1.jpg");
            //imageManager.AddImage(sprite);
            Texture tex = new Texture("sprite.jpg");
            Sprite spr = new Sprite(tex);
            //testTile = new Tile(tex);

            while (window.IsOpen())
            {
                ProcessInput();
                Update();
                RenderFrame();
                window.Draw(spr);
            }
        }

Though in my other application using the C# binding it works just fine:

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

namespace SFMLCarGame
{
    class Program
    {
        private static RenderWindow window;
        private static Sprite car;

        static void Main(string[] args)
        {
            window = new RenderWindow(new VideoMode(256, 512), "Car Game");
            window.Closed += new EventHandler(OnClose);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            Sprite bg = new Sprite(new Texture("road.png"));
            car = new Sprite(new Texture("car.png"));
            car.Position = new Vector2f(window.Size.X / 2, window.Size.Y - 96);
            while (window.IsOpen())
            {
                CheckCollision();
                window.DispatchEvents();

                window.Clear();

                window.Draw(bg);
                window.Draw(car);

                window.Display();
            }
        }

        static void CheckCollision()
        {
            CarOutOfBoundsCheck();
        }

        static void CarOutOfBoundsCheck()
        {
            Vector2f newPos = new Vector2f(0, car.Position.Y);
            if (car.Position.X < 0)
            {
                newPos.X = 0;
                car.Position = newPos;
            }
            else if (car.Position.X > window.Size.X - 32)
            {
                newPos.X = window.Size.X - 32;
                car.Position = newPos;
            }
        }

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

        static void OnKeyPressed(object sender, EventArgs e)
        {
            Vector2f newPos = new Vector2f(car.Position.X, car.Position.Y);
            KeyEventArgs ke = (KeyEventArgs)e;
            if (ke.Code.Equals(Keyboard.Key.A))
            {
                newPos.X = car.Position.X - 8;
                car.Position = newPos;
            }
            else if (ke.Code.Equals(Keyboard.Key.D))
            {
                newPos.X = car.Position.X + 8;
                car.Position = newPos;
            }
        }
    }
}
 

Pages: [1] 2