mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Fixed some camera coordinates in Camera tests, others still need to be done
This commit is contained in:
parent
60abd9f794
commit
f93fab2d10
1 changed files with 12 additions and 12 deletions
|
@ -105,23 +105,23 @@ describe 'Camera (Surface point of view)', ->
|
|||
|
||||
it 'works at 0 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1, null, 0
|
||||
expect(cam.x2y).toBeGreaterThan 9001
|
||||
expect(cam.x2z).toBeCloseTo 1
|
||||
expect(cam.z2y).toBeGreaterThan 9001
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
it 'works at 45 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1, null, Math.PI / 4
|
||||
expect(cam.x2y).toBeCloseTo Math.sqrt(2)
|
||||
expect(cam.x2z).toBeCloseTo Math.sqrt(2)
|
||||
expect(cam.z2y).toBeCloseTo 1
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
it 'works at default angle of asin(0.75) ~= 48.9 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1
|
||||
angle = Math.asin 3 / 4
|
||||
angle = 1 / Math.cos angle
|
||||
expect(cam.angle).toBeCloseTo angle
|
||||
expect(cam.x2y).toBeCloseTo 4 / 3
|
||||
expect(cam.x2z).toBeCloseTo 1 / Math.cos angle
|
||||
expect(cam.z2y).toBeCloseTo (4 / 3) * Math.cos angle
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
it 'works at 2x zoom, 90 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 2, null, Math.PI / 2
|
||||
|
@ -145,8 +145,8 @@ describe 'Camera (Surface point of view)', ->
|
|||
|
||||
it 'works at 2x zoom, 30 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 2 * 100 * Camera.MPP, testLayer, 2, null, Math.PI / 6
|
||||
expect(cam.x2y).toBeCloseTo 2
|
||||
expect(cam.x2z).toBeCloseTo 1 / Math.cos(Math.PI / 6)
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
checkCameraPos cam
|
||||
wop = x: 5, y: 4, z: 6 * cam.y2z # like x: 5, y: 10 out of world width: 10, height: 20
|
||||
sup = cam.worldToSurface wop
|
||||
|
|
Loading…
Reference in a new issue