Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- azul = 0xFFFF0000
- verde = 0xFF00FF00
- rojo = 0xFF0000FF
- blanco = 0xFFFFFFFF
- cian = 0xFFFFFF00
- magenta = 0xFF00FFFF
- amarillo = 0xFF00FFFF
- negro = 0xFF000000
- gris = 0xFF808080
- rosa = 0xFF8080FF
- violeta = 0xFF800080
- celeste = 0xFF80FFFF
- marron = 0xFF800000
- naranja = 0xFFFF8000
- lavanda = 0xFF8000FF
- turquesa = 0xFF00FF80
- oro = 0xFFBBBB20
- dofile("teclado.lua")
- xesigual= image.load("imagenes/xesigual.png")
- elevadoa2= image.load("imagenes/elevadoa2.png")
- raizmasmenos= image.load("imagenes/raizmasmenos.png")
- eqvacia= image.load("imagenes/eqvacia.png")
- fondo= image.load("imagenes/fondo.png")
- xeq=50
- yeq=125
- a= 4
- b= 3
- c= 9
- --[[° se hace con Alt+248
- ¹ se hace con Alt+251
- ² se hace con Alt+253
- ³ se hace con Alt+252
- ± se hace con alt+0177
- v se hace con Alt+8730]]
- resultado1=nil
- resultado2=nil
- squared=nil
- function isinteger(number)
- if number > 0 then
- if number - math.floor(number) == 0 then
- return true
- else return false
- end
- end
- if number < 0 then
- if number + math.abs(math.floor(number)) == 0 then
- return true
- else return false
- end
- end
- if number == 0 then
- return true
- end
- end
- while true do
- controls.read()
- fondo:blit(0,0)
- squared = ((b^2)-(4*a*c))
- if squared >=0 then
- resultado1 = (-(b) + math.sqrt(squared))/(2*a)
- resultado2 = (-(b) - math.sqrt(squared))/(2*a)
- if isinteger(math.sqrt(squared)) then
- if not isinteger(resultado1) then
- resultado1= (-(b) + math.sqrt(squared)).."/"..(2*a)
- end
- if not isinteger(resultado2) then
- resultado2= (-(b) - math.sqrt(squared)).."/"..(2*a)
- end
- end
- if not isinteger(math.sqrt(squared)) then
- resultado1 = "("..-(b).."+v"..squared..")".."/"..(2*a).." = "..((-(b) + math.sqrt(squared))/(2*a))
- resultado2 = "("..-(b).."-v"..squared..")".."/"..(2*a).." = "..((-(b) - math.sqrt(squared))/(2*a))
- end
- if resultado1 != resultado2 then
- screen.print(5,5,"Resultado 1: "..resultado1,0.9,0xFFFF0000,0x0)
- screen.print(5,25,"Resultado 2: "..resultado2,0.9,rojo,0x0)
- screen.print(5,45,"Radicando = "..squared,0.9,amarillo,0x0)
- screen.print(5,65,a.."x²+"..b.."x+"..c.."=0",0.9,verde,0x0)
- elseif resultado1 == resultado2 then
- screen.print(5,20,"Solo tiene una solución: "..resultado1,0.9,0xFFFF0000,0x0)
- screen.print(5,45,"Radicando = "..squared,0.9,amarillo,0x0)
- screen.print(5,65,a.."x²+"..b.."x+"..c.."=0",0.9,verde,0x0)
- end
- end
- if squared <0 then
- screen.print(5,25,"No tiene solución real",0.9,rojo,0x0)
- screen.print(5,45,"Radicando = "..squared,0.9,amarillo,0x0)
- end
- --screen.textwidth("",0.9)
- xesigual:blit(xeq,yeq)
- draw.line(xeq+xesigual:width(),yeq+xesigual:height()/2,xeq+50+raizmasmenos:width()+screen.textwidth("-("..b..") "..b.."-4*"..a.."*"..c.." ",0.9),yeq+xesigual:height()/2,negro)
- raizmasmenos:blit(xeq+50+screen.textwidth("-("..b.." ",0.9),yeq-30)
- draw.line(xeq+50+raizmasmenos:width()+screen.textwidth("-("..b.." ",0.9),yeq-30,xeq+50+raizmasmenos:width()+screen.textwidth("-("..b..") "..b.."-4*"..a.."*"..c.." ",0.9),yeq-30,negro)
- --screen.print(xeq+197,yeq+12,a,0.9,rojo,0x0)
- screen.print(xeq+50-7,yeq-13,"-("..b..") "..b,0.9,0xFFFF0000,0x0)
- elevadoa2:blit(xeq+50+screen.textwidth("-("..b..") "..b,0.9)-3,yeq-25)
- screen.print(20+xeq+50-7+screen.textwidth("-("..b..") "..b,0.9),yeq-13,"-4*",0.9,negro,0x0)
- screen.print(20+xeq+50-7+screen.textwidth("-("..b..") "..b.."-4*",0.9),yeq-13,a,0.9,rojo,0x0)
- screen.print(20+xeq+50-7+screen.textwidth("-("..b..") "..b.."-4*"..a,0.9),yeq-13,"*",0.9,negro,0x0)
- screen.print(20+xeq+50-7+screen.textwidth("-("..b..") "..b.."-4*"..a.."*",0.9),yeq-13,c,0.9,verde,0x0)
- screen.print((xeq+50+raizmasmenos:width()+screen.textwidth("-("..b..") "..b.."-4*"..a.."*"..c.." ",0.9))/2,yeq+15,"2*",0.9,negro,0x0)
- screen.print((xeq+50+raizmasmenos:width()+screen.textwidth("-("..b..") "..b.."-4*"..a.."*"..c.." ",0.9))/2+screen.textwidth("2*",0.9),yeq+15,a,0.9,rojo,0x0)
- screen.print(20,200,"A:Triangulo = "..a,0.9,rojo,0x0)
- screen.print(20,240,"C:Cruz = "..b,0.9,verde,0x0)
- screen.print(20,220,"B:Cuadrado = "..c,0.9,azul,0x0)
- if controls.press("triangle") then
- a = tonumber(xkeyboard(480-peke.img:width(),272-peke.img:height(),240,165,a,"A: ",1))
- --os.osk("introduce el numero A",a,10,3,1)
- if a== nil then a = 0 end
- end
- if controls.press("square") or controls.press("circle") then
- b = tonumber(xkeyboard(480-peke.img:width(),272-peke.img:height(),240,165,b,"B: ",1))
- if b== nil then b = 0 end
- end
- if controls.press("cross") then
- c = tonumber(xkeyboard(480-peke.img:width(),272-peke.img:height(),240,165,c,"C: ",1))
- if c== nil then c = 0 end
- end
- if controls.press("select") then
- xerpi()
- end
- screen.flip()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement