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 - Lord Wolfram

Pages: [1]
1
General / Re: Errors while developing SFML Platformer engine
« on: February 26, 2017, 09:15:34 pm »
Alright so how do I do that, I had tried few ways to make constructor but all ended  up wrong, so what kind of ways should I use to make that default constructor, and in which class?

2
General / Errors while developing SFML Platformer engine
« on: February 26, 2017, 07:45:21 pm »
So I've been following this guy with his tutorial on 2D platformer
https://youtu.be/T6o5OlgsCew?t=185
And when you see him compiling for first time, he gets the animation, but for me I get some errors:

main.cpp:176:62: error: no matching function for call to 'Animation::Tick(time_t (__attribute__((__cdecl__)) &)(time_t*))'

stl_map.h:504:59: error: no matching function for call to 'Animation::Animation()'


The whole class looks like this:

// Animation class
class Animation
{
public:
    std::vector<IntRect> Frames, Frames_flip;
    float CurrentFrame, Speed;
    bool Flip, IsPlaying;
    Sprite sprite;

    Animation(Texture &t, int x, int y, int w, int h, int Count, float speed, int Step)
    {
        Speed = speed;
        sprite.setTexture(t);

        CurrentFrame = 0;
        IsPlaying = true;
        Flip = false;


        for (int i = 0; i < Count; i++)
        {
            Frames.push_back( IntRect(x+i*Step,y,w,h));
            Frames_flip.push_back( IntRect(x+i*Step+w,y,-w,h));
        }
    }


    void Tick(float Time)
    {
        if (!IsPlaying) return;

        CurrentFrame += Speed * Time;

        if (CurrentFrame> Frames.size())
            CurrentFrame -= Frames.size();


        int i = CurrentFrame;

        sprite.setTextureRect( Frames[i] );
        if (Flip) sprite.setTextureRect( Frames_flip[i] );

    }

};

// Animation Manager Class
class AnimationManager
{
public:
    String CurrentAnim;

    std::map<String, Animation> animList;

    AnimationManager()
    {

    }

    void Create(String Name, Texture &t, int x, int y, int w, int h, int Count, float Speed, int Step)
    {
        animList[Name] = Animation(t,x,y,w,h,Count,Speed,Step);
        CurrentAnim = Name;
    }


    void Draw(RenderWindow &window, int x = 0, int y = 0)
    {
        animList[CurrentAnim].sprite.setPosition(x,y);
        window.draw(animList[CurrentAnim].sprite);
    }

    void Set(String name) { CurrentAnim = name; }

    void flip (bool b) { animList[CurrentAnim].Flip = b; }

    void tick(float Time) {animList[CurrentAnim].Tick(time); }

    void pause () {animList[CurrentAnim].IsPlaying = false;}

    void play () {animList[CurrentAnim].IsPlaying = true;}
};

 


So yeah, what's exactly going on here? Should I show the full code at some point?


3
System / Re: Game states and OOP
« on: January 28, 2017, 12:18:36 am »
yea, Cannot pay, but I came up myself with a nice solution, almost....

But the Render window function is non-copyable as I Noticed, any way to bypass it?

EDIT: I solved this, now I can run screens from my functions :D

Now I can advance further and see what else to try.

4
System / Re: Game states and OOP
« on: January 27, 2017, 02:43:58 pm »
I guess putting random code wasn't doing what I wanted, well I was tired and couldn't think right but here anyways is my code:

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace sf;

// Main
int main()
{

    // Create the main window
    RenderWindow app(VideoMode(256, 160), "game");

     //Setting up variables for Title screen
    Clock clock; // Clock variable for timers
    Texture ScreenTexture;
    Texture StartButtonTexture;
    ScreenTexture.loadFromFile("TitleScreen.png");
    StartButtonTexture.loadFromFile("GameStart.png");
    Sprite TitleScreen(ScreenTexture);
    IntRect GameStartRectangle(0,0,62,15);
    Sprite GameStart(StartButtonTexture, GameStartRectangle);
    GameStart.setPosition(97, 130);
    Music TitleMusic;  
    TitleMusic.openFromFile("song.ogg");
    TitleMusic.play();

        // Start the Title screen loop
    while (app.isOpen())
    {
        // Process events
        Event event;
        while (app.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                app.close();
        }

        // Animating the game start text in title screen
        if (clock.getElapsedTime().asSeconds() > 0.35f)
            {
              if (GameStartRectangle.left == 62)
                GameStartRectangle.left = 0;
              else
                GameStartRectangle.left += 62;

              GameStart.setTextureRect(GameStartRectangle);
              clock.restart();
            }

        // Drawing section //

        // Clear screen
        app.clear();

        // Draw the sprite
        app.draw(TitleScreen);
        app.draw(GameStart);

        // Update the window
        app.display();
    }
    return 0;
}

Kinda nice code right, it shows a window, Title screen to be precise but I want to do this:
* Make a new class and store everything that's related to drawing the title screen and all animations.
* Render the window in main class and manage the other classes and states, also objects like player and enemies, while the new class just provides the resources like images and so on.
* When I press Return, I can change the titlescreen to game screen. (With screenfade in and out)
* Loading and unloading data when state is having some sort of event, for example the class that handles a game stage, when player dies, change the screen to new class and window state GameOver.



5
System / Game states and OOP
« on: January 27, 2017, 03:53:13 am »
It's been a little while since I last came here.
I've followed many interesting tutorials and made simple games, like tetris and snake... anyways.
I've started to make a small project I hope to get some money with  ;) as I need to eat too.
But well after few hours of coding I run into some problems. I'll start with easier one.
For some reason I cannot store a value within a function, what I mean is I want to do something like this:

Main Class:
// Main
int main()
{
    // Create the main window
    RenderWindow app(VideoMode(256, 160), "coolgame");

    while (app.isOpen())
    {
        Event event;
        while (app.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                app.close();
        }

         DrawingClass()::Draw(app);

}

return 0;
}



and here would be the drawing class

DrawingClass::Draw(RenderWindow window)
{
        // Clear screen
        window.clear();

        // Draw the sprite
        window.draw(cutie);

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

I get an error:
no match for call to '(sf::Sprite) ()'



So uhh.... how do I make this work?

Other thing when I try to work with enums to change the game state, I.E. playing or menu, I don't really make it work out nice. I've searched several tutorials and all that but nope.

What I want to do each time I switch states. I want to load data and unload data I won't use.
Save specific data in a file and then read the data from the file for next state or when person wants to play the game other time, well like high score I want to save.

Right now that's all I can think off what to say.
Thank you for your help!

6
General / Re: Newly Compiled sfml not working.
« on: January 10, 2017, 12:28:17 am »
Thanks both of you for your great help, I finally managed to set up the project quite nicely.
Best regards to both of you.
JamesL, thru art a true help, thanks to you I made it running great, you should put your tutorial as an official one.

eXpl0it3r, thru art a true help  too. Thanks to you I have learned more about libraries. I am used to see them with the extension .dll but now I know more than that.

Thanks both of you. Now I shall advance to making games, and thee shall see some fine pieces.

7
General / Re: Newly Compiled sfml not working.
« on: January 09, 2017, 12:18:17 am »
The dependencies are shipped with SFML's source code. When building the INSTALL project or target the dependencies would get installed automatically. Since you apparently didn't do that, you'll have to copy them manually from the extlibs/libs-mingw/x86 directory.

Funny enough but when I compiled both Debug and Release, I did use the install target.

Alright, where I place those libs?
Alongside the .exe or where exactly.

8
General / Re: Newly Compiled sfml not working.
« on: January 08, 2017, 10:46:59 pm »
Thank you so far for your help, the errors have been reduced to 9.
So as far as I understand it, the compiler cannot find the dependencies? How to make him find that, I saw no files with those names.

Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s -lsfml-window-s -lsfml-audio-s -lsfml-system-s -lopengl32 -lfreetype -ljpeg -lwinmm -lgdi32 -lopenal32 -lflac -lvorbisenc -lvorbisfile -lvorbis -logg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lfreetype
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -ljpeg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lopenal32
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lflac
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbisenc
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbisfile
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lvorbis
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -logg
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
9 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

Who knows maybe the linker order is wrong.
https://www.dropbox.com/s/9phba8mfh182ai4/Capture.PNG?dl=0

So yeah, what do we do now.

Thank you for your help!

9
General / Re: Newly Compiled sfml not working.
« on: January 08, 2017, 03:18:39 pm »
The files in Debug build of SFML are named like this:
sfml-graphics-s

But the tutorial specified that I must write -d. In any case I changed the -d to -s
making it into sfml-graphics-s-d causes an error just like the one above.

But if we just link this:
sfml-graphics-s
We get a new set of errors:

Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s -lsfml-window-s -lsfml-system-s
obj\Debug\main.o: In function `main':
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:5: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:6: undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:7: undefined reference to `_imp___ZN2sf5Color5GreenE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:7: undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:15: undefined reference to `_imp___ZN2sf6Window5closeEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:12: undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:18: undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:18: undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:19: undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:19: undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:20: undefined reference to `_imp___ZN2sf6Window7displayEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:9: undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
D:/Projects/C++/SFML Games/Aurelium/main.cpp:23: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
obj\Debug\main.o: In function `ZN2sf11CircleShapeD1Ev':
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
D:/Projects/C++/SFML Games/SFML/SFML-2.4.1/include/SFML/Graphics/CircleShape.hpp:41: undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
21 error(s), 0 warning(s) (0 minute(s), 1 second(s))

Now what?

Thank you for your help so far!

10
General / Re: Newly Compiled sfml not working.
« on: January 08, 2017, 03:00:55 pm »
When you build SFML, you should build the install target, that way you get all the proper libs installed. Also follow the official and most recent tutorial for Code::Blocks, because GLEW isn't part of SFML for a long time already...

Well then, I tried to rebuild the entire thing, followed the tutorials and yet again got these errors:
Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -g -I"D:\Projects\C++\SFML Games\SFML\SFML-2.4.1\include" -c "D:\Projects\C++\SFML Games\Aurelium\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-Build(debug)\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-d -lsfml-window-d -lsfml-system-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window-d
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system-d
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 3 second(s))
4 error(s), 0 warning(s) (0 minute(s), 3 second(s))

Well this time there are only 4 of them. I honestly have no idea what is here being done wrong.
NOTE: I used to work in Visual C++ .NET
My friend told me to move to Code::Blocks
I followed the latest version and latest tutorials. But no, not working.

My Code::Blocks version- codeblocks-16.01mingw

Compiler GNU GCC Compiler

OS: Microsoft Windows 7

Maybe I must download specific SFML version? Any would work that's 2.0 or so.
Or maybe other Code::Blocks version. Compiling process seems to be not a solution for some reason.

Thank you for your help!

11
General / Newly Compiled sfml not working.(SOLVED)
« on: January 08, 2017, 12:46:19 am »
I bid hello to this great community, it's nice to be in such a great place, will make sure to share my new sfml projects with you guys!!!! But sadly I cannot do that yet because.....

I had found out that so I can work with sfml 2.4.1, I must recompile it with CMake and Code::Blocks, the IDE I'm using. The compiling process was successful, but once I wanted to set up the project the fun started....
I had to face 50 errors first. Now I have reduced them to 5.
Here are the errors!
Quote
-------------- Build: Debug in Aurelium (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"D:\Projects\C++\SFML Games\SFML\SFML-2.4.1\lib" -o bin\Debug\Aurelium.exe obj\Debug\main.o   -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d -lglew -lfreetype -ljpeg -lopenal32 -lopengl32 -mwindows
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lglew
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lfreetype
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -ljpeg
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lopenal32
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 1 second(s))
5 error(s), 0 warning(s) (0 minute(s), 1 second(s)) 0 second(s)


The compiler itself works fine, I said Hello to the world and it was fine.
Now, here are my linkers:
https://www.dropbox.com/s/u4tmzgr5dhcdba6/linkers.PNG?dl=0

I am grateful for your help, and hope to have the solution to this problem to be done pretty soon.

Pages: [1]