Created
May 24, 2012 02:31
-
-
Save devilstower/2779094 to your computer and use it in GitHub Desktop.
Battle Chips 23MAY12 (part 2)
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
OpenBtn = class() | |
function OpenBtn:init(t, x, y) | |
self.frame = Frame(x, y, x + 100, y + 30) | |
self.text = t | |
self.selected = false | |
end | |
function OpenBtn:draw() | |
pushStyle() | |
noFill() | |
if self.selected then fill(101, 118, 134, 255) end | |
stroke(255, 255, 255, 255) | |
strokeWidth(1) | |
ellipse(self.frame.left, self.frame:midY(), self.frame:height()) | |
self.frame:draw() | |
fill(34, 34, 34, 255) | |
noStroke() | |
if self.selected then fill(101, 118, 134, 255) end | |
self.frame:inset(-2,2) | |
self.frame:draw() | |
self.frame:inset(2, -2) | |
fill(255, 255, 255, 255) | |
text(self.text, self.frame.left , self.frame.bottom) | |
popStyle() | |
end | |
function OpenBtn:touched(touch) | |
return self.frame:touched(touch) | |
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
Skeet = class() | |
function Skeet:init(x, y, bounds) | |
self.x = x | |
self.y = y | |
self.color = color(255, 250, 0, 255) | |
self.active = 1 | |
if math.random(4) > 2 then | |
self.dx = -1 | |
else | |
self.dx = 1 | |
end | |
self.dy = 1 | |
self.turn = 0 | |
self.maxX = bounds:width() | |
self.maxY = bounds:height() + 5 | |
self.bounds = Frame(self.x - 10, self.y - 10, | |
self.x + 10, self.y + 10) | |
end | |
function Skeet:draw(bounds) | |
pushMatrix() | |
pushStyle() | |
strokeWidth(1) | |
noFill() | |
translate(self.x, self.y) | |
rotate(self.turn) | |
scale(self.active) | |
if self.active > 1 then self.active = self.active + 1 end | |
stroke(0, 255, 244, 255 - self.active * 25) | |
ellipse(0, 0, 20) | |
line(- 10, 0, 10, 0) | |
line(0, - 10, 0, 10) | |
line(- 7, - 7, 7, 7) | |
line(- 7, 7, 7, -7) | |
popMatrix() | |
popStyle() | |
self.x = self.x + self.dx | |
self.y = self.y + self.dy | |
if self.x < 10 then self.dx = -self.dx end | |
if self.y < 10 then self.dy = -self.dy end | |
if self.x > self.maxX then self.dx = -self.dx end | |
if self.y > self.maxY then self.dy = -self.dy end | |
self.turn = self.turn + 5 | |
if self.turn > 359 then self.turn = 0 end | |
self.bounds = Frame(self.x - 10, self.y - 10, | |
self.x + 10, self.y + 10) | |
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
Socket = class() | |
function Socket:init(code, x, y) | |
self.code = code | |
self.x = x | |
self.y = y | |
self.frame = Frame(x, y, x + 145, y + 30) | |
self.value = 1 | |
end | |
function Socket:draw() | |
pushStyle() | |
if self.code == nil then | |
fill(16, 16, 16, 255) | |
stroke(73, 73, 73, 255) | |
strokeWidth(2) | |
self.frame:draw() | |
for i = 0,4 do | |
rect(self.frame.left + i * 30, self.frame.bottom + 2, | |
self.frame.left + i * 30, self.frame.bottom + 6) | |
rect(self.frame.left + i * 30, self.frame.top - 6 , | |
self.frame.left + i * 30, self.frame.top - 2) | |
end | |
else | |
strokeWidth(3) | |
tint(self.code.color) | |
sprite(chipImg, self.frame.left, self.frame.bottom, | |
self.frame.right, self.frame.top) | |
stroke(152, 130, 130, 255) | |
noFill() | |
self.frame:draw() | |
fontSize(16) | |
fill(255, 255, 255, 255) | |
if string.len(self.code.long2) > 0 then | |
text(self.code.long1, | |
self.frame.left + 10, self.frame.bottom + 13) | |
text(self.code.long2, | |
self.frame.left + 10, self.frame.bottom + 2) | |
else | |
text(self.code.long1, | |
self.frame.left + 10, self.frame.bottom + 6) | |
end | |
if self.code.hasValue then | |
if self.code.short ~= "P" then | |
fill(63, 58, 37, 219) | |
stroke(127, 127, 127, 211) | |
strokeWidth(5) | |
ellipse(self.x + 87, self.y + 16, 20) | |
line(self.x + 90, self.y + 16, self.x + 145, | |
self.y + 16) | |
noStroke() | |
fill(231, 227, 227, 255) | |
ellipse(self.x + 110, self.y + 16, 20) | |
ellipse(self.x + 125, self.y + 16, 20) | |
rect(self.x + 110, self.y + 6, | |
self.x + 125, self.y + 26) | |
fill(47, 47, 47, 255) | |
textMode(CENTER) | |
text(self.value, self.x + 120, self.y + 15) | |
else | |
fill(233, 233, 233, 255) | |
rect(self.x + 100, self.y + 6, | |
self.x + 135, self.y + 26) | |
fill(47, 47, 47, 255) | |
textMode(CENTER) | |
text(self.value, self.x + 120, self.y + 15) | |
fill(63, 58, 37, 219) | |
stroke(127, 127, 127, 229) | |
strokeWidth(5) | |
line(self.x + 87, self.y + 30, self.x + 87, | |
self.y + 14) | |
line(self.x + 87, self.y + 16, self.x + 102, | |
self.y + 16) | |
end | |
end | |
end | |
popStyle() | |
end | |
function Socket:touched(touch) | |
if self.frame:touched(touch) then | |
return true | |
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
TextBox = class() | |
-- TextBox | |
-- ver. 1.0 | |
-- a control for basic string editing | |
-- ==================== | |
function TextBox:init(x, y, w, s) | |
self.x = x | |
self.y = y | |
self.w = w | |
self.text = s | |
self.blink = ElapsedTime | |
self.blinkstate = true | |
end | |
function TextBox:draw() | |
local x, w, h | |
pushStyle() | |
pushMatrix() | |
textMode(CENTER) | |
fontSize(18) | |
rectMode(CORNER) | |
strokeWidth(1) | |
stroke(0, 0, 0, 255) | |
fill(30, 30, 30, 180) | |
translate(self.x, self.y) | |
rect(0, 0, self.w, 24) | |
stroke(255, 255, 255, 255) | |
--noFill() | |
rect(2, 2, self.w - 4, 20) | |
fill(255, 255, 255, 255) | |
text(self.text, self.w / 2, 12) | |
w, h = textSize(self.text) | |
if self.blink < ElapsedTime - 0.3 then | |
self.blink = ElapsedTime | |
self.blinkstate = not self.blinkstate | |
end | |
if self.blinkstate then | |
strokeWidth(2) | |
stroke(255, 255, 255, 255) | |
x = self.w / 2 + w / 2 + 2 | |
line(x, 3, x, 21) | |
end | |
popMatrix() | |
popStyle() | |
end | |
function TextBox:touched(touch) | |
-- move cursor? For the moment, touching a textbox has no function | |
end | |
function TextBox:acceptKey(k) | |
if k ~= nil then | |
if string.byte(k) == nil then | |
if string.len(self.text) > 0 then | |
self.text = string.sub(self.text, | |
1, string.len(self.text) - 1) | |
end | |
end | |
self.text = self.text..k | |
end | |
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
Token = class() | |
function Token:init(code, x, y, d) | |
-- you can accept and set parameters here | |
self.x = x | |
self.y = y | |
self.divide = d | |
self.code = code | |
end | |
function Token:draw() | |
pushStyle() | |
tint(self.code.color) | |
--tint(98, 130, 152, 255) | |
sprite(chipImg, self.x, self.y, | |
self.x + 140, self.y + 32) | |
strokeWidth(2) | |
noFill() | |
stroke(100, 99, 99, 255) | |
rect(self.x, self.y, self.x + 140, self.y + 32) | |
fill(127, 127, 127, 255) | |
noStroke() | |
rect(self.x, self.y, self.x + 8, self.y - 8) | |
rect(self.x + 34, self.y, self.x + 42, self.y - 8) | |
rect(self.x + 66, self.y, self.x + 74, self.y - 8) | |
rect(self.x + 98, self.y, self.x + 106, self.y - 8) | |
rect(self.x + 132, self.y, self.x + 140, self.y - 8) | |
rect(self.x, self.y + 32, self.x + 8, self.y + 38) | |
rect(self.x + 34, self.y + 32, self.x + 42, self.y + 38) | |
rect(self.x + 66, self.y + 32, self.x + 74, self.y + 38) | |
rect(self.x + 98, self.y + 32, self.x + 106, self.y + 38) | |
rect(self.x + 132, self.y + 32, self.x + 140, self.y + 38) | |
noStroke() | |
fill(233, 233, 233, 255) | |
fontSize(16) | |
if string.len(self.code.long2) > 0 then | |
text(self.code.long2, self.x + 8, self.y + 2) | |
text(self.code.long1, self.x + 8, self.y + 14) | |
else | |
text(self.code.long1, self.x + 8, self.y + 6) | |
end | |
if self.code.hasValue then | |
if self.code.short ~= "P" then | |
fill(211, 211, 211, 255) | |
ellipse(self.x + 110, self.y + 16, 20) | |
ellipse(self.x + 125, self.y + 16, 20) | |
rect(self.x + 110, self.y + 6, self.x + 125, self.y + 26) | |
fill(127, 127, 127, 219) | |
stroke(127, 127, 127, 255) | |
strokeWidth(5) | |
ellipse(self.x + 87, self.y + 16, 20) | |
line(self.x + 90, self.y + 16, self.x + 100, self.y + 16) | |
else | |
fill(194, 194, 194, 255) | |
rect(self.x + 100, self.y + 6, | |
self.x + 135, self.y + 26) | |
fill(223, 168, 168, 255) | |
textMode(CENTER) | |
text("1", self.x + 130, self.y + 15) | |
fill(63, 58, 37, 219) | |
stroke(127, 127, 127, 228) | |
strokeWidth(5) | |
line(self.x + 87, self.y + 30, self.x + 87, self.y + 14) | |
line(self.x + 87, self.y + 16, self.x + 102, self.y + 16) | |
end | |
end | |
end | |
function Token:touched(touch) | |
if touch.x >= self.x and touch.x <= self.x + 130 and | |
touch.y >= self.y and touch.y <= self.y + 30 then | |
return true | |
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
TokenTray = class() | |
function TokenTray:init(x, y) | |
-- you can accept and set parameters here | |
self.x = x | |
self.y = y | |
self.frame = Frame(x, y, x + 200, y + 850) | |
self.selected = 0 | |
self.tokens = {} | |
self.tokens[1] = Token(codes[1], 30, 0, 1) | |
self.tokens[2] = Token(codes[2], 30, 0, 1) | |
self.tokens[3] = Token(codes[3], 30, 0, 1) | |
self.tokens[4] = Token(codes[4], 30, 0, 1) | |
self.tokens[5] = Token(codes[5], 30, 0, 3) | |
self.tokens[6] = Token(codes[6], 30, 0, 2) | |
self.tokens[7] = Token(codes[7], 30, 0, 2) | |
self.tokens[8] = Token(codes[8], 30, 0, 2) | |
self.tokens[9] = Token(codes[9], 30, 0, 2) | |
self.tokens[10] = Token(codes[10], 30, 0, 2) | |
self.tokens[11] = Token(codes[11], 30, 0, 4) | |
self.tokens[12] = Token(codes[12], 30, 0, 4) | |
self.tokens[13] = Token(codes[13], 30, 0, 4) | |
for i = 1, #self.tokens do | |
self.tokens[i].y = 2000 | |
end | |
self.dividers = {} | |
self.dividers[1] = Divider("Movement", 1, 800, 199, 830) | |
self.dividers[2] = Divider("Sensors", 1, 800, 199, 830) | |
self.dividers[3] = Divider("Weapons", 1, 800, 199, 830) | |
self.dividers[4] = Divider("Control", 1, 800, 199, 830) | |
self:selectDivider(1) | |
end | |
function TokenTray:selectDivider(i) | |
local y | |
self.selectedDivider= i | |
for i = 1, self.selectedDivider do | |
y = self.frame:height() - 1 - i * 30 | |
self.dividers[i].frame.bottom = y | |
self.dividers[i].frame.top = y + 30 | |
end | |
for i = self.selectedDivider + 1, #self.dividers do | |
y = (#self.dividers - i) * 30 | |
self.dividers[i].frame.bottom = y | |
self.dividers[i].frame.top = y + 30 | |
end | |
count = 0 | |
for i = 1, #self.tokens do | |
if self.tokens[i].divide == self.selectedDivider then | |
count = count + 1 | |
self.tokens[i].y = | |
self.dividers[self.selectedDivider].frame.bottom | |
- count * 70 | |
else | |
self.tokens[i].y = 2000 | |
end | |
end | |
end | |
function TokenTray:draw() | |
pushStyle() | |
pushMatrix() | |
fontSize(18) | |
tint(25, 27, 46, 255) | |
sprite(boardImg, self.frame.left, self.frame.bottom, | |
self.frame.right, self.frame.top) | |
stroke(249, 249, 249, 255) | |
noFill() | |
strokeWidth(2) | |
self.frame:draw() | |
fill(87, 87, 87, 221) | |
noStroke() | |
translate(self.x, self.y) | |
for i = 1, #self.dividers do | |
self.dividers[i]:draw() | |
end | |
for i = 1, #self.tokens do | |
if self.tokens[i].divide == self.selectedDivider then | |
self.tokens[i]:draw() | |
end | |
end | |
popMatrix() | |
popStyle() | |
end | |
function TokenTray:touched(touch) | |
t = Ttouch(touch) | |
self.selected = 0 | |
t:translate(self.x, self.y) | |
for i = 1, #self.tokens do | |
if self.tokens[i]:touched(t) then | |
self.selected = i | |
return true | |
--sound(SOUND_SHOOT, 773) | |
end | |
end | |
for i = 1, #self.dividers do | |
if self.dividers[i]:touched(t) then | |
self:selectDivider(i) | |
sound(SOUND_BLIT, 4824) | |
return false | |
--sound(SOUND_SHOOT, 773) | |
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
Tourney = class() | |
function Tourney:init() | |
self.matches = {} | |
self.scores = {} | |
self.robots = {} | |
self.matchNum = 0 | |
self.matchCount = 1 | |
self.isActive = false | |
self.frame = Frame(50, 500, WIDTH - 50, HEIGHT - 50) | |
self.type = 0 | |
self.timer = 0 | |
end | |
function Tourney:load(t, a, b, c, d) | |
self.matchNum = 0 | |
self.scores = {} | |
self.type = t | |
self.robots = {a, b, c, d} | |
if self.type == 1 then | |
self.matches[1] = {a, b, c, d} | |
self.matches[2] = {a, b, c, d} | |
self.matches[3] = {a, b, c, d} | |
self.matches[4] = {a, b, c, d} | |
self.timer = 100 | |
self.matchNum = 0 | |
self.matchCount = 4 | |
else | |
self.matches[1] = {a, d, nil, nil} | |
self.matches[2] = {b, c, nil, nil} | |
self.matches[3] = {a, b, nil, nil} | |
self.matches[4] = {a, b, nil, nil} | |
self.timer = 100 | |
self.matchNum = 0 | |
self.matchCount = 4 | |
end | |
end | |
function Tourney:getNextMatch() | |
self.matchNum = self.matchNum + 1 | |
if self.matchNum <= self.matchCount then | |
return self.matches[self.matchNum] | |
end | |
end | |
function Tourney:recordScores(a, b, c, d) | |
self.scores[self.matchNum] = {a, b, c, d} | |
end | |
function Tourney:draw() | |
local bot, round, temp | |
fill(192, 174, 174, 218) | |
stroke(255, 255, 255, 104) | |
strokeWidth(3) | |
self.frame:draw() | |
noFill() | |
fontSize(32) | |
textMode(CORNER) | |
text("Tourney Results", self.frame.left + 35, self.frame.top - 50) | |
fontSize(22) | |
text("Bot", self.frame.left + 50, self.frame.top - 90) | |
text("1", self.frame.left + 275, self.frame.top - 90) | |
text("2", self.frame.left + 350, self.frame.top - 90) | |
text("3", self.frame.left + 425, self.frame.top - 90) | |
text("4", self.frame.left + 500, self.frame.top - 90) | |
line(self.frame.left + 50, self.frame.top - 100, | |
self.frame.left + 500, self.frame.top - 100) | |
text("Total", self.frame.left + 575, self.frame.top - 90) | |
for bot = 1,4 do | |
textAlign(LEFT) | |
text(self.matches[1][bot].name, self.frame.left + 50, | |
self.frame.top - 100 - bot * 35) | |
temp = 0 | |
for round = 1, 4 do | |
textAlign(RIGHT) | |
text(self.scores[round][bot], | |
self.frame.left + 200 + round * 75, | |
self.frame.top - 100 - bot * 35) | |
temp = temp + self.scores[round][bot] | |
end | |
text(temp, self.frame.left + 575, | |
self.frame.top - 100 - bot * 35) | |
end | |
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
TradingCenter = class() | |
function TradingCenter:init() | |
local i, x, y | |
self.frame = Frame(20, 160, WIDTH - 10, HEIGHT - 20) | |
self.cards = {} | |
self.images = {} | |
for x = 1, 5 do | |
for y = 1, 4 do | |
i = x + (y-1) * 5 | |
self.cards[i] = | |
Frame(x * 140 - 100, y * 200 - 10 , | |
x * 140 + 30, y * 200 + 180) | |
w = self.cards[i]:width() | |
h = self.cards[i]:height() | |
self.images[i] = image(w, h) | |
end | |
end | |
self.center = 1 | |
end | |
function TradingCenter:initImages() | |
local i, w, h | |
for i = 1,20 do | |
setContext(self.images[i]) | |
w = self.cards[i]:width() | |
h = self.cards[i]:height() | |
fill(179, 179, 179, 255) | |
stroke(57, 54, 54, 255) | |
strokeWidth(6) | |
rect(1, 1, w, h) | |
strokeWidth(2) | |
stroke(112, 113, 115, 132) | |
fill(0, 0, 0, 255) | |
rect(10, 10, w - 10, h - 10) | |
fill(0, 0, 0, 255) | |
translate(w / 2 - 15, h / 2 + 50) | |
robots[i]:drawBase() | |
noStroke() | |
fill(0, 0, 0, 255) | |
rect(40,-130,65,30) | |
for c = 1, 30 do | |
fill(255, 255, 255, 255) | |
if robots[i].program[c] ~= nil then | |
p = robots[i].program[c].code | |
if p ~= nil then | |
if p.short == "F" then | |
fill(255, 0, 0, 255) | |
elseif p.short == "L" then | |
fill(255, 0, 181, 255) | |
elseif p.short == "R" then | |
fill(255, 101, 0, 255) | |
elseif p.short == "B" then | |
fill(255, 220, 0, 255) | |
elseif p.short == "W" then | |
fill(255, 0, 241, 255) | |
elseif p.short == "H" then | |
fill(14, 0, 255, 255) | |
elseif p.short == "A" then | |
fill(0, 178, 255, 255) | |
elseif p.short == "D" then | |
fill(141, 0, 255, 255) | |
elseif p.short == "G" then | |
fill(3, 255, 0, 255) | |
elseif p.short == "5" then | |
fill(0, 255, 117, 255) | |
elseif p.short == "P" then | |
fill(95, 255, 0, 255) | |
end | |
end | |
rect(-30, -129 + c * 3, -20, -126 + c * 3) | |
v = robots[i].program[c].value | |
fill(255-v * 5, 255-v * 5, 255-v * 5) | |
rect(-20, -129 + c * 3, -10, -126 + c * 3) | |
end | |
end | |
strokeWidth(1) | |
fill(156, 146, 146, 182) | |
noFill() | |
rect(-30, -129 + 1 * 3, -20, -126 + 30 * 3) | |
rect(-20, -129 + 1 * 3, -10, -126 + 30 * 3) | |
rotate(90) | |
fill(255, 255, 255, 255) | |
text(robots[i].name, -120, -65) | |
resetMatrix() | |
setContext() | |
end | |
end | |
function TradingCenter:loadRobot(r) | |
--self.robots[1] = r | |
self:initImages() | |
end | |
function TradingCenter:draw() | |
local i | |
fill(174, 190, 195, 209) | |
stroke(59, 111, 158, 190) | |
strokeWidth(5) | |
self.frame:draw() | |
fontSize(120) | |
fill(135, 171, 172, 207) | |
text("Trade", 35, HEIGHT - 180) | |
fontSize(20) | |
for i = 1,20 do | |
sprite(self.images[i], | |
self.cards[i].left, self.cards[i].bottom, | |
self.cards[i].right, self.cards[i].top) | |
end | |
end | |
function TradingCenter:touched(touch) | |
local i | |
for i = 1,20 do | |
if self.cards[i]:touched(touch) then | |
saveImage("Dropbox:"..robots[i].name, self.images[i]) | |
end | |
end | |
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
Ttouch = class() | |
-- Translatable Touch | |
-- ver. 1.0 | |
-- maps fields of a touch but is easily modified. | |
-- ====================. | |
function Ttouch:init(touch) | |
self.x = touch.x | |
self.y = touch.y | |
self.state = touch.state | |
self.prevX = touch.prevX | |
self.prevY = touch.prevY | |
self.deltaX = touch.deltaX | |
self.deltaY = touch.deltaY | |
self.id = touch.id | |
self.tapCount = touch.tapCount | |
self.timer = 0 | |
end | |
function Ttouch:translate(x, y) | |
self.x = self.x - x | |
self.y = self.y - y | |
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
colors = {} | |
colors[1] = color(255, 25, 0, 255) | |
colors[2] = color(223, 143, 145, 255) | |
colors[3] = color(255, 127, 0, 255) | |
colors[4] = color(223, 183, 152, 255) | |
colors[5] = color(255, 235, 0, 255) | |
colors[6] = color(223, 219, 168, 255) | |
colors[7] = color(96, 255, 0, 255) | |
colors[8] = color(0, 255, 10, 255) | |
colors[9] = color(130, 225, 121, 255) | |
colors[10] = color(0, 255, 220, 255) | |
colors[11] = color(152, 223, 216, 255) | |
colors[12] = color(0, 74, 255, 255) | |
colors[13] = color(129, 121, 225, 255) | |
colors[14] = color(223, 157, 220, 255) | |
colors[15] = color(188, 0, 255, 255) | |
colors[16] = color(255, 255, 255, 255) | |
tourney = Tourney() | |
backClr = color(25, 27, 46, 255) | |
function deepcopy(object) | |
local lookup_table = {} | |
local function _copy(object) | |
if type(object) ~= "table" then | |
return object | |
elseif lookup_table[object] then | |
return lookup_table[object] | |
end | |
local new_table = {} | |
lookup_table[object] = new_table | |
for index, value in pairs(object) do | |
new_table[_copy(index)] = _copy(value) | |
end | |
return setmetatable(new_table, getmetatable(object)) | |
end | |
return _copy(object) | |
end | |
function blurImage(img) | |
local x, y, count, r, g, b, a, ir, ig, ib, ia | |
timg = img:copy() | |
for x = 1, img.width do | |
for y = 1, img.height do | |
r = 0 | |
g = 0 | |
b = 0 | |
a = 0 | |
if x > 1 then | |
ir, ig, ib, ia = img:get(x - 1, y) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if x > 1 and y > 1 then | |
ir, ig, ib, ia = img:get(x - 1, y - 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if y > 1 then | |
ir, ig, ib, ia = img:get(x, y - 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if x < img.width and y > 1 then | |
ir, ig, ib, ia = img:get(x + 1, y - 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if x < img.width then | |
ir, ig, ib, ia = img:get(x + 1, y) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if x < img.width and y < img.height then | |
ir, ig, ib, ia = img:get(x + 1, y + 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if y < img.height then | |
ir, ig, ib, ia = img:get(x, y + 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
if x > 1 and y < img.height then | |
ir, ig, ib, ia = img:get(x - 1, y + 1) | |
r = r + ir | |
g = g + ig | |
b = b + ib | |
a = a + ia | |
end | |
ir,ig,ib,ia = img:get(x,y) | |
r = (r + ir) / 9 | |
g = (g + ig) / 9 | |
b = (b + ib) / 9 | |
a = (a + ia) / 9 | |
c = color(r,g,b,a) | |
--print(r,g,b,a) | |
timg:set(x,y,c) | |
end | |
end | |
print(r,g,b,a) | |
displayMode(STANDARD) | |
return timg | |
end | |
function getDefault() | |
local s | |
s = "20,Lump,0,0,14,14,15,4,30,1,F,1,2,nil,1,3,L,1,4,nil,1,5,nil,1,6,nil,1,7,nil,1,8,nil,1,9,nil,1,10,nil,1,11,nil,1,12,nil,1,13,nil,1,14,nil,1,15,nil,1,16,nil,1,17,nil,1,18,nil,1,19,nil,1,20,nil,1,21,nil,1,22,nil,1,23,nil,1,24,nil,1,25,nil,1,26,nil,1,27,nil,1,28,nil,1,29,nil,1,30,nil,1,Turner,0,0,15,8,15,7,30,1,F,1,2,H,4,3,G,1,4,L,1,5,G,1,6,nil,1,7,nil,1,8,nil,1,9,nil,1,10,nil,1,11,nil,1,12,nil,1,13,nil,1,14,nil,1,15,nil,1,16,nil,1,17,nil,1,18,nil,1,19,nil,1,20,nil,1,21,nil,1,22,nil,1,23,nil,1,24,nil,1,25,nil,1,26,nil,1,27,nil,1,28,nil,1,29,nil,1,30,nil,1,Spinner,0,0,2,7,1,4,30,1,L,1,2,W,4,3,G,1,4,nil,1,5,nil,1,6,nil,1,7,nil,1,8,nil,1,9,nil,1,10,nil,1,11,nil,1,12,nil,1,13,nil,1,14,nil,1,15,nil,1,16,nil,1,17,nil,1,18,nil,1,19,nil,1,20,nil,1,21,nil,1,22,nil,1,23,nil,1,24,nil,1,25,nil,1,26,nil,1,27,nil,1,28,nil,1,29,nil,1,30,nil,1,Smart Spinner,0,0,1,7,1,13,30,1,L,1,2,A,4,3,G,1,4,W,1,5,G,2,6,nil,1,7,nil,1,8,nil,1,9,nil,1,10,nil,1,11,nil,1,12,nil,1,13,nil,1,14,nil,1,15,nil,1,16,nil,1,17,nil,1,18,nil,1,19,nil,1,20,nil,1,21,nil,1,22,nil,1,23,nil,1,24,nil,1,25,nil,1,26,nil,1,27,nil,1,28,nil,1,29,nil,1,30,nil,1,Killbot 1000,0,0,15,3,15,3,30,1,F,1,2,H,4,3,G,1,4,R,1,5,R,1,6,A,13,7,L,1,8,F,1,9,H,11,10,G,5,11,R,1,12,G,5,13,W,1,14,G,6,15,nil,1,16,nil,1,17,nil,1,18,nil,1,19,nil,1,20,nil,1,21,nil,1,22,nil,1,23,nil,1,24,nil,1,25,nil,1,26,nil,1,27,nil,1,28,nil,1,29,nil,1,30,nil,1,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0,Generobot,0,0,14,14,15,4,0" | |
return s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment