Module: Dare

Defined in:
lib/dare.rb,
lib/dare/font.rb,
lib/dare/image.rb,
lib/dare/sound.rb,
lib/dare/clock.rb,
lib/dare/canvas.rb,
lib/dare/sprite.rb,
lib/dare/window.rb,
lib/dare/keyboard_constants.rb

Defined Under Namespace

Modules: Kb Classes: Canvas, Clock, Color, Coordinates, Font, Image, ImageTile, Sound, Sprite, Window

Constant Summary collapse

VERSION =

returns the current version of this gem

"0.2.0"
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

48
Kb1 =
49
Kb2 =
50
Kb3 =
51
Kb4 =
52
Kb5 =
53
Kb6 =
54
Kb7 =
55
Kb8 =
56
Kb9 =
57
KbA =
65
KbB =
66
KbC =
67
KbD =
68
KbE =
69
KbF =
70
KbG =
71
KbH =
72
KbI =
73
KbJ =
74
KbK =
75
KbL =
76
KbM =
77
KbN =
78
KbO =
79
KbP =
80
KbQ =
81
KbR =
82
KbS =
83
KbT =
84
KbU =
85
KbV =
86
KbW =
87
KbX =
88
KbY =
89
KbZ =
90
KbBackspace =
8
KbDelete =
46
KbDown =
40
KbEnd =
35
KbEnter =
13
KbReturn =
13
KbEscape =
27
KbF1 =
112
KbF2 =
113
KbF3 =
114
KbF4 =
115
KbF5 =
116
KbF6 =
117
KbF7 =
118
KbF8 =
119
KbF9 =
120
KbF10 =
121
KbF11 =
122
KbF12 =
123
KbSpace =
32
KbPageUp =
33
KbPageDown =
34
KbHome =
36
KbLeft =
37
KbUp =
38
KbRight =
39
KbInsert =
45
KbShift =
16
KbControl =
17
KbAlt =
18
KbCapsLock =
20
KbNumpad0 =
96
KbNumpad1 =
97
KbNumpad2 =
98
KbNumpad3 =
99
KbNumpad4 =
100
KbNumpad5 =
101
KbNumpad6 =
102
KbNumpad7 =
103
KbNumpad8 =
104
KbNumpad9 =
105
KbNumpadMultiply =
106
KbNumpadAdd =
107
KbNumpadSubtract =
109
KbNumpadDivide =
111
KbTab =
9
KbBacktick =
192
KbTilde =
192
KbGraveAccent =
192
KbMinus =
189
KbDash =
189
KbEqual =
187
KbBracketLeft =
219
KbBracketRight =
221
KbBackslash =
220
KbSemicolon =
186
KbApostrophe =
222
KbComma =
188
KbPeriod =
190
KbSlash =
191
KbCmd =
kbCmd
KbCmdLeft =
KbCmd
KbCmdRight =
kbCmdRight

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_canvasObject

Returns the value of attribute default_canvas


46
47
48
# File 'lib/dare.rb', line 46

def default_canvas
  @default_canvas
end

Class Method Details

.distance(x1, y1, x2, y2) ⇒ Object


41
42
43
# File 'lib/dare.rb', line 41

def self.distance(x1, y1, x2, y2)
  `Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))`
end

.msObject

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


37
38
39
# File 'lib/dare.rb', line 37

def self.ms
  `(new Date()).getTime()`
end

.offset_x(angle, magnitude) ⇒ Object

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


18
19
20
# 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) ⇒ Object

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


30
31
32
# File 'lib/dare.rb', line 30

def self.offset_y(angle, magnitude)
  `#{magnitude}*Math.sin(-#{angle}*Math.PI/180.0)`
end