BBeck's Profile User Rating: -----

Reputation: 533 Enlightened
Active Posts:
1,189 (1.65 per day)
24-April 12
Profile Views:
Last Active:
User is online A minute ago
Viewing Topic: GamePad and Keyboard Input - Pla...

Previous Fields

OS Preference:
Favorite Browser:
Internet Explorer
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:
Expert In:
Game Programming, XNA

Latest Visitors

Icon   BBeck is experimenting in his gaming lab. Don't be alarmed if something explodes.

Posts I've Made

  1. In Topic: GamePad and Keyboard Input - Player Movement Issues

    Posted 16 Apr 2014

    If you don't want to be locked to 8 directions, make velocity a unit vector (normalized vector). And instead of using the keys to set it's direction, use the keys to rotate it by a certain number of radians per second. That "theoretically" allows you to move in any direction, although the rate of rotation is going to cause you to miss some angles. Slow rotation for better control of direction. Fast rotation so that it doesn't take forever to turn around.

    Velocity is actually "direction" rather than velocity, because it's a normalized vector. It always has a length of one. You can "reset" the length of a normalized vector by multiplying it times the length you want. So, the "real" velocity is what you are calling "speed". It's the number you multiply times the normalized direction vector. The result is a velocity vector that points in the direction of travel and has a length equal to the pixels per frame you will move.

    Add that vector to the current position, which is stored in a vector, and the result vector will be the position after the movement.

    Since frame rate can change, what you really want is pixels of movement per second, not pixels of movement per frame. So multiply the velocity vector by the fraction of a second that has elapsed since the previous frame and your velocity will be converted from pixels per frame to pixels per second.

    So, to recap, use a 2D vector to store the direction of travel and another for position. Speed can be any number of pixels per second you want. Multiply Speed in pixels per second times the fraction of a second that has elapsed since the last frame, which will give you the pixels per frame for this frame. Multiply the normalized direction vector times the pixels per frame. Add that to the position vector and the result will be a vector holding the updated position for that frame.

    You can make the speed per second variable controlled by a throtle. You can change the direction by rotating the normalized direction vector.

    Hope that helps.
  2. In Topic: GamePad and Keyboard Input - Player Movement Issues

    Posted 16 Apr 2014

    I don't know what keyboard analog is, but if your velocity is a 2D vector where the W key sets the Y value to 1 (or -1), the S button sets it to the opposite and D sets the X value to 1, that's going to cause the problem you describe.

    Let's see if this sounds like your code. If you press W, the velocity vector is 0,1. If you press D, the velocity vector is 1,0. If you press both bottons it creates diagnol movement because the vector is 1,1. However, this is a longer vector than either key by itself. Both keys by themselves have a vector length/magnitude of 1.

    The length of the vector 1,1 is the square root of 2, not one. (Roughly 1.4142135623 or almost 150% of the unit length vectors). So, your velocity is roughly 150% as much as when you apply only 1 button.

    For these buttons, that should be an easy fix: normalize the vector so that it goes back to having a length of 1.

    You can have this same problem with the joystick. I'm not sure why you are not. XNA may correct the problem for you with the joystick. I know I use the 360 game controller all the time and have never noticed the problem come up. I'm not sure if I just haven't noticed the 150% diagnol speed increase, haven't cared since I'm not working on a professional game, or it hasn't come up.

    But you could have this problem any time you're adding two vector values together.

    You basically always want to be dealing with a normalized vector (length of 1). Sometimes you may want to allow length's less then one where 1 becomes 100% and lower values become a percentage of that. But you never want it to be longer than 1. You can think of the vector length as the percentage of velocity applied. With the keyboard it's always going to be 1. But with an joystick, it can be a percentage up to 1. Multiply that value times your speed and you should have a vector that points in the direction of travel with a length of distance per frame.
  3. In Topic: texture

    Posted 14 Apr 2014

    So, I'm totally guessing here, but its an educated guess. I've done this sort of thing in XNA. It's amazing how much XNA prepares you for this stuff.

    glTexParameteri sets a parameter for texturing a triangle. The I at the end stands for integer parameter. The first parameter of this function specifies whether this is a 2D texture or a cube map. It's going to be a texture.

    The way you specified it, this is going to be about minification and the minification method is going to be "nearest".

    When you map a texture to a triangle, or to a mesh/model, it's not going to be 1 to 1. Think about creating a quad for a mesh such as a square. You make this square mesh and you texture it with a square texture. Even if it maps exactly to the square, the camera can move closer to it or further away from it. As you move closer, this is called magnification and 1 texel in the image occupies more and more pixels on your computer monitor as you get closer. So, pixels have to be "generated" that were not there in the original image to make this magnification process work.

    When you move further away, that's called minification and eventually you get to the point where one pixel on the screen may be several texels in the original image because it's so far away. You have to average out the pixels to come up with an average to display it as one pixel on the screen. Eventually, the entire image may be so far away that the whole image is only one pixel on the screen.

    Mipmapping is related to this. But you have minification even without mipmaps.
  4. In Topic: Programming Contract Work?

    Posted 14 Apr 2014

    Of course they are taking advantage of your intern status to get cheap labor. If they weren't they wouldn't hire an intern, they would demand 3 years experience and wouldn't even talk to you.

    You're going to have to "pay your dues" until you get the experience other employers want. If you've got a lot of offers, you can be picky and make demands of them.

    The prettiest girl at the ball doesn't ask guys to dance with her, she rejects them because she can. If you have what's in demand, you can set the terms of the deal. If you don't, you have to accept what you can get. Fortunately, experience and knowledge are not things that you are born with, but rather things you can aquire. One way to aquire them is to work under less than ideal conditions as an intern or entry level job.

    So, the question is what does this give you? If you can keep on working as an intern, and earn the same money, then maybe it gives you nothing. If your internship is ending, or if you need the money, or if it gives you actual job experience rather than just "I was an intern for a year.", then maybe its worth it. If it puts you in a better position to look for the next job, then take it for 6 months or a year and then keep looking while you're employed.

    There are places on the internet where you can pretty much figure out how much you're worth based on what positions you are qualified to fill. With little experience, you're going to be at the bottom of that range. But it may be worth accepting indentured servitude in order to add something like experience to your resume. After 6 months or 12 months you can claim that experience on your resume and keep looking for something else.

    If your situation is that you continue working for the old internship as a paid contractor, while accepting another internship, you need to make sure the other internship is okay with demands on your time and possible conflicts of interest. Otherwise, it sounds to me like being a paid contractor for basically the same money, even part time, looks better on a resume than just a bunch of internships regardless of how much it pays. That's worth considering anyway. But yes, they're going to take advantage of you until you've got the experience to make demands.
  5. In Topic: how to get a job as a programmer C++

    Posted 14 Apr 2014

    You're right that 3+ months unemployed is going to make it 20 times more difficult to find a job. My first advice is to take whatever you can get. You may need to go shovel some fries at Mickey D's. Paying the bills is critical even if you have no spending cash. Also, some employment may help at least a little. At least fry chef shows that "someone" is willing to hire you and it's not like you've got a drug problem where you won't even show up for work.

    100 times better than that is to take a computer job that pays a lot less money or isn't quite in your field. Taking a 50% pay cut may still allow you to pay the bills comfortably and buy you time. But don't miss a single beat in your job search. Keep looking as if you're still unemployed. Once you have a decent IT job, even at lower pay or in a slightly different field, you're a hot commodity.

    I've experienced this first hand. Once I was unemployed for almost a year between contracts partially because I just decided to take 3+ months off. Big mistake because 3 month turned into almost a year.

    I also had this crazy work ethic thing where I thought it was unethical to look for a job while you are employed. I later figured out they won't hire you unless you look for a job while you're employed. You're expected to knife your employer in the back and go to work for whoever will offer you more money (you can give them 2 weeks notice and it's probably good to tell your future employer that you need to help the old one with the transition of losing you because they know they may be next).

    The next time between contracts I let about 30 days pass before I dropped my demand for a pay raise. After about 45 days I started looking for anything regardless of pay. Sure enough, I was employed pretty quick at about 75% of what I was getting before (after adding really big stuff to my resume that should have earned me a huge raise). But I was employeed. At that point, I could pretty much just get rude with employers and tell them "I have a job, I don't need yours. If you can't make it worth my while, shut up and stop wasting my time." I litterally laughed in the face of a few recruiters and told them I wouldn't work for them for the kind of money they were offering even though it was more than I was making at that point. And this was during the recession when things where at their worst. Sure enough, within 30 days I had another job and was making what I was making before, which wasn't bad considering everyone was getting laid off at the time and accepting pay decreases. Being employed greatly increased my leverage in getting a good job.

    Anyway hit the books. There's no excuse for not knowing "multi-threading" or whatever technology it is that's keeping you from getting the job. You've got 2 jobs when you're unemployed. 1} Looking for a new job and 2} Studying. You've got all day to sit around and read. You should be consuming every book on the subject you can get your hands on. And getting familiar with software, like version control software may mean loading some on your computer at home to work with it. That's one of the reasons I have multiple computers at home. It's a lot tougher to get up to speed if you can't get some hands on experience more than just reading the book.

