local class = require "libs.clasp" local utils = require "utils" local term = utils.term local info = utils.log.info local warn = utils.log.warn local err = utils.log.err local fatal = utils.log.fatal function enum(vals) local out = {} local count = 0 for k,v in ipairs(vals) do out[v] = k out[k] = v count = count + 1 end out._Count = count return out end local Vec2 = class { init = function(self, x, y) self.x = x self.y = y end } local CardSeed = enum { 'Heart', 'Spade', 'Diamond', 'Club', } local card_size = Vec2(20, 29) local Card = class { init = function(self, n, s, tex) self.image = tex self.number = n self.seed = s self.x = 0 self.y = 0 local offx = n - 1 local offy = s - 1 self.quad = love.graphics.newQuad( offx * card_size.x, offy * card_size.y, card_size.x, card_size.y, tex ) end, draw = function(self) love.graphics.draw( self.image, self.quad, self.x, self.y ) end } local CardData = class { init = function(self, img_path) self.image = love.graphics.newImage(img_path) self.cards = {} for s=1,CardSeed._Count do local seed = {} for n=1,10 do seed[n] = Card(n, s, self.image) end self.cards[s] = seed end end, } local card_data = null function love.load() love.graphics.setDefaultFilter('nearest', 'nearest', 0) card_data = CardData('assets/cards.png') end function love.draw() end function love.update(dt) if love.keyboard.isDown('q') or love.keyboard.isDown('escape') then love.event.quit(0) end end