0 Members and 2 Guests are viewing this topic.
I think he's talking about your own work. I know you've been doing some edits, optimizations, and remakes, but you could try making your own project. As a suggestion, you could try making a Lua sudoku. It'd be easy enough and it'd be pretty nice.
For card games you might learn a lot from chockosta. He made the freecell clone, which is really nice and runs perfect. dragable cards, checking for values and freee places etc.
I redefined some variables, I think is more legible this way:Code: [Select]--[[Things to do:Declare variables first within a functionMake things more fun and complexPoints System:OLD: Atk -{1,2,3} +{4,5} Def +{1,2,3} -{4,5}NEW: Atk -{4,5} +{4,5} Def +{1,2,3} -{1,2,3}Any better ways? Maybe make Atk more risky, so it's less about luck]]--chance = { [-1] = "", [0] = "unsuccessful . -", [1] = "successful . +" }action = { nothing="", attack="Attack", defense="Defense"}function initialize_variables() v = 0 t = 0 r1 = 0 r2 = -1 state = action.nothingend--function on.create()initialize_variables()--endfunction on.paint(gc) gc:setFont("sansserif","r",11) gc:setColorRGB(0,0,0) gc:drawString("[A]tk or [D]ef? [R]eset",10,10,"top") gc:drawString(v,10,30,"top") if state == action.attack then gc:drawString("Attack was " .. chance[r2] .. r1, 10, 50, "top") elseif state == action.defense then gc:drawString("Defense was " .. chance[r2] .. r1, 10, 50, "top") end gc:drawString("Turn " .. t,200,10,"top") if v~=0 or t~=0 then gc:drawString("Average " .. round(v/t,2), 200, 30, "top") end gc:setFont("sansserif","r",8) gc:drawString("Numstrat - Jason Ho",10,200,"top")endfunction on.charIn(ch) if ch=="a" then state = action.attack r1=math.random(4,5) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end t=t+1 end elseif ch=="d" then state = action.defense r1=math.random(1,3) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end state=action.defense t=t+1 end elseif ch=="r" then initialize_variables() end platform.window:invalidate()endfunction round(value, digits) return string.format("%." .. digits .. "f", value)end
--[[Things to do:Declare variables first within a functionMake things more fun and complexPoints System:OLD: Atk -{1,2,3} +{4,5} Def +{1,2,3} -{4,5}NEW: Atk -{4,5} +{4,5} Def +{1,2,3} -{1,2,3}Any better ways? Maybe make Atk more risky, so it's less about luck]]--chance = { [-1] = "", [0] = "unsuccessful . -", [1] = "successful . +" }action = { nothing="", attack="Attack", defense="Defense"}function initialize_variables() v = 0 t = 0 r1 = 0 r2 = -1 state = action.nothingend--function on.create()initialize_variables()--endfunction on.paint(gc) gc:setFont("sansserif","r",11) gc:setColorRGB(0,0,0) gc:drawString("[A]tk or [D]ef? [R]eset",10,10,"top") gc:drawString(v,10,30,"top") if state == action.attack then gc:drawString("Attack was " .. chance[r2] .. r1, 10, 50, "top") elseif state == action.defense then gc:drawString("Defense was " .. chance[r2] .. r1, 10, 50, "top") end gc:drawString("Turn " .. t,200,10,"top") if v~=0 or t~=0 then gc:drawString("Average " .. round(v/t,2), 200, 30, "top") end gc:setFont("sansserif","r",8) gc:drawString("Numstrat - Jason Ho",10,200,"top")endfunction on.charIn(ch) if ch=="a" then state = action.attack r1=math.random(4,5) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end t=t+1 end elseif ch=="d" then state = action.defense r1=math.random(1,3) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end state=action.defense t=t+1 end elseif ch=="r" then initialize_variables() end platform.window:invalidate()endfunction round(value, digits) return string.format("%." .. digits .. "f", value)end
--[[Things to do:Declare variables first within a functionMake things more fun and complexPoints System:OLD: Atk -{1,2,3} +{4,5} Def +{1,2,3} -{4,5}NEW: Atk -{4,5} +{4,5} Def +{1,2,3} -{1,2,3}Any better ways? Maybe make Atk more risky, so it's less about luck]]---- Call this function whenever you want to set the variables to their original valuesfunction initialize_variables() v = 0 t = 0 r1 = 0 r2 = -1 state = ""end--function on.create()initialize_variables()--endfunction on.paint(gc) gc:setFont("sansserif","r",11) gc:setColorRGB(0,0,0) gc:drawString("[A]tk or [D]ef? [R]eset",10,10,"top") gc:drawString(v,10,30,"top") if state == "attack" then if r2 == 1 then gc:drawString("Attack was successful . + " .. r1, 10, 50, "top") else --if r2 == 0 then gc:drawString("Attack was unsuccessful . -" .. r1, 10, 50, "top") end elseif state == "defense" then if r2 == 1 then gc:drawString("Defense was successful . + " .. r1, 10, 50, "top") else --if r2 == 0 then gc:drawString("Defense was unsuccessful . -" .. r1, 10, 50, "top") end end gc:drawString("Turn " .. t,200,10,"top") if v~=0 or t~=0 then gc:drawString("Average " .. round(v/t,2), 200, 30, "top") end gc:setFont("sansserif","r",8) gc:drawString("Numstrat - Jason Ho",10,200,"top")endfunction on.charIn(ch) if ch=="a" then state = "attack" r1=math.random(4,5) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end t=t+1 elseif ch=="d" then state = "defense" r1=math.random(1,3) r2=math.random(0,1) if r2==1 then v=v+r1 else --if r2==0 then v=v-r1 end t=t+1 elseif ch=="r" then initialize_variables() end platform.window:invalidate()end--This function rounds the value passed depending on the number of digits neededfunction round(value, digits) return string.format("%." .. digits .. "f", value)end
if state == "attack" then if r2 == 1 then gc:drawString("Attack was successful . + " .. r1, 10, 50, "top") else --if r2 == 0 then gc:drawString("Attack was unsuccessful . -" .. r1, 10, 50, "top") end elseif state == "defense" then if r2 == 1 then gc:drawString("Defense was successful . + " .. r1, 10, 50, "top") else --if r2 == 0 then gc:drawString("Defense was unsuccessful . -" .. r1, 10, 50, "top") end end
if state ~= "" then gc:drawString((state=="attack" and "Attack" or "Defense") .. " was " .. (r2==0 and "unsuccessful. -" or "successful. +") .. r1, 10, 50, "top")end
------ Screen Manager --------- In this table we will contain all 'screen' objects.Screens = {}-- This function is used to push a screen into the above table (Screens) function pushScreen(scrn) table.insert(Screens, scrn) platform.window:invalidate()end-- This function is used to remove the last item in the 'Screens' tablefunction pullScreen() table.remove(Screens) platform.window:invalidate()end-- Return the last item of 'Screens', the current screenfunction currentScreen() return Screens[#Screens]end-- This function will loop through all screens in the 'Screens' table and draw themfunction paintScreens(gc) for _, screen in ipairs(Screens) do screen:paint(gc) endend-- Our screen object classScreen = class()function Screen:arrowKey() endfunction Screen:paint() endfunction Screen:charIn() endfunction Screen:enterKey() end-- Link the Screen manager to 'on'function on.paint(gc) paintScreens(gc) endfunction on.arrowKey(arrow) currentScreen():arrowKey(arrow) endfunction on.charIn(ch) currentScreen():charIn(ch) endfunction on.enterKey() currentScreen():enterKey() end--- User code ----popup = Screen()function popup:paint(gc) gc:setColorRGB(255,255,255) gc:fillRect(50,50,200,100) gc:setColorRGB(0,0,0) gc:drawRect(50,50,200,100) gc:drawString("Hey!", 52, 50, "top") gc:drawString("Press enter to hide this popup", 52, 80, "top")endfunction popup:enterKey() pullScreen()endmain = Screen()function main:paint(gc) gc:drawString("Hello World! Press enter :D", 10, 10, "top")endfunction main:enterKey() pushScreen(popup)endpushScreen(main)