Forum Replies Created
-
AuthorPosts
-
I’d say examples like this, are very important to create new patreons, but equally Mark doesn’t have the time or rather he would be better doing more complex things!
+1 multi threading is *very* handy, that said I wouldn’t fancy the task of writing and debugging a multi threaded GC, unless you have a “separate” GC for each thread, any communicating between threads whether the main “application” thread or other threads will take care, a definite challenge but yeah worth it especially as even mobile processors quite commonly have 2-4 cores (not counting the low power cores!)
DOH! it was right there in front of me – how on earth did I miss the fact it was a local! very odd how printing it after creating it even had any effect….
The crash is happening when the string is being retained, and indeed works fine if you use an int instead – so looks like you might have stumbled on something fundamental…
You can if you want render everything in a shader, (it has been done) but good look getting it working on laptops and phones, as well as performance you should keep an eye towards compatibility… (not everyone has the latest hardware)
did you try the print immediately after
[/crayon]Monkey123[crayon-5cba90d7ad5ce985262559 inline="true" ]Local data:=New MyClassI’d be curious to know if that makes it work like it does here…
if you do this
[/crayon]Monkey1234[crayon-5cba90d7b0c27802856702 inline="true" ]Local data:=New MyClassPrint data.Testthen the whole thing works
I had to do this tho!
[/crayon]Monkey123[crayon-5cba90d7b0c2e439570774 inline="true" ]Local spacefilter:=cpShapeFilterNew(ULong(0), UInt(1), UInt(1) )which seems wrong!
I think it might possibly be to do with string assignment and class creating but even if I assign Test in a MyClass’s new Method (and print it) the issue still exists the only thing that seems to work is if I print the field from outside the class
I’d say this is defiantly one to report on github
btw assume you know you can set body userdata ?
Probably teaching grannie to suck eggs here but I’d recommend wrapping all the body specific stuff into its own class and keeping it in its own seperate file, that way you can just create/draw and object and keep all the chipmonk stuff out of your main code. you could probably set a class global (static) field with things like world etc that you need for object creation…
[/crayon]Monkey123[crayon-5cba90d7b489a287504779 inline="true" ]/home/chris/development/monkey2-projects/chipmonk-test/test1.monkey2 [66] : Error : Can't find overload for 'cpShapeFilterNew:chipmunk.cpShapeFilter(Ulong,Uint,Uint)' with argument types (Int,Int,Int)for
[/crayon]Monkey123[crayon-5cba90d7b48a1502815084 inline="true" ]Local spacefilter:=cpShapeFilterNew(0, 1, 1 )(Linux difference??)
so you might beat me to it, but you’re trying to print data.Test when it should probably be a ptr ? (initial guess!) edit: missed the [0] doh so not that…
afaik you’d still need to cast the value to a void pointer tho… better yet a void pointer to a struct
– sorry the lambda was only a guess, do let us all know how you get on, examples of stuff like this would be rather useful…
initial guess would be to try using a function instead of a lambda ?
This would certainly be do-able for the “default” modules that come with monkey, just in a manual script
I better way would probably be just to peek in each modules main file for #includes with <> – I’m not sure of the accuracy of depends in module.json…. (ya could put owt in there!)
To be honest I think they should just get built as they are needed when different projects are compiled…
you hit probably the main reason its not multi threaded, any attempt at this will need to understand module dependency and probably work from the bottom of the hierarchy level at a time
canvas.Scissor=New Recti( Xoffset*scaleX,Yoffset*scaleY, (960+Xoffset)*scaleX, (540+Yoffset)*scaleY )
I’m sure you can work it out for yourself…
here is an example of keeping your drawing to 16:9
[/crayon]Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677[crayon-5cba90d7c5923603723397 inline="true" ]#Import "<std>"#import "<libc>"#Import "<mojo>"#Import "assets/"using std..using mojo..using libc..global image:Imageclass MyWindow extends WindowField NewWidth:floatField NewHeight:floatmethod new()' new window deliberatly not 16:9super.new("hello",1024,768,WindowFlags.Resizable)ClearColor=new Color( 0,.25,0 )' image is same size as our virtual resolution (960x540)image = Image.Load( "asset::testcard.png" )endmethod OnRender( canvas:Canvas ) overrideApp.RequestRender()canvas.Clear(ClearColor)NewWidth = WidthNewHeight = Height' the smallest dimention is used to scale to largest 16:9 that fitsIf ((Width/16.0)<=(Height/9.0)) ThenNewHeight = (Float(Width) / 16.0) * 9.0ElseNewWidth = (Float(Height) / 9.0) * 16.0EndifLocal scaleX:float = NewWidth/960.0Local scaleY:float = NewHeight/540.0Local Xoffset:int = -((NewWidth-Width) / 2.0) / scaleXLocal Yoffset:int = -((NewHeight-Height) / 2.0) / scaleYcanvas.Scale( scaleX, scaleY )canvas.Translate(Xoffset, Yoffset)' from here on all drawing is at 16:9 and centred' NB may need to gl scissor the letter boxcanvas.DrawImage(image, 0,0)endendfunction Main()' boiler plate just to ensure random is different each runlocal tv:timevalgettimeofday( varptr(tv) )local t:long = tv.tv_sec * 1000 + tv.tv_usecSeedRnd(t)' more boiler plate just to kick the app off...new AppInstancenew MyWindowApp.Run()end -
AuthorPosts