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

Pages: 1 ... 7 8 [9] 10
121
General / How to code nicely with SFML?
« on: August 25, 2011, 11:30:05 am »
Hi Nexus!

I understand your feelings, and I believe you make all your suggestions with a good intention, and also what you're suggesting is good and it does work. For example, yesterday I've started to redesign the game internals and not only I get rid of a lot of dependencies and inconsistency, but everything seems to be more clear and well organised. Thank you for all this! :)

On the other hand, about prefixes, I think it's more about personal preference. I like to identify my stucts as structs, and I never use them as any other object but stucts. That is, they're all public. That's what they intended to be. Most of the time I regard them as containers, they don't even have any funcions inside, but their constructor to set them up. What you're talking about is much higher level of abstraction (like in Thor), which I'm trying to avoid all the time. I like to keep things simple and crystal clear.

But I'm also trying to learn from others, like as from you and from your work. There are practices however, which are just not for me. It's like when I was learning how to play the guitar, I absolutely hated the idea of tapping, even if they're cool and everybody goes crazy about it. It's jut ... it looks so stupid. :D

Cheers,
easy

122
General / How to code nicely with SFML?
« on: August 24, 2011, 08:11:13 pm »
I need to think the design of the code over again according what you've suggested.

As for the prefix issue:
- Typedefs: practically I don't use typedefs. I know I did, but I just cannot recall when I used them (it must have been a long time ago). What's the problem with them?

- Templates: I'm trying to avoid them, whenever it's possible. If they're a must, I only use them for smaller classes. Example:

template<class T> class CManager;

CManager<CEntity> entities;

123
General / How to code nicely with SFML?
« on: August 24, 2011, 06:35:43 pm »
Thanks for your answers Nexus!

I'm going to have a look at your project Thor and see how you handle all these situations.

I think yes, it's possible to separate graphics (sound, network, etc.) and logic in my case, too, but I think it's also logical that an object should take care of itself. You know the old examples of a the Box which is a class, and you can move/rotate/scale/draw it.

If I follow you correctly I should draw this Box in another place according to the parameters of the Box. In this case, Box is like a container. This way I can drop most of the dependencies of my classes. True, true and true. But I think this logic comes from the design of SFML.

About the "C" prefix: I use them on my classes. For the structs I use "S" and for the enums I use "E" prefixes.

124
General / How to code nicely with SFML?
« on: August 24, 2011, 05:46:35 pm »
Hello!

I've got concerns about the my current game code. It's going to be a simple game but with educative code inside, a proof-of-concept. It's more advanced than the provided pong example, so I needed to separate objects.

