This is the current game project I am working on.
Updates since 02_01..
Have fixed a bug with the input devices, where if the joystick/gamepad was not plugged in the program would crash.
Added os detection and input device detection.
Added primitive splash screens
=================================END==========================================
Well prepare to be underwhelmed. Any tips or advice would be greatly appreciated. I know the code is going to be pretty bad, but without peoples feedback improvement will be slow so please forgive my lack of code mastery. Lol I know its pretty nasty. But still we all start from somewhere right?
This is the character sheet scene. At the moment its generating the stats for the sheet within this scene, but in a full program its job its pretty humble, it accesses a table of statistics for the player character. A similar scene could also be created for NPCs.
Libraries abused in this technical demo..
RL-Dice - excellent little library, this is what I used to generate the player stats.
Apps used/abused.
Inkscape
And that's about it, actually in this demo it actually has more functionality than it will have in the main program. Still best to take out the low hanging fruit early.
Here is the source..
Code: Select all
-- The character sheet scene.
require("lib/RL-Dice/dice")
function love.load()
uiGraphics = love.graphics.newImage("assets/charsheet_1920x1080.png")
internalWidth = 1920
internalHeight = 1080
mfont = love.graphics.newFont("assets/Arkhip_font.ttf", 94)
sfont = love.graphics.newFont("assets/Arkhip_font.ttf", 64)
generatePC()
flag = love.graphics.newImage("assets/flags/shiny/128/Philippines.png")
psexicon = love.graphics.newImage("assets/Female_Dark.png")
end
function generatePC()
chancestats = {}
chancestats = {dice.roll(("(1d100)x3"))}
dice.setMin(2)
stats = {}
stats2 = {dice.roll(("(1d10)x14"))}
stats = stats2
end
function love.keypressed(key)
if key == "f1" then
generatePC()
end
if key == "escape" then
love.event.quit()
end
end
function menustatsdata()
pprof = {"rockerboy","solo","netrunner","techie","medtech","media","cop","corporate","fixer","nomad","mindstar","scientist"}
if chancestats[1] <= 50 then
psex = "f"
psexicon = love.graphics.newImage("assets/Female_Dark.png")
end
if chancestats[1] >= 51 then
psex = "m"
psexicon = love.graphics.newImage("assets/Male_Dark.png")
end
if chancestats[2] <= 8 then
pprofchoi = pprof[1]
if psex == "m" then
psexicon = love.graphics.newImage("assets/Male_Light_Rockerboy.png")
end
if psex == "f" then
psexicon = love.graphics.newImage("assets/Female_Light_Rockerboy.png")
end
end
if chancestats[2] >= 9 and chancestats[2] <= 16 then
pprofchoi = pprof[2]
if psex == "m" then
psexicon = love.graphics.newImage("assets/Male_Light_Solo.png")
end
end
if chancestats[2] >= 17 and chancestats[2] <= 24 then
pprofchoi = pprof[3]
end
if chancestats[2] >= 25 and chancestats[2] <= 32 then
pprofchoi = pprof[4]
end
if chancestats[2] >= 33 and chancestats[2] <= 40 then
pprofchoi = pprof[5]
end
if chancestats[2] >= 41 and chancestats[2] <= 48 then
pprofchoi = pprof[6]
if psex == "m" then
psexicon = love.graphics.newImage("assets/Male_Dark_Media.png")
end
if psex == "f" then
psexicon = love.graphics.newImage("assets/Female_Dark_Media.png")
end
end
if chancestats[2] >= 42 and chancestats[2] <= 56 then
pprofchoi = pprof[7]
if psex == "m" then
psexicon = love.graphics.newImage("assets/Male_Light_Cop.png")
end
end
if chancestats[2] >= 57 and chancestats[2] <= 64 then
pprofchoi = pprof[8]
if psex == "m" then
psexicon = love.graphics.newImage("assets/Male_Dark_Coperate.png")
end
end
if chancestats[2] >= 65 and chancestats[2] <= 72 then
pprofchoi = pprof[9]
end
if chancestats[2] >= 73 and chancestats[2] <= 80 then
pprofchoi = pprof[10]
end
if chancestats[2] >= 81 and chancestats[2] <= 88 then
pprofchoi = pprof[11]
end
if chancestats[2] >= 89 and chancestats[2] <= 100 then
pprofchoi = pprof[12]
end
page = 42
porg = "gb"
phit = 30
phum = stats[4] * 10
prun = stats[5] * 3
pjum = prun/4
pcar = stats[1] * 10
plug = stats[1] * 40
pname = "doc albu"
races = {"human", "highrider", "replicant", "gennie", "bioroid", "ai", "construct"}
love.graphics.setFont(mfont)
love.graphics.print(pname, 280, 245)
love.graphics.print(races[1], 1160, 245)
--love.graphics.print(pprof[12], 280, 435)
love.graphics.print(pprofchoi, 280, 435)
love.graphics.print(stats[1], 280, 615)
love.graphics.print(stats[2], 460, 615)
love.graphics.print(stats[3], 630, 615)
love.graphics.print(stats[4], 810, 615)
love.graphics.print(stats[5], 990, 615)
love.graphics.print(stats[6], 1160, 615) --
love.graphics.print(stats[7], 1340, 615)
love.graphics.print(stats[8], 1510, 615)
love.graphics.print(stats[9], 1690, 615) --
--love.graphics.print(phum, 810, 785) -- hum
--love.graphics.print(prun.."m", 980, 785)
love.graphics.setFont(sfont)
love.graphics.print(pcar, 270, 785) -- CARRY
love.graphics.print(plug, 260, 955) -- DlIFT
love.graphics.print(phum, 810, 785) -- hum
love.graphics.print(prun, 980, 785)
love.graphics.print(pjum, 960, 965)
love.graphics.setFont(mfont)
--love.graphics.print(psex, 1160, 435)
love.graphics.print(page, 1320, 435)
love.graphics.print(phit, 1500, 435)
--love.graphics.print(porg, 1690, 435)
end
function love.draw()
local screenWidth = love.graphics.getWidth()
local screenHeight = love.graphics.getHeight()
local ratio = math.min(screenWidth/internalWidth, screenHeight/internalHeight)
love.graphics.scale(ratio,ratio)
love.graphics.draw(uiGraphics, 0, 0)
menustatsdata()
love.graphics.draw(flag, 1680,425)
love.graphics.scale(0.80,0.80)
love.graphics.draw(psexicon, 1456,550)
end
The plan is to make custom avatars for the character sheet that can also be used in the game, that will come later but as you can see from the code above, eventually each class will have its own gender icon, I'll have it reflect the birth place of the character. Next step is to get the background tables coded - that's quite involved but technically pretty straight forward to implement. Like I did for the professions roll, just instead of 12 professions you have around 300 countries.. that's a job for tomorrow. Will make a separate function to handle this, then update the character sheet.
The resolution chosen was a bit weird, I wanted something that would work on most devices without too much hassle, so I went with 1920 x 1080. But that seems a poor choice now. In hindsight I should have been less lazy and just had a if ladder that selected the ui based on love.graphics.getWidth & love.graphics.getHeight. But that's a task for another day. I have a feeling it would be better to do this in a general scaling function that I could just call for every scene. Of-course it would mean that each scene would need to have its assets in multiple resolutions to work optimally but overall it might be worth it....
One definite takeaway is that figuring out the position to print the data at is time consuming, I get the feeling life would be a bit simpler if I went with the brute force approach of just generating a png sprite sheet for the numbers and letters instead of messing around with fonts in love.
A lot of these variables could do with being local, and probably being in a table to keep them tidy. that's another task for tomorrow.
Tomorrows tasks - finish character creation code, update character sheet code (going to take out the character generation code and put it in its own separate file, by tomorrow the only thing this code will be doing is reading from a table it got passed.
would like to get the numbers aligned right - but that's something I can do later.