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

Pages: [1] 2
1
Despite the fact that text driven adventure games genre is not present anymore, it remind me of youth days which I’ve spend playing games like King’s quest, Quest for glory (and other Sierra like ones ;) ).

I’m not far into the story yet (mostly because I’m stuck ;)), yet the plot and artwork are just amazing.
What’s most important.. your game is just fun to play!  :)

Thank you very much for creating and sharing this “little masterpiece”!

2
General / Re: Game menu
« on: April 12, 2019, 09:22:14 am »
I also had a problem like this. I made a mini game but found difficult in creating a game menu. Did you completed it? Could you show me, please. your source code or a link, etc ... Thank everyone

Like it was mentioned previously, there could be lots of ways to implement this (nicox11 posted a very good article describing how it could be handled by using finite state machine).

If you would like see live code for further inspiration, feel free to browse through my long forgotten project (which is waiting for update and refactoring for a long time… ;) ) where I’ve handled menu by using FSM.

Link to repository: https://github.com/PawelWorwa/SFMLnake/tree/master/sources/states/menu

3
SFML projects / Re: Screenshot Thread
« on: March 01, 2019, 07:29:49 pm »
I’ve prototyped mechanism for animating 2D planet/fake sphere for my current project.
Although it’s not much I must say I like the output:

To achieve this I’ve browse through dozens of articles and discussions in quest for knowledge (and at some point also ended on SFML forum  ;)).
Leaving link to prototype in case someone, one day would need inspiration  :): https://github.com/PawelWorwa/Animated-Planet

4
Graphics / Re: How do you make a sprite follow another sprite?
« on: September 26, 2018, 11:55:23 am »
Hello,

As everything, this could be achieved using various approaches.
The one that I would suggest would look like something below (I’m writing this outside of compiler so please threat this only as pseudocode – just to show the logic). Keep in mind that potential collision with environment is omitted here.

// object containing npc related information like its sprites and methods for handling movement, getting position etc.
std::vector<NPC> party;

public void moveParty(Direction direction) {
    for (int i=0; i<party.size(); ++i) {
        NPC currentNpc = party.get(i);
                               
        if ( i == 0 ) { // first NPC
            bool isMovementPossible = COLLISION_CHECKING_METHOD();
            if (!isMovementPossible) {
                break;  // movement is not possible
            }
                                       
            sf::Vector2f currentPosition = currentNpc.getPosition();
            currentNpc.updateLastPosition(currentPosition);
            currentNpc.move(direction);
                       
        } else { // other NPC's are just following
            NPC previousNpcLocation = party.get(i - 1).getLastPosition();
            currentNpc.moveToPosition(previousNpcLocation);
        }
    }
}

Above is shown at example of some npc party but the same logic would apply for one entity build from many sprites (like snake for example). It’s just a matter of defining main object name (npc, snake or whatever).

I think you’ll get the idea  :)

5
SFML projects / Re: SFMLnake - Snake clone
« on: August 20, 2018, 11:45:59 am »
Hi Grundkurs,

No, I haven’t tried out mingw-w64 compiler yet - thanks for info :).

As I mentioned before, found out that but some odd reason got issues only with cpp11 std::to_string method, so used workaround without focusing too much on this issue.
But I’ll try out new compiler (if not with this project than with another  :))

6
SFML projects / Re: SFMLnake - Snake clone
« on: July 03, 2018, 10:28:14 pm »
Hello Hapax,

Thank You for hint… but I’m afraid it’s not so trivial :)

#include <string>

int main() {
    std::to_string(1);
    return 0;
}

(...)>g++ -std=c++11  main.cpp
main.cpp: In function 'int main()':
main.cpp:4:5: error: 'to_string' is not a member of 'std'
     std::to_string(0);
     ^

gcc version 4.9.2 (tdm-1) (Standard MinGW 32-bit Edition as I'm still using 2.4.2 SFML version)

But it’s not really important for this topic :)

7
SFML projects / Re: SFMLnake - Snake clone
« on: July 02, 2018, 11:37:23 pm »
Quote
What compiler issues with std::to_string?
error: 'to_string' is not a member of 'std'

Stopped fighting with it...

8
SFML projects / Re: SFMLnake - Snake clone
« on: July 02, 2018, 10:19:02 pm »
Hello FRex,

No offense taken as I was hoping for some constructive criticism - thank You very much for all the time You've taken for review.

About “overengineering” part… I’m aware of that as main part for this project was to learn couple of new things (cmake basic, trying out new patterns, learning new tools like Travis and SonarCloud). As it was easier for me to learn by doing, this project is somehow result of this process. Yet… it may went a little too far  :(.

Clarifying two things:
Quote
“I also don't get why you've included all the SFML headers in your repo. Does CMake somehow require that?”
It’s artifact from linking project with Sonar/Travis (which I disabled at the end realizing it was a little bit overkill) - it was easier to build project using included dependencies than creating script to download, extract and include library each time. Yet true, it’s unnecessary for source code.

Quote
“There is an std::to_string since C++11 and you use C++11…”
Got some issues with compiler and decided to use a walkaround.

For the rest of comments, point taken  :)

Once again thank You for You’re time.

Best regards
Grenthal

9
SFML projects / SFMLnake - Snake clone
« on: June 24, 2018, 07:09:06 am »
Hello Community members,

As a part of my learning process I’ve created yet another snake clone… their pretty popular around here recently
What makes this project special?. As I’ve created some basic “clones” in the past like Pong, Arkanoid and Tetris but this one as only went all the way to actual final 1.0v :).
Yes, it’s my first fully finished project.

Any thoughts and feedback really appreciated.

Github project:
https://github.com/PawelWorwa/SFMLnake

Windows binaries:
https://github.com/PawelWorwa/SFMLnake/releases/tag/v1.0.0

Linux/Mac binaries:
Well I’m afraid it’s required to compile project using included cmake file.

Controls:
Arrows – movement
m key – turn music on/off

Screenshots from game:
(click to show/hide)

10
SFML projects / Re: Simplex Noise generator
« on: July 24, 2017, 08:26:14 pm »
Hello community Members,

as a quick update: I’ve made some changes within a source code (simplified it a bit and fixed one 'issue' with gradient's).

I don’t want to create another topic, so I’ll post here for what I'm currently using noise generator: as a random map generator. Below sample outputs (continental and island type maps):


While it may not be much... I feel quite happy with the generated results  :)

Best regards

11
SFML projects / Re: Simplex Noise generator
« on: July 22, 2017, 12:49:10 pm »
Hi FRex,

Thank You for feedback. As for Your question, fact it’s a different kind of noise (Perlin Noise was depreciated by its author, making Simplex Noise it’s successor) does not matter as logic You mentioned lies purely on visualisation side.

While I’ve left functions inside main file only for debug purposes... after making some tests I must admit that way described in article You provided is much more time efficient. It’s a way faster (assigning pixels to texture instead of drawing them directly).

I believe I’ve achieved something similar You mentioned (updated code) – thank You for hint.

Best Regards

12
SFML projects / Simplex Noise generator
« on: July 20, 2017, 02:44:36 pm »
Hello Community Members,

I know that there were project like this in past... nevertheless I wanted to create own or to be more precisely - port existing algorithm from other language with couple of additional functionality. Mostly for further project, that required random terrain generation.

Putting it all together there it is: Simplex Noise generator for 2D plane. I’ve used SFML to visualise output, it looks like this (greyscale):



If anyone is interested, here’s the code: https://github.com/PawelWorwa/SimplexNoise

Any feedback appreciated  :)


13
General / Re: White square issue after accesing resource from std::map
« on: October 05, 2016, 09:55:34 pm »
Finally it’s starting to make sense  :). Thanks for a clear and straight answer.

14
General / Re: White square issue after accesing resource from std::map
« on: October 05, 2016, 08:04:05 pm »
Thank You for Your response Dabbertorres.
I’ve made some research and refactored LocalTitleManager to a working state as presented below:
class LocalTitleManager {
    public:
        void create( void ) {
            loadTextures();
            createGrassTitle();
        }

        void loadTextures( void ) {
            sf::Texture texture;
            texture.loadFromFile("title.bmp");
            textures[LocalTitleType::Grass] = texture;
        }

        LocalTitle& getTitleRef( LocalTitleType titleType ) {
            return titles.at( titleType );
        }

    private:
        std::map< LocalTitleType, LocalTitle > titles;
        std::map< LocalTitleType, sf::Texture > textures;

        void createGrassTitle( void ) {
            LocalTitle title;
            title.create();
            title.setTexture( textures.at(LocalTitleType::Grass) );

            titles[LocalTitleType::Grass] = title;
        }
};

Question now it’s... why does it work?. Its the same logic as before, yet in this example sf::Texture is not going out of scope.

What am I missing?

void loadTextures( void ) {
            sf::Texture texture; // the same logic as before, yet it works
            texture.loadFromFile("title.bmp");
            textures[LocalTitleType::Grass] = texture;
}

15
General / White square issue after accesing resource from std::map
« on: October 05, 2016, 04:55:59 pm »
Hello Community,

I’m facing "strange" (in my opinion) issue – infamous white square problem, in which I can’t find its source.
I’ m well aware of official tutorial (http://www.sfml-dev.org/tutorials/2.3/graphics-sprite.php#the-white-square-problem) – used it couple of times, but this time I just don’t see what might be causing an error.
Also, I’ve searched forum for similar issue but as it seems each case is different and uique in its own way…

Describing my issue in couple words: I’m trying to create title manager – class that’s storing titles inside std::map container, so I could access them when necessary. The issue is, when I’m creating “plain” Title object – it’s drawn without problem. Once I store it inside container and try to access it, all I’m receiving is white square.

I’m a little bit stuck at this moment, so any suggestion would be very appreciated.

Minimal code provided below:

#include <SFML/Graphics.hpp>

enum class LocalTitleType {
    Grass
};

class LocalTitle {
    public:
        static const int WIDTH = 64;
        static const int HEIGHT = 64;

        void setTexture( sf::Texture &texture ) {
            title.setTexture( &texture );
        }

        sf::RectangleShape getTitle( void ) {
            return title;
        }

        void create( void ) {
            title.setSize( sf::Vector2f( WIDTH, HEIGHT ) );
        }

    private:
        sf::RectangleShape title;
};

class LocalTitleManager {
    public:
        void create( void ) {
            createGrassTitle();
        }

        LocalTitle& getTitleRef( LocalTitleType titleType ) {
            return titles.at( titleType );
        }

    private:
        std::map< LocalTitleType, LocalTitle > titles;

        void createGrassTitle( void ) {
            sf::Texture texture;
            texture.loadFromFile("media/textures/titles.png"); //one texture for simplicity

            LocalTitle title;
            title.create();
            title.setTexture( texture );

            titles[LocalTitleType::Grass] = title;
        }
};

int main() {
    LocalTitleManager manager;
    manager.create();

    sf::RenderWindow window( sf::VideoMode( 200, 200 ), "Title Manager Test" );
    while ( window.isOpen() ) {
        sf::Event event;
        while ( window.pollEvent( event ) ) {
            if ( event.type == sf::Event::Closed )
                window.close();
        }// while

        window.clear();

        LocalTitle title = manager.getTitleRef( LocalTitleType::Grass );
        window.draw( title.getTitle() ); /** here's the issue */

        /** white square problem is not existent using below:
        sf::Texture texture;
        texture.loadFromFile("media/textures/titles.png"); //one texture for simplicity
        LocalTitle localTitle;
        localTitle.create();
        localTitle.setTexture( texture );
        window.draw( localTitle.getTitle() );
        */


        window.display();
    }// while

    return EXIT_SUCCESS;
}


I know that issue lies inside “LocalTitleManager” Class, in this method precisely:
void createGrassTitle( void ) {
   sf::Texture texture;
   texture.loadFromFile("media/textures/titles.png"); //one texture for simplicity

   LocalTitle title;
   title.create();
   title.setTexture( texture );

   titles[LocalTitleType::Grass] = title;
}

...but according to my knowledge, once I’ve created desired texture, attach it to LocalTitle class and finally store it in Container, it should work.

What am I missing?

Thank You for You’re help in advance

Pages: [1] 2
anything