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

Pages: 1 2 3 [4] 5 6 7
46
Hello, BonBons! Thank you for your kind words. I'm really glad you're enjoying the book so far. :)

By tiled, do you mean the Tiled Map Editor? (http://www.mapeditor.org/) If you do, I'm afraid I have no experience with it and wouldn't know if they even use the same type of elevation principles, not to mention other parameters necessary for their own format. I'm sure you could build a tool that somehow parses their format and writes it out however you want, but I can't say too much without looking at it.

If you simply mean how a map file like that can be saved, there's a big hint at the top of the file. As you can see, it's all saved as plain-text, making it easy to read and understand should you want to make revisions. All the lines that begin with the pipe symbol "|" are ignored by the code and treated as comments. Just above each new type of map file entry, there's a comment that explains exactly what parameters are stored in that line. For example, entities are stored by writing in the name of the entity type first, then the X and Y coordinates of the entity, and finally the elevation. Tiles store an additional value for their solidity, which can be either 0 or 1. That's pretty much all there is to it. If you can do basic file I/O, you know enough to save your entities and tiles in this format.

Hopefully this answers your question. I'm currently working on something that I can't say too much about, but let's just say that a portion of it deals with creating software that helps you build your own maps really easily. It should be out soon, so stay tuned. :)

47
Thanks for making it available and sharing your knowledge. I  am your happy customer. :)
Thank you for your kind words! I'm really glad to know you found it useful. :)

48
Hello again, Bryan,

I'm glad you got the code working! The shlwapi.lib inclusion is actually covered in the beginning of Chapter 6, as well as Shlwapi.h and Windows.h. I actually doubt that PathCch.h is required. You can give it a try and remove it, as the code runs just fine on my end without it. As far as the .txt extensions, someone else had the same issue. Were they like that in the code package you downloaded? If so, it might be something worthy of reporting to Packt, as it clearly wasn't intended to be like that.

Please feel free to let me know if you have any more issues. I will do my best to help you whenever possible. :)

49
Hello Bryan,

First of all, thank you for buying the book. I really hope you are enjoying it so far, and sorry about the problems you're experiencing.

For the first issue, somehow the type definitions didn't get updated along with the rest of the code. You don't want to use unordered_map for the GUI_Interfaces container type. Instead, you could simply switch to std::map, or try something that looks like this:
using GUI_InterfaceType = std::pair<std::string, std::unique_ptr<GUI_Interface>>; // Smart pointer or raw, doesn't matter.
using GUI_Interfaces = std::vector<GUI_InterfaceType>; // Vector DOES support reverse iterators.
using GUI_Container = std::unordered_map<StateType, GUI_Interfaces>;
std::map would be an easier switch. Obviously some GUI code might have to change a little bit, because of the way information is accessed if it's a vector. I will try to contact Packt and get this fixed, as it should have been updated in the final product.

The second issue you're experiencing simply has to do with the encoding of your project. Your IDE is set to use wide characters, so instead of the char type you could simply use wchar_t, or you could re-work the function like this (use the 'A' suffix for two functions):
inline std::string GetWorkingDirectory() {
        HMODULE hModule = GetModuleHandle(0);
        if (hModule) {
                char path[256];
                GetModuleFileNameA(hModule, path, sizeof(path));
                PathRemoveFileSpecA(path);
                strcat_s(path, "\\");
                return std::string(path);
        }
        return "";
}
I would recommend the former, but it's your call. More information on that can be found here: http://www.cplusplus.com/forum/windows/185258/


50
Thank you! I'm glad you're enjoying the book so far. :) Yes, you are free to use the code as you please. I'd appreciate if you gave credit, but you are by no means obligated to do so. That's just for the code though. Make sure you check the licenses of whatever resources you're going to use from the book. If you use the same graphics, and/or music/sounds, I can't guarantee that the original copyright holders won't mind. All of the resources used in the book have been linked to, however, so you can easily find them and make sure.

51
Without really having access to your code, I can't really say what might be wrong with it at this point. If you could archive all of your code, as well as the Resources folder, and send it to me in a PM, that would be great. I'll take a look at it and get back to you as soon as I can. :)

52
In that case, just get rid of strcat_s completely and return like this:
inline std::string GetWorkingDirectory() {
        HMODULE hModule = GetModuleHandle(nullptr);
        if (!hModule) { return ""; }
        char path[256];
        GetModuleFileName(hModule,path,sizeof(path));
        PathRemoveFileSpec(path);
        return std::string(path) + "\\";
}

53
Try using std::strcat instead of strcat_s. When doing so, make sure that <cstring> is included as well.

54
In EntityManager.h, SharedContext is forward-declared:
struct SharedContext;
This means it has to be included in the EntityManager.cpp file:
#include "SharedContext.h"
Also, make sure Character.cpp includes EntityManager.h:
#include "EntityManager.h"

In case you don't have the GetContext() method defined for the EntityManager class, here's what you need to add:
Header:
class EntityManager{
public:
        ...
        SharedContext* GetContext();
private:
        ...
        SharedContext* m_context;
};
Implementation:
SharedContext* EntityManager::GetContext(){ return m_context; }

55
I was just about to reply to you about including the shared context header. Please make sure you consult the code files that came with the book. You will find complete source code there, with all of the necessary includes in place.

56
Hello. Im still on chapter 4 input and events. Ive been trying to debug how the game handles single input only on mouse? at what part of the code it handles it? Ive been trying to do a simple prototype of the code couldnt achieve the same result.
I'm not sure I know what you mean by that. Handling mouse events is the same as any other event. All you have to do is give it a name by adding it to the keys.cfg file, and then register a callback for an event with that name.

57
That's correct. I will definitely end up changing the 'magics' into something more obvious if I get to do some revisions. Needless to say, -1 is meant to represent the 'uninitialized' value.

Speaking of which, I also just caught a mistake that was fixed in the final drafts, but somehow made it into production:
if (bind->m_details.m_keyCode == -1) { // <-- Supposed to be ==, not !=.
     bind->m_details.m_keyCode = e_itr.second.m_code;
}

Again, I don't know how that happened, but I will be fixing it if I get a chance.

58
This is because all event types are unified. Here's the full enumeration of the type:
enum class EventType{
        KeyDown = sf::Event::KeyPressed,
        KeyUp = sf::Event::KeyReleased,
        MButtonDown = sf::Event::MouseButtonPressed,
        MButtonUp = sf::Event::MouseButtonReleased,
        MouseWheel = sf::Event::MouseWheelMoved,
        WindowResized = sf::Event::Resized,
        GainedFocus = sf::Event::GainedFocus,
        LostFocus = sf::Event::LostFocus,
        MouseEntered = sf::Event::MouseEntered,
        MouseLeft = sf::Event::MouseLeft,
        Closed = sf::Event::Closed,
        TextEntered = sf::Event::TextEntered,
        Keyboard = sf::Event::Count + 1, Mouse, Joystick
};
Everything leading up to Keyboard isn't necessarily in order, and we may be adding new events later, so everything after that point is given the maximum possible value in order to avoid clashing. There aren't necessarily 23 event types here, but sf::Event provides that amount - 1.

59
Sounds logical ! But it wasn't written in the book to add it.

Finaly managed to get that black screen! Thanks a lot.

I'll probably be back sooner than later for more questions!
I'll make sure to fix that, should the publishers ever allow me to do a second edition. Either way, I'm happy to help! Hope you're enjoying the book so far, albeit with minor hiccups. Thanks for reading! :)

60
This is Game.h : http://pastebin.com/0D7UuAy5
and the StateManager.h : http://pastebin.com/PpsnL6Kc

You're right, there is no m_context defined in game.h.
That's the problem. You need to define a SharedContext data member inside the Game class like so:
class Game{
public:
        ...
private:
        SharedContext m_context;
        ...
};
Can't manipulate or pass in members that don't exist. :)

Pages: 1 2 3 [4] 5 6 7
anything