• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

doyleman77

Members
  • Content count

    54
  • Joined

  • Last visited

Community Reputation

367 Neutral

About doyleman77

  • Rank
    Member
  1. nothing?   So far, I've just skipped doing alpha & blends on textures; but I am curious more if there's a better way than the above proposed?
  2. I'm using a map to store all of my textures, from which entity's refer upon. There may be an instance where I want one entity whom shares a texture with possibly many other entities to be transparent or blended, but not the others.   Right off the bat, I thought about having flag or check per entity on their alpha or blend mode, and modifying the texture just before drawing, and then resetting the texture's blend & alpha (this way, all entities will eventually be able to modify the texture as they need, and it'd default when done).   I am not sure if that'd work, though I *think* so. My question, though, is: is there a more optimal way of handling blending and alpha on a texture that is shared?
  3. The pointers are (I believe) the only local objects now, and are then passed to the map/vector which covers the entire app/game's scope, anyway. The code hasn't changed much, other than declaring new on entities. I also removed the string as a parameter, because somewhere along the line I would have to make a string object to pass upon it.   Also, my bad on calling it the stl. I suppose I assumed because it's standard, templated, and a library, that was it's appropriate name. I'm guessing the STL is more of unofficial libraries, where the C++ Libraries are official, and required for most, if not all, C++ compilers...?     Also, when this segfault happens, Code::Blocks auto opens stl_map.h file - also leading me to believe this is the STL?   Anyway, yeah - the code hasn't changed much. I know, I should have all of this loading / game loop outside of the constructor. I'll move it - I've just been occupied with this crashing, so far. Game::Game() { gameWindow = SDL_CreateWindow(globals::SCREENTITLE.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, globals::SCREENWIDTH, globals::SCREENHEIGHT, SDL_WINDOW_SHOWN); gameRenderer = SDL_CreateRenderer(gameWindow, 0, SDL_RENDERER_ACCELERATED); loadTexture("raindrop.png"); loadTexture("texture.png"); /// this is me, making sure that the map pulls texture.png. this works. SDL_Texture* myTex = textureLibrary["texture.png"]; Entity* newEntity = new Entity(textureLibrary["raindrop.png"]); Entity* anotherEntity = new Entity(textureLibrary["texture.png"]); gameVec.push_back(newEntity); gameVec.push_back(anotherEntity); running = true; while(running) { handleInput(gameInput); update(); draw(); SDL_Delay(16); } }; void Game::loadTexture(const char filename[]) { //SDL_Texture** newTexture = new SDL_Texture*; SDL_Surface* loadedSurface = IMG_Load(filename); /// Set the image invisibility color SDL_SetColorKey(loadedSurface, SDL_TRUE, SDL_MapRGB(loadedSurface->format, 0xFF, 0, 0xFF)); //*newTexture = SDL_CreateTextureFromSurface(gameRenderer, loadedSurface); textureLibrary[filename] = SDL_CreateTextureFromSurface(gameRenderer, loadedSurface); SDL_FreeSurface(loadedSurface); return; }; Entity::Entity(SDL_Texture* itsTexture) { texture = itsTexture; SDL_QueryTexture(itsTexture, NULL, NULL, &texRect->w, &texRect->h); }; Here, I initialize SDL, load in some textures (which are then placed into the map/cache), and then I test out by pulling into myTex. Originally, just below that, I did a quick RenderClear, RenderCopy, and RenderPresent to show myTex, and it appeared - in all it's glory.   Where as before, when newEntity and anotherEntity were on the stack, rather than the heap, I could _at least_ get newEntity to load it's texture, and display properly, and the anotherEntity would crash; the segfault now happens on newEntity.   Following the call stack, the only place other than stl_map.h that maybe is a problem area is the constructor of Game, or maybe of Entity (despite it looking like Entity's constructor isn't on the stack at all, yet).   Thanks for the replies.   **edit**   I've just given up on this...
  4. I have. It crashes at line 472 of stl_map.h: iterator __i = lower_bound(__k); // __i->first is greater than or equivalent to __k. if (__i == end() || key_comp()(__k, (*__i).first)) __i = insert(__i, std::make_pair(std::move(__k), mapped_type())); return (*__i).second; } the call stack shows it crashes at the [] operator call of map<>:     I have made my Entities on the heap, and then pushing them onto the Vector<Entity*> GameVec vector - and the segfault occurs there, too - but the app doesn't crash at that point, it just doesn' display the images (where as before, I could do one entity and display it, it'd just crash on 2.)   I guess I don't know how to pry open the map<> and test the addresses of what it's pointing too, but for what its worth: it does work if I do a direct SDL_RenderCopy and using the map, rather than the Entity, or if I make a local Texture and assign it a texture from the map, too.
  5. I've read the wiki article before, and while minimal, the code listings arent helping me understand what is going on. Lambdas are by far the worst for me to understand. :-/   On a seperate note, regarding my textureLibrary map: would it be that I need to have a getTexture() function that iterates the map, and returns it? Am I not able to simply use textureLibrary["texture.png"] to bring up the appropriate texture? The only problem I could see that causing, at the moment, is that if I use the wrong key, it'd grab a newly made, blank texture. But I don't see why that'd still segfault.   I've cleaned up the local variables, and the string bits - and I'm still getting crashes. It's odd, because it seems to work fine on one entity, but not the 2nd. I can directly display the texture using the same key, it only seems to crash when I try to instantiate an Entity with that texture...   I apologize if my wording is confusing.
  6. I haven't wrapped my mind around lambda's yet, unfortunately. :(   Most of c++11 still seems mystified to me; and I can't find a place that breaks down the new features well enough for me to understand.   I appreciate and thank you for your explanations, though!
  7.   I acknowledge that I'm not up to date with '11, yet. It's on my todo list, to get caught up - but this is an 8 week challenge that's already 4 weeks in. I'll try to learn the new smart pointers, eventually.   As per the quoted code - I guess I'm not sure what exactly is going on. You're making a structure that overloads the (), takes a texture, and then frees it? and then the last line - using TexturePtr. I'm not sure where TexturePtr is declared, or how it's defined, or what it is really. What is happening when you make a unique pointer with Texture and TextureDeleter?
  8. (Don't mean to double post... I couldn't find an edit button on my post)   Also - Yeah, I do intend on going back and doing error checking. I promise, normally I do. I'm just not used to SDL2, and wanted to try to get something up and running quick. That SDL_Quit() call was the last line I added last night before calling it quits, I wanted to see if it even found the image. That part has since been removed. Sorry!
  9. Ack. Yeah. I should be declaring new on the textures and the entities, and having the map be a pointer to those pointers. Sorry.   The map is in fact, a map<std::string, SDL_Texture>. that filename.c_str() is local, but isn't it just calling the characters that make up that string, and storing it into map?   IE if I pass "raindrop.png" into loadTexture, it'll pass that into the string, but the string just pumps the characters into the map<string,texture>; and then using map["texture.png"] call it up? I guess I am still new to the STL map - I had to make my own in Data Structures II class at uni, and assumed I could use it somewhat similarly... I've been reading over http://www.cplusplus.com/reference/map/map/ article over and over.   What should I be doing instead of filename.c_str() when trying to pass my filename path to the loadTexture function; and then saving it as a key on the map?
  10. I've been to figure out why this keeps breaking for the last 3 days. I'm using a std::map to store all textures in, hopefully, and then just have my link to the images from that map. This works fine on one image; I can load it, store it, and retrieve it to have an entity use it and finally, it gets drawn properly. The minute I add in another texture, however, my game crashes on trying to create an entity that refers to any/either of the textures - GDB has it crashing on a segfault inside the std::map header file, presumably when I'm trying to retrieve the texture.   Here's the code in question:   Game.cpp Game::Game() { time(&gameTime); timeInfo = localtime(&gameTime); gameWindow = SDL_CreateWindow(globals::SCREENTITLE.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, globals::SCREENWIDTH, globals::SCREENHEIGHT, SDL_WINDOW_SHOWN); gameRenderer = SDL_CreateRenderer(gameWindow, 0, SDL_RENDERER_ACCELERATED); loadTexture("texture.png"); loadTexture("raindrop.png"); //gameVector.push_back(&(textureLibrary["raindrop.png"])); Entity newEntity(textureLibrary["raindrop.png"]); //Entity anotherEntity(&(textureLibrary["raindrop.png"])); gameVec.push_back(&(newEntity)); //gameVec.push_back(&(anotherEntity)); running = true; while(running) { handleInput(gameInput); update(); draw(); SDL_Delay(16); } }; Game.cpp void Game::loadTexture(std::string filename) { SDL_Texture* newTexture = NULL; SDL_Surface* loadedSurface = IMG_Load(filename.c_str()); if(loadedSurface == NULL) SDL_Quit(); /// Set the image invisibility color SDL_SetColorKey(loadedSurface, SDL_TRUE, SDL_MapRGB(loadedSurface->format, 0xFF, 0, 0xFF)); newTexture = SDL_CreateTextureFromSurface(gameRenderer, loadedSurface); SDL_FreeSurface(loadedSurface); textureLibrary[filename.c_str()] = newTexture; return; }; And finally, my entity constructor - very basic. Entity::Entity(SDL_Texture* itsTexture) { texture = itsTexture; SDL_QueryTexture(itsTexture, NULL, NULL, &texRect->w, &texRect->h); }; texture is the member of Entity, and is a simple SDL_Texture*.   Again; this system worked fine when I had only one image loaded - it wasnt until I had both ["raindrop.png"] and ["texture.png"] that it started segfaulting on the Entity newEntity(textureLibrary["raindrop.png"]); bit.   Any clues? Don't mind the terrible coding. This is me trying to get a game worked out in a 8wk challenge; and I'm sure it may be sloppy. :(
  11.   I'm not sure if Visual Studio's editor supports tablets. It could; but I doubt it'd pick up on pressure detection. For that, something like Krita, GIMP, PaintSai, or a program along those sorts may be what you want. If you're learning art, however, I'd vote to actually put the tablet aside, and start at the mouse / paint level, as that helps develop the fundamentals much better. Well, that's how I had learned some, anyway.
  12. I thank everyone who had explanations on all topics. I tried a few sample lambdas to try to get a feel; and it's beginning to make sense. I'll be honest in that I never really used a callback; let alone know what one is. From my understanding, it's passing a function into another, and having it perform at a later point within that first function. Move constructors and assignments are entirely cleared up; that actually seems like a brilliant move; and left me wondering why that wasn't part of the standard earlier.   decltype has also been cleared up; and I can see the uses for that definitely. I bookmarked the GoingNative page; and will check that out later today when I finish classes; thanks for the link!   I really do appreciate all of your guy's explanation, and time taken to give them. The depth of some of them were quite long, but served to help more than what the book had shown; so thanks to all on their contributions!
  13. Pretty comfortable with my c++ code now; I get classes, I get using templates and STL, smart pointers, and to an extent, exceptions. What I don't get is most of the new 2011 standard. Lambdas confuse me, in both their syntax and their purpose.   I've looked up articles trying to show practical uses for them, but they seem to go even further above my head than just the word 'lambda'. Rvalue / moving seems confusing just as well; decltype... gah. None of the new stuff makes much of any sense. The only thing I've understood so far is auto, and to a half-way extent: the new for loop style.   I've read through a third of C++ Primer 5th, and so far it's not really shed any new light to me. The frustration of these new features and my inability to grasp them has me concerned... How is it some clicked onto the new concepts rather fast? And where can I go to get to that point?
  14. Oh wow. I've not had a lot of experience reading code from others... usually it's done more... cleanly? than mine? or maybe up to date. I usually have a very rudementary setup as far as my C++ goes. I could definately follow along with what was going on.   Am I right in guessing that, then, your Renderer class holds all textures via textureDictionary? and scaling a texture is also done via renderer?   Either way; very clean and documented code. I think I see what you mean now!
  15.   Separate in the sense that I want to organize data into appropriate objects. Sprites have images, not windows, etc. But a window displays the screen, which is what a sprite in SDL2 needs to have passed in in order to be loaded and placed into a texture.   I think I understand what fastcall and adamsmithee were talking about; but what do you mean separate the renderer from the window? That seems a bit more abstract than it should be; as a SDL window, at least this one, 'renders' content - and thus should hold the renderer struct. That was my intent, anyway.   Proper separation for me would be a window not needing to know anything about image loading, but images i suppose do need to know about what window they'll eventually be displayed on? Hrm.