Skip to content

Commit

Permalink
further inheritance fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-zethraeus committed Mar 7, 2012
1 parent 08dd3e6 commit 72b2dc9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
28 changes: 1 addition & 27 deletions src/camera.coffee
@@ -1,29 +1,3 @@
class Camera extends WorldObject
pitch: 0
yaw: 0
look: 0
fresh_look: false
constructor: (x=0,y=0,z=0)->
super(x,y,z)
this.look = new Vector3(x,y,z)
setPitch: (p) ->
this.pitch = p
this.fresh_look = false
setYaw: (y) ->
this.yaw = y
this.fresh_look = false
getPitch: ->
return this.pitch
getYaw: ->
return this.yaw
getLook: ->
if not this.fresh_look
this.look = new Vector3(Math.sin((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180), -Math.sin((this.pitch*Math.PI)/180), -Math.cos((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180))
this.look.normalize()
this.fresh_look = true
return this.look
getHorizontalLook: ->
vlook = this.getLook()
hlook = new Vector2(vlook.x, vlook.z)
hlook.normalize()
return hlook
super(x,y,z)
2 changes: 2 additions & 0 deletions src/player.coffee
@@ -1 +1,3 @@
class Player extends WorldObject
constructor: (x=0, y=0, z=0) ->
super(x,y,z)
36 changes: 33 additions & 3 deletions src/worldobject.coffee
@@ -1,6 +1,36 @@
class WorldObject
pos : new Vector3(0,0,0)
location : new Vector3(0,0,0)
look: 0
pitch: 0
yaw: 0
fresh_look: false
constructor: (x=0,y=0,z=0)->
this.pos = new Vector3(x,y,z)
this.location = new Vector3(x,y,z)
this.look = new Vector3(x,y,z)
setLocation: (x=0,y=0,z=0)->
this.pos = new Vector3(x,y,z)
this.location = new Vector3(x,y,z)
setPitch: (p) ->
this.pitch = p
this.fresh_look = false
setYaw: (y) ->
this.yaw = y
this.fresh_look = false
getPitch: ->
return this.pitch
getYaw: ->
return this.yaw
getLocation: ->
return this.location
getLook: ->
if not this.fresh_look
this.look = new Vector3(Math.sin((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180), -Math.sin((this.pitch*Math.PI)/180), -Math.cos((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180))
this.look.normalize()
this.fresh_look = true
return this.look
getHorizontalLook: ->
vlook = this.getLook()
hlook = new Vector2(vlook.x, vlook.z)
hlook.normalize()
return hlook
synchronizeWithWorldObject: (obj)->
this.location = obj.getLocation()

0 comments on commit 72b2dc9

Please sign in to comment.