module Dare

Constants

Kb0

These are the corresponding character keycodes for keyboard presses e.g. if button_down? Dare::KbDown

player.crouch #or something

end

for convenience, you can “include Dare::Kb” at the top of your main app file (after require ‘dare’), and then refer to these constants directly e.g. if button_down? KbI

open_inventory

end

Kb1
Kb2
Kb3
Kb4
Kb5
Kb6
Kb7
Kb8
Kb9
KbA
KbAlt
KbApostrophe
KbB
KbBackslash
KbBackspace
KbBacktick
KbBracketLeft
KbBracketRight
KbC
KbComma
KbControl
KbD
KbDash
KbDelete
KbDown
KbE
KbEnd
KbEnter
KbEqual
KbEscape
KbF
KbF1
KbF10
KbF11
KbF12
KbF2
KbF3
KbF4
KbF5
KbF6
KbF7
KbF8
KbF9
KbG
KbGraveAccent
KbH
KbHome
KbI
KbInsert
KbJ
KbK
KbL
KbLeft
KbM
KbMinus
KbN
KbNumpad0
KbNumpad1
KbNumpad2
KbNumpad3
KbNumpad4
KbNumpad5
KbNumpad6
KbNumpad7
KbNumpad8
KbNumpad9
KbNumpadAdd
KbNumpadDivide
KbNumpadMultiply
KbNumpadSubtract
KbO
KbP
KbPageDown
KbPageUp
KbPeriod
KbQ
KbR
KbReturn
KbRight
KbS
KbSemicolon
KbShift
KbSlash
KbSpace
KbT
KbTab
KbTilde
KbU
KbUp
KbV
KbW
KbX
KbY
KbZ
VERSION

returns the current version of this gem

Attributes

default_canvas[RW]

Public Class Methods

distance(x1, y1, x2, y2) click to toggle source
# File lib/dare.rb, line 41
def self.distance(x1, y1, x2, y2)
  `Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))`
end
ms() click to toggle source

returns the number of milliseconds since the Unix epoch useful for delta physics

# File lib/dare.rb, line 37
def self.ms
  `(new Date()).getTime()`
end
offset_x(angle, magnitude) click to toggle source

returns the magnitude of the horizontal component of a vector at some angle and some magnitude where the angle is in degrees starting on the unit circle pointing to the right and going counterclockwise e.g. Dare.offset_x(90, 10) # returns 0 Dare.offset_x(45, 10) # returns 10 times the square root of 2

# File lib/dare.rb, line 18
def self.offset_x(angle, magnitude)
  `#{magnitude}*Math.cos(-#{angle}*Math.PI/180.0)`
end
offset_y(angle, magnitude) click to toggle source

returns the magnitude of the vertical component of a vector at some angle and some magnitude where the angle is in degrees starting on the unit circle pointing to the right and going counterclockwise e.g. Dare.offset_y(90, 10) # returns 10 Dare.offset_y(45, 10) # returns 10 times the square root of 2

# File lib/dare.rb, line 30
def self.offset_y(angle, magnitude)
  `#{magnitude}*Math.sin(-#{angle}*Math.PI/180.0)`
end