My Information

Member Title:
Here to help.
Age Unknown
Birthday Unknown
Dallas, Texas, US of A, Planet Earth, Sol System, Milky Way Galaxy
Rock music composition and performance, Grunge Music, Bebop (think Thelonios Monk), Swing (think Cab Calloway), Gaming, Astronomy, RPGs, Scuba, Sail Boats, Furniture Building, Cooking, Rocky Patel Cigars, Character Driven Dramas(like HBO's Deadwood), Story Telling (plot writing), Linguistics, Economics, Target Shooting, Electronics (don't know as much as I'd like to), all aspects of 3D game programing including music, physics, modeling, texturing, annimation, probability, AI, lighting, etc., Texas Holdem' Poker, Learning, Dogs, the love of my life (my pit bull), guns (especially 19th century black powder), putting make-up on ogres, etc.
Programming Languages:
C, C++, C#, Visual Basic, Java, Pascal, T-SQL, HTML, FoxPro, ASP.Net(very little), Assembler, Machine Code(conceptually anyway)

Contact Information

Website URL:
Website URL


Page 1 of 1
  1. Photo

    BBeck Icon

    11 Aug 2013 - 04:27
    Generally, yes. :-)
  2. Photo

    aaron1178 Icon

    10 Aug 2013 - 00:42
    You wouldn't happen to get high marks in written exams would you ;)
Page 1 of 1