Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# Flashcards
- -- This is where you edit your flashcards...
- -- If enough people actually want me to, I will add that you can edit them from inside the app
- -- I will also make it so it is more interesting to learn (like other flashcard apps)
- -- Adding or Removing from this list should still keep it working, if it doesn't let me know
- -- Make sure you have the same amount of questions and answers! (there will be an error otherwise)
- -- Thanks for trying this out! It is my first completed app!
- Questions={ "Q1",
- "Q2",
- "Q3",
- "Q4",
- "Q5",
- "Q6",
- "Q7",
- "Q8",
- "Q9",
- "Q10"}
- Answers={ "A1",
- "A2",
- "A3",
- "A4",
- "A5",
- "A6",
- "A7",
- "A8",
- "A9",
- "A10"}
- --# Main
- function setup()
- --Check Q/A for errors
- print("Checking Cards...")
- if #Questions ~= #Answers then
- error("There are not the same amount of questions and answers. Please review.")
- else
- end
- print("Check Complete!")
- --Load Theme
- loadTheme()
- --Download Icon
- if readImage("Project:Icon") == nil then
- http.request("https://www.dropbox.com/s/b5rsxdikj9o7xc5/flashcardsicon.png?dl=1",
- function(image)
- saveImage("Project:Icon",image)
- end)
- end
- --Flashcard Stuff
- flashcard = {}
- flashcard.no=1
- flashcard.side=false
- flashcard.shuffle=false
- flashcard.shufftext="Off"
- flashcard.default=false
- flashcard.deftext="Q"
- --Display
- displayMode(FULLSCREEN_NO_BUTTONS)
- showCard = true
- end
- function draw()
- Time=os.date("%H"..":".."%M")
- -------------------------------------------------------------------------------------------------------------
- ---------------------------------------------- Normal Screen ------------------------------------------------
- -------------------------------------------------------------------------------------------------------------
- if showCard then
- --Stuff
- fontSize(20)
- font("ArialRoundedMTBold")
- textAlign(CENTER)
- textWrapWidth(475)
- --Background
- background(255)
- sprite("Cargo Bot:Background Fade",512,384,1024,768)
- fill(theme.back)
- noStroke()
- rect(-1,-1,1030,790)
- --Flashcard Color
- fill(255)
- stroke(0)
- strokeWidth(2)
- rect(212,200,612,500)
- --Buttons
- fill(theme.button.fill)
- stroke(theme.button.stroke)
- if flashcard.shuffle==false then
- rect(262,125,100,50)
- rect(674,125,100,50)
- else
- rect(412,125,200,50)
- end
- rect(242,50,140,50)
- rect(654,50,140,50)
- rect(0,718,101,50)
- --Button Text
- fill(theme.text)
- if flashcard.shuffle==false then
- text("Previous",312,150)
- text("Next",724,150)
- text("Card "..flashcard.no.." out of "..#Questions,512,150)
- else
- text("Next Card",512,150)
- end
- text("Options",50,743)
- text("Shuffle: "..flashcard.shufftext,312,75)
- text("Default: "..flashcard.deftext,724,75)
- textWrapWidth(500)
- text("Tap the card to flip!",512,730)
- --Take a Guess
- text(Time,990,750)
- --Exit Button
- fill(theme.exit.fill)
- stroke(theme.exit.stroke)
- rect(462,50,100,50)
- fill(theme.exit.text)
- text("Exit",512,75)
- --Extra Flashcard Studd
- if flashcard.no > #Questions then
- flashcard.no=1
- elseif flashcard.no == 0 then
- flashcard.no=#Questions
- end
- --Flashcard Text
- fontSize(14)
- fill(209, 209, 209, 255)
- if flashcard.side==false then
- text("Question",512,675)
- else
- text("Answer",512,675)
- end
- fill(0, 0, 0, 255)
- fontSize(30)
- if flashcard.side==false then
- text((Questions[flashcard.no]),512,450)
- else
- text((Answers[flashcard.no]),512,450)
- end
- --Shuffle Cards
- if flashcard.shuffle==false then
- flashcard.shufftext="Off"
- else
- flashcard.shufftext="On"
- end
- --Default Side
- if flashcard.default==true then
- flashcard.deftext="A"
- else
- flashcard.deftext="Q"
- end
- else
- -------------------------------------------------------------------------------------------------------------
- ---------------------------------------------- Option Screen ------------------------------------------------
- -------------------------------------------------------------------------------------------------------------
- --Background
- background(255)
- sprite("Cargo Bot:Background Fade",512,384,1024,768)
- fill(theme.back)
- noStroke()
- rect(-1,-1,1030,790)
- --Themes
- fill(0)
- rect(-1,550,1026,50)
- fill(255, 0, 0, 255)
- rect(242,555,40)
- fill(255, 118, 0, 255)
- rect(342,555,40)
- fill(255, 228, 0, 255)
- rect(442,555,40)
- fill(49, 255, 0, 255)
- rect(542,555,40)
- fill(0, 93, 255, 255)
- rect(642,555,40)
- fill(209, 0, 255, 255)
- rect(742,555,40)
- --Text
- fill(255)
- fontSize(30)
- text("Options",512,725)
- fontSize(25)
- text("Theme",512,625)
- fontSize(20)
- text("Current Theme: "..theme.name,512,525)
- --Yet Again
- text(Time,990,750)
- --Return Button
- fill(theme.button.fill)
- stroke(theme.button.stroke)
- strokeWidth(2)
- rect(0,718,101,50)
- fill(theme.text)
- text("Return",50,743)
- --About
- fill(255)
- fontSize(25)
- text("About",512,475)
- fontSize(20)
- text("Created by Jonathon Gaczol\nThis is just a simple flashcards app for your simple flashcards. It was originally created for preparing for my German Oral exam but I decided to continue to work on it.\n\nPlease Note:\nI know the themes aren't the greatest so please PM if you have any better ideas, or just anything that I should incorporate into this. Thanks :)",512,340)
- --Version
- fontSize(25)
- text("Version",512,175)
- fontSize(20)
- text("1.0",512,150)
- end
- end
- function touched(touch)
- if touch.state==ENDED then
- --Normal Screen
- if showCard then
- if touch.x > 462 and touch.x < 562 and
- touch.y > 50 and touch.y < 100 then
- exit()
- elseif touch.x > 212 and touch.x < 824 and
- touch.y > 200 and touch.y < 700 then
- flashcard.side = not flashcard.side
- elseif touch.x > 262 and touch.x < 362 and
- touch.y > 125 and touch.y < 175 and flashcard.shuffle==false then
- flashcard.no=flashcard.no-1
- Defaultcard()
- elseif touch.x > 674 and touch.x < 774 and
- touch.y > 125 and touch.y < 175 and flashcard.shuffle==false then
- flashcard.no=flashcard.no+1
- Defaultcard()
- elseif touch.x > 242 and touch.x < 382 and
- touch.y > 50 and touch.y < 100 then
- flashcard.shuffle = not flashcard.shuffle
- randomcard()
- Defaultcard()
- elseif touch.x > 412 and touch.x < 612 and
- touch.y > 125 and touch.y < 175 and flashcard.shuffle==true then
- randomcard()
- Defaultcard()
- elseif touch.x > 654 and touch.x < 794 and
- touch.y > 50 and touch.y < 100 then
- flashcard.default = not flashcard.default
- elseif touch.x > 0 and touch.x < 100 and
- touch.y > 718 then
- showCard=false
- end
- --Option Screen
- elseif not showCard then
- if touch.x > 242 and touch.x < 282 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Red")
- loadTheme()
- elseif touch.x > 342 and touch.x < 382 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Orange")
- loadTheme()
- elseif touch.x > 442 and touch.x < 482 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Yellow")
- loadTheme()
- elseif touch.x > 542 and touch.x < 582 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Green")
- loadTheme()
- elseif touch.x > 642 and touch.x < 682 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Blue")
- loadTheme()
- elseif touch.x > 742 and touch.x < 782 and
- touch.y > 555 and touch.y < 595 then
- saveLocalData("theme.name","Magenta")
- loadTheme()
- elseif touch.x > 0 and touch.x < 100 and
- touch.y > 718 then
- showCard=true
- end
- end
- end
- end
- --Pick a Random Card
- function randomcard()
- if flashcard.shuffle==true then
- flashcard.no=math.random(1,#Questions)
- else
- end
- end
- --Default Flashcard Side
- function Defaultcard()
- if flashcard.default==false then
- flashcard.side=false
- else
- flashcard.side = true
- end
- end
- --Obvious I Hope
- function exit()
- saveLocalData("theme.name",theme.name)
- close()
- end
- --# Themes
- function loadTheme()
- theme = {}
- theme.name = readLocalData("theme.name","Blue")
- if theme.name == "Blue" then
- --Background
- theme.back = color(0, 246, 255, 135)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(89, 82, 232, 255)
- theme.exit.stroke = color(30,25,159,255)
- theme.exit.text = color(25, 28, 155, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(0, 137, 255, 226)
- theme.button.stroke = color(0,85,255,355)
- --Misc
- theme.text = color(10, 0, 255, 255)
- elseif theme.name == "Red" then
- --Background
- theme.back = color(255, 0, 0, 81)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(255, 9, 0, 116)
- theme.exit.stroke = color(206, 16, 14, 255)
- theme.exit.text = color(255, 13, 0, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(255, 6, 0, 113)
- theme.button.stroke = color(255, 20, 0, 255)
- --Misc
- theme.text = color(255, 0, 5, 255)
- elseif theme.name == "Orange" then
- --Background
- theme.back = color(255, 117, 0, 135)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(206, 106, 14, 154)
- theme.exit.stroke = color(255, 106, 0, 255)
- theme.exit.text = color(255, 118, 0, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(209, 107, 13, 226)
- theme.button.stroke = color(255, 134, 0, 255)
- --Misc
- theme.text = color(255, 168, 0, 255)
- elseif theme.name == "Yellow" then
- --Background
- theme.back = color(255, 249, 0, 135)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(185, 173, 19, 255)
- theme.exit.stroke = color(255, 253, 0, 255)
- theme.exit.text = color(255, 235, 0, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(203, 197, 15, 255)
- theme.button.stroke = color(255, 248, 0, 255)
- --Misc
- theme.text = color(239, 255, 0, 255)
- elseif theme.name == "Green" then
- --Background
- theme.back = color(60, 255, 0, 135)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(60, 185, 18, 255)
- theme.exit.stroke = color(35, 255, 0, 255)
- theme.exit.text = color(49, 255, 0, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(45, 203, 14, 255)
- theme.button.stroke = color(36, 255, 0, 255)
- --Misc
- theme.text = color(54, 255, 0, 255)
- elseif theme.name == "Magenta" then
- --Background
- theme.back = color(183, 0, 255, 135)
- --Exit Button
- theme.exit = {}
- theme.exit.fill = color(197, 0, 255, 132)
- theme.exit.stroke = color(255, 0, 250, 255)
- theme.exit.text = color(229, 0, 255, 255)
- --Other Buttons
- theme.button = {}
- theme.button.fill = color(171, 13, 203, 255)
- theme.button.stroke = color(255, 0, 238, 255)
- --Misc
- theme.text = color(255, 0, 252, 255)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement