Jump to content
  • Advertisement

Mr_Threepwood

Member
  • Content Count

    68
  • Joined

  • Last visited

Community Reputation

150 Neutral

About Mr_Threepwood

  • Rank
    Member
  1. Mr_Threepwood

    Reading in from a file

    I'm working on a school assignment where we have to read in a large set of data and manipulate customer orders. So we have files that have the customers, credit card #'s, orders, etc. The problem I am having is on a very trivial aspect, and it's frustrating me so badly so I was hoping someone could help me out. Something is wrong with this section of my code I think for ( int x=0; x< numCards ;x++) { int cardNum=0, cardMonth=0,cardYear=0,cardCode = 0; string cardType; fileReader >> cardNum; fileReader >> cardMonth; fileReader >> cardYear; fileReader >> cardCode; getline (fileReader,cardType); custToInsert->AddCreditCard(new CreditCard (cardNum,cardMonth,cardYear,cardCode,cardType)); } This section of the code is supposed to be reading in credit card information. Right before the loop it reads in the number of credit cards to load, each credit cards information is stored on a single line with tabs in between the data. The problem is this code works only once for some reason. IE if you had numcards = 2 then it will read in the first line of credit card information correctly, but it won't read the second line in correctly (it will just not put anything into the variables). fileReader is a ifstream by the way. So does anyone know why this would read in the variables of one line and then not work for the second line on? Edit: FIXED After wasting a total of 2 hours on this stupid problem, it turned out i should have made the variables of type long long, it was having overflow problems. [Edited by - Mr_Threepwood on June 7, 2008 7:14:52 PM]
  2. Mr_Threepwood

    When to scrap a project?

    Thanks for the replies. I think I'm going to take a break from it for now since it's no longer enjoyable to work on it, though it bugs me to have it unfinished. I think I'll stay away from attempting another game for a while and instead learn some more and make different applications for learning purposes. I think it would be beneficial for me to go around looking at other peoples code for games and see how they dealt with it, because I don't want to get my mind stuck in dealing with the game problems my way, since other implementations could be better. What I really need to find is an open source 2D sidescroller, so that I can see things like how they dealt with resources, how their sprite sheets are constructed, how they made their levels, etc. I'll go on a google hunt for that later.
  3. Mr_Threepwood

    When to scrap a project?

    Ok so I've been working on this game for the past few weeks, and being a beginner I've run into several problems. 1. Object interfaces are difficult to work with, and doing things like adding a new type of monster takes a lot of extra work and workarounds. 2. Managing game resources has become a nightmare, so far I've been manually loading the textures in the program, so I've got somewhere around 30 and it's cumbersome to add new resources/change resources. My biggest problem here is I think I'm misunderstanding sprite sheets. So far what I've been doing to make the sheets is measuring the widest sprite, and measuring the tallest sprite. Once I have those measurements I use that are the new dimension for every cell, so even if one image was shorter/narrower it would still be in a cell much wider and taller than it. 3. It's also come to the point where there's so much "hack" code that was put in temporarily to get things working. At the time I thought to myself "oh I'll have no problem fixing that later", but now that there's code like that everywhere (and some of the hack code relies on other hack code) it's very difficult to try and fix any of it. So the biggest problem now is that because of all these things it's come to the point where when I work on it I'm not learning things so much as I am fighting the code I've already got. I'd say the game's 60% done, but at this point I'm not sure if I should bother finishing it up, or cut my losses and take the lessons I've learned to try something different knowing that this situation can arise if I don't plan out the interfaces well. Any thoughts onto any of these points?
  4. Hello, so as a beginner I'm making a 2d arcade game and as many beginners probably do, I've wound up with a hard to use software interface in my game where stuff had to be added on mid development (IE I didn't think about it at the start, and had to work around the interfaces to get features to work). Next project I'm going to try and plan out a better interface at the beginning, since to me the actual coding isn't usually as hard as making the interfaces work well together. So now I've got that situation and I want to be able to attach particle systems to my game objects (I've got a base class that all of the monsters, bullets, players etc. are derived from). I'm using Haaf's Game Engine for the record, and it has a nice particle system class that I want to make use of. Basically I want to have the following features: 1. Be able to attach a particle system to an object. 2. Be able to change the particle system attached to an object. 3. Be able to start/stop the particle system from shooting off particles. The problem is I'm not sure of a good way to do this. The way I've thought of might work but it seems really dangerous and sloppy. Here's the approach that seems like it might work to me: Add a pointer as a member of GameObject (ie hgeParticleSystem* m_particles). Initialize this pointer to NULL in the objects constructor. When attaching a particle system, check to make sure that m_particles is NULL, if it's not then delete m_particles before making m_particles equal the newly send in particle system pointer. In the objects destructor, check if m_particles is NULL, if it's not null then delete it so that it doesn't cause a memory leak. This seems like a sloppy way of doing things to me since you have to check for NULL in several spots to make sure you don't get a memory leak. Should the GameObject class even have the member pointer to the hgeParticleSystem, or should it actually have an instance of it (not sure how that would work)? Here's the page I've been looking at to try and figure out the particle system hgeParticleSystem. Any help would be appreciated here.
  5. Mr_Threepwood

    rand(), while, and vectors (oh my!)...

    The way you did it looks reasonable to me, you don't need to do srand every time it rolls the die though (seeding it once in a program randomizes the random number generator). Edit: Actually, you don't need the vector at all since you never actually use the data in the vector. For some reason I read that it returned a vector, maybe I'm going crazy. int d4(int rolls) { int total=0; //You should initialize this srand(time(0)); //This only needs to be done once in the program, not every roll for(int i = 0; i < rolls; ++i) { int CurrentRoll = (rand() % 4 +1); total += CurrentRoll; while(CurrentRoll == 4) { CurrentRoll = (rand() % 4 +1); total += CurrentRoll; } } return total; } Re edited the source since I didn't like the variable name I'd used.
  6. Mr_Threepwood

    Problem having rectangles in different places

    One problem is that it always sets all of the elements to used to 0, so the check you do at the start of the function that sets them has no effect. So it won't know what blocks were used previously. Also for your start case you just set the position of the rects, but don't tell it that those spots are now used. The loop that you have seems illogical, because it has to keep on trying until it happens to select 2 spots. Why not just do something like pick the unused spot, then pick one of the remaining two spots that aren't used? The way you have it makes it technically possible for an infinite loop (won't happen in practice). It would also make more sense to have the positions in an array, rather than individual variables. Another thing is that your function that checks for array equality is ugly(and also wrong, you have it checking used[2] == used[2] rather than used[2]==temp[2] ), it would make more sense to make a general purpose array equality function using templates that takes two arrays of the same types and then loops through the elements. [Edited by - Mr_Threepwood on March 26, 2008 3:20:04 PM]
  7. Mr_Threepwood

    Handling C++ Projects

    One way to know about the HGE object in that file would be to include something like: extern HGE* myHge; Near the top of the Entity.cpp file (you will also have to include the HGE headers). Another option would be to pass the HGE object into the render function by a call in Main.cpp. As for textures, you could do the same things, either pass them in or use the extern keyword on the globals in the other file. I'm not sure about what is the neatest/proper way to do this since I'm also a beginner, so far I've been using globals for textures. I'd imaging in a larger project some sort of texture manager or something would be needed since manually declaring all of the textures would get huge.
  8. Mr_Threepwood

    Windows API documentation

    Ok thanks for the replies, I'm trying to make a small windows application so maybe it's not my best bet to try and use the WinAPI directly. Maybe I'll mess around with the form designer in VC++. How much better (easier to use) is the windows application making process in VC#? I'd imagine it would be more user friendly than in C++, but is it user friendly enough to warrant me trying out C# rather than C++ for this application? I've never used C# and am only novice-intermediate in C++, but if it's a much nicer interface than I could give it a shot. The only real requirements I want is that it can run as a standalone program (not needing an interpreter to be installed or anything), and it only has to run on Windows.
  9. Hello, I'm having one hell of a time figuring out how to use the Windows API documentation and I'm wondering if I'm doing it right. Right now I've just been using the help in VC++ on MSDN, and it could be that I don't understand the organization, but personally I find the help files to be organized terribly. I'm used to the Java API documentation, which is incredibly organized and easy to read IMO. I'm trying to make a windows app using the windows API to create buttons, lists, etc, but I'm wondering if I'm even looking at the right thing for the documentation. Is there a downloadable version or a more organized version somewhere? It really drives me bonkers when every click causes a page refresh (flashing white for a second).
  10. Mr_Threepwood

    Developers Mentality

    Quote:Original post by wodinoneeye Quote:Original post by Cl0vis Just wondering what kind of mentality a developer would need to be successful. I know I don't really have what it takes, I rarely find the creation of anything to be satisfying mainly because the learning process is usually difficult it takes time and what comes out at the end although good is never enough to warrent the effort involved to create it. I was just wondering what makes developers satisfyed by what they do or if infact you are satisfyed? Is it really just that you have made a game and people give positive comments or that you earn some money from it. Why do you do it? Be aware that many companies dont operate in a miode that let you be satisfied with what you produce. Schedules and funding limitations often cause products to be half finished (but working 'good enough' to get by). Ive been professionally both a Programmer/Designer and a QA tester and Ive seen too much crappy code/applications that were a far ways from being what they could and should have been before being sold. Unfortunately that is the real world. Too many times Ive played a game and have seen incredible problems and lack of quality which could/should have been fixed, but past a certain point the game company simply stops doing patches (like after the 2nd one) leaving the game forever in that shoddy state. Vampire the Masquerade: Bloodlines :P. Awesome game but wasn't finished. I program mostly because it's fun, but when doing projects it can definitely get to a state where it's frustrating. That's when I find it a good time to take a break from the project (and programming) for a day or so. You also have to be good at reading is a big factor, this isn't good for me because I'm not a great reader. I mean I can read fine, but the problem is I get bored/distracted very easily when reading. Every time I open up a page on a topic and it's over 2 pages long then it's really a bummer to get through.
  11. Mr_Threepwood

    New here !

    Well a good place to start with graphics is probably by checking out the XNA starter page. I've never used XNA myself, but it's fairly popular and seems nice. If you're new to programming though I would seriously recommend not doing any graphical game programming for now, and first getting a solid understanding of programming concepts by reading a good book. It may seem tempting to dive right in to programming graphical games, but it could end up just bogging you down in the long run if you don't know the concepts. A good starter project would be to program something like tic-tac-toe using console output.
  12. Mr_Threepwood

    New here !

    1. That's subjective, there is no "best language" and it's something that's asked every other post here. Stick with C# if you started with it is what I'd say, it's got XNA which looks neat for hobbyist programmers. 2. Engines are basically a collection of code designed to make things like displaying something easier, and more organized. The answer to the second half of the question is you won't use them for a long time probably. To use those engines you're going to need much more programming knowledge, linear algebra knowledge, and graphics programming knowledge. 3. If you feel confident enough then start off by making something like pong (using XNA for the graphics), but even that requires a decent grasp of programming. If you are new at this then your best bet is probably to get a decent book and work through programming examples and exercises. Check out the books section of this site or just go on Amazon and look at reviews. Since this is in the beginners section I've gone and assumed you are a beginner to programming in general, if that's not the case then you could focus on learning more game specific things. I'm not exactly "new" at programming but I am far from an expert, for me I've been taking game programming in smaller steps. Learning general programming techniques before you attempt to make games is always nice, college has been pretty good for that. A lot of it is just trial, error, and research is what I've found. My first real game program was tick tack toe, then pong, and now I'm working on a 2D arcade game. Those seem like logical steps to me that you could try if you want. You mention you want to make a 3rd game, so you've already done two? If so what are they, if that was a typo and you meant 3D then you may be aiming a bit high. [Edited by - Mr_Threepwood on March 13, 2008 3:42:08 PM]
  13. Mr_Threepwood

    Music in games legality

    I'm just wondering about the legality of using music from other video games, is that illegal or OK if I don't sell the game for money? The reason I ask is because I've seen a lot of remakes of games recently (classic adventure games and others) that use the original soundtracks, so I was wondering if I could do the same or not. I'd really love to use that heavy metal music at the start of Doom 3, but the last thing I want is a lawsuit from a huge company :P. If that's illegal I guess I'll attempt to find something similar that is free.
  14. Mr_Threepwood

    Larger scale collision detection system

    Ok I Think I thought of a *reasonable* way to actually implement the resolution, but it still bugs me. I did more research on dispatch techniques and here's what I've basically come up with for the resolution. So we're at the point where we have all of the collisions detected, right, now we have to actually deal with them. Since all of out objects came from a generic GameObject class, put pure virtual functions in for every kind of collision, so here's a snippet that would exist if we only had the base class and two subclasses (called Bullet and Monster): Ignore small syntax errors if I've made them, I haven't actually implemented this yet, just thought about it. in the GameObject class: virtual void PerformCollision(GameObject& objHit) = 0; virtual void PerformCollision(Bullet& objHit) = 0; virtual void PerformCollision(Monster& objHit) = 0; It really bothers me having the parent know about it's children, but it's the only way I could think of getting this to work. Now in Bullet we have something like this: void PerformCollision(GameObject& objHit) { objHit.collideWith(*this) } void PerformCollision(Bullet& objHit) { //Do nothing since Bullet-Bullet collisions are meaningless in my game } void PerformCollision(Monster& objHit) { MonsterBulletCollision(objHit,*this); } In Monster we have similar code: void PerformCollision(GameObject& objHit) { objHit.collideWith(*this) } void PerformCollision(Bullet& objHit) { MonsterBulletCollision (*this,objHit); } void PerformCollision(Monster& objHit) { //Do nothing since monster-monster collisions are meaningless in my game } And then there is a function called MonsterBulletCollision (Monster& theMonster,Bullet& theBullet) somewhere that uses public methods of the monster and bullet objects to perform the collision logic (losing hit points, deaths, explosions etc.) Does this sound reasonable? Are there any glaring flaws with this? I thought having the function separated would be better than dealing with a Monster-Bullet collision and a Bullet-Monster collision in two different spots (once in Monster, and once in Bullet).
  15. Your iterator breaks when you call erase(), fortunately the erase function also returns an iterator to the next element after the one erased. So I think this would work: vector<Arrow*> Arrows; for(vector<Arrow*>::const_iterator iter = Arrows.begin(); iter != Arrows.end(); iter++) { //do stuff delete (*iter); iter=Arrows.erase(iter); } Edit: They way mentioned above by ToohrVyk is safer I think is the advantage of it, I don't understand what's going on there really but I'd guess it's safer.
  • 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!