Forum Replies Created
-
AuthorPosts
-
You need a constructor in the “TweenEquationCallLinear”
thats the error I get when I try to check for errors. I added the “Method New()” and the error went away.
For safety purpose you should add a default constructor to all of your classes. if you don’t you might run into something similar when you try to implement something similar with other classes.
Thanks, I was trying to do some some experimenting and wasn’t sure if it was doable or not. I was just wondering if I could move a node from one list to another by doing it that way.
another question:
are linked Lists slow or just this module? I know arrays are faster but was wonder. I guess I could do some tests..
Mark, I saw that you modified the List to work with skn3 Post. My question is, Is the only way to use InsertBefore or InsertAfter by using nodes with in the list? I tried to add a removed node to it and it failed. produced an endless for loop. I tried it before the current modifications and after the modifications with same results.
[/crayon]Monkey1234567891011121314151617181920212223242526272829303132333435363738394041[crayon-5cba9e1ad0895398660298 inline="true" ]#Import "<std>"Using std..Function Main:Void()Local items := New List<Item>()Local item1 := New Item("one")item1.node = items.AddLast(item1)Local item2 := New Item("two")item2.node = items.AddLast(item2)Local item3 := New Item("three")item3.node = items.AddLast(item3)Print "before"For Local item := Eachin itemsPrint item.nameNextitem1.node.Remove()item2.node.InsertBefore(item1.node)Print "after"For Local item := Eachin itemsPrint item.nameNextPrint ""EndClass ItemField node:List<Item>.NodeField name:StringMethod New(name:String)Self.name = nameEndEndGot it! Thanks Mark.
I created a simple generic pool class. I think t’s as fast as it can get. it has no limitation on size and has a return to pool function. The only requirements is that all objects to be stored or created must extend StoreObject class:
[/crayon]Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859[crayon-5cba9e1ad85df010178979 inline="true" ]'*******************************************************'* Pool *'*******************************************************Class Store<T>Field last:TField total:IntMethod New()End MethodMethod New(count:Int)Fill(count)End MethodMethod Fill:Void(total:Int)For Local i:Int = 0 Until totalLocal c:T = New Tc._pred = lastlast = cNextSelf.total += totalEnd MethodMethod Count:Int()Return totalEnd MethodMethod GetItem:T()If lastLocal c:T = lastlast = Cast<T>(last._pred)c._pred = Nulltotal -= 1Return cEndifReturn New TEnd MethodMethod ReturnItem:Void(obj:T)obj._succ = Nullobj._pred = lastlast = objtotal += 1End MethodEnd ClassClass StoreObject AbstractField _pred:StoreObjectMethod New()End methodEnd Classcan I clear a pixel from the canvas Image to 0,0,0,0? I know I can draw a pixel with alpha 0 and it will just leave the canvas pixel as is but I need to clear the canvas pixel alpha to 0. I mean the canvas from an image.
I went from using DrawImage, to using DrawRect to draw the images and it has improved the speed significantly not as fast as the original but pretty close now. it’s doable. I am wondering if the Image class or DrawImage is the cause of the slowdown.
I did but didn’t help much. it is still quite a bit slower than the previous version.
what’s with the printing of “Flush!” over and over. I think it might have something to do with the slowdown. Does it in debug and release mode.
release mode seems to be slow also.Thanks Mark.
I am not concerned with the speed of the enscripten target I was expecting it to be a bit slower. I was concerned with the speed difference in the desktop target. I figured that if I could keep about 55fps it would be ok in release mode but now I can’t be sure anymore. and it’s going to be a bother to be checking release mode every time I want to check it’s performance.I just saw your last post. Yes, that would help.
Thats funny, I have been through the string documentation several times but for some reason I never actually payed attention to those functions.
here a more complete set:
[/crayon]Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394[crayon-5cba9e1af15cd360651536 inline="true" ]#import "<std>"Using mojo..Using std..Function DecimalToHex:String(dec:Int)If(Not dec) Then Return "00"Local dic:String = "0123456789ABCDEF"Local hex:String = ""While(dec)Local bits := dec & $fLocal hi := String.FromChar(dic[bits])hex = hi + hexdec = dec Shr 4WendReturn hexEndFunction DecimalToBin:String(dec:Int)If(Not dec) Then Return "0"Local bin:String = ""While(dec)bin = String(dec & 1) + bindec = dec Shr 1WendReturn binEndFunction HexToDecimal:Int(str:String)If str = "" Return 0Local dic := "0123456789ABCDEF"Local dec :Int = 0While str.Length > 0Local char := str.Left(1).ToUpper()If dic.Contains(char)dec = (dec Shl 4) | dic.Find(char)ElseReturn 0Endifstr = str.Mid(1,str.Length-1)WendReturn decEnd FunctionFunction BinToDec:Int(str:String)If str = "" Return 0Local dec :Int = 0While str.Length > 0Local char := str.Left(1)If char = "0" Or char = "1"dec = (dec Shl 1) | Int(char)ElseReturn 0Endifstr = str.Mid(1,str.Length-1)WendReturn decEnd FunctionFunction Main()Print(DecimalToHex(26))Print(DecimalToBin(5))Print(HexToDecimal("1aA"))Print(BinToDec("10001"))End -
AuthorPosts