Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tank = {
- x = 0,
- y = 0,
- dir = 0,
- power = 50,
- moves = 4,
- color = colors.blue
- }
- local w, h = term.getSize()
- local function draw(string, x, y, txtcol, bakcol)
- string = string or ""
- txtcol = txtcol or colors.white
- bakcol = bakcol or colors.black
- term.setCursorPos(x, y)
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(string)
- end
- local function Tank:new(x, y, dir, power, color)
- local class = {x = x, y = y, dir = dir, power = 50, moves = 4, color = color}
- setmetatable(class, self)
- self.__index = self
- return class
- end
- local function Tank:display()
- local tankimg = {{0, self.color, 0}, {self.color, self.color, self.color}}
- paintutils.drawImage(tankimg, self.x, self.y)
- local barrel, x, y
- local back = 2^15
- if self.dir == 1 then
- barrel, x, y = "-", -1, 0
- elseif self.dir == 2 then
- barrel, x, y = "\\", -1, -1
- elseif self.dir == 3 then
- barrel, x, y = "|", 0, -1
- elseif self.dir == 4 then
- barrel, x, y = "/", 1, -1
- elseif self.dir == 5 then
- barrel, x, y = "-", 1, 0
- elseif self.dir == 6 then
- barrel, x, y = "\\", 1, 1
- back = self.color
- elseif self.dir == 7 then
- barrel, x, y = "|", 0, 1
- back = self.color
- elseif self.dir == 8 then
- barrel, x, y = "/", -1, 1
- back = self.color
- end
- draw(barrel, self.x + x, self.y + y, colors.white, back)
- end
- local function Tank:changeAngle(events)
- end
- local function Tank:move(events)
- self.moves = self.moves - 1
- if events[2] == keys.left then
- self.x = self.x + 1
- elseif evebts[2] == keys.right then
- self.x = self.x - 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement