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

Pages: [1]
1
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?


2
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!

3
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]
anything