Currently I've got a bunch of .h and .cpp files:
    CAnimator - an animator class for animating sprites,
    CCamera - manages cameras for one or two players,
    CEntity - handles the players, monsters,
    CInterface - all the GUI stuff is in here,
    CLevel - manages the level related stuff,
    CGame - groups all these togther, [/list]

    It all works fine, and shaping up really nicely, but there are some things I don't like about it:
      - It's half this and half that: SFML has references all around, and my classes use pointers (the actual example below does not actually show the pointers)
      - Due to the SFML design, I'm not passing pointers but references to the constructors, which enforces me to initalize them on startup... which is exxxtremely restrictive
      - I like the clean design of SFML but I seem to not understand some basic concepts here... I'm a pointer-user guy


    For example, look at the following piece of code. You can see the animator  and the entity class constructors. Since the entity has 2 animators, I have to initiate them in the constructor. And the dependencies would grow from class to class.

    Code: [Select]
    //! Constructor
    CAnimator(sf::RenderWindow& Window, sf::Texture& Texture, int TileSize, sf::Sprite& Sprite,
              const SAnimation& Animation = SAnimation())
    : window(Window), texture(Texture), tileSize(TileSize), sprite(Sprite), animation(Animation)
    {
    /* ...*/
    }

    //! Constructor
    CEntity::CEntity(sf::RenderWindow& Window, sf::Texture& Texture, int TileSize, CLevel& Level,
                     CInterface& Interface, const sf::Vector2i& TilePos, int Direction)
        : window(Window), texture(Texture), tileSize(TileSize), level(Level), interface(Interface),
          tilePos(TilePos), direction(Direction),
          bodyAnimator(window, texture, tileSize, body), faceAnimator(window, texture, tileSize, face)
    {
      /* ... */
    }


    So, basically, I'd like advises on: How to code nicely with SFML?

    Thanks in advance,
    easy

    125
    SFML projects / iCE³ - clone of Minecraft
    « on: August 24, 2011, 02:32:48 pm »
    Quote from: "Kalith"
    Can you try this new binary ? No need for extensive testing, just run it once and wait for ~20sec, then exit.
    If everything runs fine, the log file should be approximately ~700Kb (each thread describes what it's doing, so with 4000 chunks it gets quite verbose). Then please upload it somewhere so I can take a look at it ;)


    I did try it yesterday evening, I just didn't have time to upload it until now.

    Here's the log file. It looks quite all right for me...

    I've played a longer period because I've been building a house. :D
    I still have the freeze-on-exit bug.

    126
    SFML projects / iCE³ - clone of Minecraft
    « on: August 23, 2011, 10:41:48 am »
    Quote
    When I have the time, I'll make a special release for you, which will output some more information in the log file. That should help to track down the issue.


    Okay, but I think you should leave most of the debug-log info in your game after! You'll never know when you'll need a logfile from a user, I always write out debug info to the console and into a file if the project is bigger.

    127
    SFML projects / iCE³ - clone of Minecraft
    « on: August 22, 2011, 07:38:47 pm »
    Quote
    ... that's what the compilation flag "-rpath ./" does actually, so you don't have to make that kind of script  


    Ok! I'm not that experienced with coding on Linux, I've been a Windows guy for many years...

    Quote
    That's an expected behavior if you took the first screen shot only after several seconds of gameplay. Is it still the same after ~20-30secs ?


    Yes, it didn't go lower.

    Quote
    Back on the original problem, can you try the Win32 version with wine ? It should work out of the box as well.


    I don't have Wine installed, sorry. :)

    128
    General / Input class cannot copy App.GetInput()
    « on: August 22, 2011, 07:32:08 pm »
    Use a reference there:

    sf::Input& Input;

    129
    Graphics / Line and Rectangle does not show up
    « on: August 22, 2011, 01:16:19 pm »
    Thanks SCPM!

    That really solved the problem.

    The fixed code is:

    Code: [Select]
    #include <SFML/Graphics.hpp>


    int main()
    {
        // Create the main window
        sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Test");

        sf::Shape line = sf::Shape::Line(0, 0, window.GetWidth(), window.GetHeight(), 5, sf::Color::Red);

        sf::Shape rectangle = sf::Shape::Rectangle(200, 200, window.GetWidth() - 400, window.GetHeight() - 400, sf::Color::Green);

        sf::Shape circle = sf::Shape::Circle(window.GetWidth() / 2, window.GetHeight() / 2, window.GetHeight() / 5, sf::Color::Blue);

        sf::Shape polygon;
        float cx = window.GetWidth() * 0.5f;
        polygon.AddPoint(cx - 1, 0, sf::Color::White);
        polygon.AddPoint(cx + 1, 0, sf::Color::White);
        polygon.AddPoint(cx + 1, window.GetHeight() * 1, sf::Color::White);
        polygon.AddPoint(cx - 1, window.GetHeight() * 1, sf::Color::White);

        while (window.IsOpened())
        {
            // Process events
            sf::Event Event;
            while (window.PollEvent(Event))
            {
                // Close window
                if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape) window.Close();
                if (Event.Type == sf::Event::Closed) window.Close();
           }

            // Clear screen
            window.Clear();

            // Draw objects
            window.Draw(line);
            window.Draw(rectangle);
            window.Draw(circle);
            window.Draw(polygon);

            // Update the window
            window.Display();
        }

        return 0;
    }


    Now that it is obvious, I've also found it in the wiki, even though I've already read it:
    http://www.sfml-dev.org/tutorials/1.4/graphics-shape.php

    Code: [Select]
    sf::Shape Line   = sf::Shape::Line(X1, Y1, X2, Y2, Thickness, Color, [Outline], [OutlineColor]);
    sf::Shape Circle = sf::Shape::Circle(X, Y, Radius, Color, [Outline], [OutlineColor]);
    sf::Shape Rect   = sf::Shape::Rectangle(X1, Y1, X2, Y2, Color, [Outline], [OutlineColor]);


    Next time I should read more carefully. :)
    Thank you!

    130
    Graphics / Line and Rectangle does not show up
    « on: August 22, 2011, 10:23:55 am »
    Hi!

    As the title states, sf::Line and sf::Rectangle does not work for me. I'm using SFML2 snapshot "LaurentGomila-SFML-9cda5d0" which was downloaded on 2011-08-19.

    Here's the minimal code:

    Code: [Select]
    #include <SFML/Graphics.hpp>


    int main()
    {

        // Create the main window
        sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Test");

        sf::Color red(255, 0, 0, 255);

        sf::Shape line;
        line.Line(0, 0, window.GetWidth(), window.GetHeight(), 5, red);

        sf::Shape rectangle;
        rectangle.Rectangle(100, 100, window.GetWidth() - 200, window.GetHeight() - 200, red);

        sf::Shape polygon;
        float cx = window.GetWidth() * 0.5f;
        polygon.AddPoint(cx - 1, 0, red);
        polygon.AddPoint(cx + 1, 0, red);
        polygon.AddPoint(cx + 1, window.GetHeight() * 1, red);
        polygon.AddPoint(cx - 1, window.GetHeight() * 1, red);

        while (window.IsOpened())
        {
            // Process events
            sf::Event Event;
            while (window.PollEvent(Event))
            {
                // Close window
                if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Keyboard::Escape) window.Close();
                if (Event.Type == sf::Event::Closed) window.Close();
            }

            // Clear screen
            window.Clear();

            window.Draw(line);
            window.Draw(rectangle);
            window.Draw(polygon);

            // Update the window
            window.Display();
        }

        return 0;
    }


    And the result:



    As you can see, neither the diagonal line nor the rectangle in the center shows up, only the polygon-line in the middle.

    Am I missing something obvious, or is it a bug?

    Cheers,
    easy

    131
    Graphics / SFML 2 Water Shader Problem
    « on: August 22, 2011, 10:03:51 am »
    I don't know how it works, but I'd do this:

    1. Render the scene to a texture
    2. Pass this texture (or a part of it) to the shader
    3. Draw the shaded surface

    I'm most definately telling you obvious things about shader programming which I absolutely don't know, so I just shut up from now :)

    132
    SFML projects / iCE³ - clone of Minecraft
    « on: August 22, 2011, 09:57:39 am »
    Yes I've thought too that maybe we have different versions of SFML, so I've opened the ice3 directory and seen that you've provided yours. To ensure that it loads these libraries, I've added a line to your startup script:

    Code: [Select]
    iCE3.sh:

    #!/bin/bash

    cd `dirname $0`
    export LD_LIBRARY_PATH=.
    ./iCE3


    By the way, after this I've also tried "ldd iCE3", and it seems to be fine:

    Code: [Select]

    linux-gate.so.1 =>  (0xb77f7000)
    libfreetype.so.6 => /usr/lib/i386-linux-gnu/libfreetype.so.6 (0xb7741000)
    libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb773d000)
    libsfml-window.so => ./libsfml-window.so (0xb7729000)
    libsfml-graphics.so => ./libsfml-graphics.so (0xb768c000)
    libsfml-system.so => ./libsfml-system.so (0xb7682000)
    libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7594000)
    libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb756e000)
    libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7550000)
    libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb73f6000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb73e2000)
    libGL.so.1 => /usr/lib/i386-linux-gnu/libGL.so.1 (0xb7310000)
    libGLEW.so.1.5 => /usr/lib/libGLEW.so.1.5 (0xb72b9000)
    libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb729f000)
    /lib/ld-linux.so.2 (0xb77f8000)
    libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb7165000)
    libGLU.so.1 => /usr/lib/i386-linux-gnu/libGLU.so.1 (0xb70f3000)
    libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb70cf000)
    libXrandr.so.2 => /usr/lib/i386-linux-gnu/libXrandr.so.2 (0xb70c7000)
    libnvidia-tls.so.280.13 => /usr/lib/i386-linux-gnu/tls/libnvidia-tls.so.280.13 (0xb70c3000)
    libnvidia-glcore.so.280.13 => /usr/lib/i386-linux-gnu/libnvidia-glcore.so.280.13 (0xb57b2000)
    libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xb57a0000)
    librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xb5797000)
    libXmu.so.6 => /usr/lib/libXmu.so.6 (0xb5781000)
    libXi.so.6 => /usr/lib/i386-linux-gnu/libXi.so.6 (0xb5771000)
    libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb5752000)
    libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0xb5748000)
    libXt.so.6 => /usr/lib/i386-linux-gnu/libXt.so.6 (0xb56eb000)
    libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb56e8000)
    libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb56e1000)
    libSM.so.6 => /usr/lib/i386-linux-gnu/libSM.so.6 (0xb56d9000)
    libICE.so.6 => /usr/lib/i386-linux-gnu/libICE.so.6 (0xb56c0000)
    libuuid.so.1 => /lib/libuuid.so.1 (0xb56bb000)


    This time, it loaded up without a freeze, and actuall when I've started goind off the hill I've seen a new chunk appearing, but then it stopped loading. So I've tried what you've said, to dig into the empty space (ice3-7.jpg) but as you can see, I only could dig into the loaded chunks. I've also tried to dig *and* go into the empty space, but it keeps blocking my character movement, so the collision works fine :)



    What Linux distro are you using (or used, when compiled your game and SFML)? This is Linux Mint, the debian-based version, 32bits. I've got 4Gb of RAM, Intel Core 2 Duo T6670 2.20Ghz CPU, nVidia GeForce 310M with 512Mb VRAM.

    I've started a system monitor and the game pretty much uses both my CPUs at 100% (ice3-8.jpg) and you can see the graph after I've killed the process (yeah, it has frozen again) on "ice3-9.jpg".





    Log:

    Code: [Select]
    [00:00:00:000] : Starting iCE3...
    [00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
    [00:00:00:055] : Done.
    [00:00:00:055] :
    [00:00:00:055] : New state : TestState.
    [00:00:00:234] : Minimum memory size of a block : 5
    [00:00:00:234] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
    [00:00:00:234] :
    [00:00:00:250] : Terrain generation info :
    [00:00:00:250] : World seed  : 3140
    [00:00:00:250] : Persistence : 0.5
    [00:00:00:250] : Frequency   : 0.01 (period : 100)
    [00:00:00:250] : Amplitude   : 50
    [00:00:00:250] : Octaves     : 5
    [00:00:00:250] :
    [00:01:00:978] :
    [00:01:00:978] : Closing state : TestState.


    Quote
    Yes, by default the program tries to load "NewWorld001", and if it doesn't exist, generate a new one. That's a temporary behavior, but it's good enough for testing purposes  You can safely delete the "Worlds" or "NewWorld001" directories when you want to start anew (my dustbin is full of it...).


    Note that it did exist, but it has crashed when loading it!

    Trying to start the game, and it just don't. Log:

    Code: [Select]
    [00:00:00:000] : Starting iCE3...
    [00:00:00:044] : Done.
    [00:00:00:044] :
    [00:00:00:044] : New state : TestState.
    [00:00:00:233] : Minimum memory size of a block : 5
    [00:00:00:233] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
    [00:00:00:233] :
    [00:00:00:249] : Terrain generation info :
    [00:00:00:249] : World seed  : 3140
    [00:00:00:249] : Persistence : 0.5
    [00:00:00:249] : Frequency   : 0.01 (period : 100)
    [00:00:00:249] : Amplitude   : 50
    [00:00:00:249] : Octaves     : 5
    [00:00:00:249] :
    [00:00:00:249] :
    [00:00:00:249] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
    [00:00:00:249] : Clearing old world...
    [00:00:00:270] : Done.
    [00:00:00:270] :
    [00:00:00:358] : # Error # : Main : World : Unit lookup list is outdated.
    [00:00:00:358] :
    [00:00:00:358] : Closing iCE3...
    [00:00:00:358] : Average FPS : nan
    [00:00:00:358] : Best FPS : 0
    [00:00:00:358] : Worst FPS : inf
    [00:00:00:358] :
    [00:00:00:359] : Done.


    Sigh... deleted the saved world, started again. Ok. Trying to remake a collision-fail example... Ok. It seems when you've got 3 empty cubes above and you jump, you can see through the ceiling. I've digged a tunnel for you, when startup just go forward to the bottom of the next hill and you'll find it there. Go until the glass cubes and jump! Ok I've made an asphalt arrow to show where the tunnel starts. So I was climbing up to the start mounting when I've literally fallen through the whole map, see "ice3-10.jpg"! :)



    And here's the saved world:

    http://data.hu/get/4156681/Saves.zip

    Scroll down, use the big gray "Lassú letöltés" button under the red signs!

    I don't know how long these sreenshots and this .zip is available, so you might consider saving them to you hdd.

    See if all these help you,
    Regards,
    easy

    133
    Graphics / SFML 2 Water Shader Problem
    « on: August 22, 2011, 12:18:35 am »
    Quote from: "lolz123"
    @ Easy: The name of the project is Gore Factor (I could not come up with something better). It uses a form of vector animation in combination with sprite animation. Here is a YouTube video, download link is in the description:

    http://www.youtube.com/watch?v=bI2sRM_N8Xc


    Thanks for the video! I haven't downloaded it yet, I guess it's for Windows, and I'm on Linux... But it look very smooth and detailed, I can see you've put a great amount of time into this project. Congratulations - and keep it up!

    I hope you're gonna make a multiplayer game of this!

    134
    SFML projects / iCE³ - clone of Minecraft
    « on: August 22, 2011, 12:13:10 am »
    Freezing is not random, see my complete bug report below.

    Yes, chunks on the edge stop loading and no more gets loaded. At least I can see no new chunks apprearing.

    I took some screenshots for you about everything, read on:

    Code: [Select]
    Froze on startup again -- I had to kill the process. Log:

    [00:00:00:000] : Starting iCE3...
    [00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
    [00:00:00:056] : Done.
    [00:00:00:056] :
    [00:00:00:057] : New state : TestState.
    [00:00:00:235] : Minimum memory size of a block : 5
    [00:00:00:235] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
    [00:00:00:235] :
    [00:00:00:252] : Terrain generation info :
    [00:00:00:252] : World seed  : 3140
    [00:00:00:252] : Persistence : 0.5
    [00:00:00:252] : Frequency   : 0.01 (period : 100)
    [00:00:00:252] : Amplitude   : 50
    [00:00:00:252] : Octaves     : 5
    [00:00:00:252] :
    [00:00:00:252] :
    [00:00:00:252] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
    [00:00:00:252] : Clearing old world...
    [00:00:00:272] : Done.
    [00:00:00:272] :

    So I've tried it again, but it has frozen on startup:

    [00:00:00:000] : Starting iCE3...
    [00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
    [00:00:00:049] : Done.
    [00:00:00:049] :
    [00:00:00:049] : New state : TestState.
    [00:00:00:228] : Minimum memory size of a block : 5
    [00:00:00:229] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
    [00:00:00:229] :
    [00:00:00:245] : Terrain generation info :
    [00:00:00:245] : World seed  : 3140
    [00:00:00:245] : Persistence : 0.5
    [00:00:00:245] : Frequency   : 0.01 (period : 100)
    [00:00:00:245] : Amplitude   : 50
    [00:00:00:245] : Octaves     : 5
    [00:00:00:245] :
    [00:00:00:245] :
    [00:00:00:245] : Loading world 'Saves/Worlds/NewWorld001/NewWorld001.wrld'...
    [00:00:00:245] : Clearing old world...
    [00:00:00:266] : Done.
    [00:00:00:266] :

    So I've cheated a bit and renamed "NewWorld001" to "aaaaaaaa_NewWorld001" in Saves/Worlds. And yes it started up again! I'm gonna take some screenshots for you right now of the edges... (A bit annoying that I have to ALT-TAB out of the window to get back my mouse pointer, otherwise it's not shown!)

    I've made 3 screenshots: "ice3-1.jpg" and "ice3-2.jpg" in on a border of the map, and then I've walked to the other end and took "ice3-3.jpg". After a couple of minutes I'm gonna take another screenshot for you of about 10 minutes playing.

    Oops.. I'm creating an underground tunnel (ice3-4.jpg) and if I jump up, I can jump through the ceiling and see the world from below. I'm gonna try to capture it... success (ice3-5.jpg).

    Okay, 10 minutes is over, here goes my last screenshot: "ice3-6.jpg".

    I've tried to press the close button an it froze again:

    [00:00:00:000] : Starting iCE3...
    [00:00:00:001] : # Warning # : Application : Lua::State : DoFile : can't open "Saves/Config.lua".
    [00:00:00:052] : Done.
    [00:00:00:052] :
    [00:00:00:053] : New state : TestState.
    [00:00:00:232] : Minimum memory size of a block : 5
    [00:00:00:232] : Minimum memory size of a chunk : 276 + 5 * 3375 = 17151
    [00:00:00:232] :
    [00:00:00:248] : Terrain generation info :
    [00:00:00:249] : World seed  : 3140
    [00:00:00:249] : Persistence : 0.5
    [00:00:00:249] : Frequency   : 0.01 (period : 100)
    [00:00:00:249] : Amplitude   : 50
    [00:00:00:249] : Octaves     : 5
    [00:00:00:249] :
    [00:12:02:281] :
    [00:12:02:281] : Closing state : TestState.














    I hope all these can help you!
    Cheers,
    easy

    135
    SFML projects / iCE³ - clone of Minecraft
    « on: August 21, 2011, 01:09:52 pm »
    Thanks! It's a very nice work!

    I've just tested it on Linux Mint Debian, the linux package worked out-of-the-box. However, on quitting it has frozen. Also, it seemed to me that no new chunks were loaded, that is I only had a certain area to play inside.

    Cheers,
    easy

    Pages: 1 ... 7 8 [9] 10
    anything