Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

293 Neutral

About StoneMask

  • Rank
  1. Huh, looks good. Thanks Nypren! I think this will work with what I'm trying to do.
  2. I am trying to make a game in the console. (MS-DOS, right?) Here's an example from a really early build of the game. I'm trying to work under certain limitations.   So there's just some stuff I'm confused about and I'm not sure how to remedy. Like if I want to make it so you can "walk" unless you hold a button allowing you to "run". I could live without that feature, but if there's a way to do it I'd like to try and implement it. As long as I can make it compatible with most modern Windows OSs then I should be fine. I just want it done.
  3. Do you think _kbhit/getch() would be my best bet then? I'm probably not aiming to be crazy cross-platform. As long as it works for Windows I'm fine.   I thought of using DirectInput or something similar, but I'm not sure how it'll effect the filesize of the executable or if something like that would work with the console. Again, as long as it works with pretty much all versions of Windows I could maybe compromise with my limitations. I'm pretty much trying to make it so this could fit on a floppy disk.
  4. I've sifted through a lot of topics on the internet (including looking at the code for this article, which looked useful but didn't explain much to me as a beginner) and I need a lightweight, simple method for handling real time input in the command prompt window. I was using the kbhit()/getch() combination for awhile, but I don't think I can make that work for say, if I'm holding a key down that alters the actions of pressing a different key, like if I hold the B button on a controller to run. I'm also using a game state driven structure and so I would think I'd need to make some kind of object to handle this stuff to make things cleaner.   The problem when I look at these is that I'm just not experienced in these methods or the lingo involved. They almost never explain things. I tend to learn pretty well through explicit definitions, rigorously varied examples, perhaps some underlying mechanics, and pro/con analyses. But most people just say "do this followed by this" and it discourages me because I like to micromanage when possible, and I can never get to a point where I know everything someone is saying unless I spend hours in Google. In this case I specifically do not want to put bulky libraries in my code because I have to keep the filesize ridiculously small, and I thought it might be easier if I coded my own method for my specific purposes so I don't have extraneous bits lying around. It'd be awesome if I could figure out controller input as well.   If someone could explain a good way to do this I'd be really grateful. Thanks!
  5. StoneMask

    Cannot initialize constant base member value

    I'm using the EntityIDs enum to differentiate between what kinds of objects are colliding during each Collide() function. So my IDs consist of things like Block, Player, Enemy, etc. It's what I'd figure I'd use. Since I don't intend to have any of the types change it's also a constant that is accessible publicly so I don't have to have a GetType function. Just other->ID. That's still fine, right? Though I guess it is kind of a hassle with stuff like this.   I've seen games that have entities that each have unique IDs. Would I come up with some method for generating one and then initialize them with that unique ID in a similar fashion?
  6. StoneMask

    Cannot initialize constant base member value

    Oh gosh. Thank you so very much. Everything's working now.
  7. StoneMask

    Cannot initialize constant base member value

    Okay, sorry, again, I'm tired, so I'm skimming details. I do have that.   class Entity { static unsigned short Count; public: Entity() : ID (eIDError) {} Entity(EntityIDs id) : ID (id) {} const __int32 ID; }; class Block : public Entity { public: Block() : ID (eIDError) {} Block(EntityIDs id) : ID (id) {} }; In the Block class it gives me the same aforementioned error:   error C2614: 'Block' : illegal member initialization: 'ID' is not a base or member Unless I redefine ID in the child class, which again, brings up issues over the ambiguous ID.  
  8. Okay, I've literally struggled with this for hours, because I had a base class that had a value class base { public: const __int32 ID; }; the ID would be filled with a value that designates what kind of entity it is, and the program wouldn't work unless I also defined a const __int32 ID in my child classes as well. This led to ambiguous use of ID which caused me many hours of frustration. And now I simply can't figure out how to do it; if I remove the second ID from the child class it won't allow me to use the constant in my base class under any circumstance. I've looked online and nobody else seems to have this issue. I tried doing fancy things with overloading constructors and whatever, but the compiler will not let this go. I don't know what rule is keeping me from assigning an ID value into my child class when creating a new object of this type. I wouldn't know what this issue is called. I have the error code and that didn't help me. (For instance, C2614: 'Block' : illegal member initialization: 'ID' is not a base or member)   I'm really tired and out of it and I essentially spent an all nighter on a probably really stupid thing. Does anyone know what problem I'm having so I can move on with my life?  
  9. This is probably really simple, but I absolutely cannot find a solution anywhere online. I've included the libraries D3D11 and D3DX11, as well as DirectXMath, and LPDIRECT3DTEXTURE9 supposedly isn't on them, and I can't find anything that looks similar in Intellisense. What am I supposed to use for those kinds of objects--ie, LPDIRECT3DSURFACE9, D3DCOLOR, LPDIRECT3DDEVICE9, etc.?
  10. @Melkon/Nypyren Yeah, I tried that.   @phil_t Okay, so I looked it over, and it turns out that I did redeclare Position, Velocity, and Dimensions in my derived objects. I took them out and now it works perfectly.   @boogyman So what exactly would I put for a virtual destructor? For anything, really? They don't have any assets I necessarily need to delete, I think.   Once again, thank you all for your help.
  11. Block::Block(short x, short y) :     ID (eIDBlock) {     Position.X = x;     Position.Y = y;     Dimensions.X = 16;     Dimensions.Y = 16;     Velocity.X = 1;     Velocity.Y = 0;     Velocity.Z = 0; } Player::Player(short x, short y):     ID (eIDPlayer) {     Position.X = x;     Position.Y = y;     Dimensions.X = 16;     Dimensions.Y = 16;     Dimensions.Z = 0; }
  12. @Melkon I get you now. I guess the syntax just slipped my mind.   @Pink Horror Using GetX/GetY gives me the same result.   @Nypyren I figured it was some weird memory thing, because it gives me the same value regardless of what the value actually is.   I guess I forgot to mention, the "other" object is a Block object, which is practically identical to the Player object, except it has a different sprite and a velocity of 0. The problem is that it IS initialized, the COORD variable DOES have actual values, and if I output the coordinates from the Block object, it gives me the correct result. The only time it gives me issues is when I pass the Position (20, 10) to somewhere outside the Block object.
  13. The COORD type is part of Windows.h. I'm using a lot of things from it, such as SetConsoleCursorPosition. This seems to be its defintion: typedef struct _COORD {     SHORT X;     SHORT Y; } COORD, *PCOORD; I haven't written a virtual destructor for Entity. Is that essential? I don't create any new objects inside them, so I figured the default one would kick in, or am I forgetting something? If so, what should I put as a virtual destructor?   Also, what's the problem with my convention, from your point of view?
  14. @Mnemotic Yeah, I've stepped through it. The X and Y values are just what I set them to be; X of 20, Y of 10, but when it's returned, it consistently gives me -12851 for both the X and Y variables.   @Melkon I was trying to test to see if it was some weird signed/unsigned mismatch, because my friend suggested it to me, as well as to see if returning individual values helped-- obviously it didn't. I don't normally write signed/unsigned in front of everything. I'll edit that part out. The const was to specify that the getter shouldn't change anything, and that it's just to return a value. Whether or not it's there doesn't change the result.   @both My convention is to have member variables capitalized, and things like local variables to have camelCase. I don't think I'm inconsistent in it...   Thank you for your replies. I really hope to find out what's going on in here soon.
  15. I have a sort of infrastructure thing going on for running my game, and everything works just about fine, except when I return a COORD type variable to a different object, it consistently returns -12851, regardless of the value of the actual COORD values. Here's the relevant code; the problem happens in the Collide function. The Player object is a derived class of the Entity virtual base class: | void SceneManager::Init(__int32 stateID, short info) {     // initialize the level     Entities.push_back(new Player(10, 10));     Entities.push_back(new Block(25, 10));     for (short i = 0; i < Entities.size(); i++)         Entities[i]->Init(); } void SceneManager::Tick() {     for (unsigned short i = 0; i < Entities.size(); i++)     {         Entities[i]->Act(hOut);         Entities[i]->Draw(hOut);         for (unsigned short j = 0; j < Entities.size(); j++)         {             if (j == i)                 continue;             else                 Entities[i]->Collide(Entities[j]);         }     } } Collision Player::Collide(Entity* other) {     Collision info;     COORD pos = other->GetPos();          if (pos.X == Position.X && pos.Y == Position.Y)         info.Contact = true;     else         info.Contact = false;          info.Intersection.X = 0;     info.Intersection.Y = 0;     info.Intersection.Z = 0;     info.OtherID = other->ID;     info.Velocity.X = 0;     info.Velocity.Y = 0;     info.Velocity.Z = 0;     if (other->ID == eIDBlock && info.Contact)         Velocity.X *= -1;     return info; } class Entity {     static unsigned short Count; public:     Entity();     virtual void Init()  = 0;     virtual void Act (const HANDLE) = 0;     virtual void Draw(const HANDLE) = 0;     virtual Collision Collide(Entity*) = 0;     virtual bool Alive() = 0;     const COORD GetPos()  { return Position; };     const bool  GetDraw() { return Redraw; };     const __int32 ID; protected:     virtual void Move() = 0;     virtual void Die()  = 0;     COORD* Beacon;     COORD  Position;     Vector Velocity;     Vector Dimensions;     bool   Redraw;     char   Flags;     char   Frames[4];     short CurFrame, EndFrame;     short FrameDelay, FrameTimer;     unsigned short Timer; }; | Please let me know if you see anything else I did wrong, or if you need more code to work with. This is an ASCII game, so there aren't really any graphical considerations to take into account.
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!