Class: Rubynk
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Common
#alert, #black, #over?, #ynk_setup
Constructor Details
#initialize ⇒ Rubynk
Returns a new instance of Rubynk.
38
39
40
41
42
43
44
45
|
# File 'lib/app.rb', line 38
def initialize
ynk_setup
@p = $p
@window = $window
@sprites = []
@m = 0
@sprite = 0
end
|
Instance Attribute Details
#dragX ⇒ Object
Returns the value of attribute dragX.
37
38
39
|
# File 'lib/app.rb', line 37
def dragX
@dragX
end
|
#dragY ⇒ Object
Returns the value of attribute dragY.
37
38
39
|
# File 'lib/app.rb', line 37
def dragY
@dragY
end
|
#p ⇒ Object
Returns the value of attribute p.
37
38
39
|
# File 'lib/app.rb', line 37
def p
@p
end
|
#sprites ⇒ Object
Returns the value of attribute sprites.
37
38
39
|
# File 'lib/app.rb', line 37
def sprites
@sprites
end
|
#window ⇒ Object
Returns the value of attribute window.
37
38
39
|
# File 'lib/app.rb', line 37
def window
@window
end
|
Instance Method Details
#drag(x, y) ⇒ Object
60
61
62
|
# File 'lib/app.rb', line 60
def drag(x,y)
@dragX,@dragY = x,y
end
|
#keyPressed ⇒ Object
88
89
|
# File 'lib/app.rb', line 88
def keyPressed
end
|
#mouseClicked ⇒ Object
82
83
|
# File 'lib/app.rb', line 82
def mouseClicked
end
|
#mouseMoved ⇒ Object
85
86
|
# File 'lib/app.rb', line 85
def mouseMoved
end
|
#mousePressed ⇒ Object
76
77
|
# File 'lib/app.rb', line 76
def mousePressed
end
|
#mouseReleased ⇒ Object
79
80
|
# File 'lib/app.rb', line 79
def mouseReleased
end
|
#passMili?(time) ⇒ Boolean
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/app.rb', line 64
def passMili?(time)
@m = @p.millis if @m == 0
@m2 = @p.millis
@m3 = @m2 - @m
if @m3 >= time
@m,@m2 = 0,0
return true
else
return false
end
end
|
#pushSprite(sprite) ⇒ Object
56
57
58
|
# File 'lib/app.rb', line 56
def pushSprite(sprite)
@sprites.push(@p.loadImage(sprite))
end
|
#renderSprite(milisec, x, y, w, h) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/app.rb', line 48
def renderSprite(milisec, x, y, w, h)
@p.image(@sprites[@sprite],x,y,w,h)
@sprite += 1 if passMili?(milisec)
@sprite = 0 if @sprites.length == @sprite
end
|