Forum Replies Created
-
AuthorPosts
-
Paypal ‘donate’ will go nearly 100% in mark’s pocket.. You could give him 10$ this way. It will probably be more than a one year patreon of 1$. Some patreons switched to ‘Donate’ after patreon had made a mistake with their server security. And realised they take a percentage too..
had a try…
the polyshape funcs definitions in shape.monkey2 still had cpBody Ptr as argument so I replaced them with cpBody..
but polys are not showing!
In debug Mode I get the following error (a small notice window) (w7&w10):
MSV C++ Runtime lib.:
This application has requested the runtime to terminate it in an usual wayIn release mode it’s running but I can’t see the polygon (that I was seeing using the previous “unmodified” chipmunk module with just the “const” hack)
I just added this code to the hellochipmunk (after circle init):
[/crayon]Monkey12345678910111213141516[crayon-5cba8e08522dc413808993 inline="true" ] '--- A Pentagonmass = 0.3Local NUM_VERTS := 5Local verts:=New cpVect[NUM_VERTS]for Local it:=0 To NUM_VERTS-1Local angle:cpFloatangle = -2.0*Pi*it/(1.0*NUM_VERTS)verts[it] = cpv(30*Cos(angle), 30*Sin(angle))Nextmoment= cpMomentForPoly(mass, NUM_VERTS, Varptr verts[0], cpvzero, 0.0)polyBody = space.AddBody(cpBodyNew(mass,moment))polyBody.Position=cpv(0.0, -190.0)polyShape=space.AddShape(cpPolyShapeNew(polyBody, NUM_VERTS, Varptr verts[0], cpTransformIdentity, 0.0))' this was working with the unmodified chipmunk importpolyShape.Friction=0.03The full file is attached to a previous post.
Great! waw! My debugDraw implementation looks so awful compared to yours!
Happy this is now built in! (woohoo)I saw there has been some things modified in chipmunk and c2mx2 but It’s still the same on my side. Need to hack the “const”.
tried some implicit conversion from const_cpVect to cpVect with “struct extension” and “operator to:” but no luck, the “‘const cpVect'” is crapping the .h and .cpp output
I’ll stop trying to mess with it..
Do you think it’s better to remove the “const” in the original “chipmunk.h” or use the =”const cpVect” hack.
or is there any other better solution in your mind? Should I post an issue on github?The debugDraw is kind of mandatory so something have to be done.. the actual “build in” chipmunk module can’t manage debug polygon draws for now.(and probably other callbacks with “const”)
The first ideal idea I had was trying to write this:
Alias cpSpaceDebugDrawPolygonImpl:Void( Int, cpVect Ptr="const cpVect*" ,...Hoping all would be internally managed by the transpiler/linker! But not..
If this is possible it could be a good solution for automation.
c2mx2 detects an un-implemented typedef func (Alias func:..(..)) or a pure virtual method with some const/const& as parameter then adds ="const foo" or ="const foo&" or wathever.
And this way there’s no conversion to be done..In the chipmunk’s debugdraw case the actual hack is not problematic because the module user won’t even notice it’s there. He/She’s just gonna call it with a simple call. If someone want to create it’s own implementation then he/she will have to notice it but has an example to start with.
Is there any plan on c2mx2 being c++ aware?
ok found how to do it
modified the chipmunk_extern.monkey2:
added[/crayon]Monkey1234[crayon-5cba8e0862bfc042257836 inline="true" ]Struct const_cpVect="const cpVect"Field x:cpFloatField y:cpFloatEndand modified the problematic line
[/crayon]Monkey123[crayon-5cba8e0862c03876244782 inline="true" ]Alias cpSpaceDebugDrawPolygonImpl:Void( Int, cpVect Ptr, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer )ToAlias cpSpaceDebugDrawPolygonImpl:Void( Int, const_cpVect Ptr, cpFloat, cpSpaceDebugColor, cpSpaceDebugColor, cpDataPointer )and my implementation has a const_cpVect Ptr as argument of course…
@Mark: Fix working on Ted2’s text screen and mojo apps!
However the console output is still 7bit limited.. Not vital but could probably be quickly corrected after this utf8 fix.
[/crayon]Monkey12345678910111213[crayon-5cba8e0867075437852171 inline="true" ]#Import "<std>"Using std..Function Main()Local s:StringFor Local j:=0 To 3s=""For Local i:=1+(j*63) To 63+(j*63)s=s+String.FromChar(i)NextPrint sNextPrint "éléphant"EndBy full pass indent I mean an auto intend button that indents all your file: clearing all spaces and tabs at the beginning of each line then intend by fold+if/elseif/case…
The ifs are probably a bit difficult because it needs some analysis to know wether it’s a one line or not.I’ve had some problems with the text cursor. Sometimes it desapears completely after coming back to ted.
I personaly prefer when the cursor doesn’t “flash” (for a more zen workspace.)the mx2cc is clearly a better solution because when compiling starts it starts to write things on disk and that’s bad.
Tested your fork:
It would be nice if the Classes/Methods/Fields/Vars in the left column where sorted in some kind. Here I have some mixed Methods and Fields withing my class.
And sorted by alpha or with the same order than in the File.I’m looking forward to see code folding and full pass indent. Hope it’s in your plan.
nice work!
Here your code corrected and running..
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233[crayon-5cba8e086f38c245363317 inline="true" ]Namespace myapp#Import "<std>"#Import "<mojo>"#import "Ultim"Using std..Using mojo..Using Ultim..Class MyWindow Extends WindowField s:StringMethod New()s=UltimC.Init()endMethod OnRender( canvas:Canvas ) Overridecanvas.DrawText( "Hello World "+s,Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()Endthe Ultim.monkey2
[/crayon]Monkey123456789[crayon-5cba8e086f393880478708 inline="true" ]Namespace UltimClass UltimClassMethod Init:String( )Return "Ultim"endEndGlobal UltimC:= New UltimClassNote that I renamed things called Ultim to Ultimsomething because you can’t have the same for a variable and a namespace/filename.
Here’s a little zip with a working example of multiple imports.
Runs fine with 1.0.7 but should be ok with earlier versions.main:
[/crayon]Monkey12345678910111213141516171819202122232425262728293031[crayon-5cba8e0873dd1151103674 inline="true" ]Namespace myapp#Import "<std>"#Import "lib_a"'you could comment this line because lib_d imports lib_b but as I directly use lib_b I prefer to import it twice, won't be double after compil#Import "lib_b"#Import "lib_c"#Import "lib_d"Using std..Using lib_b..' I use lib_c. prefix and not "Using lib_c.." for demonstrationUsing lib_d..Function Main()'Glob_a is already defined in lib_a (=5)Glob_b=7lib_c.Glob_c=12 'using namespace prefixLocal foo:=New Class_b(21)Local foo2:=New Class_d(37)Print Glob_aPrint Glob_bPrint lib_c.Glob_cPrint foo.Get()Print foo2.Get()Print fooGlobal.Get()'defined in lib_dEndlib_a
[/crayon]Monkey123[crayon-5cba8e0873dd8864493384 inline="true" ]namespace myappGlobal Glob_a:=5lib_b
[/crayon]Monkey1234567891011121314[crayon-5cba8e0873dde984732400 inline="true" ]Namespace lib_bGlobal Glob_b:IntClass Class_bField fi:IntMethod New(i:Int)fi=iEndMethod Get:Int()Return fiEndEndlib_c
[/crayon]Monkey1234[crayon-5cba8e0873de4242299668 inline="true" ]Namespace lib_cGlobal Glob_c:Intlib_d
[/crayon]Monkey123456789101112131415161718[crayon-5cba8e0873dea184823063 inline="true" ]Namespace lib_d'if lib_b is imported elsewhere via main you could miss the following but it would be bad practice, keep sure your dependecies are imported'anyway you can import this several times, it won't be duplicated after compilation#Import "lib_b"Using lib_b..Global fooGlobal:=New Class_d(51)Class Class_d Extends Class_bMethod New(i:Int) 'in monkey2 you must define the constuctor if you defined one in the super classSuper.New(i)EndMethod Set(i:Int)fi=iEndEndedit:added a global class declared outside of main so use import-1.monkey2
Attachments:
Hope you’ll find a pleasant way in that nice project..
I just forgot that passing by reference was an issue with abstract method only.
However it should faster by value..Now with all bodies and joints types working and a aabbQueryCallback for mouse joints all in monkey2 language only.
The bodies_and_joints.monkey2 is the one with most features available now.
https://github.com/abakobo/Box2D_for_monkey2
https://github.com/abakobo/Box2DIt’s getting to be almost usable!
I have some memory question… It starts at 24M of Ram and it grows to 36M but then stops. Is it a normal behaviour or is there a problem with my memory management (lots of externals here…)? If someone can have a look at the code it would be great. (the code should be better documented but I think it’s readable..)
-
AuthorPosts