Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

177 Neutral

About Kazuo5000

  • Rank
  1. Kazuo5000

    C++ help

    I highly recommend the Handmade Hero series (https://hero.handmade.network/episodes). You'll learn a lot about the underlying stuff that the engines, you may use, do. There is a lot of material and he explains it in depth and from someone who has made game professionally. 
  2. I highly recommend reading this blog post http://scientificninja.com/blog/write-games-not-engines. It gives a general description of what an engine is, and also good reasons to why you should really just go out and make games and not worry too much about engines. You'll find when you make games, you may reuse some code from a previous project. If you find yourself doing this, then you could refactor this and package it into your won framework/Game Development Library/Engine
  3. Kazuo5000

    Question About Vectors

    First thing: TileContainer is just a redefinition of std::vector<Tile>. So you need to create a TileContainer: TileContainer tileContainer; Second thing: you declare TileContainer to hold a Tile. You then declare a Tile pointer (Tile*) and then dynamically allocate memory for a Tile (new Tile()). Your vector container does not store Tile*, so you would need to need to either do: Tile tile; ... ... tileContainer.push_back(tile); or do: tileContainer.push_back(*tile); // dereference the pointer to put a copy of the object into the vector delete tile;
  4. Your vectors are not storing pointers. If they were storing pointers they would be declared something like this: vector<particle*> v_pParticles; // store a pointer to a particle whereas you are storing a particle object. When you call erase for your vector this will call the destructor for the particle and thus destroy your particle. If however, you have pointers to textures or other objects that are not released or destroyed then when your particle object is destroyed this will leave memory leaks. The objects you are storing in the vectors is where you should be looking for your memory leaks (in your example the Particle class and the Enemy class to see if every new or new [] has a delete or delete[] and all pointers are not left dangling).
  5. Kazuo5000

    Composition vs Virtual Inheritance

    Every example I've seen on the subject suggests that composition is emulating an inheritance model. In the above example I called the classes Components just for illustration purposes.[/quote] Composition is NOT inheritance. Inheritance models an ' is a' relationship, for example, a Duck is a Bird. Where as the composition models a "has a" relationship, for example, a Car has an engine, has an exhaust etc. Each component is its own object: struct Engine { /* engine stuf here */ } struct Car { Car(); ~Car() void Upate(float dt); private: Engine* m_Engine; } Car::Car() { m_pEngine = new Engine(); } void Car::Upate()float dt) { m_pEngine->Update(dt /*, Any more params it needs */); }
  6. Kazuo5000

    Multi Array Directx C++

    If this dynamic declaration of a new two dimensional array is within a function this is fine. however, if cv_Vertices is part of a class, you can not declare a two dimensional array like this, a[X][Y]. To be honest, I am not totally sure why, but I have encountered the same problem. However, there is no difference between a single dimensional array and a two dimensional array (or even an Nth dimentional array). [font="'Courier New"]In memory [/font]OURCUSTOMVERTEX[HEIGHT][WIDTH] is the same as OURCUSTOMVERTEX[WIDTH*HEIGHT]. It is easier to visualise it and understand it when written like this, a[1][1]. All OURCUSTOMVERTEX[HEIGHT][WIDTH] is doing is accessing the the array like so, cv_Vertices[i * WIDTH + HEIGHT]. so for example if you want an array of vertices that is 10 x 10 you can declare it like this: OURCUSTOMVERTEX *cv_Vertices = new OURCUSTOMVERTEX[10*10]; and then iterate over the array like so: for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) [font="'Courier New"] cv_Vertices[(i * 10) + j] = { /* vertex info */ };[/font] [font="'Courier New"] [/font] [font="'Courier New"]if for ease of use you want to access your array of vertices like a two dimensional array you could write a wrapper class that allows you to index into your array like a two dimensional array:[/font] [font="'Courier New"] [/font] [font="'Courier New"]class Table // 2 D arrays are often visualised like a table -- Columns and Rows[/font] [font="'Courier New"]{[/font] [font="'Courier New"]public:[/font] [font="'Courier New"] Table(int width, int height);[/font] [font="'Courier New"] ~Table;[/font] [font="'Courier New"] [/font] [font="'Courier New"] OURCUSTOMVERTEX& operator[][] (int i, int j);[/font] [font="'Courier New"] .......[/font] [font="'Courier New"]private:[/font] [font="'Courier New"] OURCUSTOMVERTEX* cv_Vertices;[/font] [font="'Courier New"]};[/font] [font="'Courier New"] [/font] [font="'Courier New"]Hope that helps[/font]
  7. Kazuo5000

    C++ class design questions

    Quote:Original post by simpler Oh thanks alot! I didn't remember there were pure virtual functions. What does a virtual function do, I thought it was used for polymorphism as well. What is the big difference? And yes you are right that I want to use polymorphism. And you think that having a single list of all Objects is the best option? pure virtual functions are used in polymorphism: Polymorphism in C++ they allow derived classes to define their own version of the pure virtual function. So when you do: Object* pObject = new Platform; // create a pointer of type object and point to a platform object pObject->Update(deltaTime); // this will run Platform's update, not Object's update. it will call the Platform's update. Having a single list of objects (i.e. std::list<Object*> objectList) is a good idea as it allows you to perform a single update and render loop: std::list<Object*>::iterator ObjectIter = objectList.begin(); for(ObjectIter, ObjectIter != ObjectList.end(); iter++) { (*ObjectIter)->update(deltaTime); (*ObjectIter)->render(); } and therefore do not have to provide a update / render loop for each object type there is. Plus when creating a level file using an editor, everything is based off Object so when loading in the level everything can be stored in that list. Obviously as you write more of your game, you may want to create more lists that hold objects, for example, you could have a list that holds only the objects on screen and a list to hold the objects that are offscreen and then you would only need to update and render the onscreen object list. Play around with it and find an approach that suits your game. Merry Xmas, and again I hope this helps!
  8. Kazuo5000

    C++ class design questions

    Should I use a single std::list<Object*>ObjectList or one list for all different types of Objects? At the minute the class design for Object wouldn't successfully allow you to do, std::list<Object*>ObjectList. I gather you are trying to (either unknowingly or not, to use Polymorphism to allow each object to be update etc through the one list), to do this you need to add some pure virtual functions to the Object class that derived (inherited / child) classes will then overwrite. This will allow you then to do the following: std::list<Object*>::iterator ObjectIter = objectList.begin(); for(ObjectIter, ObjectIter != ObjectList.end(); iter++) { (*ObjectIter)->update(deltaTime); } so your would need to add some functions like this: virtual void update(float deltaTime) = 0; // = 0 makes it a pure virtual function virtual void render() = 0; and this would allow you to use polymorphism, and also declare a list of Object*'s. And then you can do this: objectList.push_back(new Platform); Hope that helps!
  9. Kazuo5000

    Reset states of the matrix

    The matrix identity for a 4x4 matrix is 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 so, if matrix a is the identity matrix and matrix b is a translation matrix a * b = b The when multiplied with the identity it does nothing. So the identity will 'reset' the world matrix and when used in with the next object it will not be affected by the previous transformations (rotation, scaling etc.) Use: // object 1 transformation and rendering here D3DXMatrixIdentity(&matWorld) // set the world matrix to its identity m_pDevice->SetTransform(D3DTS_WORLD, &matWorld); // render 2nd object.
  10. Kazuo5000

    Reset states of the matrix

    if you are rendering objects seperately (without data encapsulation) you would do (Psuedocode) // object one RotateMatrix ScaleMatrix Transform Multiply SetWorldMatrix (SetTransform) RenderObject // end of object one rendering LoadMatrixIdentity(worldMat) => DirectX it's D3DXMatrixIdentity(&matWorld) // object two RotateMatrix ScaleMatrix Transform Multiply SetWorldMatrix (SetTransform) RenderObject // end of object two render .. and so on... Hope that helps
  11. Kazuo5000

    Strange error in my class

    From the error its producing it looks like you are doing this: In your header you declare Load to be: void Load(char fileName[], IDirect3DDevice9 *Dev); but in the implementation you have it as: void SKINNEDMESH::Load(char *, IDirect3DDevice9 *) so you need to have void Load(char fileName[], IDirect3DDevice9 *Dev); changed to: void Load(char* filename, IDirect3DDevice9 *Dev); The error is saying that a symbol is missing, this usually means that you are trying to call a function that has not been declared. In your case you are calling a member function that does not exist in the class SKINNEDMESH for the reasons above. Hope this helps.
  12. Kazuo5000

    Strange error in my class

    void SKINNEDMESH::Load(char * const,struct IDirect3DDevice9 *) does not match what is in the Header file: void Load(char fileName[], IDirect3DDevice9 *Dev); so it is looking for a function that does not exist.
  13. Kazuo5000

    SSE in Assembly - wrong output

    CPPNick, I think its because you cant directly access the SSE registers like you can with normal CPU registers, but I am not entirely sure on this. You could always try loading in the address of [a] instead using the lea command. Personally, I don't have a great deal of knowledge in SSE but have a little bit of experience in it. Again I hope this helps
  14. Kazuo5000

    SSE in Assembly - wrong output

    Hey there, One thing I did notice is you did not align your data. SSE can only accept 16 bit aligned data. So I think you need to do a __declspec(align(16)) (if the underscores did not get posted then there are two underscores before declspec). Ive not seen the movups command before. I would first load the data into a normal asm register (eax for example) and the do movdqa xmm0, [eax]. Hope this helps
  15. Try the Exceptional CPP book by Herb Sutter. Lots of problems in there. Exceptional CPP As to the AddandReturn function it is a bit ambiguous. - Do you want to increment value and then return it or - Increment the value and then return the old value?
  • 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!