-- 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:
parent
520dddedf6
commit
c9a1ef3d82
7 changed files with 164 additions and 10 deletions
6
Maps/default.vsmf
Normal file
6
Maps/default.vsmf
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
name=default
|
||||||
|
size=1920.1080
|
||||||
|
id=001
|
||||||
|
statics=house1.100.1080,house2.500.1080
|
||||||
|
interactables=
|
||||||
|
objects=bat.1000.1080.50
|
||||||
6
Maps/template.vsmf
Normal file
6
Maps/template.vsmf
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
name=(name)
|
||||||
|
size=x.y
|
||||||
|
id=INT(XYZ)
|
||||||
|
statics=static.x.y,
|
||||||
|
interactables=interactable.x.y,
|
||||||
|
objects=object.x.y,
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
-- Info about the savegame
|
||||||
|
savegame = {}
|
||||||
|
savegame.createDate = ""
|
||||||
|
savegame.loadDate = ""
|
||||||
|
savegame.name = ""
|
||||||
|
savegame.characterName = ""
|
||||||
|
savegame.playTime = 0
|
||||||
|
|
||||||
|
-- These events will run upon initialization
|
||||||
|
|
||||||
|
character = {}
|
||||||
|
|
||||||
|
NPCs = {}
|
||||||
70
main.lua
70
main.lua
|
|
@ -8,6 +8,7 @@ functiongenerator = {}
|
||||||
check_space = {}
|
check_space = {}
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
globalMode = "devMode"
|
||||||
window = {}
|
window = {}
|
||||||
window.x, window.y = love.window.getDesktopDimensions()
|
window.x, window.y = love.window.getDesktopDimensions()
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
|
|
@ -16,6 +17,7 @@ function love.load()
|
||||||
physics_ini = require('physics')
|
physics_ini = require('physics')
|
||||||
menu_ini = require('menu')
|
menu_ini = require('menu')
|
||||||
npc_ini = require('scripts/NPC')
|
npc_ini = require('scripts/NPC')
|
||||||
|
map_ini = require('world')
|
||||||
menu.load()
|
menu.load()
|
||||||
NPCs = {}
|
NPCs = {}
|
||||||
ground = {
|
ground = {
|
||||||
|
|
@ -32,11 +34,17 @@ function love.load()
|
||||||
player.width = 20
|
player.width = 20
|
||||||
player.height = 80
|
player.height = 80
|
||||||
mouse = {}
|
mouse = {}
|
||||||
|
currentMap = "none"
|
||||||
function player.functions.getRunningSpeed(runningStatus) if runningStatus then return player.attributes.maxRunningSpeed*2 else return player.attributes.maxRunningSpeed end end
|
function player.functions.getRunningSpeed(runningStatus) if runningStatus then return player.attributes.maxRunningSpeed*2 else return player.attributes.maxRunningSpeed end end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
if Scene == "gameTest" then
|
if Scene == "gameTest" then
|
||||||
|
if currentMap ~= "default" then
|
||||||
|
print ("loading map...")
|
||||||
|
World.loadMap("default")
|
||||||
|
currentMap = "default"
|
||||||
|
end
|
||||||
keyboard_input_held(player, dt)
|
keyboard_input_held(player, dt)
|
||||||
gravity(player, dt)
|
gravity(player, dt)
|
||||||
mouvement(player, dt)
|
mouvement(player, dt)
|
||||||
|
|
@ -56,7 +64,10 @@ end
|
||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.print(Scene, 100, 100)
|
love.graphics.print(Scene, 100, 100)
|
||||||
if Scene == "gameTest" then
|
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)
|
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
|
||||||
if player.bools.isFacingRight then
|
if player.bools.isFacingRight then
|
||||||
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
|
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
|
||||||
|
|
@ -66,6 +77,7 @@ function love.draw()
|
||||||
for i = 1, #NPCs do
|
for i = 1, #NPCs do
|
||||||
love.graphics.rectangle("fill", NPCs[i].x, NPCs[i].y, NPCs[i].width, NPCs[i].height)
|
love.graphics.rectangle("fill", NPCs[i].x, NPCs[i].y, NPCs[i].width, NPCs[i].height)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #NPCs do
|
for i = 1, #NPCs do
|
||||||
if NPCs[i].bools.isInteracting then
|
if NPCs[i].bools.isInteracting then
|
||||||
local font = love.graphics.getFont()
|
local font = love.graphics.getFont()
|
||||||
|
|
@ -73,6 +85,30 @@ function love.draw()
|
||||||
love.graphics.draw(helloText, NPCs[i].x, NPCs[i].y-10)
|
love.graphics.draw(helloText, NPCs[i].x, NPCs[i].y-10)
|
||||||
end
|
end
|
||||||
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
|
elseif Scene == "menu" then
|
||||||
menu.draw()
|
menu.draw()
|
||||||
end
|
end
|
||||||
|
|
@ -94,6 +130,13 @@ function defaulkeybinds()
|
||||||
keybinds.interact = "e"
|
keybinds.interact = "e"
|
||||||
keybinds.run = "lshift"
|
keybinds.run = "lshift"
|
||||||
keybinds.create = "f"
|
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
|
end
|
||||||
|
|
||||||
function character.create(chosenSubclasses, isPlayerControlled)
|
function character.create(chosenSubclasses, isPlayerControlled)
|
||||||
|
|
@ -108,6 +151,8 @@ function character.create(chosenSubclasses, isPlayerControlled)
|
||||||
object.attributes.wanderpoint = math.random(0, window.x)
|
object.attributes.wanderpoint = math.random(0, window.x)
|
||||||
object.bools.isInteracting = false
|
object.bools.isInteracting = false
|
||||||
object.attributes.time_spoken = 0
|
object.attributes.time_spoken = 0
|
||||||
|
else
|
||||||
|
character.subclasses.create.inventory(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
|
@ -126,7 +171,8 @@ function character.subclasses.create.bools(object)
|
||||||
isAirborne = true,
|
isAirborne = true,
|
||||||
isWalking = false,
|
isWalking = false,
|
||||||
isRunning = false,
|
isRunning = false,
|
||||||
isFacingRight = true
|
isFacingRight = true,
|
||||||
|
inventoryOpen = false
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
function character.subclasses.create.attributes(object)
|
function character.subclasses.create.attributes(object)
|
||||||
|
|
@ -136,4 +182,22 @@ function character.subclasses.create.attributes(object)
|
||||||
end
|
end
|
||||||
function character.subclasses.create.functions(object)
|
function character.subclasses.create.functions(object)
|
||||||
object.functions = {}
|
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
|
||||||
|
|
|
||||||
1
menu.lua
1
menu.lua
|
|
@ -7,6 +7,7 @@ menuButtons = {
|
||||||
Quit = {}
|
Quit = {}
|
||||||
}
|
}
|
||||||
font_ini = require('scripts/fonts')
|
font_ini = require('scripts/fonts')
|
||||||
|
world_ini = require('world')
|
||||||
function menu.load()
|
function menu.load()
|
||||||
RGB = 1
|
RGB = 1
|
||||||
RGB_hover = 0.5
|
RGB_hover = 0.5
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ function keyboard_input_held(object, dt)
|
||||||
if love.keyboard.isDown("lshift") then
|
if love.keyboard.isDown("lshift") then
|
||||||
object.bools.isRunning = true
|
object.bools.isRunning = true
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown(keybind.left) and love.keyboard.isDown(keybind.right) then
|
if love.keyboard.isDown(keybinds.left) and love.keyboard.isDown(keybinds.right) then
|
||||||
-- you're stopped now :3c
|
-- you're stopped now :3c
|
||||||
elseif love.keyboard.isDown(keybind.left) then
|
elseif love.keyboard.isDown(keybinds.left) then
|
||||||
object.bools.isWalking = true
|
object.bools.isWalking = true
|
||||||
if math.abs(object.physics.velocityX) + 0.1 < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX - 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning)* -1 end
|
if math.abs(object.physics.velocityX) + 0.1 < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX - 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning)* -1 end
|
||||||
elseif love.keyboard.isDown(keybind.right) then
|
elseif love.keyboard.isDown(keybinds.right) then
|
||||||
object.bools.isWalking = true
|
object.bools.isWalking = true
|
||||||
if math.abs(object.physics.velocityX) < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX + 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning) end
|
if math.abs(object.physics.velocityX) < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX + 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning) end
|
||||||
end
|
end
|
||||||
|
|
@ -38,19 +38,26 @@ end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
if Scene == "gameTest" then
|
if Scene == "gameTest" then
|
||||||
if key == keybind.jump then player.physics.velocityY = player.physics.velocityY - 3 end
|
if key == keybinds.jump and player.bools.isAirborne == false then player.physics.velocityY = player.physics.velocityY - 5 end
|
||||||
if key == keybind.interact then
|
if key == keybinds.interact then
|
||||||
check_space.interactables(player.x, player.y)
|
check_space.interactables(player.x, player.y)
|
||||||
end
|
end
|
||||||
if key == keybind.create then
|
if key == keybinds.create then
|
||||||
NPCs[#NPCs+1] = character.create({"attributes", "functions","bools","physics"}, false)
|
NPCs[#NPCs+1] = character.create({"attributes", "functions","bools","physics"}, false)
|
||||||
NPCs[#NPCs].x = math.random(0, window.x-20)
|
NPCs[#NPCs].x = math.random(0, window.x-20)
|
||||||
NPCs[#NPCs].y = window.y/2-window.y/20
|
NPCs[#NPCs].y = window.y/2-window.y/20
|
||||||
NPCs[#NPCs].width = 20
|
NPCs[#NPCs].width = 20
|
||||||
NPCs[#NPCs].height = 80
|
NPCs[#NPCs].height = 80
|
||||||
end
|
end
|
||||||
|
if key == keybinds.primary then
|
||||||
|
player.current_equip = 1
|
||||||
|
end
|
||||||
|
if key == keybinds.secondary then
|
||||||
|
player.current_equip = 2
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
if key == keybind.jump then
|
if key == keybinds.jump then
|
||||||
titleCard.duration = true
|
titleCard.duration = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
57
world.lua
Normal file
57
world.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
World = {
|
||||||
|
currentMap = nil,
|
||||||
|
map = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function World.loadMap(name)
|
||||||
|
local path = ("maps/"..tostring(name)..".vsmf")
|
||||||
|
--path = ("world.txt")
|
||||||
|
for line in love.filesystem.lines(path) do
|
||||||
|
line = tostring(line)
|
||||||
|
print ("Itterating line: " .. line)
|
||||||
|
|
||||||
|
local hasPassedEqual = false
|
||||||
|
local command = ""
|
||||||
|
local args = {""}
|
||||||
|
local i = 1
|
||||||
|
|
||||||
|
for character in string.gmatch(line, '.') do
|
||||||
|
print ("Itterating character: " .. character)
|
||||||
|
if hasPassedEqual == true then
|
||||||
|
if character == "." then
|
||||||
|
i = i + 1
|
||||||
|
else
|
||||||
|
if args [i] == nil then
|
||||||
|
args[i] = character
|
||||||
|
else
|
||||||
|
args[i] = args[i] .. character
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif character == "=" then
|
||||||
|
hasPassedEqual = true
|
||||||
|
else
|
||||||
|
command = command .. character
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print (command .. " " .. args[1] .. "\n")
|
||||||
|
for x = 1, #args do
|
||||||
|
if x == 1 then
|
||||||
|
World.map[command] = {}
|
||||||
|
World.map[command][args[1]] = {}
|
||||||
|
World.map[command].catalogue = {}
|
||||||
|
table.insert(World.map[command].catalogue, args[1])
|
||||||
|
print ("Put " .. args[1] .. " in " .. command)
|
||||||
|
else
|
||||||
|
World.map[command][args[1]][x - 1] = args[x]
|
||||||
|
print ("Added " .. args[x] .. " to " .. args[1] .. " at " .. x-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function World.drawMap()
|
||||||
|
if World.map.objects then
|
||||||
|
for i = 1, #World.map.objects.catalogue do
|
||||||
|
love.graphics.circle("line", World.map.objects[World.map.objects.catalogue[i]][1], World.map.objects[World.map.objects.catalogue[i]][2] - World.map.objects[World.map.objects.catalogue[i]][3], World.map.objects[World.map.objects.catalogue[i]][3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue