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

Pages: 1 ... 12 13 [14] 15
196
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?

197
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?

198
General / Re: State Machine and Engine problem
« on: August 10, 2012, 10:49:37 pm »
I found out the problem. SFML 2 does not support Xcode's C++11 so, I will have to manually compile my code.

199
General / Re: State Machine and Engine problem
« on: August 10, 2012, 09:03:12 pm »
Heres the full error, sorry about that:

"sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)", referenced from:

ShockEngine::SplashScreenState::SplashScreenState(bool) in SplashScreenState.o

"sf::Window::create(sf::VideoMode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, sf::ContextSettings const&)", referenced from: ShockEngine::GameEngine::GameEngine(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int, unsigned int, bool) in Engine.o

That's all it gives me. And yes, the original examples work.

200
General / Re: State Machine and Engine problem
« on: August 10, 2012, 08:42:48 pm »
Sorry to break up you guys's "discussion"  ;) but when I was trying out your code eXpl0it3r, I get 2 errors from the screen.create and the texture loadfromFile. It says this for screen.create:

"sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)", referenced from:
      ShockEngine::SplashScreenState::SplashScreenState(bool) in SplashScreenState.o

And loadFromFile:

"sf::Window::create(sf::VideoMode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, sf::ContextSettings const&)", referenced from:
      ShockEngine::GameEngine::GameEngine(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int, unsigned int, bool) in Engine.o

I triple checked all your code, and everything is matching, but the problem persists. Any idea what the problem could be? I am using Xcode if that matters at all.

201
General / Re: State Machine and Engine problem
« on: August 04, 2012, 02:28:55 pm »
Yeah I was taking some concepts from Game Dev Geek, but the code was really weird and didn't make much sense in some places. I really like how you manage game states, I will probably take the concept of yours and modify it to how I like. Thanks a lot!

202
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.

203
Graphics / Re: Resource Manager
« on: July 26, 2012, 06:50:22 pm »
No it's ok guys, I got the thing sorted out and I threw my old design out and created a new one that actually works lol. Thanks for the help anyways.

204
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.

205
Graphics / Re: Won't let me do this
« on: July 24, 2012, 10:17:10 pm »
It works! I can't believe I forgot about loading to a sprite.. lol....

206
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?

207
Graphics / Re: std::vector or std::map for texture manager
« on: July 24, 2012, 05:35:27 pm »
I'm developing on my mac, on xcode, do you know exactly how to link thor in? I have successfully made the libraries  in Cmake.

208
Graphics / Re: std::vector or std::map for texture manager
« on: July 24, 2012, 05:27:18 pm »
I'll look into thor. Do you mean by "maps" tilemaps?

209
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?

210
Graphics / Re: Best way to create tilemaps?
« on: July 23, 2012, 06:16:51 pm »
All the tiles are going to be the same size which is 16x16 pixels, but thanks for the info

Pages: 1 ... 12 13 [14] 15