Flipping a sprite in DirectX

I have a sprite which faces to the right. I wanted to make it face left when moving left. After reading a dozen-plus forum threads without finding an answer, I’m posting this for reference. I’m a DirectX noob so this may not be the best solution, but it worked for me.

D3DXVECTOR2 position(caveman.x, caveman.y);
D3DXVECTOR2 spriteCenter(caveman.width / 2.0f, caveman.height / 2.0f);
D3DXVECTOR2 scaling(caveman.faceLeft ? -1 : 1, 1);
D3DXMATRIX matrix;
D3DXMatrixTransformation2D(&matrix, &spriteCenter, 0, &scaling, NULL, 0, &position);

Also, you will need to turn off culling on your DirectX device object.

d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

The Feynman Algorithm

Excerpted from: http://c2.com/cgi/wiki?FeynmanAlgorithm

1. Write down the problem.

2. Think real hard.

3. Write down the solution.

How to use the Feynman Algorithm

1. Write the problem down in an unambiguous way. Often this is just as hard as the next step. Indeed, really, really understanding the problem is sometimes the only hard bit. Once you really, really understand the problem, the answer may be obvious.

2. Become convinced it’s important. Really important. Think about odd ways to solve it, things you wouldn’t tell other people for fear of being laughed into the next century. Look at simple things. Look at really complicated intricate solutions. Then talk to others. Talking to others will allow you to crystallize some of the ideas you have, and produce more ideas for you to think about. Repeat until you have an answer you can write down. If you do this right, immediately before you come up with the answer people will think you’re almost obsessed with the problem and the answer to it.

Note: If you don’t have people to talk to, write down some intermediate results or something to make them become real.

Some problems don’t have answers, only compromises, or proofs of impossibility. These are also valid answers if you can show that a real answer doesn’t exist.

3. Write the answer.


A Man on the Moon

A Man On The Moon by Andrew Chaikin retells the story of Apollo through his interviews with each of the astronauts and dozens of engineers and support staff. This book put my childhood fascination in historical context and illuminated many of the less visible aspects of the program: the immense amount of planning, the scientific achievements of the later missions, and the years of individual preparation required. It gave me an insight into the daily lives of the astronauts as they helped design and test the spacecraft. It reads pretty quickly although I found myself constantly derailed as I searched out additional source material. I would highly recommend this book to every space junkie.

The book helped me appreciate the scale of surface features on the moon. Craters less than 6 miles across are classified as “small”! The surface itself does not experience erosion like on Earth, but rather is constantly pelted with micrometeorites (<2mm diameter)–there is no atmosphere to burn up these space particles. One side effect is everything is very sharp. Dust on the moon is highly abrasive and quickly damages spacecraft and equipment.

Apollo 15 landed at the base of the Appenine Mountains. Using the lunar rover (photo), the astronauts climbed over 500 ft up the side of a 16,000 ft tall mountain–taller than any mountain in the continental US. Apollo 17 set the record for most distance covered (12.5 miles).


Detail of surface features. (Higher resolution available on Wikipedia.)