Jump to content
  • Advertisement

HughG

Member
  • Content Count

    89
  • Joined

  • Last visited

Community Reputation

116 Neutral

About HughG

  • Rank
    Member
  1. HughG

    Simple DWORD addition

    Yes but I still don't see how adding 1 to a dword increments through the different bytes. I guess I just can't visualize how adding a 1 to something increments it by a whole byte. I understand how pointer arithmetic works but this is an actual value and not just a pointer. EDIT: Wow I feel silly. Disregard the question I figured it out. Thanks! [Edited by - HughG on January 29, 2005 8:47:25 PM]
  2. I know this is probably ridiculously simple but I'm a little puzzled. I'm working with this function: inline void Plot_Pixel_24(int x, int y, int red, int green, int blue, UCHAR *video_buffer, int lpitch) { // this function plots a pixel in 24-bit color mode // assuming that the caller already locked the surface // and is sending a pointer and byte pitch to it // in byte or 8-bit math the proper address is: 3*x + y*lpitch // this is the address of the low order byte which is the Blue channel // since the data is in RGB order DWORD pixel_addr = (x+x+x) + y*lpitch; // write the data, first blue video_buffer[pixel_addr] = blue; // now red video_buffer[pixel_addr+1] = green; // finally green video_buffer[pixel_addr+2] = red; } // end Plot_Pixel_24 I believe you have to multiply x by 3 because the x you pass to the function represents the pixel you wish to start at. Since each pixel has 3 bytes then you multiplying by 3 gets to the actual memory address of the xth byte. E.G. if you wanna plot something at the 10th pixel it will be at memory offset 30. Correct? I understand the y*lpitch. Now you need to access every individual byte of each pixel. So adding one to a dword will cycle through the individual bytes inside of the dword? The code I'm referring to is: video_buffer[pixel_addr + 1]. Can someone explain why this doesn't just add 1 to whatever pixel_addr is? What if I just want to add one to a DWORD? How would I do this? TIA
  3. HughG

    Making an Array of Strings

    Congrats on getting your problem solved. One thing I might suggest is to take another look at Rob Loach's post. You may be failing to see just how valuable that little snippet of code is. If you are trying to learn C++ then an excellent way to do that would be to study the STL. Rob gives you a great example of using both Vectors and strings together, two very important parts of the STL. You will be using Vector a great deal in the future and should put forth the effort to learn what Rob just posted. I know it looks daunting but the STL is invaluable. Although I understand what he wrote I am not at the point where I could duplicate it without referencing a book and love seeing simple examples of the STL to boost my confidence.
  4. HughG

    Anyone know anything about Vision correction?

    Quote:Original post by reaptide Quote:Original post by Raymondo LASIK is allowed both for the airforce... If you meant airforce pilot, you have no idea how much I wish you were right. I'll never get to fly a hornet because of my vision. You have to have 20/20 naturally. No corrections or anything. Its a rather idiotic regulation considering that the US airforce recuits pilots with laser correction and will even pay for the treatment in some cases. Our airforce is really hurting for pilots right now and they could open up the field to a lot of people if they allowed laser correction. I'd happily shell out a couple hundred bucks to get a laser shot at my eyes if it means I have a chance at flying a bug. I'm going to have to settle for a technical position once I enlist. I wouldn't worry too much about not getting in the military with bad vision. I'm active duty Navy and have some of the worst vision imaginable. The Airforce has Hornets? I thought this was a Navy jet. And where can you get laser eye surgery for a couple hundred bucks? Last I looked it was about 900 an eye but that was awhile ago.
  5. HughG

    Bitmap Display Problem

    Quote:Original post by Gor435 Ok maybe I wasnt the one confused because everytime the window refreshes it sends a WM_PAINT message. So using the InvalidateRect() function will not help me to get a WM_PAINT message. No you were right the first time, you are the one confused. InvalidateRect() should eventually call a WM_PAINT message. Edit: I don't think you need the BeginPaint and Endpaint functions. In this case I don't see what they do since they are normally used to return a HDC which you already do with the GetDC() function. I think the problem with your code is no paint message is being generated. With the InvalidateRect function it should work.
  6. HughG

    Is it morally wrong...

    "I don't care if this chic was my own mother, I'd still fuck her and have a son and a new brother at the same time and just say that it ain't mine" -Eminem
  7. HughG

    = - What does it mean?

    Additional info: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoprbitwiseand.asp
  8. HughG

    Worst game companies

    Quote:Original post by Alura Blizzard - pathetic stuff happening in WoW, such as christian preaching, bannings due to exploring new areas, gm abuse, etc. Could you elaborate on this? I was considering taking the plunge into the MMORPG world and trying WoW but not if this is the case. Christian preachings? Banned for exploring new areas? Wtf?
  9. I used to think it was the pace of the game that made me horrible at FPS's. For months I tried to find the perfect way to hold my mouse, the best position on my desk for it, the ideal sensitivity, etc. Eventually I came to the conclusion that I just wasn't cut out for FPS games. I still play and really enjoy them despite getting railed on a constant basis as long as the game is honest. The real problem with fps's are without a doubt fing cheaters!
  10. HughG

    Some people disturb me

    EDIT: OOPs didn't mean to do that.
  11. HughG

    Hahahaha! For once I agree with Bush

    Quote:Original post by shmoove The difference (a big one in my opinion) is that Japan and Germany attacked first. shmoove PS: And the US did stand by doing nothing while millions of people were killed far more brutally than anything Saddam has ever done until it was attacked. You assume the United States knew exactly what was going on inside of those camps from the start. Did they get reliable satellite data back in 1940? And yes the Holocaust was brutal but I don't know if I want to argue which death is more painful: chemical weapons or gas chamber. Saddam was every bit as wicked as Hitler but lacked the resources to wage the type of campaign Germany did. I've always had a strong solidarity and am in full support of the Israeli nation. I think you'll find a lot of Americans feel the same way despite the consequences and the backlash from the Arab community. To suggest that America is a heartless nation that would sit back with a bag of jiffy pop while jews were being exterminated is outrageous .
  12. I'll give you a little push: So inside of this array you will have a bunch of objects. You are going to need a way to compare all of them. My advice would be to implement the comparable interface in all of the classes you are writing that will go inside this multiset class. Inside of the CompareTo() method you are forced to write after implementing this interface you can determine the criteria that determines if two objects are equal. For instance, say you have an Account class like so: class Account{ int accountID; int money; } In order to determine if two accounts are the same the logical choice would be to check the account numbers. Since we are implementing Comparable our class now looks like this: class Account implements Comparable{ int accountID; int money; public int compareTo(Object o){ //o is the object we want to compare to return this.accountID - (Account)o.accountID; } Since we passed a plain object to this method we must type cast it to an Account object. Inside of the MultiSet class we would then test the objects inside of the array by : if (a.compareTo(b) == 0) //objects are the same Now with this code you can be used to determine the diversity by writing an algorithm that counts the number of distinct elements inside the array. The cardinality is easy. Just increment it each time you add something to an array. isEmpty, removeInstance, removeElement, and toString are all trivial and should be no problem. isMember should also be easy. Just iterate through the entire array and use the compareTo method on each object. If you have specific questions feel free to post em.
  13. HughG

    noob java question

    When used with primitive data types "==" checks to see if the two values are equal. For instance: int x = 5; int y = 5; if(x == y) System.out.println("Equal"); This is different from the assignment operator "=". If you mistakenly use: if(x = y) you should get a compiler error in java because conditional statements only accept boolean data types. When used with objects in java the "==" operator checks to see if the object reference is pointing to the same object.
  14. HughG

    sprites'??

    I had this same question not too long ago. I couldn't figure out why you would need to call something a Sprite when it was simply a bitmap. Well, in order to maintain reusability with the bitmap class and ensure it isn't clogged with unnecessary code I made a separate Sprite class to put all the sprite functionality inside of. What is this functionality? Well typically when you animate a bitmap it's now called a Sprite. So inside of the sprite class I wrote code to animate the bitmap. Another important feature for animated bitmaps would be collision. So another instance variable of the sprite class could be a bounding rectangle (for very simple collision detection). Since it's animated you'll need to store it's velocity (I did it in a win32 POINT struct) and have code to update it's position based on velocity (UpdateSprite method). I also did a lot of really neat things inside the sprite class concerning collision detection. For instance, I have a variable that determines what happens to the sprite when it collides with something. For example, a ball sprite will bounce and a missile sprite will simply die. Most of this doesn't really belong inside of a Bitmap class and it's why I think people make the distinction between sprites and simple bitmaps.
  15. If I understand you correctly, I would just order the items in the list based on the Z order and then draw them. I have a simple 2D engine that I'm working with that keeps track of all sprites in the game and here's how I keep track of the inserts: vector<Sprite*>::iterator SpriteIter; for (SpriteIter = m_vSprites.begin(); SpriteIter != m_vSprites.end(); SpriteIter++) if (PassedSprite->GetZOrder() < (*SpriteIter)->GetZOrder()) { // Insert the sprite into the sprite vector SpriteList.insert(SpriteIter, PassedSprite); return; } } // The sprite's z-order is highest, so add it to the end of the vector SpriteList.push_back(PassSprite); } Where SpriteList is an instance variable in the GameEngine class and PassedSprite is passed to this function (AddSprite).
  • 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!