Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 Nov 2007
Offline Last Active Feb 11 2012 05:28 PM

Posts I've Made

In Topic: Starting your career as a composer-sound designer (FAQ and answers)

05 February 2012 - 10:06 PM

I forgot that I had made this post. I create pretty much instrumental and I created a few video game related tracks. Shortly after I asked that question I started using SoundCloud.

In Topic: Sending Flags Across C# Class Flies

07 November 2011 - 05:28 AM

Firstly, a nitpick: just because you happen to have a single class per file doesn't mean that you want to send the flag between the files themselves. What you really want is a message to be passed between objects. For this, a convenient solution is the observer pattern, implemented in C# using delegates and events. On the other hand, I think this is massively overworked for what you're actually trying to do - I think you've got your class responsibilities confused. Why does the player know when it reaches the edge of the screen - why does it know about the screen at all? Have the logic update the player's position, and then test to see if the position is suitable and call 'background.Flip' (or whatever) if so.

The reason the player class needs to know where it place on the screen is because I set up collision detection to constrain the player to just the screen area. Also, the player class know about the screen is because I passed the values for the screen width and height from the main logic. Having those values let me offset the players sprite 128 pixels off of the vertical center to accommodate a hud.at the top of the screen. I don't think its all that massively worked since I have the files to organize my code instead of having a lot of data in one file. Since my background is broken down into 128 tiles over a 2D array wating for the update code. While my player class has an array that store 12 frames. 2 for animations in 4 directions and one frame for the players attack.

In Topic: C# and Three Class files

10 June 2011 - 08:55 PM

Can you post some code? There are a bunch of different things that might be causing it. The one I suspect off the top of my head is 'passing by value'.

Here's the code from the Background Class file:

// OverworldX and OverworldY
//	are supposed to pass the data from m_nOverworldX and m_nOverworldY
// 	in the main class file
public void Update(GameTime gameTime,  int OverworldX, int OverworldY)

	    // m_nX and m_nY are the varriables
            //   that manipulate the direction that the background scrolls in
            OverworldX = m_nX;
            OverworldY = m_nY;         

        void DrawOverworld(SpriteBatch spriteBatch)
            for (int y = 0; y < 8; y++)
                for (int x = 0; x < 16; x++)
                    int xx = x + m_nX;
                    while (xx >= 1)
                        xx -= 1;
                    while (xx < 0)
                        xx += 1;
                    int yy = y + m_nY;
                    while (yy >= 1)
                        yy -= 1;
                    while (yy < 0)
                        yy += 1;
                    spriteBatch.Draw(m_objTile[xx, yy], new Rectangle(x * m_nScreenWidth , y * m_nScreenHeight +128, m_nScreenWidth, m_nScreenHeight -128),

Where I accessed OverworldX and OverworldY the main class file:

  m_objBackground.Update(gameTime,  m_nOverworldX,  m_nOverworldY);
            // Heroheight and HeroWidth are equal to m_objHero int the link class  

This where I pass the player sprite height and location data to the main class file.

   public void Update(GameTime gameTime, int HeroHeight, int HeroWidth, 
           int HeroDirX, int HeroDirY)
            // HeroHeight and HeroWidth pass the values for the m_objHero
            //  height and width to the draw function in Game1's draw function.
            HeroHeight = m_objHero[m_nDirection * 3 + m_nFrame + m_nPlayerAttack].Width;
            HeroWidth = m_objHero[m_nDirection * 3 + m_nFrame + m_nPlayerAttack].Height;
            // sets HeroDirX and HeroDirY to m_nHeroDirX and HeroDirY
            //  So those varibles can be accessed by the game1 class
            HeroDirX = m_nHeroDirX;
            HeroDirY = m_nHeroDirY;

This is where it returns to:

     m_objLink.Update(gameTime, m_nHeroWidth, m_nHeroHeight, 
                m_nHeroDirX, m_nHeroDirY);

This is the code that check to see if the player is at the edge of the play area.
Its supposed to return a value for m_nOverworldX and m_nOverworldY.
Then that valued is passed to the a background so that it can change in the direction that the player is heading in.

// when m_nHeroHeight is equal to window's height and with
            // Draw m_objhero on the tile next of the current one on screen
            if (m_nHeroWidth + m_nHeroDirX > Window.ClientBounds.Width)
            if (m_nHeroDirY == 0)
            if (m_nHeroHeight + m_nHeroDirY == Window.ClientBounds.Width)
            if (m_nHeroHeight == 128)

To be honest I'm just trying to pass the variable accross the class files.

In Topic: Starting your career as a composer-sound designer (FAQ and answers)

04 June 2011 - 07:36 AM

What would you suggest as good digital portfolio for music?

In Topic: What is wrong with this code?

02 June 2011 - 08:50 AM

You might want to consider breaking your code down into a few more cpp and header files. You might be better off using Visual Studio Express, I think that would be a better IDE for you. Organize your code and build your project often while you code. Work with one thing at a time and make sure it works and complies before moving on to the next. thing.