mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-28 19:13:42 +01:00
↪️ implemting Canvas.rotate and prototype degree control (k & l)
This commit is contained in:
parent
0e481bf5c9
commit
bdfcae4fa0
@ -37,6 +37,9 @@ module.exports = class Canvas
|
|||||||
translate: (x, y) ->
|
translate: (x, y) ->
|
||||||
mat2d.translate @matrix, @matrix, vec2.fromValues(x, y)
|
mat2d.translate @matrix, @matrix, vec2.fromValues(x, y)
|
||||||
|
|
||||||
|
rotate: (angle) ->
|
||||||
|
mat2d.rotate @matrix, @matrix, angle/180*Math.PI
|
||||||
|
|
||||||
clear: ->
|
clear: ->
|
||||||
@buffer.clear()
|
@buffer.clear()
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ module.exports = class Renderer
|
|||||||
setSize: (@width, @height) ->
|
setSize: (@width, @height) ->
|
||||||
@canvas = new Canvas @width, @height
|
@canvas = new Canvas @width, @height
|
||||||
|
|
||||||
draw: (@view, @zoom) ->
|
draw: (@view, @zoom, @degree) ->
|
||||||
return if @isDrawing
|
return if @isDrawing
|
||||||
@isDrawing = true
|
@isDrawing = true
|
||||||
@lastDrawAt = Date.now()
|
@lastDrawAt = Date.now()
|
||||||
|
@ -26,6 +26,7 @@ module.exports = class Termap
|
|||||||
mousePosition: [0, 0]
|
mousePosition: [0, 0]
|
||||||
mouseDragging: false
|
mouseDragging: false
|
||||||
|
|
||||||
|
degree: 0
|
||||||
center:
|
center:
|
||||||
lat: 0
|
lat: 0
|
||||||
lng: 0
|
lng: 0
|
||||||
@ -110,23 +111,27 @@ module.exports = class Termap
|
|||||||
|
|
||||||
when "z" then @zoomBy @config.zoomStep
|
when "z" then @zoomBy @config.zoomStep
|
||||||
when "a" then @zoomBy -@config.zoomStep
|
when "a" then @zoomBy -@config.zoomStep
|
||||||
|
|
||||||
|
when "k" then @degree += 15
|
||||||
|
when "l" then @degree -= 15
|
||||||
|
|
||||||
when "left" then @view[0] += 5
|
when "left" then @view[0] += 5
|
||||||
when "right" then @view[0] -= 5
|
when "right" then @view[0] -= 5
|
||||||
when "up" then @view[1]+= 5
|
when "up" then @view[1]+= 5
|
||||||
when "down" then @view[1]-= 5
|
when "down" then @view[1]-= 5
|
||||||
|
|
||||||
else
|
else
|
||||||
false
|
null
|
||||||
|
|
||||||
if draw
|
if draw isnt null
|
||||||
@_draw()
|
@_draw()
|
||||||
# else
|
else
|
||||||
# # display debug info for unhandled keys
|
# display debug info for unhandled keys
|
||||||
# @notify JSON.stringify key
|
@renderer.notify JSON.stringify key
|
||||||
|
|
||||||
|
|
||||||
_draw: ->
|
_draw: ->
|
||||||
@renderer.draw @view, @zoom
|
@renderer.draw @view, @zoom, @degree
|
||||||
@renderer.notify @_getFooter()
|
@renderer.notify @_getFooter()
|
||||||
|
|
||||||
_getTiles: ->
|
_getTiles: ->
|
||||||
|
Loading…
Reference in New Issue
Block a user