bomber imp
This commit is contained in:
@@ -20,7 +20,7 @@ function pdDialogue.wrap(lines, width, font)
|
||||
lines: an array of strings
|
||||
width: the maximum width of each line (in pixels)
|
||||
font: the font to use (optional, uses default font if not provided)
|
||||
]] --
|
||||
]]--
|
||||
font = font or gfx.getFont()
|
||||
|
||||
local result = {}
|
||||
@@ -62,10 +62,10 @@ function pdDialogue.window(text, startIndex, height, font)
|
||||
startIndex: the row index to start the window
|
||||
height: the height (in pixels) of the window
|
||||
font: the font to use (optional, uses default font if not provided)
|
||||
]] --
|
||||
]]--
|
||||
font = font or gfx.getFont()
|
||||
|
||||
local result = { text[start_index] }
|
||||
local result = {text[start_index]}
|
||||
local rows = pdDialogue.getRows(height, font) - 1
|
||||
|
||||
for index = 1, rows do
|
||||
@@ -85,7 +85,7 @@ function pdDialogue.paginate(lines, height, font)
|
||||
lines: array of strings (pre-wrapped)
|
||||
height: height to limit text (in pixels)
|
||||
font: optional, will get current font if not provided
|
||||
]] --
|
||||
]]--
|
||||
|
||||
local result = {}
|
||||
local currentLine = {}
|
||||
@@ -129,7 +129,7 @@ function pdDialogue.process(text, width, height, font)
|
||||
width: width to limit text (in pixels)
|
||||
height: height to limit text (in pixels)
|
||||
font: optional, will get current font if not provided
|
||||
]] --
|
||||
]]--
|
||||
local lines = {}
|
||||
font = font or gfx.getFont()
|
||||
|
||||
@@ -168,10 +168,10 @@ class("pdDialogueSprite").extends(gfx.sprite)
|
||||
function pdDialogueSprite:init(dialogue)
|
||||
--[[
|
||||
dialogue: an instance of pdDialogueBox
|
||||
]] --
|
||||
]]--
|
||||
pdDialogueSprite.super.init(self)
|
||||
self.image = gfx.image.new(dialogue.width, dialogue.height)
|
||||
self:setImage(self.image)
|
||||
self.image = gfx.image.new(dialogue.width, dialogue.height)
|
||||
self:setImage(self.image)
|
||||
self.dialogue = dialogue
|
||||
-- Remove sprite when dialogue is closed
|
||||
local onClose = self.dialogue.onClose
|
||||
@@ -182,22 +182,22 @@ function pdDialogueSprite:init(dialogue)
|
||||
end
|
||||
|
||||
function pdDialogueSprite:add()
|
||||
pdDialogueSprite.super.add(self)
|
||||
if not self.dialogue.enabled then
|
||||
self.dialogue:enable()
|
||||
end
|
||||
pdDialogueSprite.super.add(self)
|
||||
if not self.dialogue.enabled then
|
||||
self.dialogue:enable()
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogueSprite:update()
|
||||
pdDialogueSprite.super.update(self)
|
||||
-- Redraw dialogue if it has changed (update returns true)
|
||||
if self.dialogue:update() then
|
||||
self.image:clear(gfx.kColorClear)
|
||||
gfx.pushContext(self.image)
|
||||
self.dialogue:draw(0, 0)
|
||||
gfx.popContext()
|
||||
self:markDirty()
|
||||
end
|
||||
if self.dialogue:update() then
|
||||
self.image:clear(gfx.kColorClear)
|
||||
gfx.pushContext(self.image)
|
||||
self.dialogue:draw(0, 0)
|
||||
gfx.popContext()
|
||||
self:markDirty()
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
@@ -206,11 +206,9 @@ end
|
||||
pdDialogueBox = {}
|
||||
class("pdDialogueBox").extends()
|
||||
|
||||
local ABTN = Graphics.image.new("assets/sprites/buttons/A")
|
||||
|
||||
function pdDialogueBox.buttonPrompt(x, y)
|
||||
gfx.setImageDrawMode(gfx.kDrawModeCopy)
|
||||
ABTN:draw(x, y)
|
||||
gfx.getSystemFont():drawText("Ⓐ", x, y)
|
||||
end
|
||||
|
||||
function pdDialogueBox.arrowPrompt(x, y, color)
|
||||
@@ -228,7 +226,7 @@ function pdDialogueBox:init(text, width, height, font)
|
||||
width: width of dialogue box (in pixels)
|
||||
height: height of dialogue box (in pixels)
|
||||
font: font to use for drawing text
|
||||
]] --
|
||||
]]--
|
||||
|
||||
pdDialogueBox.super.init(self)
|
||||
self.speed = 0.5 -- char per frame
|
||||
@@ -250,17 +248,19 @@ function pdDialogueBox:asSprite()
|
||||
end
|
||||
|
||||
function pdDialogueBox:getInputHandlers()
|
||||
local _speed = self:getSpeed()
|
||||
return {
|
||||
AButtonDown = function()
|
||||
self:setSpeed(2)
|
||||
if self.dialogue_complete then
|
||||
self:disable()
|
||||
elseif self.line_complete then
|
||||
self:nextPage()
|
||||
else
|
||||
self:setSpeed(_speed * 2)
|
||||
end
|
||||
end,
|
||||
AButtonUp = function()
|
||||
self:setSpeed(0.5)
|
||||
self:setSpeed(_speed)
|
||||
end,
|
||||
BButtonDown = function()
|
||||
if self.line_complete then
|
||||
@@ -406,6 +406,7 @@ function pdDialogueBox:nextPage()
|
||||
if self.currentPage + 1 <= #self.pages then
|
||||
self.currentPage += 1
|
||||
self:restartLine()
|
||||
self:onNextPage()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -461,6 +462,10 @@ function pdDialogueBox:onPageComplete()
|
||||
-- Overrideable by user
|
||||
end
|
||||
|
||||
function pdDialogueBox:onNextPage()
|
||||
-- Overrideable by user
|
||||
end
|
||||
|
||||
function pdDialogueBox:onDialogueComplete()
|
||||
-- Overrideable by user
|
||||
end
|
||||
@@ -522,7 +527,7 @@ function pdPortraitDialogueBox:init(name, drawable, text, width, height, font)
|
||||
end
|
||||
end
|
||||
pdDialogueBox.init(self, text, width - self.portrait_width, height, font)
|
||||
self:setAlignment(kTextAlignment.left)
|
||||
self:setAlignment(kTextAlignment.left)
|
||||
end
|
||||
|
||||
function pdPortraitDialogueBox:setAlignment(alignment)
|
||||
@@ -539,7 +544,7 @@ function pdPortraitDialogueBox:getAlignment()
|
||||
end
|
||||
|
||||
function pdPortraitDialogueBox:draw(x, y)
|
||||
local offset = self.alignment == kTextAlignment.left and self.portrait_width or 0
|
||||
local offset = self.alignment == kTextAlignment.left and self.portrait_width or 0
|
||||
pdPortraitDialogueBox.super.draw(self, x + offset, y)
|
||||
end
|
||||
|
||||
@@ -571,120 +576,123 @@ end
|
||||
----------------------------------------------------------------------------
|
||||
-- #Section: dialogue box used in pdDialogue
|
||||
----------------------------------------------------------------------------
|
||||
pdDialogue.DialogueBox_x, pdDialogue.DialogueBox_y = 5, 186
|
||||
pdDialogue.DialogueBox_x, pdDialogue.DialogueBox_y = 5, 186
|
||||
pdDialogue.DialogueBox = pdDialogueBox(nil, 390, 48)
|
||||
pdDialogue.DialogueBox_Callbacks = {}
|
||||
pdDialogue.DialogueBox_Say_Default = nil
|
||||
pdDialogue.DialogueBox_Say_Nils = nil
|
||||
pdDialogue.DialogueBox_KeyValueMap = {
|
||||
width = {
|
||||
set = function(value) pdDialogue.DialogueBox:setWidth(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getWidth() end
|
||||
width={
|
||||
set=function(value) pdDialogue.DialogueBox:setWidth(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getWidth() end
|
||||
},
|
||||
height = {
|
||||
set = function(value) pdDialogue.DialogueBox:setHeight(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getHeight() end
|
||||
height={
|
||||
set=function(value) pdDialogue.DialogueBox:setHeight(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getHeight() end
|
||||
},
|
||||
x = {
|
||||
set = function(value) pdDialogue.DialogueBox_x = value end,
|
||||
get = function() return pdDialogue.DialogueBox_x end
|
||||
x={
|
||||
set=function(value) pdDialogue.DialogueBox_x = value end,
|
||||
get=function() return pdDialogue.DialogueBox_x end
|
||||
},
|
||||
y = {
|
||||
set = function(value) pdDialogue.DialogueBox_y = value end,
|
||||
get = function() return pdDialogue.DialogueBox_y end
|
||||
y={
|
||||
set=function(value) pdDialogue.DialogueBox_y = value end,
|
||||
get=function() return pdDialogue.DialogueBox_y end
|
||||
},
|
||||
padding = {
|
||||
set = function(value) pdDialogue.DialogueBox:setPadding(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getPadding() end
|
||||
padding={
|
||||
set=function(value) pdDialogue.DialogueBox:setPadding(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getPadding() end
|
||||
},
|
||||
font = {
|
||||
set = function(value) pdDialogue.DialogueBox:setFont(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getFont() end
|
||||
font={
|
||||
set=function(value) pdDialogue.DialogueBox:setFont(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getFont() end
|
||||
},
|
||||
fontFamily = {
|
||||
set = function(value) pdDialogue.DialogueBox.fontFamily = value end,
|
||||
get = function() return pdDialogue.DialogueBox.fontFamily end
|
||||
fontFamily={
|
||||
set=function(value) pdDialogue.DialogueBox.fontFamily = value end,
|
||||
get=function() return pdDialogue.DialogueBox.fontFamily end
|
||||
},
|
||||
nineSlice = {
|
||||
set = function(value) pdDialogue.DialogueBox:setNineSlice(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getNineSlice() end
|
||||
nineSlice={
|
||||
set=function(value) pdDialogue.DialogueBox:setNineSlice(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getNineSlice() end
|
||||
},
|
||||
speed = {
|
||||
set = function(value) pdDialogue.DialogueBox:setSpeed(value) end,
|
||||
get = function() return pdDialogue.DialogueBox:getSpeed() end
|
||||
speed={
|
||||
set=function(value) pdDialogue.DialogueBox:setSpeed(value) end,
|
||||
get=function() return pdDialogue.DialogueBox:getSpeed() end
|
||||
},
|
||||
drawBackground = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawBackground"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawBackground"] end
|
||||
drawBackground={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["drawBackground"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["drawBackground"] end
|
||||
},
|
||||
drawText = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawText"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawText"] end
|
||||
drawText={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["drawText"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["drawText"] end
|
||||
},
|
||||
drawPrompt = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawPrompt"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawPrompt"] end
|
||||
drawPrompt={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["drawPrompt"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["drawPrompt"] end
|
||||
},
|
||||
onOpen = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onOpen"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["onOpen"] end
|
||||
onOpen={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["onOpen"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["onOpen"] end
|
||||
},
|
||||
onPageComplete = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onPageComplete"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["onPageComplete"] end
|
||||
onPageComplete={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["onPageComplete"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["onPageComplete"] end
|
||||
},
|
||||
onDialogueComplete = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] end
|
||||
onNextPage={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["onNextPage"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["onNextPage"] end
|
||||
},
|
||||
onClose = {
|
||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onClose"] = func end,
|
||||
get = function() return pdDialogue.DialogueBox_Callbacks["onClose"] end
|
||||
onDialogueComplete={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] end
|
||||
},
|
||||
onClose={
|
||||
set=function(func) pdDialogue.DialogueBox_Callbacks["onClose"] = func end,
|
||||
get=function() return pdDialogue.DialogueBox_Callbacks["onClose"] end
|
||||
}
|
||||
}
|
||||
function pdDialogue.DialogueBox:drawBackground(x, y)
|
||||
if pdDialogue.DialogueBox_Callbacks["drawBackground"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["drawBackground"](dialogue, x, y)
|
||||
pdDialogue.DialogueBox_Callbacks["drawBackground"](self, x, y)
|
||||
else
|
||||
pdDialogue.DialogueBox.super.drawBackground(self, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:drawText(x, y, text)
|
||||
function pdDialogue.DialogueBox:drawText(x, y ,text)
|
||||
if pdDialogue.DialogueBox_Callbacks["drawText"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["drawText"](dialogue, x, y, text)
|
||||
pdDialogue.DialogueBox_Callbacks["drawText"](self, x, y, text)
|
||||
else
|
||||
pdDialogue.DialogueBox.super.drawText(self, x, y, text)
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:drawPrompt(x, y)
|
||||
if pdDialogue.DialogueBox_Callbacks["drawPrompt"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["drawPrompt"](dialogue, x, y)
|
||||
pdDialogue.DialogueBox_Callbacks["drawPrompt"](self, x, y)
|
||||
else
|
||||
pdDialogue.DialogueBox.super.drawPrompt(self, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:onOpen()
|
||||
pd.inputHandlers.push(self:getInputHandlers(), true)
|
||||
if pdDialogue.DialogueBox_Callbacks["onOpen"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["onOpen"]()
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:onPageComplete()
|
||||
if pdDialogue.DialogueBox_Callbacks["onPageComplete"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["onPageComplete"]()
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:onNextPage()
|
||||
if pdDialogue.DialogueBox_Callbacks["onNextPage"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["onNextPage"]()
|
||||
end
|
||||
end
|
||||
function pdDialogue.DialogueBox:onDialogueComplete()
|
||||
if pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] ~= nil then
|
||||
pdDialogue.DialogueBox_Callbacks["onDialogueComplete"]()
|
||||
end
|
||||
end
|
||||
|
||||
function pdDialogue.DialogueBox:onClose()
|
||||
-- Make a backup of the current onClose callback
|
||||
local current = pdDialogue.DialogueBox_Callbacks["onClose"]
|
||||
@@ -738,7 +746,7 @@ function pdDialogue.say(text, config)
|
||||
--[[
|
||||
text: string (can be multiline) to say
|
||||
config: optional table, will provide temporary overrides for this one dialogue box
|
||||
]] --
|
||||
]]--
|
||||
if config ~= nil then
|
||||
pdDialogue.DialogueBox_Say_Default, pdDialogue.DialogueBox_Say_Nils = pdDialogue.setup(config)
|
||||
end
|
||||
@@ -752,4 +760,4 @@ function pdDialogue.update()
|
||||
pdDialogue.DialogueBox:update()
|
||||
pdDialogue.DialogueBox:draw(pdDialogue.DialogueBox_x, pdDialogue.DialogueBox_y)
|
||||
end
|
||||
end
|
||||
end
|
@@ -569,7 +569,7 @@ function ParticlePixel:update()
|
||||
for part = 1, #self.particles, 1 do
|
||||
local pix = self.particles[part]
|
||||
|
||||
playdate.graphics.drawPixel(pix.x,pix.y,pix.size)
|
||||
playdate.graphics.drawPixel(pix.x,pix.y)
|
||||
|
||||
pix.x += math.sin(math.rad(pix.dir)) * pix.speed
|
||||
pix.y -= math.cos(math.rad(pix.dir)) * pix.speed
|
||||
|
Reference in New Issue
Block a user