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 - The Terminator

Pages: 1 2 [3]
31
Graphics / Are resource managers really necessary?
« on: August 13, 2012, 01:47:48 pm »
I've written a resource manager, and I think honestly it's more pain than just using the plain old methods for the individual objects like textures, soundbuffers, etc. Do you guys think that a resource manager is worth it for a smallish game (under 20000) lines? If so, could you explain why?

32
Graphics / Is this possible?
« on: August 13, 2012, 01:56:55 am »
For my collision detection, is it possible to create a sprite and assign it a sf::Rect<int> for collision checking? If this is possible, would it be easier and more simple than comparing the height + width with just a sprite? I know you can use contains to see if two rects are intersecting, but how would I use it with a sprite?

33
General discussions / Does Code::Blocks have support for C++11?
« on: August 12, 2012, 08:31:36 pm »
I am trying to use Code::Blocks for my SFML engine, but I cannot use some c++11 features such as unique_ptr. It recognizes it, but whenever I try to use it I get an error. Do I need to upgrade my gcc? If so do you guys know to what?

34
General / State Machine and Engine problem
« on: August 03, 2012, 11:30:06 pm »
I'm having some issues with calling a function through an object pointer in my game state class:

    class GameState {
    public:
        virtual void init(Engine*) = 0;
        virtual void cleanUp() = 0;
       
        virtual void pause(Engine*) = 0;
        virtual void resume(Engine*) = 0;
       
        virtual void handleEvents(Engine*) = 0;
        virtual void update(Engine*) = 0;
        virtual void draw(Engine*) = 0;
       
        void changeEvent(Engine* game, GameState* state) {
           
        }
    };

Every single line gives me errors, because of the Engine pointers I'm trying to make. (and yes I have included the Engine.h file) But, when in my Engine.h file when I use the GameState pointers, they work fine:

    class Engine {
    private:
        sf::RenderWindow window;
        sf::Event event;
       
        std::vector<GameState*> states;
       
    public:
        void init();
        void start();
        void cleanUp();
       
        void changeState(GameState*);
        void pushState(GameState*);
        void popState();
       
        void handleEvents();
        void update();
        void draw();
    };

I think it's some sort of initialization problem, once class getting defined before the first, but I don't know how to fix it. Any help is appreciated, thank you for your time.

35
Graphics / Resource Manager
« on: July 25, 2012, 05:23:46 pm »
I'm trying to create a resource manager, here's my main abstract class for the other managers to inherit from. I'm trying to use a templated class so it can be generic:

Manager.h:

namespace ShockEngine {
    template<class T> class Manager {
    protected:
        std::map<std::string, T> mediaList;
       
    public:
        virtual T getMedia(const T& fileName) = 0;
    };
}

Here's my texture manager, which is a derived class of Manager:

TextureManager.h:

#include "Manager.h"

namespace ShockEngine {
    class TextureManager: public Manager<sf::Texture> {
    protected:
        std::map<std::string, sf::Texture> textureList;
       
    public:
        TextureManager();
        virtual ~TextureManager();
       
        Manager<sf::Texture> addMedia(const std::string& fileName);
    };
   
    static TextureManager textureManager;
}

When I try to build and run this, 3 errors come up with my static definition of a texturemanager object, saying "Variable type TextureManager is an abstract class" I've tried to rewrite the template, use different techniques, but nothing works.

36
Graphics / Won't let me do this
« on: July 24, 2012, 07:26:44 pm »
For my texture manager I'm trying load a .png file and it keeps giving me an error.

void Engine::loadTextures() {
        if (textureManager->loadTexture("tileset.png")) {
            rw->draw(textureManager->getTexture("tileset.png"));
        }
}

When I'm trying to draw to the renderwindow (rw) it gives me this error: "No matching member function for call to 'draw'

Heres my .h file of my TextureManager class:

namespace Engine {
    class TextureManager {
    private:
        std::map<std::string, sf::Texture> textureList;
       
    public:
        TextureManager();
        ~TextureManager();
       
        bool loadTexture(std::string fileName);
        sf::Texture getTexture(std::string fileName);
       
    };
   
    static TextureManager* textureManager;
}

And .cpp file:

Engine::TextureManager::TextureManager() {
   
}

Engine::TextureManager::~TextureManager() {
   
}

bool Engine::TextureManager::loadTexture(std::string fileName) {
    sf::Texture tempTexture;
   
    if (!tempTexture.loadFromFile(resourcePath() + fileName))
        return false;
       
    textureList[fileName] = tempTexture;
    return true;
}

sf::Texture Engine::TextureManager::getTexture(std::string fileName) {
    return textureList[fileName];
}

Anybody know what the problem is?

37
Graphics / std::vector or std::map for texture manager
« on: July 23, 2012, 11:54:51 pm »
Hey guys, I'm making a tilemap game, and for the textures (player, tiles, etc) should I use a vector or a map to hold them? I want to assign all the tiles a specific value, like for example water's key would be 1. Which would be better for what I'm doing? I'm thinking map because you can hold the textures with a value, am I right?

38
Graphics / Best way to create tilemaps?
« on: July 23, 2012, 03:29:14 am »
For my engine that I'm creating, I want to include tilemap support. The problem is, I want several different things and I don't really know how to do it in a clean, simple way. A way that I know I could do it is with multidimensional arrays and manually assigning them in code, but I'm not so sure that's the easiest way. Is there a way to read the values from a txt file or XML file? I also want to make it to where some tiles have collision against them. Like for example, if you attempt to run onto a rock tile, you would collide against it and stop. Same with water, etc. Help is greatly appreciated, thank you for your time.

39
Hi there, I'm relatively new to SFML and I have successfully made a pong clone, and I'm working on my own 2d game engine. So far, I have implemented a texture manager, a state machine for the actual engine, and a bounding box collision system. Everything works, I have tested it all already. The one thing I'm having trouble with though, is how the main menu buttons are going to work. I need some help figuring out a class for the main menu, and it's methods that will check if the mouse is clicking or hovering over some text. For example, I want 2 buttons, which are play and exit, that when you hover over the text, it will change colors and when you click it, it will either start the actual game, or exit the program.

Any help is hugely appreciated, and thank you for your time.

Pages: 1 2 [3]