Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

119 Neutral

About dynamiteandy

  • Rank

Personal Information

  1. dynamiteandy

    A Super Mario Source Code

    Nice, I like it. But as already mentioned, remember to put your required .dll's and other files in the zip.
  2. Hi, I have this class called panel and a class that manages this class called panel manager. A panel can have a color, a type, and a size this is set by using the randomize function which calls protected functions in the panel class. The functions used to determine the type of block is shown below.   The numbers in the returnColour class are used for returning the image of the block that should be used. void panelManager::setActive(int i, bool active) {     gamePanel.Randomize();     gamePanel.setActive(active); } void panelManager::Randomize(TextureManager *textureM) {     for (int i = 0; i < MAX_PANELS; i++)     {         gamePanel.Randomize();         gamePanel.setTextureManager(&textureM[gamePanel.ReturnColour()]);     } } //============================================================================= // Non-protected function for outside user for randomizing the block when the // game is finished. Function will call set size, set type then set colour to // provide the block with a random image. //============================================================================= void Panel::Randomize() { countdown = rand() % 60 + 1; setSize(); setType(); setColour(); switch(rand() % 2 + 1) { case 1: active = true; break; case 2: active = false; break; }; } //============================================================================= // Protected function for setting the size of the rectangle, a block can either // be small or large. //============================================================================= void Panel::setSize() { switch(rand() % 2 + 1) { case 1: size = panelNS::SMALL; // Block is small height = 57; spriteData.height = height; // Size of the panel spriteData.rect.bottom = height; // Size of the panel break; case 2: size = panelNS::LARGE; // Block is large height = 74; spriteData.height = height; // Size of the panel spriteData.rect.bottom = height; // Size of the panel break; } } //============================================================================= // Protected function for setting the type of block //============================================================================= void Panel::setType() { switch(rand() % 6 + 1) { case 1: type = panelNS::NORMAL; // Standard Point Block break; case 2: type = panelNS::DEATH; // -100 Points Block break; case 3: type = panelNS::DOUBLE; // *2 Points break; case 4: type = panelNS::SLOW; // Slow the opponent down break; case 5: type = panelNS::SPEED; // Speed the player up break; case 6: type = panelNS::SUPER; // Add the friend player break; } } //============================================================================= // Protected function for setting the colour of the block //============================================================================= void Panel::setColour() { if (type == panelNS::NORMAL) // If the panel is a normal type { // Give it a normal colour switch(rand() % 6 + 1) { case 1: colour = panelNS::PINK; break; case 2: colour = panelNS::YELLOW; break; case 3: colour = panelNS::GREEN; break; case 4: colour = panelNS::BLUE; break; case 5: colour = panelNS::RED; break; case 6: colour = panelNS::PURPLE; break; } } else // Otherwise its a powerup block so give it { // a powerup colour colour = panelNS::POWERUP; } } //============================================================================= // Panel Return Colour, Usies the size colour and type to return the number // ID of the correct block //============================================================================= int Panel::ReturnColour() { switch(size) { case panelNS::SMALL: switch(colour) { case panelNS::POWERUP: switch(type) { case panelNS::DEATH: return 0; break; case panelNS::DOUBLE: return 2; break; case panelNS::SLOW: return 4; break; case panelNS::SPEED: return 6; break; case panelNS::SUPER: return 8; break; } break; case panelNS::PINK: return 10; break; case panelNS::YELLOW: return 12; break; case panelNS::GREEN: return 14; break; case panelNS::BLUE: return 16; break; case panelNS::RED: return 18; break; case panelNS::PURPLE: return 20; break; } break; case panelNS::LARGE: switch(colour) { case panelNS::POWERUP: switch(type) { case panelNS::DEATH: return 1; break; case panelNS::DOUBLE: return 3; break; case panelNS::SLOW: return 5; break; case panelNS::SPEED: return 7; break; case panelNS::SUPER: return 9; break; } break; case panelNS::PINK: return 11; break; case panelNS::YELLOW: return 13; break; case panelNS::GREEN: return 15; break; case panelNS::BLUE: return 17; break; case panelNS::RED: return 19; break; case panelNS::PURPLE: return 21; break; } break; } } 0 & Evens = Small block, Odds = Large Blocks   So, during the game when I'm checking for collisions If a collision has occurred I return the block type and perform the correct action, for example a death block = score - 100 and so on. But somewhere, something is going wrong and the block types are getting messed up, for example the large blue block should have the normal type but will somehow become a super block and im very uynsure how.   This is shown on a video I uploaded of my progress at the time 34/35 where the opponent hits a normal colour block.     The code that I'm using for checking for collisions is this.   //============================================================================= // Handle collisions //============================================================================= void CreateThis::collisions() { VECTOR2 collisionVector; if(gameBall.collidesWith(player, collisionVector)) { gameBall.bounce(collisionVector,player); activehit = 1; } if(gameBall.collidesWith(opponent, collisionVector)) { gameBall.bounce(collisionVector,opponent); activehit = 2; } if(gameBall.collidesWith(friendpower, collisionVector)) { gameBall.bounce(collisionVector,opponent); activehit = 0; } for (int i = 0; i < MAX_PANELS; i++) { if(gameBall.collidesWith(gamePanels.ReturnPanel(i), collisionVector)) { gameBall.bounce(collisionVector,gamePanels.ReturnPanel(i)); gamePanels.setActive(i,false); if (gamePanels.ReturnType(i) == "Death") { switch(activehit) { case 1: player.UpdateScore(-100); break; case 2: opponent.UpdateScore(-100); break; } } else if (gamePanels.ReturnType(i) == "Super") { switch(activehit) { case 1: if (!friendpower.getActive()) { friendpower.setCenteredPosition(156,GAME_HEIGHT/2); friendpower.setActive(true); friendpower.setTextureManager(&paddleTexture[8]); } break; case 2: if (!friendpower.getActive()) { friendpower.setCenteredPosition(GAME_WIDTH-156,GAME_HEIGHT/2); friendpower.setActive(true); friendpower.setTextureManager(&paddleTexture[7]); } break; } } } } } Entity panelManager::ReturnPanel(int i) { return gamePanel; } std::string panelManager::ReturnType(int i) { switch(gamePanel.GetType()) { case 0: return "Normal"; break; case 1: return "Death"; break; case 2: return "Double"; break; case 3: return "Slow"; break; case 4: return "Speed"; break; case 5: return "Super"; break; } } I'm very unsure as to where I am going wrong and would really appreciate some help in finding out where.. I'm hosting this on my dropbox for accessing it in different places if you wanna have a look to possibly help me fix this feel free to. If you go to compile the game it requires the june 2010 directX sdk.   https://www.dropbox.com/sh/6bsif5da5iaeoc9/UsFCs-zYdI
  3. dynamiteandy

    C++ - Passing array of textures through function

    That fixed that bit, but now i face this problem in panelManager intialize.   bool panelManager::initialize(Game *gamePtr, int width, int height, int ncols, TextureManager *textureM) { for (int i = 0; i < MAX_PANELS; i++) { gamePanel.initialize(gamePtr,panelNS::WIDTH,gamePanel.getHeight(),ncols,textureM[gamePanel.ReturnColour()]); } } 1 IntelliSense: invalid destructor declaration 2 IntelliSense: no suitable conversion function from "TextureManager" to "TextureManager *" exists Edit: Think i got it, replaced textureM[gamePanel.ReturnColour()] with &textureM[gamePanel.ReturnColour()]
  4. Hi, So in my game I've been working on all morning I've decided to create a class that will manage the multiple panels in my game.   Before this I was originally just making the panels in the game loop. So anyways in my game.cpp file I have texture array which has all the textures for the panels.   TextureManager panelTexture[22]; Is what it is. This was initalised calling the function initalize with the following parameters, the panel had a variety of sizes and colours. hence the two functions inside of it. if(!gamePanel.initialize(this,paddleNS::WIDTH,gamePanel.ReturnSize(),0,&panelTexture[gamePanel.ReturnColour()])) throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing player paddle")); because i've now decided to use this manager class the function will now need to pass the panelTexture array to the panel manager class. Like so? // Panelmanager.h virtual bool initialize(Game *gamePtr, int width, int height, int ncols, TextureManager *textureM[]); // Panelmanager.cpp bool panelManager::initialize(Game *gamePtr, int width, int height, int ncols,                             TextureManager *textureM[]) {     for (int i = 0; i < MAX_PANELS; i++)     {         gamePanel.initialize(gamePtr,panelNS::WIDTH,gamePanel.getHeight(),ncols,textureM[gamePanel.ReturnColour()]);     } } So i am now able to call the panelmanager initalize function to initalize the game panels., however im having problems with this.   if(!gamePanels.initialize(this,0,0,0,&panelTexture)) throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing player paddle"));   I cant seem the pass the array, when i try &panelTexture i get the following error 1 IntelliSense: argument of type "TextureManager (*)[22]" is incompatible with parameter of type "TextureManager **" when i try &panelTexture[] i get this error 1 IntelliSense: expected an expression Basically I am stumped with errors at this bit, Could anyone advise on how to get past this?
  5. dynamiteandy

    Coding Style: Curly Braces

    When it comes to curly braces... I used to do this... if (x == 0) // do something else // do something else But during university I was taught that I should always use curly braces and I should always comment everything - my lecturer was pretty strict with coding styles and marked us on the style instead of the code itself. Since leaving my coding style has changed from above to.. // Used to check if x is equal to 0 if (x == 0) { x = 5; // give x the value of 5 } else // if x is not equal to 0 then do this { x = 4; // give x the value of 4 } Personally I now find this easier on the eyes and easier to read, However i've found myself now starting to do this for functions void ReturnX() { return x; }
  6. dynamiteandy

    Keeping functions in a game engine. Switching engines

    &nbsp; &nbsp; What I was referring to is actual code, the game engine that I'm currently using is written in c++ and uses only .cpp and .h files.
  7. I liked a @YouTube video http://t.co/qiMjuiOcAZ Linkin Park - CASTLE OF GLASS (featured in Medal of Honor Warfighter)
  8. Being developer's when a game engine doesn't have a function that we require, we build our own - such as returning certain things we may require, However game engines tend to be updated regularly and when we move to a new version of that engine we lose the functions that we have built and incorporated into that engine. I was just wondering how people managed to move from the old engine to a newer versions keeping their functions without having to constantly remake them?
  9. Considering building a mousehover function that will detect if the mouse xy is over an image. hmm.
  10. dynamiteandy

    C++ Function to center image?

    That did the trick, thank you! :)
  11. Hey, So i'm working with a game engine that was wrote by charles kelly for his book programming 2D games. His engine is rather good, however positioning images is rather bad as it does it as x = left corner and y = top of image I don't want to do the maths to center an image in the position x,y i'd much rather write a function for it.. there's already functions for getting the center x and center y.   however how would i go about writing a function so that it takes int x, int y and moves the image so that its center is x,y? // Return center X. virtual float getCenterX() {return spriteData.x + spriteData.width/2*getScale();} // Return center Y. virtual float getCenterY() {return spriteData.y + spriteData.height/2*getScale();} // getScale() incase needed // Return scale factor. virtual float getScale() {return spriteData.scale;} The image to above shows what im after.. red = current setting. blue = what im after
  12. Been a rather productive day, ported some of my game to a new engine and developed a few extra text features for it. More to do tomorrow...
  13. Head deep in books today, 2D Game Collision Detection, 2D Game Programming and several others.
  14. World of Warcraft Horde Shirt for your Xbox Avatar - Raptr Reward http://t.co/ah1LCe1Rqt
  • 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!