Created
May 24, 2012 02:34
-
-
Save devilstower/2779104 to your computer and use it in GitHub Desktop.
Battle Chips 23MAY12 (part 3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VColorSlider = class() | |
function VColorSlider:init(x, y) | |
self.frame = Frame(x - 30, y - 328, x + 60, y + 56) | |
self.previousY = 0 | |
self.pots = {} | |
for i = 0, 15 do | |
self.pots[i + 1] = Frame(self.frame.left, | |
self.frame.top - i * 24 - 24, | |
self.frame.right, self.frame.top - i * 24) | |
end | |
self.selected = 0 | |
end | |
function VColorSlider:draw() | |
pushStyle() | |
fill(143, 158, 166, 255) | |
stroke(25, 25, 25, 255) | |
strokeWidth(1) | |
self.frame:draw() | |
for i = 1, 16 do | |
fill(colors[i]) | |
self.pots[i]:draw() | |
end | |
popStyle() | |
end | |
function VColorSlider:touched(touch) | |
if self.frame:touched(touch) then | |
for i = 1, 16 do | |
self.selected = 0 | |
if self.pots[i]:touched(touch) then | |
strokeWidth(3) | |
stroke(106, 130, 155, 255) | |
self.selected = i | |
fill(colors[i]) | |
self.pots[i]:draw() | |
return true | |
end | |
end | |
end | |
return false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VRobotSlider = class() | |
function VRobotSlider:init(x, y) | |
self.frame = Frame(x - 25, y - 640, x + 35, y + 210) | |
self.previousY = 0 | |
self.pots = {} | |
for i = 1, 21 do | |
self.pots[i] = Frame(self.frame.left + 2, | |
self.frame.top - (i) * 40, | |
self.frame.right - 2, self.frame.top - (i) * 40 + 40) | |
end | |
self.selected = 0 | |
end | |
function VRobotSlider:draw(robots) | |
pushStyle() | |
textMode(CENTER) | |
fontSize(32) | |
fill(0, 0, 0, 255) | |
stroke(255, 255, 255, 155) | |
strokeWidth(1) | |
self.frame:draw() | |
fontSize(32) | |
for i = 1, 21 do | |
if i == 1 then | |
fill(92, 92, 92, 183) | |
text("?", self.pots[1]:midX(), self.pots[1]:midY()) | |
end | |
if i > 1 then | |
noStroke() | |
--self.pots[i]:draw() | |
pushMatrix() | |
translate(self.pots[i]:midX(), | |
self.pots[i]:midY()) | |
scale(0.5) | |
if i > 1 then | |
robots[i - 1]:drawBase() | |
end | |
popMatrix() | |
end | |
end | |
popStyle() | |
end | |
function VRobotSlider:touched(touch) | |
if self.frame:touched(touch) then | |
for i = 1, 21 do | |
self.selected = 0 | |
if self.pots[i]:touched(touch) then | |
strokeWidth(3) | |
noFill() | |
stroke(106, 130, 155, 255) | |
self.pots[i]:draw() | |
self.selected = i - 1 | |
print(i, self.selected, self.pots[1].left) | |
return true | |
end | |
end | |
end | |
return false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vslider = class() | |
function Vslider:init(x, y, v) | |
self.frame = Frame(x - 30, y - 200, x + 30, y + 60) | |
self.value = v | |
self.previousY = 0 | |
end | |
function Vslider:draw() | |
pushStyle() | |
fill(143, 158, 166, 255) | |
stroke(25, 25, 25, 255) | |
strokeWidth(1) | |
self.frame:draw() | |
fill(231, 227, 227, 255) | |
noStroke() | |
ellipse(self.frame.left + 20, self.frame.top - 15, 25) | |
ellipse(self.frame.right - 20, self.frame.top - 15, 25) | |
rect(self.frame.left + 20, self.frame.top - 3, | |
self.frame.right - 20, self.frame.top - 27) | |
fill(23, 23, 23, 255) | |
textMode(CENTER) | |
fontSize(18) | |
text(self.value, self.frame.left + 30, self.frame.top - 15) | |
strokeWidth(2) | |
line(self.frame:midX(), self.frame.bottom + 10, | |
self.frame:midX(), self.frame.top - 50) | |
stroke(207, 207, 207, 255) | |
line(self.frame:midX() + 4, self.frame.bottom + 10, | |
self.frame:midX() + 4, self.frame.top - 50) | |
line(self.frame:midX() - 4, self.frame.bottom + 10, | |
self.frame:midX() - 4, self.frame.top - 50) | |
popStyle() | |
end | |
function Vslider:touched(touch) | |
if self.frame:touched(touch) then | |
self.value = math.floor((self.frame.top - 50 - touch.y) / 6) | |
if self.value < 1 then self.value = 1 end | |
if self.value > 30 then self.value = 30 end | |
return true | |
end | |
return false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment