Fixed anchor on Sprites, added GameJolt login and 2 trophies.
This commit is contained in:
parent
f7655cb484
commit
578ce18fba
@ -1 +1 @@
|
||||
Subproject commit 2b5cd6a16b3ca076a77d81d9e7c30a9081331a0a
|
||||
Subproject commit f14173fa68e681c3ac638a46864e4b992314b0e0
|
@ -375,14 +375,14 @@ function module.drawSprites()
|
||||
love.graphics.setShader(loadedShaders[sprite.shader])
|
||||
end
|
||||
|
||||
local quadx, quady = quad.quad:getTextureDimensions()
|
||||
local _, _, quadx, quady = quad.quad:getViewport()
|
||||
|
||||
love.graphics.draw(sprite.image, quad.quad,
|
||||
(sprite.position.x - quad.offset.x - sprite.extraOffset.x + cameraOffset.x * sprite.modifier) + render.offset.x,
|
||||
(sprite.position.y - quad.offset.y - sprite.extraOffset.y + cameraOffset.y * sprite.modifier) + render.offset.y,
|
||||
math.rad((sprite.rotation or 0) - (quad.rotated and 90 or 0)),
|
||||
quad.resize.x * (sprite.flipX and -1 or 1), quad.resize.y * (sprite.flipY and -1 or 1),
|
||||
quadx * sprite.anchor.x, quady * sprite.anchor.y
|
||||
(quadx - quad.offset.x) * sprite.anchor.x, (quady - quad.offset.y) * sprite.anchor.y
|
||||
)
|
||||
|
||||
love.graphics.setShader(defaultShader)
|
||||
|
BIN
sprites/menu/login.png
Normal file
BIN
sprites/menu/login.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
14
sprites/menu/login.xml
Normal file
14
sprites/menu/login.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TextureAtlas imagePath="login.png">
|
||||
<!-- Created with Adobe Flash CS6 version 12.0.0.481 -->
|
||||
<!-- http://www.adobe.com/products/flash.html -->
|
||||
<SubTexture name="login idle0000" x="0" y="0" width="251" height="158"/>
|
||||
<SubTexture name="login idle0001" x="251" y="0" width="251" height="158"/>
|
||||
<SubTexture name="login idle0002" x="502" y="0" width="251" height="158"/>
|
||||
<SubTexture name="login idle0003" x="753" y="0" width="251" height="158"/>
|
||||
<SubTexture name="login idle0004" x="0" y="158" width="251" height="158"/>
|
||||
<SubTexture name="login selected0000" x="251" y="158" width="509" height="286"/>
|
||||
<SubTexture name="login selected0001" x="0" y="444" width="509" height="286"/>
|
||||
<SubTexture name="login selected0002" x="509" y="444" width="509" height="286"/>
|
||||
<SubTexture name="login selected0003" x="0" y="730" width="509" height="286"/>
|
||||
</TextureAtlas>
|
@ -13,9 +13,9 @@ local volume = 100
|
||||
local mounted = love.filesystem.mount(gamePath, "") -- Mounting the game directory, should be accessible like if normal.
|
||||
|
||||
require("modules.loveanimate")
|
||||
print("y")
|
||||
require("modules.types")
|
||||
require("modules.math")
|
||||
require("modules.tagged-gamejolt")
|
||||
|
||||
---@class engine.state
|
||||
local StateClass = {}
|
||||
|
@ -40,12 +40,12 @@ return function()
|
||||
for index, credit in next, credits do
|
||||
local color = index == currentOne and {0.5, 0.5, 0.5} or {0,0,0}
|
||||
|
||||
love.graphics.print({color, credit.name}, font, 150, love.graphics.getHeight() / 2 + (index - evilCurrentOne - 0.5) * 200)
|
||||
love.graphics.print({color, credit.name}, font, love.graphics.getWidth() / 2 - font:getWidth(credit.name) / 2, love.graphics.getHeight() / 2 + (index - evilCurrentOne - 0.5) * 200)
|
||||
|
||||
if icons[credit.name] then
|
||||
local icon = icons[credit.name]
|
||||
|
||||
icon.position = Vector2(0, love.graphics.getHeight() / 2 + (index - evilCurrentOne - 0.7) * 200)
|
||||
icon.position = Vector2(love.graphics.getWidth() / 2 - font:getWidth(credit.name) / 2 - 150, love.graphics.getHeight() / 2 + (index - evilCurrentOne - 0.7) * 200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
78
states/loginstate.lua
Normal file
78
states/loginstate.lua
Normal file
@ -0,0 +1,78 @@
|
||||
local files = require "modules.files"
|
||||
local json = require "modules.json"
|
||||
local data = love.filesystem.getSaveDirectory()
|
||||
local font = love.graphics.newFont("fonts/Phantomuff.ttf", 35)
|
||||
|
||||
|
||||
return function ()
|
||||
---@type engine.state
|
||||
local state = {}
|
||||
|
||||
local settings = {}
|
||||
local username = ""
|
||||
local key = ""
|
||||
|
||||
local onkey = false
|
||||
local message
|
||||
|
||||
function state.load()
|
||||
love.window.setTitle("TaggedEngine: GameJolt Login")
|
||||
|
||||
local bg = Image("images/menuBG.png")
|
||||
bg.layer = -5
|
||||
|
||||
local stringsettings = files.read_file(data.."/Settings.json")
|
||||
|
||||
settings = json.parse(stringsettings)
|
||||
end
|
||||
|
||||
function state.draw()
|
||||
render.drawSprites()
|
||||
|
||||
if message then
|
||||
love.graphics.print(message, font, 640 - font:getWidth(message) / 2, 360)
|
||||
else
|
||||
local message = string.format(onkey and "Your GameJolt GameKey: %s" or "Your GameJolt Username: %s", onkey and key or username)
|
||||
love.graphics.print({{0,0,0}, message}, font, 640 - font:getWidth(message) / 2, 360)
|
||||
end
|
||||
end
|
||||
|
||||
function state.keypressed(okey)
|
||||
if okey == "backspace" then
|
||||
if onkey then
|
||||
key = ""
|
||||
else
|
||||
username = ""
|
||||
end
|
||||
elseif okey == "escape" then
|
||||
state.changeState("menustate")
|
||||
elseif okey == "return" then
|
||||
if onkey then
|
||||
local looged = gamejolt.authUser(username, key)
|
||||
gamejolt.openSession()
|
||||
gamejolt.giveTrophy(278482)
|
||||
|
||||
message = looged and "Logged in" or "Failed to log in."
|
||||
|
||||
if looged then
|
||||
settings.user = {}
|
||||
|
||||
settings.user.name = username
|
||||
settings.user.key = key
|
||||
|
||||
files.write_file(data.."/Settings.json", json.stringify(settings))
|
||||
end
|
||||
else
|
||||
onkey = true
|
||||
end
|
||||
else
|
||||
if onkey then
|
||||
key = key..okey
|
||||
else
|
||||
username = username..okey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return state
|
||||
end
|
@ -1,6 +1,7 @@
|
||||
local logging = require "modules.logging"
|
||||
local files = require "modules.files"
|
||||
local json = require "modules.json"
|
||||
local logging = require "modules.logging"
|
||||
local files = require "modules.files"
|
||||
local json = require "modules.json"
|
||||
|
||||
local defaultSettings = { -- The way its in the JSON
|
||||
Downscroll = false,
|
||||
Keybinds = {
|
||||
@ -12,42 +13,53 @@ local defaultSettings = { -- The way its in the JSON
|
||||
Offset = 0
|
||||
}
|
||||
|
||||
local currentOption = 1
|
||||
local currentOption = 1
|
||||
|
||||
MountedMod = 1 -- main
|
||||
local settings = {}
|
||||
|
||||
local modFolders = {
|
||||
"characters",
|
||||
"charts",
|
||||
"fonts",
|
||||
"images",
|
||||
"modules",
|
||||
"playableCharValues",
|
||||
"resultScreens",
|
||||
"songs",
|
||||
"sounds",
|
||||
"sprites",
|
||||
"stages",
|
||||
"states",
|
||||
"videos",
|
||||
"weeks"
|
||||
}
|
||||
local data = love.filesystem.getSaveDirectory()
|
||||
print(data)
|
||||
local settings = files.read_file(data .. "/Settings.json")
|
||||
print(settings)
|
||||
|
||||
if not settings then
|
||||
os.execute("mkdir " .. data)
|
||||
files.write_file(data .. "/Settings.json", json.stringify(defaultSettings))
|
||||
print("Written")
|
||||
else
|
||||
settings = json.parse(settings)
|
||||
--Incase the settings are old
|
||||
for index, setting in next, defaultSettings do
|
||||
if not settings[index] then
|
||||
settings[index] = setting
|
||||
end
|
||||
end
|
||||
files.write_file(data .. "/Settings.json", json.stringify(settings))
|
||||
|
||||
if settings.user then
|
||||
print(logging.dump(settings))
|
||||
gamejolt.authUser(settings.user.name, settings.user.key)
|
||||
gamejolt.giveTrophy(278494)
|
||||
end
|
||||
end
|
||||
|
||||
return function()
|
||||
---@type engine.state
|
||||
local state = {}
|
||||
|
||||
|
||||
local options = {
|
||||
"storymode",
|
||||
"freeplay",
|
||||
"options",
|
||||
"credits",
|
||||
"login"
|
||||
}
|
||||
local optionStates = {
|
||||
storymode = "weekstate",
|
||||
freeplay = "freeplaystate",
|
||||
options = "optionsstate",
|
||||
credits = "creditsstate"
|
||||
credits = "creditsstate",
|
||||
login = "loginstate"
|
||||
}
|
||||
local evilCurrentOption = 1
|
||||
local optionSprites = {}
|
||||
@ -56,26 +68,6 @@ return function()
|
||||
function state.load()
|
||||
love.window.setTitle("TaggedEngine: Main Menu")
|
||||
|
||||
local data = love.filesystem.getSaveDirectory()
|
||||
print(data)
|
||||
local settings = files.read_file(data.."/Settings.json")
|
||||
print(settings)
|
||||
|
||||
if not settings then
|
||||
os.execute("mkdir "..data)
|
||||
files.write_file(data.."/Settings.json", json.stringify(defaultSettings))
|
||||
print("Written")
|
||||
else
|
||||
settings = json.parse(settings)
|
||||
--Incase the settings are old
|
||||
for index, setting in next, defaultSettings do
|
||||
if not settings[index] then
|
||||
settings[index] = setting
|
||||
end
|
||||
end
|
||||
files.write_file(data.."/Settings.json", json.stringify(settings))
|
||||
end
|
||||
|
||||
if not freaky then
|
||||
freaky = love.audio.newSource("sounds/freakyMenu.ogg", "stream")
|
||||
freaky:setVolume(0.25)
|
||||
@ -92,10 +84,12 @@ return function()
|
||||
bg.layer = -10
|
||||
|
||||
for index, option in next, options do
|
||||
optionSprites[option] = {index = index}
|
||||
optionSprites[option].sprite = Sprite(string.format("sprites/menu/%s.png", option), string.format("sprites/menu/%s.xml", option))
|
||||
optionSprites[option] = { index = index }
|
||||
optionSprites[option].sprite = Sprite(string.format("sprites/menu/%s.png", option),
|
||||
string.format("sprites/menu/%s.xml", option))
|
||||
optionSprites[option].sprite:PlayAnimation(string.format("%s idle", option), 24, true)
|
||||
optionSprites[option].sprite.layer = 5
|
||||
optionSprites[option].sprite.anchor = Vector2(0.5, 0.5)
|
||||
if not optionSprites[option].sprite.quads[optionSprites[option].sprite.animation][0] then
|
||||
optionSprites[option].sprite.starterFrame = 1
|
||||
optionSprites[option].sprite.frame = 1
|
||||
@ -111,14 +105,14 @@ return function()
|
||||
elseif key == "down" then
|
||||
currentOption = next(options, currentOption) or 1
|
||||
elseif key == "up" then
|
||||
currentOption = options[currentOption - 1] and currentOption -1 or #options
|
||||
currentOption = options[currentOption - 1] and currentOption - 1 or #options
|
||||
elseif key == "9" then
|
||||
state.changeState("secretcodestate") --since we don't have shucks anymore... why not have a little fun, yeah?
|
||||
end
|
||||
end
|
||||
|
||||
function state.draw()
|
||||
love.graphics.clear({1,1,1})
|
||||
love.graphics.clear({ 1, 1, 1 })
|
||||
render.drawSprites()
|
||||
render.drawUI()
|
||||
end
|
||||
@ -131,7 +125,7 @@ return function()
|
||||
for option, optionSprite in next, optionSprites do
|
||||
local sprite = optionSprite.sprite
|
||||
|
||||
sprite.position = Vector2(0, love.graphics.getHeight() / 5 + (optionSprite.index - evilCurrentOption) * 150)
|
||||
sprite.position = Vector2(640, love.graphics.getHeight() / 2 + (optionSprite.index - evilCurrentOption) * 150)
|
||||
|
||||
if optionSprite.index == currentOption and optionSprite.sprite.animation ~= string.format("%s selected", option) then
|
||||
optionSprites[option].sprite:PlayAnimation(string.format("%s selected", option), 24, true)
|
||||
@ -142,4 +136,4 @@ return function()
|
||||
end
|
||||
|
||||
return state
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user