Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------- LIB RINGMENU v1 by CHIMECHO (c) -------------------------------------
- -- Copylefts bla bla bla
- -- Rollazo del autor
- -- y.. prohibidio usarlo en el psp génesis! ¬¬'
- function order(tbl)
- local ordr = {} -- zm, pos, esto va a ordernar segun el zoom, las mas chicas primero, las mas grandes despues...
- for i=1,#tbl do
- table.insert(ordr,{zm=tbl[i].zoom,pos=i})
- end
- table.sort(ordr,function (a,b) return a.zm < b.zm end)
- return ordr
- end
- function rotate(opt, des) -- opciones, desfase de la primera imagen
- local ang_act = des
- for i=1,#opt do
- opt[i].ang = ang_act
- opt[i].x = math.cos(math.rad(opt[i].ang)) * opt.w/2
- opt[i].y = math.sin(math.rad(opt[i].ang)) * opt.h/2 -- los mas chiquitos, arriba
- opt[i].zoom = (1 + math.sin(math.rad(opt[i].ang)) * 0.2)
- opt[i].w = screen.textwidth(opciones[i].text,opciones[i].size) * opt[i].zoom
- opt[i].h = 15 * opt[i].zoom
- ang_act = ang_act - opt.ang
- end
- opt.orden = order(opt)
- end
- ringmenu = {}
- function ringmenu.blit(obj,desfx,desfy)
- if not desfx then desfx = 0 end
- if not desfy then desfy = 0 end
- if controls.press("right") then obj.dir = "right" end
- if controls.press("left") then obj.dir = "left" end
- if controls.up() then obj.desy=math.max(obj.desy-0.1,-1) end
- if controls.down() then obj.desy=math.min(obj.desy+0.1,1) end
- if obj.dir=="right" then
- obj.angulo = obj.angulo + (obj.ang/10) -- que la anim siempre dure 10 frames
- obj.anganillo = obj.anganillo + (obj.ang/10)
- rotate(obj, obj.anganillo)
- if obj.angulo>=obj.ang then -- solo hasta el siguiente elemento
- obj.dir="stop"
- obj.angulo = 0
- end
- elseif obj.dir=="left" then
- obj.angulo = obj.angulo - (obj.ang/10)
- obj.anganillo = obj.anganillo - (obj.ang/10)
- rotate(obj, obj.anganillo)
- if obj.angulo<=-obj.ang then
- obj.dir="stop"
- obj.angulo = 0
- end
- end
- for j=1,#obj do
- i=obj.orden[j].pos
- screen.print(desfx + 240 + obj[i].x - (obj[i].w/2), desfy + 136 + (obj[i].y * obj.desy) - (obj[i].h/2),opciones[i].text,opciones[i].size,opciones[i].color,opciones[i].colorfondo) -- centrado y con zoom
- end
- end
- function ringmenu.create(w,h,imgs_tbl) -- ancho del anillo, alto del anillo, imagenes
- local cant_op = #imgs_tbl
- local ang = 180 - (((cant_op - 2)/cant_op)*180) -- angulo entre cada vertice del poligono, fuente: wikipedia
- local ring = {orden = {}, w = w, h = h, ang = ang, anganillo = 90, angulo = 0, dir = "stop", desy = 1, blit = ringmenu.blit}
- for i=1,cant_op do
- ring[i] = {imagen = imgs_tbl[i]}
- end
- rotate(ring, ring.anganillo)
- return ring
- end
- -------------------------------------- HASTA AKI LA LIB -------------------------------------
- --blanco = color.new(255,255,255)
- --colores = {color.new(255,0,0),color.new(0,255,0),color.new(0,0,255),color.new(0,255,255),color.new(255,0,255),color.new(255,255,255)}
- opciones = {
- {text = "Jugar",color=color.new(255,0,0),colorfondo=0x0,size=0.85},
- {text = "Scores",color=color.new(0,255,0),colorfondo=0x0,size=0.85},
- {text = "Créditos",color=color.new(0,0,255),colorfondo=0x0,size=0.85},
- {text = "Salir",color=color.new(155,155,0),colorfondo=0x0,size=0.85}
- }
- menu = ringmenu.create(320,60,opciones)
- while true do
- controls.read()
- menu:blit()
- if controls.press("cross") then Chimecho() end
- screen.flip()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement