Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by RamblingBaba

  1. Hello, So I have been programming with C++ for 2.5 years now. I have been interested in checking out C# for fun. My question is pretty simple. Does C# use a form typically for their games? The simple game examples I have watched on YouTube reminds me A LOT of Visual Basic. Was this just an easy way to show you C#? Or using the form is a big part of C#? Or is it nothing more than using something like MFC and completely irrelevant to making games? Thanks
  2. Hello, So I'm reading a book called SFML By Example C++ . I'm having trouble using my own sprite sheet and I have been messing around with their equation for getting the correct tile. In the Map class, they have an enum called Sheet that has the TileSize = 32, Sheet_Width = 250, Sheet_Height = 250. They determine the texture rect like this sf::IntRect tileBoundaries(m_id % (Sheet::Sheet_Width / Sheet::Tile_Size) * Sheet::Tile_Size, m_id / (Sheet::Sheet_Height / Sheet::Tile_Size) * Sheet::Tile_Size, Sheet::Tile_Size, Sheet::Tile_Size); What I noticed is the Y-axis does not determine the correct tile if the sheet isn't the same dimensions. So what I did is divide m_id by 2 and it seems to work for the most part. I also was using 64 for the tile size instead of 32 ...., m_id / 2 / (Sheet::Sheet_Height / Sheet::Tile_Size) * Sheet::Tile_Size, Sheet::Tile_Size, Sheet::Tile_Size); I decided to just run their formula vs my formula adjustment vs keeping the dimensions the same as the X axis in the console to see what was going on. Their formula was always off, and my adjustment by dividing by 2 worked until a specific point. When I was plugging in 896 and moving up by 64 to test numbers it began to fall apart. Is there a specific equation I could do with Y where I wouldn't have to worry about it falling apart? I don't have a sprite sheet that big, but 15 sprites down don't seem unrealistic and I'd like to be accurate every time. What confuses me is using the same dimensions for X and Y always worked, but I'm not sure if that could lead to some unwanted problems. I'd like to say it would not and I'd like to confirm that. I just find it pointless to have a Sheet_Height if the equation needs equal dimensions as the Sheet_Width. They specifically mention that the size doesn't' have to be the same. But it might as well be called SheetSize. Thanks, I hope that makes sense.
  3. Hello everyone, hope today's been nice. I use C++ and trying to become better with game programming concepts. I was wondering if someone could perhaps explain to me more about SceneNodes/SceneManagers. I see how you would declare things such as a circle player (basic example) as a node, which could be anything from a Player or enemy and the scene manager would add this all to create a "Level". Even the Map would be a Scene. I have a great example of one (and 2 from a book), but for whatever reason, I can't understand what it replaces? What would make you say to yourself, "That would be a great idea to use for this!" Can anyone maybe explain this like you would a 5-year-old and tell me perhaps another way to think about this? I usually see this concept in games like Asteroids and I have a few books who use that as well! When I say like a 5-year-old I don't necessarily need to know how it works or the intricate details, but how you would use it, or perhaps, even prefer it? A simple 2D engine setup I usually use is...StateManager (Splash, Menu, GameState), EntityManager, InputManager, AudioManager, TextureManager, Map class (tiles), and components for the entity. It seems to me these SceneManagers replaces your typical Map class with a Scene class and you use Nodes for your entities. Which is why I believe I'm having a hard time understanding when/why this is a great addition to have. It seems like it usually is fit with specific games. I realize a "Map class" could be done many ways but just think of this complete basic terms (might be hard for some of you experts) so to sum it up in this case just reads a file, creates an array of a Tile struct, sets the sprite for each tile, and displays the intended map. I'll stop here before I go on. I hope this question makes SOME kind of sense. I don't feel I did a great job explaining my question. I have books that use it, I see how it works, but I have difficulty understanding it for my type of games (RPG/Old School Rogue) and if this is more of niche use. Thanks, everyone!
  4. RamblingBaba

    Explain to me Scene Node/Manager

    Apology, I don't use GameDev regularly so I forgot all about this post. From what I researched it seemed like it really isn't for every game genre in general. That is an excellent idea though, despite having zero interest in either looking into it a bit more might be beneficial. I just find it interesting, the example is always a space game. I was able to set up an example I came across where you add one character (main node so to speak) and you could toggle to any character added, and adding additional character would allow you to move any character added under the toggled (highlighted) character you choose like a big chain. The first character added could move the whole chain. Very interesting. Thanks for the suggestion.
  5. Hello, I've been following along a C++ book that uses SDL(1.6!?) but has updated source code provided for SDL2, which is what I follow from. It's called "The Black Art of Multiplatform Game Programming" by Jazon YamamatoIt goes through the basics of SDL and then creates a mini engine. I am towards the end of the book now and it goes through creating a side-scrolling map, where you can pick numbers 1-4 and drop various enemies on the map and they run back and forth to the edges of what platform they are on. The problem is I get very weird behavior and lots of warnings which I tracked down to the Scene class. There is a part of the map where the NPC could be dropped and it would fall through causing a memory leak that would crash it. I decided to play around and I removed the decrementing part you can see comment below. // Remove 'removed' nodes for (it = m_nodes.begin(); it != m_nodes.end(); it++) { if((*it)->isRemoved()) { SceneNode* oldNode = (*it); it--; // REMOVED THIS AND PROGRAM WORKS AS INTENDED, BUT FREEZES UP (STOP RESPONDING) ON CLOSE. removeNode(oldNode); } } What errors I have come across messing with the class were related to "decrementing iterators before begin" and vice-a-versa. I came across a website specifically mentioning some of the faults of the std::list with memory leaks. When I remove that part it doesn't drop through the map at that "special" spot and the NPC's move back and forth as intended. But when closing the program it does the "not responding" crash. I wasn't surprised that it caused that behavior, but I was just trying to tinker. I am still rather new and was hoping some could tell me a solution. I wanted to mention that I previously had the for loops modernized, but decided to resort to the official source code in case I might have done something wrong. This is directly copied from the book, with the renaming of the class member variables with an "m_" prefix. So, unfortunately, it's not an error on my end. Here is the source code for the Scene Class Thanks, everyone! #ifndef SCENE_H #define SCENE_H #include "vld.h" #include <list> #include "SceneNode.h" #include "Rectangle.h" class SceneNode; // Model a scene and manage it class Scene { private: std::list<SceneNode*> m_nodes; // holds all scene nodes public: Scene(); ~Scene(); void addNode(SceneNode* node); void removeNode(SceneNode* node); void update(); void draw(Rectangle* view, Graphics* gfx); std::list<SceneNode*>* getNodes(); }; #endif #include "Scene.h" Scene::Scene()= default; Scene::~Scene() = default; // Adds a node into the scene void Scene::addNode(SceneNode* node) { node->setScene(this); m_nodes.push_back(node); } // Removes desired node and deletes it. IT also removes every single node in the scene if nullptr is passed as argument void Scene::removeNode(SceneNode* node) { if(node != nullptr) { SceneNode* n = node; m_nodes.remove(node); delete n; n = nullptr; } else { while (!m_nodes.empty()); { removeNode(*m_nodes.begin()); } } } // Updates every single object from scene. Removes objects that are flagged for removal void Scene::update() { std::list<SceneNode*>::iterator it; // Remove 'removed' nodes for (it = m_nodes.begin(); it != m_nodes.end(); it++) { if((*it)->isRemoved()) { SceneNode* oldNode = (*it); } } // Update nodes for (it = m_nodes.begin(); it != m_nodes.end(); it++) { (*it)->update(); } } // View represents the portion of the scene that is to be drawn. Think of this as a camera that can scroll through the scene void Scene::draw(Rectangle* view, Graphics* gfx) { for (std::list<SceneNode*>::iterator it = m_nodes.begin(); it != m_nodes.end(); it++) { (*it)->draw(view, gfx); } } // Returns a pointer to the game object list std::list<SceneNode*>* Scene::getNodes() { return &m_nodes; }
  6. Hello, I am currently reading Procedural Generation Content with C++. They start you off with a basic template using SFML, and it slowly builds off it. I have noticed a bug that is really bothering me now. I thought it might have been an error on my part. Unfortunately, it seems to be the source code in general. I did a google for the source code on github to see if someone fixed the problem. I only found some people who literally copied the final example's source code, which isn't helpful because I own it already. What is happening is when I am stationary and press either down or right, there is a quick red flicker. If I am already moving and press down or right, there is no problem. I've tried messing around with the texture manager and they have done in a way I have not come across yet and I'm wondering if this is the issue or if I'm wasting my time. I would like to keep the book's code, but I might just replace the whole thing. // Gets a texture from the texture manager from an ID. sf::Texture& TextureManager::GetTexture(const int textureID) { auto it = m_textures.begin(); auto found = false; while (it != m_textures.end()) { if (it->second.first == textureID) { return *it->second.second; } else { ++it; } } } I can't recall exactly what I did. But messing around with a modern for loop and the traditional way gave me different results. With one of the for loops, I got a "white" flicker when I went left now. I changed it back and the white is now gone. So I believe it has something to do with this. The original code from the book did this for (auto it = m_textures.begin(); it != m_textures.end(); ++it) { if (it->second.first == textureID) { return *it->second.second; } } When I changed the for loop to the modern iteration, the white flicker appears. So I have no idea what that means since I thought it was the same thing. I hope this is enough information for an idea of the problem. Down below I posted a link of the source code from someone's Github that is basically the exact same from the basic template standpoint. If anyone can get me through this, I would greatly appreciate it. https://github.com/utilForever/ProceduralContentGeneration Thanks, have a great day!
  7. RamblingBaba

    Red Flicker down or right direction

    I managed to fix 95% of the problem. In the Game constructor, the book code has //m_window.setVerticalSyncEnabled(true); I commented that out and it went away. But I can still occasionally see it appear, but it no longer happens every single time. If I press down and right enough times, I'll see it appear. For the MOST part, it has been solved. I was wondering if anyone has some additional input on that and if it's possible to totally remove it from here? Thanks for all the help and advice, I really appreciate it. JTippetts, I greatly appreciate you taking the time to run the code yourself as well. Perhaps you are on to something mixed with this vertical sync feature. Thanks everyone!
  8. RamblingBaba

    Red Flicker down or right direction

    Hello guys, This wasn't my code, it was provided as a template project to continue off. The only changes I have made are to the gameplay itself. So I have not touched their code for creating the level, animation, texture loading. Rutin, I've made a texture manager before and I've never had this problem. But I would have assumed the author of the book knew what he was doing. I was just trying to see if I can fix it the way he provided. I might just have to do this my way, which is what I was trying to avoid since I rather focus my attention on gameplay. I will definitely give those debugging tips a shot. Also, I don't expect you to take a look at all that code and appreciate your thoughts on it. So it is from the original piece of code. Since you can compile it straight out of the box, with no alterations, and get the same bug. I have found various people on Github who must have been using the book as well, and you see right away the bug is present. I believe the link I provided required some work to get it to run. But it's essentially the same deal. I appreciate all the tips! Unfortunately, I might just do the animation and texture manager over. For now, I'm just going to finish off the book and come back to it. Zakwayda: I'll be sure to try that and I appreciate all the help. AtomicWinter, I posted the github link to someone who has, what looks like the final example source code (I'm not sure if it was even changed). You could click that and just view the source for the TextureManager, Input, Object, Level, SoundBuffer. Because like I said, that part was never changed so it will be the same. Once again the link was https://github.com/utilForever/ProceduralContentGeneration . The only thing that's different from my version and the final example is gameplay elements. Everything else was fresh from the book and never changed. Thanks, everyone! PS: Lots of stuff provided to try and solve the problem and I'll be sure to report back if I figure it out!
  9. RamblingBaba

    Red Flicker down or right direction

    Hello Zakwayda, The template provided in the book has the bug. I haven't changed anything related to the provided code for Input, TextureManager, SoundBuffer, or the Object code. Which basically makes up the very small engine example to work with. I thought it was something I did, so I ran the template from scratch and the final example. But they all produce the same bug. So I tried to find someone on Github who possibly noticed this and fixed it themselves, but I just found direct copies of the final example (which I have all the chapters). When I say 'flicker', I mean when I press either the down or right direction from a stationary position, there is a red box, sort of outlining the sprite for a split second, that is noticeable. It reminds me of a red square placed on top of the sprite with some transparency to it, where I still can see the character. When you are walking around, the animation runs smoothly and you don't see any of the "red box flicker". Up and left do NOT produce this. But going back to where I said "I changed the 'for loop' to a modernized one" straight from the book, it actually created the same problem, except the "left direction" produced a WHITE Flicker, replicating the RED from the right and down direction. So left was white, right and down remained red. I fixed the WHITE flicker issue though by going back to the original 'for loop' or using a while loop like my first code snippet. That was a recommendation from ReSharper to use the 'modernized loop' which caused the white flicker. -------------------------------------------------------------------------------------------------------------------------------------------------------- (The warning 'not all control paths have a return Warning) I'm glad you mentioned the unused 'found' variable. I did some googling on 'not all control paths have a return'. I could not really find anything that helped me solve it. I thought changing the code with the while loop and adding the else would help. ReSharper suggest's an extra return (for the warning obviously). But I'm not sure how to get rid of the warning correctly and this could be related to the problem. This is what the 'for loop' is iterating. static std::map<std::string, std::pair<int, std::unique_ptr<sf::Texture>>> m_textures; At one point, I had found a quick solution to get rid of the warning. Long story short, I had to copy the original template code again after replacing the code and forgot about how I fixed that warning. I believe I did something very odd and created an empty texture. I doubt it was the correct way and just got rid of the warning. I also get this same warning with the SoundBuffer class. What my problem is, I'm not sure what to return as a 'sf::Texture' that will correct the warning and possibly the issue. The previous books I've read, typically do this differently. Thanks, sorry the long post. I thought I'd provide 2 separate parts in one post.
  10. Hello GameDev vets, I use to program when I was younger (few college courses as well) and as I got older I got away from it. I've now been really taking learning programming very serious. I bought Sam's Teach Yourself C++ to learn the newer stuff added to C++ and refresh myself of all the basics. I am looking for the next book to help me actually start on a simple rogue RPG. I wish I could find a book (recent date) that covers heavily DirectX12 or 11 and RPGs. Especially procedural generation and tiles. I assume my book on Isometric programming still has relevant ways of doing tiles. Can anyone help me pick out 2-3 books that will help make me a comfortable windows programmer. 3D is probably my LAST stop. I just would really enjoy non outdated books regarding 2D RPG games (and eventually 3D). But I am trying to go through the stages in a more practical way. Price is not really an issue. Any other sources are great as well. Thanks everyone! I have the following books: Sam's teach yourself C++(8th Edition) |Beginning C++ Game Programming by John Horton Beginning C++ Through Game Programming (4th Edition) by Michael Dawson Game Programming Patterns The Art of Game Design Level Up (Also own a kindle version of 2D programming by I forget who, it was great during its time) OLD OUTDATED BOOKS: Programming Role Playing Games with DX9 Programing Isometric Games with DX7 (maybe 9) Programming Multiplayer Games
  11. Hello, I use to program all through 5th/6th grade through high school and finished c++ classes at a community college. It has been 9 years since I've programmed. I have a lot of spare time at the moment and want to get back into programming. I was wondering if anyone could recommend a few books talking about the design of a simple tile based RPG game. Perhaps with an indepth build of the engine and something to build off of. My game programming books are so outdated, but I do have my original C++ books. I think my last gaming book was DirectX 9. I should be able to get the language down fast again, but I really like the books that hold your hand and walk you down everything in the engine ect. My last book I read for fun was Programming 2D games I believe? It was very good and I'll be reading it again. I'd just prefer a note on topic book. If anyone could help I would appreciate it! I tried a search on Amazon and it looks like the programming market books don't exist anymore. I wrote down a list of ones that could be good, but anxious to hear from the veterans and see if any of the suggestions were on my list. Thank you!
  12. RamblingBaba

    Looking for a roguelike influenced book

    What exactly had changed? This is both interesting and disappointing. Can you guide me to a book that will update me?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!