This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - Chockosta
Pages: 1 ... 10 11 [12] 13 14 ... 31
166
« on: February 16, 2012, 08:37:05 am »
Mine is 7043...
167
« on: February 09, 2012, 11:57:00 am »
It's time for a beta release ! I'm really sorry for the very slow developpement of this project. Anyway, there are 20 nice levels, and I changed the player sprite (I know, I'm not an artist at all  ). See attachment for the TNS file and screenies. PS : Do you think I should upload this beta version on ticalc.org and TI-Planet ?
168
« on: January 28, 2012, 12:38:53 pm »
If you have English-French and German-French traduction, why can't you add English-German ?
169
« on: January 28, 2012, 06:59:34 am »
You're right, I just modified that.
Right now I'm busy integrating it to nSpaint... It should be released next week.
170
« on: January 23, 2012, 12:44:39 pm »
Oh, sorry, I haven't seen those messages.
@GB : Yeah, the mouse only works with a touchpad. You still can play with the arrows.
@cyanophycean314 : I never understood the point of this... Is it just a way to do it faster ? But I sure could add it.
171
« on: January 20, 2012, 04:37:49 pm »
I finished the GUI engine, it now handles mouse events and everything. (almost) So now I start to write new functions !
If you are interested, here is the source code of a demo :
--[[
window : {wtype,name,buttons,layout,size} --> wtype : "dialogBox","custom" --> size : {sizeX,sizeY} (only for custom)
buttons : {{"name",function1},{"name",function2},...}
layout : {{"type",...}} --> type : "label","textBox","colorSlider","list"
label : {text,x,y}
textBox : {text,x,y,sizeX,cursor}
colorSlider : {color,value,x,y} --> color : "red","green","blue"
list : {elements,scroll,x,y,sizeX,sizeY,selected}
]]
--GUI GESTION gui={} gui.windows={} gui.dialogBox={} gui.custom={} gui.textBox={} gui.colorSlider={} gui.list={} gui.resized=false gui.img={} gui.img.upButton=image.new("\011\000\000\000\010\000\000\000\000\000\000\000\022\000\000\000\016\000\001\0001\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\198\255\255\255\255\255\255\255\255\156\243\255\255\255\255\255\255\255\2551\1981\198\255\255\255\255\255\255\214\218\000\128\214\218\255\255\255\255\255\2551\1981\198\255\255\255\255\247\222B\136\000\128B\136\247\222\255\255\255\2551\1981\198\255\255\247\222B\136!\132\000\128!\132B\136\247\222\255\2551\1981\198\247\222B\136!\132B\136R\202B\136!\132B\136\247\2221\1981\198\132\144B\136B\136\247\222\255\255\247\222B\136B\136\132\1441\1981\198\156\243\132\144\247\222\255\255\255\255\255\255\247\222\132\144\189\2471\1981\198\255\255\222\251\255\255\255\255\255\255\255\255\255\255\222\251\255\2551\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\198") gui.img.downButton=image.new("\011\000\000\000\010\000\000\000\000\000\000\000\022\000\000\000\016\000\001\0001\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\198\255\255\222\251\255\255\255\255\255\255\255\255\255\255\222\251\255\2551\1981\198\156\243\132\144\247\222\255\255\255\255\255\255\247\222\132\144\189\2471\1981\198\132\144B\136B\136\247\222\255\255\247\222B\136B\136\132\1441\1981\198\247\222B\136!\132B\136R\202B\136!\132B\136\247\2221\1981\198\255\255\247\222B\136!\132\000\128!\132B\136\247\222\255\2551\1981\198\255\255\255\255\247\222B\136\000\128B\136\247\222\255\255\255\2551\1981\198\255\255\255\255\255\255\214\218\000\128\214\218\255\255\255\255\255\2551\1981\198\255\255\255\255\255\255\255\255\156\243\255\255\255\255\255\255\255\2551\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\1981\198")
--GUI UTILS
function gui.errorMessage(errorText) gui.addWindow("dialogBox","Error",{{"OK",function() gui.closeWindow() refresh() end}},errorText) end
function gui.addWindow(windowType,windowName,windowButtons,windowLayout,windowSize) table.insert(gui.windows,{wtype=windowType,name=windowName,buttons=windowButtons,layout=windowLayout,size=windowSize}) gui.focus=-1 refresh() end
function gui.closeWindow() table.remove(gui.windows) gui.focus=-1 refresh() end
function gui.nbWindows() return #gui.windows end
function gui.current() return gui.windows[#gui.windows] end
function gui.refreshCurrent() local current=gui.current() local sizeX,sizeY=unpack(current.size) local xPos,yPos=(width()-sizeX)/2,(height()-sizeY-15)/2 refresh(xPos,yPos,sizeX,sizeY+39) end
--GUI EVENTS function gui.mouseDown(xPos,yPos) if gui.nbWindows()>=1 then local window=gui.current() if window.size then local sizeX,sizeY=unpack(window.size) local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2 if xPos>x and xPos<x+sizeX and yPos>y then if yPos<y+sizeY and gui.current().wtype=="custom" then gui.setFocus(xPos-x,yPos-y,window) elseif yPos>y+sizeY and yPos<y+sizeY+39 then gui.buttonDown(xPos,yPos,window.buttons) end end end end end
function gui.paint(gc) for i,e in pairs(gui.windows) do gui[e.wtype].paint(gc,e,i) end gui.resized=false end
function gui.resize() gui.resized=true end
function gui.tabKey() if gui.nbWindows()>0 then gui.moveFocus(1) gui.refreshCurrent() end end
function gui.backtabKey() if gui.nbWindows()>0 then gui.moveFocus(-1) gui.refreshCurrent() end end
function gui.arrowKey(arrow) if gui.nbWindows()>0 then if gui.focus<0 then if arrow=="left" then gui.moveFocus(1) gui.refreshCurrent() elseif arrow=="right" then gui.moveFocus(-1) gui.refreshCurrent() end elseif gui.focus>0 then local currentElem=gui.current().layout[gui.focus] if gui[currentElem[1]].arrowKey then gui[currentElem[1]].arrowKey(arrow,currentElem) gui.refreshCurrent() end end end end
function gui.enterKey() if gui.nbWindows()>0 then if gui.focus<0 then gui.current().buttons[-gui.focus][2]() end end end
function gui.charIn(char) if gui.nbWindows()>0 then if gui.focus>0 then local currentElem=gui.current().layout[gui.focus] if gui[currentElem[1]].charIn then gui[currentElem[1]].charIn(char,currentElem) gui.refreshCurrent() end end end end
function gui.backspaceKey() if gui.nbWindows()>0 then if gui.focus>0 then local currentElem=gui.current().layout[gui.focus] if gui[currentElem[1]].backspaceKey then gui[currentElem[1]].backspaceKey(currentElem) gui.refreshCurrent() end end end end
function gui.escapeKey() if gui.nbWindows()>0 then gui.closeWindow() end end
--GUI LAYOUT ELEMENTS EVENTS
function gui.textBox.charIn(char,textBox) if string.len(char)==1 then textBox.prev={textBox.text,textBox.cursor} textBox.text=string.usub(textBox.text,1,textBox.cursor)..char..string.usub(textBox.text,textBox.cursor+1) textBox.cursor=textBox.cursor+1 end end
function gui.textBox.arrowKey(arrow,textBox) if arrow=="right" and textBox.cursor<string.len(textBox.text) then textBox.cursor=textBox.cursor+1 elseif arrow=="left" and textBox.cursor>0 then textBox.cursor=textBox.cursor-1 end end
function gui.textBox.mouseDown(textBox,x) textBox.setCursor=x-2 end
function gui.textBox.backspaceKey(textBox) if string.len(textBox.text)>0 then textBox.text=string.usub(textBox.text,1,textBox.cursor-1)..string.usub(textBox.text,textBox.cursor+1) textBox.cursor=textBox.cursor-1 end end
function gui.colorSlider.arrowKey(arrow,slider) if arrow=="right" then slider.value=slider.value<250 and slider.value+5 or 255 elseif arrow=="left" then slider.value=slider.value>5 and slider.value-5 or 0 end end
function gui.colorSlider.mouseDown(slider,x) x=(x-2)*4 x=x>0 and x or 0 x=x<255 and x or 255 slider.value=x end
function gui.list.arrowKey(arrow,list) if arrow=="up" and list.selected>1 then list.selected=list.selected-1 elseif arrow=="down" and list.selected<#list.elements then list.selected=list.selected+1 end end
function gui.list.mouseDown(list,x,y) if x>list.sizeX-17 then if y>list.sizeY/2 and list.selected<#list.elements then list.selected=list.selected+1 elseif y<list.sizeY/2 and list.selected>1 then list.selected=list.selected-1 end else list.setSelection=y end end
--GUI MISC FUNCTIONS
function gui.moveFocus(nb) local currentWindow=gui.current() local test=false local originalFocus=gui.focus nb=gui.focus<0 and -nb or nb gui.focus=gui.focus+nb if #currentWindow.buttons==0 then gui.focus=-1 test=true end while not test do if gui.focus<0 then if -gui.focus<=#currentWindow.buttons then test=true else gui.focus=1 nb=1 end elseif gui.focus==0 then if originalFocus<0 then if currentWindow.wtype=="dialogBox" then gui.focus=-#currentWindow.buttons test=true elseif #currentWindow.layout==0 then gui.focus=-#currentWindow.buttons test=true else gui.focus=#currentWindow.layout end else gui.focus=nb<0 and -1 or 1 end else if currentWindow.wtype=="dialogBox" then test=true gui.focus=-1 elseif currentWindow.wtype=="custom" then if gui.focus<=#currentWindow.layout then if currentWindow.layout[gui.focus][1]=="label" then gui.focus=gui.focus+(nb<0 and -1 or 1) else test=true end else test=true gui.focus=-1 end end end end end
function gui.buttonDown(x,y,buttons) for i,e in pairs(buttons) do if x>e.pos and x<e.pos+e.size then gui.focus=-i e[2]() end end end
function gui.setFocus(x,y,window) for i,e in pairs(window.layout) do if e[1]=="list" then if x>e.x and y>e.y and x<e.x+e.sizeX and y<e.y+e.sizeY then gui.focus=i gui.list.mouseDown(e,x-e.x,y-e.y) end elseif e[1]=="textBox" then if x>e.x and y>e.y and x<e.x+e.sizeX and y<e.y+22 then gui.focus=i gui.textBox.mouseDown(e,x-e.x,y-e.y) end elseif e[1]=="colorSlider" then if x>e.x and y>e.y and x<e.x+68 and y<e.y+20 then gui.focus=i gui.colorSlider.mouseDown(e,x-e.x,y-e.y) end end end gui.refreshCurrent() end
--GUI DRAWING
function gui.dialogBox.paint(gc,dialogBox,windowID) local sizeX,sizeY if not dialogBox.size then gc:setFont("sansserif","r",10) sizeX=improvedStr.width(gc,dialogBox.layout)+24 sizeY=improvedStr.height(gc,dialogBox.layout)+17 gui.windows[windowID].size={sizeX,sizeY} else sizeX,sizeY=unpack(dialogBox.size) end gui.paintWindowBG(gc,dialogBox.name,sizeX,sizeY) gui.paintTextArea(gc,dialogBox.layout,sizeX,sizeY) gui.paintButtons(gc,dialogBox.buttons,sizeX,sizeY,windowID) end
function gui.custom.paint(gc,window,windowID) gui.paintWindowBG(gc,window.name,window.size[1],window.size[2]) gui.paintLayout(gc,window.layout,window.size[1],window.size[2]) gui.paintButtons(gc,window.buttons,window.size[1],window.size[2],windowID) end
function gui.paintLayout(gc,layout,sizeX,sizeY) local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2 for i,e in pairs(layout) do if e[1]=="textBox" then gui.paintTextBox(gc,e,x,y,gui.focus==i) elseif e[1]=="label" then gui.paintLabel(gc,e,x,y) elseif e[1]=="colorSlider" then gui.paintColorSlider(gc,e,x,y,gui.focus==i) elseif e[1]=="list" then gui.paintList(gc,e,x,y,gui.focus==i) end end end
function gui.paintLabel(gc,label,x,y) gc:setFont("sansserif","r",10) if label.text=="colorLabel" then gc:setColorRGB(0,0,0) gc:fillRect(x+label.x,y+label.y,30,20) gc:setColorRGB(unpack(color)) gc:fillRect(x+label.x+1,y+label.y+1,28,18) else gc:setColorRGB(0,0,0) gc:drawString(label.text,x+label.x,y+label.y,"top") end end
function gui.paintTextBox(gc,textBox,x,y,selected) if gc:getStringWidth(textBox.text)>textBox.sizeX-5 then textBox.prev=textBox.prev or {"",0} textBox.text,textBox.cursor=unpack(textBox.prev) end if textBox.setCursor then textBox.cursor=string.len(textBox.text) for i=string.len(textBox.text),1,-1 do if gc:getStringWidth(string.sub(textBox.text,1,i))>textBox.setCursor then textBox.cursor=i-1 end end textBox.setCursor=nil end if selected then gc:setColorRGB(50,150,190) gc:fillRect(x+textBox.x-2,y+textBox.y-2,textBox.sizeX+5,27) end gc:setColorRGB(255,255,255) gc:fillRect(x+textBox.x,y+textBox.y,textBox.sizeX,22) gc:setColorRGB(0,0,0) gc:drawRect(x+textBox.x,y+textBox.y,textBox.sizeX,22) gc:setFont("sansserif","r",10) gc:drawString(textBox.text,x+textBox.x+3,y+textBox.y+1,"top") if selected then gc:fillRect(gc:getStringWidth(string.usub(textBox.text,1,textBox.cursor))+x+textBox.x+3,y+textBox.y+2,1,19) end end
function gui.paintColorSlider(gc,slider,x,y,selected) if selected then gc:setColorRGB(50,150,190) gc:fillRect(x+slider.x-2,y+slider.y-2,72,24) end gc:setColorRGB(0,0,0) gc:fillRect(x+slider.x,y+slider.y,68,20) for i=0,63 do gc:setColorRGB(slider.color=="red" and i*4 or color[1],slider.color=="green" and i*4 or color[2],slider.color=="blue" and i*4 or color[3]) gc:fillRect(x+slider.x+i+2,y+2+slider.y,1,16) end if isCX() then gc:setColorRGB(255-slider.value,255-slider.value,255-slider.value) else gc:setColorRGB(255,255,255) end gc:fillRect(x+slider.x+slider.value/4+1,y+slider.y-2,3,24) end
function gui.paintList(gc,list,x,y,selected) if selected then gc:setColorRGB(50,150,190) gc:fillRect(x+list.x-2,y+list.y-2,list.sizeX+4,list.sizeY+4) end gc:setColorRGB(0,0,0) gc:fillRect(list.x+x,list.y+y,list.sizeX,list.sizeY) gc:setColorRGB(255,255,255) gc:fillRect(list.x+1+x,list.y+1+y,list.sizeX-2,list.sizeY-2) gc:setColorRGB(100,100,100) gc:drawImage(gui.img.upButton,list.x+x+list.sizeX-14,y+list.y+3) gc:drawImage(gui.img.downButton,list.x+x+list.sizeX-14,y+list.y+list.sizeY-13) gc:drawRect(list.x+x+list.sizeX-14,y+list.y+15,10,list.sizeY-31) gc:setFont("sansserif","r",10) local fontHeight=gc:getStringHeight("a") local capacity=math.floor(list.sizeY/fontHeight) if list.setSelection then list.selected=math.floor(list.setSelection/fontHeight)+1+list.scroll list.selected=list.selected<#list.elements and list.selected or #list.elements list.setSelection=nil end if list.selected<list.scroll+1 then list.scroll=list.selected-1 elseif list.selected>list.scroll+capacity then list.scroll=list.selected-capacity end if list.scroll>#list.elements-capacity then local scroll=#list.elements-capacity scroll=scroll<0 and 0 or scroll list.scroll=scroll end if #list.elements*fontHeight>list.sizeY then local scrollBarSize=(list.sizeY-31)*list.sizeY/(#list.elements*fontHeight) gc:fillRect(list.x+x+list.sizeX-14,y+list.y+15+list.scroll*(list.sizeY-31)/#list.elements,11,scrollBarSize) end gc:setColorRGB(0,0,0) local step=0 for i=list.scroll+1,list.scroll+capacity do if list.elements[i] then if list.selected==i then gc:setColorRGB(50,150,190) gc:fillRect(list.x+x+1,list.y+y+step*fontHeight+1,list.sizeX-16,fontHeight-2) gc:setColorRGB(0,0,0) end gc:drawString(list.elements[i],list.x+x+3,list.y+y+step*fontHeight,"top") step=step+1 end end end
function gui.paintButtons(gc,buttons,sizeX,sizeY,windowID) local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2 gc:setFont("sansserif","r",10) if (not buttons[1].size) or gui.resized then local totalSize,size,pos=-7,{},{} for i,e in pairs(buttons) do size[i]=gc:getStringWidth(e[1])+10 totalSize=totalSize+size[i]+7 end pos[1]=(width()-totalSize)/2 for i=2,#buttons do pos[i]=pos[i-1]+size[i-1]+7 end for i,e in pairs(buttons) do gui.windows[windowID].buttons[i].size=size[i] gui.windows[windowID].buttons[i].pos=pos[i] end buttons=gui.windows[windowID].buttons end for i,e in pairs(buttons) do gc:setColorRGB(136,136,136) gc:fillRect(e.pos,y+sizeY+9,e.size,23) gc:fillRect(e.pos+1,y+sizeY+8,e.size-2,25) gc:fillRect(e.pos+2,y+sizeY+7,e.size-4,27) gc:setColorRGB(255,255,255) gc:fillRect(e.pos+2,y+sizeY+9,e.size-4,23) gc:setColorRGB(0,0,0) gc:drawString(e[1],e.pos+5,y+sizeY+20,"middle") end if gui.focus<0 and windowID==gui.nbWindows() then local button=buttons[-gui.focus] if isCX() then gc:setColorRGB(50,150,190) else gc:setColorRGB(0,0,0) end gc:drawRect(button.pos-3,y+sizeY+4,button.size+5,32) gc:drawRect(button.pos-2,y+sizeY+5,button.size+3,30) end end
function gui.paintTextArea(gc,text,sizeX,sizeY) local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2 if isCX() then gc:setColorRGB(128,128,128) else gc:setColorRGB(255,255,255) end gc:drawRect(x+6,y+6,sizeX-13,sizeY-13) gc:setColorRGB(0,0,0) gc:setFont("sansserif","r",10) improvedStr.draw(gc,text,x+12,y+9) end
function gui.paintWindowBG(gc,name,sizeX,sizeY) local x,y=(width()-sizeX)/2,(height()-sizeY-15)/2 if isCX() then gc:setColorRGB(100,100,100) else gc:setColorRGB(200,200,200) end gc:fillRect(x-1,y-23,sizeX+4,sizeY+65) gc:fillRect(x,y-22,sizeX+4,sizeY+65) gc:fillRect(x+1,y-21,sizeX+4,sizeY+65) if isCX() then gc:setColorRGB(128,128,128) else gc:setColorRGB(0,0,0) end gc:fillRect(x-2,y-24,sizeX+4,sizeY+65) if isCX() then for i=1,22 do gc:setColorRGB(32+i*3,32+i*3,32+i*3) gc:fillRect(x,y+i-23,sizeX,1) end else gc:setColorRGB(0,0,0) gc:fillRect(x,y-22,sizeX,22) end gc:setColorRGB(255,255,255) gc:setFont("sansserif","r",10) gc:drawString(name,x+2,y-9,"baseline") gc:setColorRGB(224,224,224) gc:fillRect(x,y,sizeX,sizeY+39) gc:setColorRGB(128,128,128) gc:fillRect(x+6,y+sizeY,sizeX-12,2) end
--MULTIPLE LINE STRING GESTION improvedStr={}
function improvedStr.draw(gc,str,x,y) str=tostring(str) local table1={improvedStr.cut(str)} for i,e in pairs(table1) do gc:drawString(e,x,y+(i-1)*gc:getStringHeight("a"),"top") end end
function improvedStr.width(gc,str) str=tostring(str) local table1={improvedStr.cut(str)} local table2={} for i,e in pairs(table1) do table2[i]=gc:getStringWidth(e) end table.sort(table2) return table2[#table2] end
function improvedStr.height(gc,str) str=tostring(str) local table1={improvedStr.cut(str)} return gc:getStringHeight("a")*#table1 end
function improvedStr.cut(str) local table1,finished={},false local posStart,posEnd,last=1,0,1 while not finished do posStart,posEnd=string.find(str,"\n",posEnd+1) if posStart then table.insert(table1,string.sub(str,last,posStart-1)) last=posEnd+1 else table.insert(table1,string.sub(str,last)) finished=true end end return unpack(table1) end
color={0,255,0} function width() return platform.window:width() end function height() return platform.window:height() end function isCX() return platform.isColorDisplay() end function refresh(x,y,width,height) platform.window:invalidate(x,y,width,height) end function openCustom() gui.addWindow("custom","custom",{{"Close",function() gui.closeWindow() end}},{{"label",text="Hello !",x=15,y=5},{"textBox",text="type here",cursor=3,x=10,y=30,sizeX=80},{"colorSlider",color="red",value=200,x=15,y=70},{"list",x=100,y=10,sizeX=70,sizeY=80,scroll=0,selected=1,elements={"elem a","elem b","elem c","elem d","elem e","elem f","another","...","Blue","Yellow","Green"}}},{200,100}) end
gui.addWindow("dialogBox","Title",{{"Error message",function() gui.errorMessage("Error test") end},{"Open custom window",function() openCustom() end}},"This text shows multi-line text functions :\nLorem ipsum dolor sit amet\n...")
function on.paint(gc) gui.paint(gc) end
function on.mouseDown(x,y) gui.mouseDown(x,y) end
function on.resize() gui.resize() end
function on.tabKey() gui.tabKey() end
function on.backtabKey() gui.backtabKey() end
function on.enterKey() gui.enterKey() end
function on.arrowKey(ar) gui.arrowKey(ar) end
function on.charIn(ch) gui.charIn(ch) end
function on.escapeKey() gui.escapeKey() end
function on.backspaceKey() gui.backspaceKey() end And a screenie is attached.
172
« on: January 20, 2012, 06:11:21 am »
By the way, is there a way to use it with OS 3.0.2 ? I think I read this somewhere... Because I use this OS and I don't want to loose the print() in Lua.
173
« on: January 19, 2012, 04:04:01 pm »
Yeah ! At last ! A lot of thanks to ExtendeD for his amazing work. (And all the ndless beta-testers)
174
« on: January 19, 2012, 12:10:25 pm »
My 3D engine is too slow for that, it wouldn't be a good idea to use it. About criss cross paths, I can try... But now I'm working on others projects, so you have to wait a bit
175
« on: January 18, 2012, 02:38:40 pm »
Colors are all allowed, and it should be 20*30
176
« on: January 17, 2012, 01:43:08 pm »
By the way, does someone have a nice idea for the guy's sprite ? Or if someone would like to draw it for me, it would be even more awesome...
177
« on: January 17, 2012, 01:24:18 pm »
-Allow going behind blocks. Right now we have to wait until we're about 4 steps away from a block before being able to move behind it, else we die.
This would be quite hard to do. I would have to change my collision detection. And since my blocks are squares and not cubes, they dont have a defined thickness. (I'm not sure this is the correct word) -Add a minimum value for the space between the two blocks appearing at once, so we don't end up stuck in dead-ends as much or without enough space to go between two blocks.
This is possible, but I think it would possibly become too easy. I will test this.
178
« on: January 16, 2012, 12:49:16 pm »
Actually, there are only 5 levels in the released version... So this crash is normal.
179
« on: January 15, 2012, 08:15:39 am »
You should'nt think they will be too easy... or else you will have a nice surprise. The ones that you tried were just test levels, and the new ones are much better.
180
« on: January 13, 2012, 11:25:35 am »
That's right, final version won't have this.
Right now there is 12 definitive levels. When I will have 20 of them, I'll release a new version.
Pages: 1 ... 10 11 [12] 13 14 ... 31
|