mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-07 16:54:22 +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) ->
|
||||
mat2d.translate @matrix, @matrix, vec2.fromValues(x, y)
|
||||
|
||||
rotate: (angle) ->
|
||||
mat2d.rotate @matrix, @matrix, angle/180*Math.PI
|
||||
|
||||
clear: ->
|
||||
@buffer.clear()
|
||||
|
||||
|
@ -76,7 +76,7 @@ module.exports = class Renderer
|
||||
setSize: (@width, @height) ->
|
||||
@canvas = new Canvas @width, @height
|
||||
|
||||
draw: (@view, @zoom) ->
|
||||
draw: (@view, @zoom, @degree) ->
|
||||
return if @isDrawing
|
||||
@isDrawing = true
|
||||
@lastDrawAt = Date.now()
|
||||
|
@ -26,6 +26,7 @@ module.exports = class Termap
|
||||
mousePosition: [0, 0]
|
||||
mouseDragging: false
|
||||
|
||||
degree: 0
|
||||
center:
|
||||
lat: 0
|
||||
lng: 0
|
||||
@ -110,23 +111,27 @@ module.exports = class Termap
|
||||
|
||||
when "z" 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 "right" then @view[0] -= 5
|
||||
when "up" then @view[1]+= 5
|
||||
when "down" then @view[1]-= 5
|
||||
|
||||
else
|
||||
false
|
||||
null
|
||||
|
||||
if draw
|
||||
if draw isnt null
|
||||
@_draw()
|
||||
# else
|
||||
# # display debug info for unhandled keys
|
||||
# @notify JSON.stringify key
|
||||
else
|
||||
# display debug info for unhandled keys
|
||||
@renderer.notify JSON.stringify key
|
||||
|
||||
|
||||
_draw: ->
|
||||
@renderer.draw @view, @zoom
|
||||
@renderer.draw @view, @zoom, @degree
|
||||
@renderer.notify @_getFooter()
|
||||
|
||||
_getTiles: ->
|
||||
|
Loading…
Reference in New Issue
Block a user