summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-09 10:02:26 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-09 14:15:09 (GMT)
commit56a3ad373c126da22be05e4c5b64a446c7d7dff0 (patch)
tree207d7852678d4e39f018fc3bd94557f40e1265a0 /src
parent7f83cb10611e6073c72a38eb97116a2895871435 (diff)
downloadpowder-56a3ad373c126da22be05e4c5b64a446c7d7dff0.zip
powder-56a3ad373c126da22be05e4c5b64a446c7d7dff0.tar.gz
Fix photon reflection.
In cases such as photons travelling horizontally left towards a line with a shallow slope downwards from left to right. Direction map now includes directions parallel to photon velocity in these cases.
Diffstat (limited to 'src')
-rw-r--r--src/powder.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/powder.c b/src/powder.c
index 1dd233c..1124296 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -260,14 +260,14 @@ int try_move(int i, int x, int y, int nx, int ny)
static unsigned direction_to_map(float dx, float dy)
{
- return (dx >= 0) |
- (((dx + dy) >= 0) << 1) | /* 567 */
- ((dy >= 0) << 2) | /* 4+0 */
- (((dy - dx) >= 0) << 3) | /* 321 */
- ((dx <= 0) << 4) |
- (((dx + dy) <= 0) << 5) |
- ((dy <= 0) << 6) |
- (((dy - dx) <= 0) << 7);
+ return (dx >= -0.1) |
+ (((dx + dy) >= -0.1) << 1) | /* 567 */
+ ((dy >= -0.1) << 2) | /* 4+0 */
+ (((dy - dx) >= -0.1) << 3) | /* 321 */
+ ((dx <= 0.1) << 4) |
+ (((dx + dy) <= 0.1) << 5) |
+ ((dy <= 0.1) << 6) |
+ (((dy - dx) <= 0.1) << 7);
}
static int is_blocking(int t, int x, int y)