World Gen #1, Inventory #1

-- Added loading of .vsmf map files
-- Updated some variable names
-- Added developer information to the top left of the screen
-- Added a trial inventory
This commit is contained in:
Hannah-Dagemark 2023-09-15 20:52:30 +02:00
commit c9a1ef3d82
7 changed files with 164 additions and 10 deletions

View file

@ -8,6 +8,7 @@ functiongenerator = {}
check_space = {}
function love.load()
globalMode = "devMode"
window = {}
window.x, window.y = love.window.getDesktopDimensions()
math.randomseed(os.time())
@ -16,6 +17,7 @@ function love.load()
physics_ini = require('physics')
menu_ini = require('menu')
npc_ini = require('scripts/NPC')
map_ini = require('world')
menu.load()
NPCs = {}
ground = {
@ -32,11 +34,17 @@ function love.load()
player.width = 20
player.height = 80
mouse = {}
currentMap = "none"
function player.functions.getRunningSpeed(runningStatus) if runningStatus then return player.attributes.maxRunningSpeed*2 else return player.attributes.maxRunningSpeed end end
end
function love.update(dt)
if Scene == "gameTest" then
if currentMap ~= "default" then
print ("loading map...")
World.loadMap("default")
currentMap = "default"
end
keyboard_input_held(player, dt)
gravity(player, dt)
mouvement(player, dt)
@ -56,7 +64,10 @@ end
function love.draw()
love.graphics.print(Scene, 100, 100)
if Scene == "gameTest" then
if love.graphics.getColor() ~= 1, 1, 1 then love.graphics.setColor(1, 1, 1) end
love.graphics.setColor(1, 1, 1)
World.drawMap()
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
if player.bools.isFacingRight then
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
@ -66,6 +77,7 @@ function love.draw()
for i = 1, #NPCs do
love.graphics.rectangle("fill", NPCs[i].x, NPCs[i].y, NPCs[i].width, NPCs[i].height)
end
for i = 1, #NPCs do
if NPCs[i].bools.isInteracting then
local font = love.graphics.getFont()
@ -73,6 +85,30 @@ function love.draw()
love.graphics.draw(helloText, NPCs[i].x, NPCs[i].y-10)
end
end
if player.bools.inventoryOpen then
-- Draw Inventory
else
for i = 1, player.hotbar_len do
if player.current_equip == i then
love.graphics.setColor(0, 1, 0.2)
else
love.graphics.setColor(1, 1, 1)
end
love.graphics.rectangle("line", window.x - ((player.hotbar_len + 1) * 100) + (i * 100), 0, 100, 100)
end
end
if globalMode == "devMode" then
love.graphics.print("Velocity X " .. player.physics.velocityX, 100, 300)
love.graphics.print("Velocity Y " .. player.physics.velocityY, 100, 350)
love.graphics.print("Airtime " .. player.physics.airtime, 100, 400)
---
love.graphics.print("Is Airborne " .. tostring(player.bools.isAirbornes), 100, 450)
love.graphics.print("Is Walking " .. tostring(player.bools.isWalking), 100, 500)
love.graphics.print("Is Running " .. tostring(player.bools.isRunning), 100, 550)
love.graphics.print("Is Facing Right " .. tostring(player.bools.isFacingRight), 100, 600)
love.graphics.print("Inventory Open " .. tostring(player.bools.inventoryOpen), 100, 650)
end
elseif Scene == "menu" then
menu.draw()
end
@ -94,6 +130,13 @@ function defaulkeybinds()
keybinds.interact = "e"
keybinds.run = "lshift"
keybinds.create = "f"
keybinds.primary = "1"
keybinds.secondary = "2"
keybinds.functionality = "t"
keybinds.minor = "g"
keybinds.additional1 = "3"
keybinds.additional2 = "4"
keybinds.additional3 = "5"
end
function character.create(chosenSubclasses, isPlayerControlled)
@ -108,6 +151,8 @@ function character.create(chosenSubclasses, isPlayerControlled)
object.attributes.wanderpoint = math.random(0, window.x)
object.bools.isInteracting = false
object.attributes.time_spoken = 0
else
character.subclasses.create.inventory(object)
end
return object
@ -126,7 +171,8 @@ function character.subclasses.create.bools(object)
isAirborne = true,
isWalking = false,
isRunning = false,
isFacingRight = true
isFacingRight = true,
inventoryOpen = false
}
end
function character.subclasses.create.attributes(object)
@ -136,4 +182,22 @@ function character.subclasses.create.attributes(object)
end
function character.subclasses.create.functions(object)
object.functions = {}
end
end
function character.subclasses.create.inventory(object)
object.hotbar_cont = {}
object.inventory_cont = {}
object.hotbar_len = 2
object.inventory_len = 0
object.current_equip = 1
end
function inventory(mode, slot, item)
if mode == "add" then
hotbar_cont[slot] = item
elseif mode == "remove" then
hotbar_cont[slot] = nil
elseif mode == "move" then
item = hotbar_cont[slot[1]]
hotbar_cont[slot[2]] = item
end
end