As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

#define THREAD_TITLE "PA Programming Thread"

1394042444562

Posts

  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    It is the worst abomination on the world.

    The worst.

    It's good for programmers that can't program and need DB functionality. Like I said, access++.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited September 2010
    GnomeTank wrote: »
    I prefer MySQL over Postgre, but it's really personal preference.

    I've only ever used mySQL at home, and Oracle and our proprietary B-tree garbage at work. I had heard mySQL doesn't scale as well as Postgre. Not that my home projects have any scale to speak of, but how true has this held for you?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    I don't really know the answer to that question, I have never used MySQL for anything so large scaling became a serious issue. I've only used SQL Server and Oracle in those scenarios.

    e: I should add, I prefer MySQL over Postgre from a pure usability point of view. MySQL and it's tool feel very familiar to me after using SQL Server for so many years. Though the SQL dialect is more like PL/SQL (as much as something can be like PL/SQL), the GUI tools are very SQL Server-esque.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited September 2010
    GnomeTank wrote: »
    I don't really know the answer to that question, I have never used MySQL for anything so large scaling became a serious issue. I've only used SQL Server and Oracle in those scenarios.

    e: I should add, I prefer MySQL over Postgre from a pure usability point of view. MySQL and it's tool feel very familiar to me after using SQL Server for so many years. Though the SQL dialect is more like PL/SQL (as much as something can be like PL/SQL), the GUI tools are very SQL Server-esque.

    I agree on all points but the GUI tools. Because, umm...what GUI tools are you talking about?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • EndEnd Registered User regular
    edited September 2010
    MySQL has a set of gui tools.

    I've used the query portion, and I wasn't a fan. The query editor is too small, unless you use the script editor, but then I didn't see a way to get output back from a query.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • Recoil42Recoil42 Registered User regular
    edited September 2010
    Slightly programming related:

    Does anyone happen to know where I might be able to find a large, downloadable database of recipes?

    Or in general other good sources of open, downloadable database information?

    Recoil42 on
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    You want just large text blobs?

    Kakodaimonos on
  • MKRMKR Registered User regular
    edited September 2010
    Recoil42 wrote: »
    Slightly programming related:

    Does anyone happen to know where I might be able to find a large, downloadable database of recipes?

    Or in general other good sources of open, downloadable database information?

    http://www.bea.gov/national/index.htm

    MKR on
  • Recoil42Recoil42 Registered User regular
    edited September 2010
    You want just large text blobs?

    The project I'm currently planning involves recipes, but I thought it would be a good idea to get an idea of what's available in general (in terms of publicly available datasets) for the future.

    Recoil42 on
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    You can grab the project Gutenberg feed. May be bigger datasets than you want.

    http://www.gutenberg.org/wiki/Gutenberg:Feeds

    Kakodaimonos on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    templewulf wrote: »
    GnomeTank wrote: »
    I prefer MySQL over Postgre, but it's really personal preference.

    I've only ever used mySQL at home, and Oracle and our proprietary B-tree garbage at work. I had heard mySQL doesn't scale as well as Postgre. Not that my home projects have any scale to speak of, but how true has this held for you?

    It's bologna. For instance DAoC was built around it.

    MySQL had speed, Postgre had "features." That gap is substantially closed in on. The largest reason to use MySQL? Pretty much everyone and their mom uses it for a LAMP setup. Postgre you have to go out of your way. Chances are if you need help, someone can give it with MySQL. Not so much so with Postgre.

    I think Postgre's largest draw was stability and failover features. Not sure how much has changed as I don't keep on top of them anymore. But I do remember Postgre was the most stable of the SQL servers a few years back.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    This seems like a good a place as any.

    If you browse H/A regularly, you probably know that I occasionally mess around with game programming, typically rogue-like type games, and apparently do everything the wrong way.

    I've been messing around again, and had a question. I'm using libtcod with C++, if it matters. This is regarding displaying tiles and the things that might occupy those tiles. I have a class for storing my map information that basically creates a large 2d array and stores various info relating to that tile, isWalkable, isTransparent, isExplored, etc. My render function centers the PC and draws the seeable tiles around him, and scrolls as the PC walks. I can draw the tiles fine, but now I've started trying to draw other things, like npcs and items.

    I had npcs drawing fine, but it was horribly inefficient. I currently store my npcs in a linked list, and I was basically navigating through that list for each tile to see if an npc was there. I had the idea of instead going through the list once and storing each npc's position in a character array as their graphic, then checking the relevant position in the array for each tile that's in view. That would probably work, but then I thought about other things that might be there, like items or monsters, and what if there are multiple items in a tile, etc. Or just simply trying to get information about the npc in that tile. Surely there's a better way. Any suggestions?

    Also, are there any good online resources for this kind of thing?

    Sir Carcass on
  • MKRMKR Registered User regular
    edited September 2010
    Why not look at a roguelike's source and see how it's done?

    MKR on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Your map array could hold another piece of information, pointer to an object. If an object is in the square, you can find out directly, rather than traversing the linked list each time. I mean you'll probably want a linked list to hold them anyways for AI logic and such, if they're moving or performing actions, but, the map itself could hold an "object" address and point directly to an npc, an item, or monster.

    That way as you hit the tile you can do a quick check, display them, and move on.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited September 2010
    bowen wrote: »
    templewulf wrote: »
    GnomeTank wrote: »
    I prefer MySQL over Postgre, but it's really personal preference.

    I've only ever used mySQL at home, and Oracle and our proprietary B-tree garbage at work. I had heard mySQL doesn't scale as well as Postgre. Not that my home projects have any scale to speak of, but how true has this held for you?

    It's bologna. For instance DAoC was built around it.

    MySQL had speed, Postgre had "features." That gap is substantially closed in on. The largest reason to use MySQL? Pretty much everyone and their mom uses it for a LAMP setup. Postgre you have to go out of your way. Chances are if you need help, someone can give it with MySQL. Not so much so with Postgre.

    I think Postgre's largest draw was stability and failover features. Not sure how much has changed as I don't keep on top of them anymore. But I do remember Postgre was the most stable of the SQL servers a few years back.

    Yeah, mySQL has been an absolute breeze to set up, so I'm not going to use anything else for the foreseeable future. It doesn't hurt that every LAMP tutorial is mysql focused. Now I just have to figure out how to wrap mysqli in my own class to throw the appropriate exceptions.

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    MKR wrote: »
    Why not look at a roguelike's source and see how it's done?

    I may end up doing that, but it would mean digging through a ton of code to find where they do it, and then trying to figure out how they do it. I'm not sure I'm quite up to that task yet, to be honest.
    bowen wrote: »
    Your map array could hold another piece of information, pointer to an object. If an object is in the square, you can find out directly, rather than traversing the linked list each time. I mean you'll probably want a linked list to hold them anyways for AI logic and such, if they're moving or performing actions, but, the map itself could hold an "object" address and point directly to an npc, an item, or monster.

    That way as you hit the tile you can do a quick check, display them, and move on.

    But what if there are multiple things in a single tile, like a an npc that drops all of his equipment?

    Sir Carcass on
  • EndEnd Registered User regular
    edited September 2010
    But what if there are multiple things in a single tile, like a an npc that drops all of his equipment?

    Linked list per tile.

    You'd probably have something like linked list to items, single pointer to npc in your tile struct.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    For instance, this is pseudo c# code, no idea if it'll compile
    
    public class GameObject
    {
        //the base class for game objects
        //npcs, monsters, items, whatever
    }
    
    public class MapTile
    {
        public Image tileImage;
        public GameObject objectAtTile;
    }
    
    public static void main()
    {
        MapTile[,] theMap = new MapTile[25,100];
        //do all the rest of your junk here
        //then you could do something like
        if(theMap[x,y].objectAtTile != null) {
            theMap[x,y].objectAtTile.Move(-1,0);
        }
    }
    
    

    That should be more or less what you want to do in that situation. Traversing through the list matching x,y combos could make that a much worse process than it has to be. I'd probably still keep the linked list for AI logic like I said, traverse it to see if you need to do any processing. Move an NPC, make a monster shoot a weapon, whatever. Then it could update the map itself on logic too, so you have two ways to do it.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Yeah like End said, simply changing that objectAtTile to a linked list should handle multiples.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • hackswordhacksword WinnipegRegistered User regular
    edited September 2010
    This seems like a good a place as any.

    If you browse H/A regularly, you probably know that I occasionally mess around with game programming, typically rogue-like type games, and apparently do everything the wrong way.

    I've been messing around again, and had a question. I'm using libtcod with C++, if it matters. This is regarding displaying tiles and the things that might occupy those tiles. I have a class for storing my map information that basically creates a large 2d array and stores various info relating to that tile, isWalkable, isTransparent, isExplored, etc. My render function centers the PC and draws the seeable tiles around him, and scrolls as the PC walks. I can draw the tiles fine, but now I've started trying to draw other things, like npcs and items.

    I had npcs drawing fine, but it was horribly inefficient. I currently store my npcs in a linked list, and I was basically navigating through that list for each tile to see if an npc was there. I had the idea of instead going through the list once and storing each npc's position in a character array as their graphic, then checking the relevant position in the array for each tile that's in view. That would probably work, but then I thought about other things that might be there, like items or monsters, and what if there are multiple items in a tile, etc. Or just simply trying to get information about the npc in that tile. Surely there's a better way. Any suggestions?

    Also, are there any good online resources for this kind of thing?

    What about a std::multimap that maps the (x, y) location of a tile to the NPCs, items, monsters, etc. at that location? If you're already storing NPCs in a list, then you can map (x, y) to the iterators within your list. Something like:
    // Contains the (x,y) location of a tile
    typedef pair<int, int> TilePosition;
    
    // Contains your NPCs
    list<Character> npcs;
    
    // Function that draws an NPC
    void draw(const Character &c);
    
    // Contains the locations for your NPCs
    typedef multimap<TilePosition, list<Character>::iterator> LocationMap;
    LocationMap npcLocations;
    
    ...
    
    // Get the NPCs at (100, 200) and draw them
    pair<LocationMap::iterator, LocationMap::iterator> range =
       npcLocations.equal_range(make_pair(100, 200));
    for (LocationMap::iterator i = range.first; i != range.second; ++i)
    {
       list<Character>::iterator j = i->second;
       draw(*j);
    }
    
    

    You could also use a std:map that maps TilePosition to a secondary location which in turn contains all of the items that reside at that location.

    EDIT: looks like a bunch of other people answered while I was writing my post.

    hacksword on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Also another good idea.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    Ah, okay. That kinda makes sense. I'll give it a go and then come back in here when I fail horribly.

    Sir Carcass on
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited September 2010
    Also, are there any good online resources for this kind of thing?

    I think bowen has the right idea for a solution. As for resources, I'm pretty sure I did some of these tutorials about 8 years ago: http://www.gamedev.net/reference/list.asp?categoryid=24#151

    They're woefully out of date, but hopefully you can pick up on some of the methods that you can use.

    Edit:
    But what if there are multiple things in a single tile, like a an npc that drops all of his equipment?
    You can use a list of pointers-to-object, and if the length of the list is > 1, display a nondescript sack or something.

    I know I'm going to get corrections trying to write this off the top of my head, but here goes:
    class Tile
    {
    	protected:
    	TileMapIndex tmIndex;
    	std::vector<Entity*> entityPointers;
    
    	public DrawTileContents()
    	{
    		GraphicIndex gfx;
    		if (entityPointers.length() > 1)
    		{
    			gfx = GraphicIndex::MiscSack;
    		}
    		else if (entityPointers.length() == 1)
    		{
    			gfx = entityPointers[0]->gfx;
    		}
    	}
    }
    

    Edit 2:
    God damn it, I need to post faster. Stupid job!

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Haha at least it's good to know we're all thinking the same thing.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • peterdevorepeterdevore Registered User regular
    edited September 2010
    I've been messing around again, and had a question. I'm using libtcod with C++, if it matters. This is regarding displaying tiles and the things that might occupy those tiles.

    Don't use libtcod for tile graphics. It's a nice library to aside from that, but seriously, here is what I think is the main part of its image blitting code:
    for (cx=minx; cx < maxx; cx ++) {
    	for (cy=miny; cy < maxy; cy ++) {
    		TCOD_color_t col=TCOD_image_get_pixel(image,cx-minx+offx,cy-miny+offy);
    		if ( !img->has_key_color || img->key_color.r != col.r
    			|| img->key_color.g != col.g || img->key_color.b != col.b ) {
    			TCOD_console_set_back(console,cx,cy,col,bkgnd_flag);
    		}
    	}
    }
    

    It's reading out every pixel of every image that you ask it to blit out individually, in software. They might have their reasons for it, but this is dog slow for any decent resolution or anything that would animate, even for a turn based game. I suggest you write your own tile renderer using proper SDL surfaces, pretty easy for top down perspective. Or if you're a champ you could rewrite their image blitting code to actually blit rectangular areas.

    peterdevore on
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    I've been messing around again, and had a question. I'm using libtcod with C++, if it matters. This is regarding displaying tiles and the things that might occupy those tiles.

    Don't use libtcod for tile graphics

    Well, when I say tile I mean in the... metaphorical? sense. I'm not using sprites, just straight ascii. Baby steps, here. :P

    So my first step is rewriting what I currently have to use the List class (something I've been meaning to learn) instead of my own hacky node stuff. I'm kind of stuck. How exactly am I supposed to use member functions with it? Here is what I have:
    list<Person> personList;
    
    if(personList.empty())
    {
    	personList.push_front(IDcount);	//not sure if this is correct, was using "new Person(IDcount)" before
    	IDcount++;
    }
    
    for(list<Person>::iterator it=personList.begin();it!=personList.end();++it)
    {
    	cout << "Name: " << *it.getName() << endl;
    
    }
    

    I get an error on the cout saying that the iterator has no member named getName(). The Person class does, but I'm not sure how I'm supposed to access it. Sorry for the newb questions.

    Sir Carcass on
  • peterdevorepeterdevore Registered User regular
    edited September 2010
    '*' has a lower binding strength than '.' so it's doing *(it.getName()) and failing instead of doing (*it).getName() like you'd want it to.

    peterdevore on
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    '*' has a lower binding strength than '.' so it's doing *(it.getName()) and failing instead of doing (*it).getName() like you'd want it to.

    Ah, that fixed it. Never knew that. Thanks.

    Sir Carcass on
  • EndEnd Registered User regular
    edited September 2010
    *cough*

    That's what -> is for.

    Meaning it->getName()

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    I feel partially to blame for that with my C#.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Sir CarcassSir Carcass I have been shown the end of my world Round Rock, TXRegistered User regular
    edited September 2010
    End wrote: »
    *cough*

    That's what -> is for.

    Meaning it->getName()

    This has always confused me. I generally know when to use . or -> but still haven't completely grasped why.

    Sir Carcass on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    -> is pointer notation. If you need to access members of a pointer, you'd use ->. If you need to access members for variables declared on the stack, you'd use .

    Which is why:
    (*myPtr).Method();

    Is the same as:

    myPtr->Method();

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Question for you guys familiar with COM.

    I've got a COM library already registered on a system, I did some changes to it, and now when I try to use a form builder and drag the COM library onto the form I get:

    "OLE error code 0x80029c4a: Error loading type library/DLL."

    It works fine everywhere else as far as I can tell, but I can't get it into drag/drop state that the other developer needs it for.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Lux782Lux782 Registered User regular
    edited September 2010
    I have a question for everyone.

    How would you go about writing a function that handles drawing some polygon (by user input) and then deciding what is inside the polygon and what is outside and automatically filling the inside area in with some color.

    Lux782 on
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    bowen wrote: »
    Question for you guys familiar with COM.

    I've got a COM library already registered on a system, I did some changes to it, and now when I try to use a form builder and drag the COM library onto the form I get:

    "OLE error code 0x80029c4a: Error loading type library/DLL."

    It works fine everywhere else as far as I can tell, but I can't get it into drag/drop state that the other developer needs it for.

    Did you change anything in the COM library interface? And did you up the version rev on it? Either of those two will require you to re-reg the COM lib.

    Kakodaimonos on
  • iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    edited September 2010
    bowen wrote: »
    Question for you guys familiar with COM.

    I've got a COM library already registered on a system, I did some changes to it, and now when I try to use a form builder and drag the COM library onto the form I get:

    "OLE error code 0x80029c4a: Error loading type library/DLL."

    It works fine everywhere else as far as I can tell, but I can't get it into drag/drop state that the other developer needs it for.

    Did you change anything in the COM library interface? And did you up the version rev on it? Either of those two will require you to re-reg the COM lib.
    I think this is the key. Really, any time you change a COM lib in any way you should go ahead and unregister the previous one, and register the new one.

    iTunesIsEvil on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Did that. Nothing's changed, I changed some logic behind the scenes. But now for some reason it won't register in the guy's foxpro application. I hate foxpro.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    Does FoxPro require to implement any crazy interfaces? Like implementing IDispatch directly? If you're using ATL, this should be done for you (if you used the right macros), but a raw, pure C, COM object won't automatically dispatch. I know VB requires it, so maybe FoxPro does too.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    Hmmmm. All the example code doesn't really highlight on it but let me dig deeper on it.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    No dice. Weird. Fucking foxpro. I think he's lying to me when he said it worked earlier.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
This discussion has been closed.