Created
November 5, 2023 10:44
-
-
Save Achie72/9287b4537a261b300c1fbf3dcbb082ad to your computer and use it in GitHub Desktop.
Lina: Suika Hunt - Coloring Combo Strings in PICO-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- color table to define which direction should have | |
-- which color during the printing | |
local colorTable = { | |
⬅️ = 9, | |
⬇️ = 10, | |
⬆️ = 11, | |
➡️ = 12 | |
} | |
-- iterate through all elemenets in the fruitCollection | |
-- and put them into fruit one by one | |
for fruit in all(fruitCollection) do | |
-- draw the fruit on the screen | |
spr(fruit.type, fruit.x, fruit.y) | |
-- debug draw the type | |
print(fruit.type, fruit.x+8, fruit.y, 8) | |
-- under each fruit we want to list | |
-- the buttons needed for their combo | |
for i=1,#fruit.comboString do | |
-- we grab the combo string letter by letter with this | |
-- for cycle and the comboString[i] | |
-- then we find the needed spot for it on the screen in the x axis | |
-- this is a bit ugly, but we offset from the start to be in the middle in the end, | |
-- then we just add an offset for each letter by their needed space with ((i-1)*6) | |
-- after that we grab the needed color from the table, by using the direction | |
-- as an index | |
print(fruit.comboString[i], fruit.x-#fruit.comboString*4+4+((i-1)*6), fruit.y+8, colorTable[fruit.comboString[i]]) | |
end | |
-- this is the old plain print | |
-- print(fruit.comboString, fruit.x-#fruit.comboString*4+4, fruit.y+8, 7) | |
end | |
-- combo string text on the screen | |
local comboText = "Current Combo:" | |
print(comboText, 2, 110, 12) | |
-- doing the color play for the player combo string as well | |
for i=1,#playerComboString do | |
print(playerComboString[i], 2+#comboText*4 + ((i-1)*6), 110, colorTable[playerComboString[i]]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment