Jump to content
  • Advertisement

MajinMusashi

Member
  • Content Count

    203
  • Joined

  • Last visited

Community Reputation

182 Neutral

About MajinMusashi

  • Rank
    Member
  1. Hi! Do you know any method to compose sprites/bitmaps at run-time? The idea is to generate a bitmap (to be used as an OpenGL texture) based on a configuration file and a set of pre-defined shapes. Those shapes should be freely translated/resized in the resulting sprite. Example: a smiley face. Supposing I have "face" and "eye" bitmaps, the user should be able to define, at run-time, the height of the eyes, their size and color, and the system should compose a final bitmap. Doing this at a per-pixel basis is not an option. Maybe using SVG/Cairo would ease my job, since shapes could be resized without any resolution loss. What do you think? Thanks a lot!
  2. MajinMusashi

    Class design of an animation library

    Quote:Original post by Anonymous Poster Does anything outside the Sequence classes need access to the Frame classes? See if you can make them inner classes or something, which may cut down on class bloat. Yes, because the frame objects are stored inside a vector in the Object-derived classes. Sequences keep only references to frames... Quote: There is something called namespace aliasing. An example of how I (would) use it: namespace win32 { class Window {...}; } namespace osx { class Window {...}; } #ifdef _WIN32 namespace os = win32; #else namespace os = osx; #endif // OS os::Window NewWindow; Very interesting trick, but how can this be applyed to the given example? Thanks a lot, AP! [Edited by - MajinMusashi on July 23, 2006 6:08:56 AM]
  3. MajinMusashi

    Class design of an animation library

    Quote:Original post by JasonBlochowiak Does it need to be anything more complicated than this? template <typename T, typename U> class cSequence { std::vector<T> mFrames; std::vector<U *> mSequences; }; typedef cSequence<cBitmapFrame, cBitmapSequence> cBitmap; class cDerivedBitmap : public cBitmap { }; Hi, Jason! I'm a bit confused about the source code you've posted. The "frames" and "sequences" don't belong to the sequence class, neither Bitmap is a sequence, nor I need a derived bitmap. Please, could you elaborate? Thanks a lot!
  4. Quote:From Samgzman: "how can components communicate when the recipients of messages are unknown to the sender?" Quote:From Hymerman: "pretty much equivalent to a message based system in which components can decide which messages they are able to recieve" Quote:From Ravuya: "One of the big problems is the overhead of message passing (e.g. picking up only the ones that Audio Player cares about)" Sorry if I haven't understood the whole thing, but aren't you talking about the almighty "Observer" design pattern? I use it, but I've changed it a bit so that the observers/subjects unregister themselves (dangling references no more), and it could be templated. Bye!
  5. MajinMusashi

    One of the best gaming websites to come

    Quote:Original post by owl Quote:Original post by xSKOTTIEx i think its funny how Juega means game in spanish. I think it's funny how little spanish you know :) "Juega" is the conjugation for the 3rd person singular of the verb "to play" (to play games). He plays the game = El juega el juego. Hi Owl! So "juegagaming" means "plays gaming" ?! Still very strange :) Abraços do Brasil!
  6. Hi! CONTEXT: I'm using C++ and OpenGL, and I'll extend an old 2D animation library (mostly used as a sprite manager) used in my little projects so that it can handle text, sound effects and streaming audio (imagine a simplified Macromedial Flash for use in games). This is the supposed class diagram: // The different "Frame" classes have different member variables. Example: class BitmapFrame { Vector2 pos; float width; float height; }; class TextFrame { Color color; Rectangle box; }; // "Sequence" classes in the same domain inherit from a base class. Example: class BitmapSequence { virtual void update( unsigned int passedTime ) = 0; }; class BitmapColorSequence : public BitmapSequence { // ... }; class BitmapMotionSequence : public BitmapSequence { // ... }; PROBLEM: I can't imagine a simple way of doing that without hardtyping a lot of code related to the frames and sequences. Maybe if something like a "templated namespace" existed things would be easier, but AFAIK this is not the case. QUESTION: Do you have any advice on how to best represent this hierarchy? Is there some design pattern I'm not aware of (or I'm not intelligent enough to understand and adapt) that would do the job? Thanks a lot! PS.: Object-derived classes need access to the Frame class, so I can't make the previous a nested class of Sequence (Sequence keeps only references to two consecutive frames) [Edited by - MajinMusashi on July 23, 2006 1:31:54 PM]
  7. MajinMusashi

    Implementing multiple game modes

    Hi, guys! The solutions using abstract classes or function pointers fall into the "State" design pattern (a better solution IMHO) category. Quote:The State pattern is used when you want to have an enclosing class switch between a number of related contained classes, and pass method calls on to the current contained class. Design Patterns suggests that the State pattern switches between internal classes in such a way that the enclosing object appears to change its class. More details here: Link (warning: PDF inside) Now I'm almost certain that DLLs and scripting languages are more than what is really needed to solve my problems, and I'll stick with the "state" solution. Thanks a lot! PS.: Please, feel free to comment/criticize
  8. MajinMusashi

    Implementing multiple game modes

    Quote:Original post by Anonymous Poster using scripts or modules would give you some mod support but is probably the best option even if you don't intend to support mods. What do you mean by "modules" and "module system"? The terms are far general... Quote:the easiest way is probably to have your engine call functions from a dll or run a script whenever X happens. this is easy if the game modes are very similar (since the number of functions that needs to be in modules or scripts would be limited), if the modes are very different the module system would be more complex (and the game would become highly modable as a side effect) I don't understand why I should keep game modes inside a DLL. Can you elaborate, please? Thanks! PS.: Do you really need to reply as an anonymous poster? [wink]
  9. MajinMusashi

    Implementing multiple game modes

    Quote:Original post by Anonymous Poster depends a bit on how complex the game is and how different the game modes are. using scripts or modules (dll/so) is great if you want a very flexible system that is easy to expand for a simple game you can use simple states or even simple if statements like this : if (mode == 1 || mode == 2) { //do this } if (mode == 2 || mode == 3) { //do this } //do this for all modes this can get really really ugly if you got lots of modes though. Yes, this is really ugly and I want to avoid it at all costs (as I've said, there will be more than four modes). The game will not be anything near the complexity of Wacraft III or Half Life, and no "mod" support is planned. Thanks!
  10. Hi! CONTEXT: I'm a not so beginner, and I'm designing a new game that is slightly more sofisticated than Pong or Breakout. In a Pong-like environment, 1P or 2P game mode is a matter of setting a boolean attribute of the game (for example, "bool singlePlayer") and checking the value of this attribute in some places of the code. PROBLEM: In this new game, this cannot be made that simple because there will be more than four modes (single player classic, single player time attack, two player time attack etc. etc. etc), and each one will present a very different behaviour. EXAMPLE: // Pong void Game::onKeyPress( Key pressedKey ) { switch( key ) { case KP_8: // Keypad 8 if ( !singlePlayer ) { rightPaddle.moveUp(); } break; // ... } } // New game void Game::onKeyPress( Key pressedKey ) { switch( key ) { case KP_8: switch( gameMode ) { case GM_SINGLEPLAYERCLASSIC: // action 1 break; case GM_SINGLEPLAYERTIMEATTACK: // action 2 break; case GM_TWOPLAYERCLASSIC: // action 3 break; // ... MAINTAINANCE HELL } break; // ... } } QUESTION: Some options that pops in my mind are to implement the "State" design pattern (used inside a "play" game state, for example), to create a new game state for each mode, or to use of a script language. What approach do you usually follow? What is the best way? Thanks a lot!
  11. CONTEXT: In my GUI library, the component's class hierarchy is defined like this (simplified for the example): COMPONENT (the base/root class) <- GRAPHICAL <- FOCUSABLE <- CONTAINER Container components contain one vector of components (actually pointers to components) for each of those types. I've made this way so the GUI don't need to search for ALL the components in a form, test if it is, for example, focusable, and finally perform a "onKeyPress" event on it (it just traverses the "focusables" vector). Currently, when a component is added to a container, the variable "Component::baseType" is used to decide to what vector(s) that component will be added. For example, a "panel" (baseType == container) will be added to all the vectors. PROBLEM: I think this approach is somewhat inelegant and prone to errors. I know of the "dynamic_cast" approach to solve this question, and also of using virtual methods to return the base type, but I don't really know what is the prefered way of doing this sort of work. QUESTION: Do you guys have any advice on how I should proceed? Is the general design decision I've made that bad?
  12. MajinMusashi

    Photoshop "drop shadow" and TGA exporting

    Hi, Professor420! I've already tried something like that, and this is the final result (note that the drop shadows kept a little of white in the exported TGA). Is this normal? ingame screenshot Photoshop screenshot Thanks! PS.: Yes, the shadows are black
  13. CONTEXT: Currently all of my projects use the TGA file format for textures (all of them created using Photoshop CS2). Recently, I've discovered how to use layer effects, and one of those interesting layer effects is "drop shadow". PROBLEM: Until now, all of the images I've created used a simple, rectangular alpha mask, but in images with drop shadows creating such masks is not anymore a trivial task. QUESTION: How do I need to proceed so that the drop shadow is kept in the exported TGA (with the correct alpha values)? Is there a semi-automated way to create that alpha mask? Thanks a lot!
  14. MajinMusashi

    Viewports Viewports

    Hi, Simplicity! Things are not ok in your code, so I'll point them: // Your first example glViewport( 0, 0, WinWidth, WinHeight ); glClearColor(1.0f, 1.0f, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glViewport( 0, 0, WinWidth * 0.5f, WinHeight * 0.5f ); glClearColor(1.0f, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); What you are doing here is telling your OpenGL program to (supposing WinWidth == 800 and WinHwight == 600): 1- Set a viewport with bottom-left at (0,0) and top-right at (800,600); 2- Clear ALL the screen to yellow (glClear will not distinguish between viewports); 3- Set a viewport with bottom-left at (0,0) and top-right at (400,300); 4- Clear ALL the screen (again?!) to red; 5- Swap the front and back buffers This is wrong for multiple reasons. You should try something like this simplified example (I can't test it right now, sorry): //////////////////// // FIRST VIEWPORT // //////////////////// // Be sure you are handling the projection matrix glMatrixMode( GL_PROJECTION ); // Reset the projection matrix glLoadIdentity(); // Set the desired viewport glViewport( 0, 0, WinWidth, WinHeight ); // Set the type of the projection matrix. glOrtho is for orthogonal // projection (for perspective, use gluPerspective or glFrustum). Remember that the bottom-left coordinate (in this case, "0,0", is RELATIVE to the bottom-left of the viewport) glOrtho( 0, WinWidth, 0, WinHeight, -1, 1 ); // From now on, use the modelview matrix to animate my scene glMatrixMode( GL_MODELVIEW ); // Reset the modelview matrix glLoadIdentity(); // Draw a square in the (0, 0, 800, 600) viewport square.draw(); // Remember to clear the depth buffer (if you use it, of course) or strange // things will happen to your scene. DON'T CLEAR the color buffer (only at the // END OF ALL THE DRAWING PROCESS) glClear( GL_DEPTH_BUFFER_BIT ); ///////////////////// // SECOND VIEWPORT // ///////////////////// // Be sure you are handling the projection matrix glMatrixMode( GL_PROJECTION ); // Reset the projection matrix glLoadIdentity(); // Set the desired viewport (it will be drawn OVER the first viewport. Is this // what you really want? Whathever... glViewport( 0, 0, WinWidth * 0.5f, WinHeight* 0.5f ); // Set the type of the projection matrix. glOrtho is for orthogonal // projection (for perspective, use gluPerspective or // glFrustum). Remember that the bottom-left coordinate (in this case, // "0,0", is RELATIVE to the bottom-left of the viewport). // WARNING WARNING: if your viewport has 400x300 pixels, this will PAST the // bounds of it glOrtho( 0, WinWidth, 0, WinHeight, -1, 1 ); // From now on, use the modelview matrix to animate my scene glMatrixMode( GL_MODELVIEW ); // Reset the modelview matrix glLoadIdentity(); // Draw a diamond in the (0, 0, 400, 300) viewport diamond.draw(); // Remember to clear the depth buffer (if you use it, of course) or strange // things will happen to your scene. DON'T CLEAR the color buffer (only at the // END OF ALL THE DRAWING PROCESS) glClear( GL_DEPTH_BUFFER_BIT ); /////////////// // FINISHING // /////////////// // Clear the color buffer glClear( GL_COLOR_BUFFER_BIT ); // Swap the front and back buffers glutSwapBuffers(); Hope it helps! Goodbye!
  15. Quote:Original post by ApochPiQ How do you actually use the GLText class? ... Whoops, just missed your last post - in this case I'd say definitely go with the approach of having each GLText instance be statically given the string to render. If you'd like to be able to change the text dynamically without allocating a new instance of GLText, just add a new SetText(const std::string&) member that overwrites the internal string. Agreed, ApochPiQ. But I'm sad for having to remove such useful feature, and sadder for the C++ Standard Libraries not to offer such useful feature in a simple and efficient manner. Is it a good idea to try to create a std::string derived class that defines the << operator, and use template specialization to treat the more complicated cases (int, float etc.)? Thanks a lot!
  • 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!