diff --git a/assets/images.json b/assets/images.json index 70a8274..1219e31 100644 --- a/assets/images.json +++ b/assets/images.json @@ -1,6 +1,42 @@ { + "cthulhu":{ + "x":23, + "y":6 + }, "grass":{ "x":56, "y":15 + }, + "kobold_female_green":{ + "x":50, + "y":31 + }, + "orc_male":{ + "x":40, + "y":32 + }, + "stick":{ + "x":64, + "y":46 + }, + "tent":{ + "x":4, + "y":22 + }, + "todo":{ + "x":64, + "y":1 + }, + "tree":{ + "x":13, + "y":19 + }, + "machine":{ + "x":56, + "y":16 + }, + "centaur_female_brown":{ + "x":22, + "y":31 } } diff --git a/assets/races.json b/assets/races.json index 1b7f2c3..f36defe 100644 --- a/assets/races.json +++ b/assets/races.json @@ -51,6 +51,7 @@ ] }, "Half Orc":{ + "icon":"orc_male", "stats":["health"] }, "Hob-Nobbit":{ @@ -60,6 +61,7 @@ ] }, "Land Squid":{ + "icon":"cthulhu", "stats":["health","strength"], "tasks":[ "Drinking plenty of water" @@ -81,12 +83,14 @@ ] }, "Talking Pony":{ + "icon":"centaur_female_brown", "stats":["intelligence","magic"], "tasks":[ [4, "Singing their theme song"] ] }, "Trans-Kobold":{ + "icon":"kobold_female_green", "stats":["wisdom"], "tasks":[ [10, "#TransRights"] diff --git a/src/lib/character.lua b/src/lib/characters.lua similarity index 84% rename from src/lib/character.lua rename to src/lib/characters.lua index 0b693c9..7820722 100644 --- a/src/lib/character.lua +++ b/src/lib/characters.lua @@ -1,7 +1,9 @@ local classes = require "data.classes" +local constants = require "data.constants" +local images = require "data.images" local races = require "data.races" -local character = {} +local characters = {} local base_stat_roll = function() return 3 + math.random(1, 6) + math.random(1, 6) + math.random(1, 6) @@ -48,7 +50,7 @@ end -character.new = function(name) +characters.new = function(name) name = name or progress_quest_random_name() -- name not affected by seed local seed = math.random() @@ -81,10 +83,13 @@ character.new = function(name) character.max_encumberance = character.strength + 10 character.inventory = {} - return character + character.x = 1 + character.y = 1 + + return setmetatable(character, { __index = characters, }) end -character.level_up = function(character) +characters.level_up = function(character) character.health = character.health + 1 + math.floor(character.constitution / 3) + math.random(1, 4) character.magic = character.magic + 1 + math.floor(character.intelligence / 3) + math.random(1, 4) @@ -96,4 +101,9 @@ character.level_up = function(character) -- TODO this is where a spell could be added, and end -return character +characters.draw = function(self) + local icon = races[self.race].icon or "todo" + love.graphics.draw(images.love_image, images[icon], self.x * constants.tile_size, self.y * constants.tile_size) +end + +return characters diff --git a/src/main.lua b/src/main.lua index 7ffb922..43b5bf0 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,6 +1,6 @@ local window_width, window_height = love.graphics.getDimensions() -local character = require "lib.character" +local characters = require "lib.characters" local log = require "lib.log" local lovebird = require "lib.lovebird" local macOS_say = require "lib.macOS_say" @@ -23,11 +23,12 @@ local images = require "data.images" -- TEMP local test_new_character = function() - local character = character.new() + local character = characters.new() local message = "My name is " .. character.name .. ", and I am a " .. character.class .. " " .. character.race .. "!" macOS_say(message) + return character end -test_new_character() +local test_character = test_new_character() -- TEMP test progress_bar local test_bar = progress_bar(0, window_height - constants.progress_bar_height * 2, window_width, constants.progress_bar_height) @@ -68,6 +69,8 @@ end love.draw = function() love.graphics.draw(images.love_image, images.grass, 50, 50) -- TEMP + love.graphics.draw(images.love_image, images.centaur_female_brown, 50, 50) -- TEMP + test_character:draw() -- TEMP test_bar:draw() -- TEMP book_progress:draw()