Forum Replies Created
-
AuthorPosts
-
Mark has been speaking about it but I think it’s in the todo list..
True that whether you use pointer or array you’ll end with an index!
Class will slow down your loops.Yes there is two ways:
The safe one: use a reference based data structure i.e.: Class or Array.
In your case an array (of size 1) is probably the best solution.The “unsafe way” use pointer to pass the variable by reference. You must keep the scope to the variable or you’ll get a fatal “memory access violation” runtime error.
Monkey1234567Local a:int = 3test(Varptr a)Print a ‘ prints 4Function test(b:Int Ptr)b[0] = 4EndHi Playniax
I’ve started to play with pyro2 (pluging box2d+JsonRUBE Reader) but found some little things:
LayerEllipse and LayerRectangle have ints for their constructors which is bad for debugdrawing/zooming in the physics world. Floats would be better…
when you unzoom very far you get a memory access violation from the ExpandArray function. Visibly asking for an array too big for the reseved memory or something…
_zoom is VERY Small 6.7e-007 and the call to ExpandArray maxw=466096c -> maxh=349530 -> creating a HUGE array. Why does Pyro2 needs such array? Again for huge physics world this can be a problem. Isn’t such arrays taking lots of memory when unzooming?It would be great if you where making a github repo of pyro2 so we can discuss and improve.
but I want do that anonymously not via facebook
I have no Facebook and I’m backing mx2 via patreon. So yes it’s possible
Where and how should I put the source code because I’ve never used Github
-Create a github accout
-Fork original mx2 repo
Repeat
–browse your github fork to the directory where you want to upload a modified file
–click on “Upload files” and choose the file(s) (the first time you do it, create a new branch. After that, choose the branch you’ve created.)
Until all files are uploaded
-click on compare and make a pull request!You can do it with github desktop too but for a one shot it will be simpler via gihub/browser.
That’s great news that you managed to get it more fluid! Kudos!
It would probably be simpler to try pure openGl wich very basic api’s like darwin or carbon…
Good luck and please make a pull request if you find something sdl2/opengl/mx2/mojo side.
You could go even further http://wiki.osdev.org/Main_Page
Indent by fold creates indentation automatically by fold levels. It auto indents all the file by clearing all indentations and then indent all the file according to folding points.
There’s a well known Notepad++ plugin that does that. It helps a lot in some situation and keeps your brain cooler
else/elsif are not well managed in that plugin though.
https://www.fesevur.com/indentbyfold/I’d be happy you could find how to get mx2 supper fluid. But it’s becoming too technical for me, I’m affraid I can’t help on that.. And I must say for now I’m not disturbed buy the micro stutters. Doesn’t have SierraHigh though.
You can use inverted matrix to reverse the transformation. As for the camera in the center, I pasted a Canvas extension I often use to watch the world “by viewpoint at the center of the screen” so SetCameraByCenter(New Vec2f(0,0)) will place things drawn at 0,0 on the center of the screen. you can even rotate now!
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123#Import "<std>"#Import "<mojo>"Using std..Using mojo..Global gMyWindow:MyWindowClass MyWindow Extends WindowField pan : Vec2fField zoom:Float = 1.0Method New()Super.New("", 800, 600)Stuff.Create()pan=New Vec2f (Width/2,Height/2) 'now set as center to beginEndMethod OnRender(canvas:Canvas) OverrideApp.RequestRender()If Keyboard.KeyDown(Key.Raw|Key.R)zoom = 1.0pan = New Vec2f (Width/2,Height/2)EndIf Keyboard.KeyDown(Key.Raw|Key.Q)zoom -= 0.01EndIf Keyboard.KeyDown(Key.Raw|Key.E)zoom += 0.01EndIf Keyboard.KeyDown(Key.Raw|Key.A) Then pan.X -= 1*zoom 'it's nice to use Key.Raw for non qwerty keyboards..If Keyboard.KeyDown(Key.Raw|Key.D) Then pan.X += 1*zoomIf Keyboard.KeyDown(Key.Raw|Key.W) Then pan.Y += 1*zoomIf Keyboard.KeyDown(Key.Raw|Key.S) Then pan.Y -= 1*zoomcanvas.SetCameraByCenter(pan,zoom) 'no need to push and pop matrix if it's the only tranform of the OnRender() CallStuff.Draw(canvas)If Mouse.ButtonPressed(MouseButton.Left)Local mouseWorldCoord:=-canvas.Matrix*Mouse.Location '- inverts the matrix (to reverse the transformation)'* applies the transformation to the vector (multiplies the vector by the matrix)Stuff.Hit(mouseWorldCoord)EndEndEndClass Stuff AbstractGlobal Items:Vec2f[]Global Hits:Bool[]Function Create()Items = New Vec2f[100]Hits = New Bool[100]For Local i := 0 Until Items.LengthItems[i] = New Vec2f(i * 20, Rnd(-100, 100))Hits[i] = FalseNextEndFunction Hit(p:Vec2f)For Local i := 0 Until Items.LengthLocal x := Items[i].XLocal y := Items[i].YIf Contains(x - 5, x + 5, y - 5, y + 5, p.x, p.y)Hits[i] = TruePrint("Hit Success: " + i)ExitEndNextEndFunction Contains:Bool(minx:Float, maxx:Float, miny:Float, maxy:Float, x:Float, y:Float)Return x>=minx And x<maxx And y>=miny And y<maxyEndFunction Draw(canvas:Canvas)For Local i := 0 Until Items.LengthIf Not Hits[i]canvas.Color = Color.WhiteElsecanvas.Color = Color.RedEndcanvas.DrawRect(Items[i].X - 5, Items[i].Y - 5, 10, 10)NextEndEndClass Canvas ExtensionMethod SetCameraByCenter(point_x:Float,point_y:Float,zoom:Float=1.0,rotation:Float=0.0)Translate(Viewport.Width/2,Viewport.Height/2) 'Modify this line to change to something else than centerScale(zoom,zoom)Rotate(rotation)Translate(-point_x,-point_y)EndMethod SetCameraByCenter(point:Vec2f,zoom:Float=1.0,rotation:Float=0)Translate(Viewport.Width/2,Viewport.Height/2) 'Modify this line to change to something else than centerScale(zoom,zoom)Rotate(rotation)Translate(-point)EndEndFunction Main()New AppInstancegMyWindow = New MyWindowApp.Run()EndHey nerobot great work on the IDE so far.
I’m personally still dreaming of a folding feature (and an indent by fold feature). Do you plan to work on it some day?
Can the parser return the lines where a fold can be done (like function, class, multiline if’s,…)
I’d like to at least make a full file auto indented for my own usage but the problem is detecting multiline if’s..This is unrelated really
sorry, have been reading the code too fast..
Consts initialization is a weak side of monkey2
Things have been corrected already, what should be mentioned? To me it’s logical that the code would not work even thought “List” is global (I would have called it “LIST”..). But “List” can be declared in head declarations BEFORE “TEST”. It would have the same effect as it global anyway.
Do you mean that the fact we can’t make some Forward declaration should be documented?
An example to illustrate my logic (here there’s no class instance but the global is declared in head declarations):Monkey1234567891011121314151617181920Namespace test#Import "<std>"Using std..Global LIST := New List<Test> ' invert those two lines and it will failConst TEST := Test.Count() 'invert those two and it will failFunction Main()Print "Main"EndClass Test FinalFunction Count:Int()Print "Test.Count is called"Return LIST.Count()EndEndAbout Classes documentation, there’s is a lack about Classes functions. They are not mentioned at all and thus it’s not mentioned that Classes’ functions may not use a class field (“Error : Field ‘xxxx’ cannot be accessed without an instance.”)
As for a practical working example, wouldn’t a function pointer be more “dynamic”. Here there is a class instance which is Const (and containg only global “fields”)..
Is all this expected behaviour (note the Const Class has it’s field modified, I suppose it’s the reference that is Const)?Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344Namespace test#Import "<std>"Using std..Const TESTER:=New Test()Const TESTCOUNT_FUNC := TESTER.CountConst TESTCOUNT_INT:=TESTCOUNT_FUNC()Function Main()Print "Main"Print "TESTCOUNT_INT: "+TESTCOUNT_INTPrint "TESTCOUNT_FUNC(): "+TESTCOUNT_FUNC()Print ""TESTER.AddStuff()TESTER.AddStuff()Print ""Print "TESTCOUNT_INT: "+TESTCOUNT_INT + " -> has not changed"Print "TESTCOUNT_FUNC(): "+TESTCOUNT_FUNC()Print "direct acces to Test.LIST without Instance: "+Test.LIST.Count()EndClass Test FinalGlobal LIST := New List<Test>Method AddStuff()Print "Test.AddStuff is called"Local t:=New Test()LIST.Add(t)EndFunction Count:Int()Print "Test.Count is called"Return LIST.Count()EndEndyou can run/play with the sdl2 banana to see if it’s mojo related, if you still see your micro stutter then you’d probably have to play with xcode and try to get something working out of pure opengl without GC (or sdl2+opengl too)…? I doubt mx2’s GC does those stutters though. I think it’s probably sdl2 too..
Then when you find the source of the hiccups PLEASE make a Pull Request to the corresponding community and enhance the world of game dev!
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103#import "<sdl2>"#Import "<opengl>"Namespace sdl2testUsing sdl2..Using opengl..Class SdlWindowField sdlWindow:SDL_Window PtrField sdlGLContext:SDL_GLContextField incrementer:=0Method New()SDL_Init( SDL_INIT_VIDEO )libc.atexit( SDL_Quit )SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_PROFILE_ES )'COMPATIBILITY )SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION,2 )SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION,1 )SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER,1 )SDL_GL_SetAttribute( SDL_GL_RED_SIZE,8 )SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE,8 )SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE,8 )sdlWindow=SDL_CreateWindow( "SDL2 OpenGL Window",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,640,480,SDL_WINDOW_OPENGL )sdlGLContext=SDL_GL_CreateContext( sdlWindow )SDL_GL_MakeCurrent( sdlWindow,sdlGLContext )bbglInit()EndMethod Run()RepeatLocal event:SDL_EventWhile( SDL_PollEvent( Varptr event ) )Select event.typeCase SDL_WINDOWEVENTLocal wevent:=Cast<SDL_WindowEvent Ptr>( Varptr event )Select wevent->eventCase SDL_WINDOWEVENT_CLOSElibc.exit_(0)EndEndWendOnRender()SDL_GL_SwapWindow( sdlWindow )ForeverEndMethod OnRender()glClearColor( 1,1,0,1 )glClear( GL_COLOR_BUFFER_BIT )glEnable( GL_SCISSOR_TEST )For Local y:=0 Until 256glScissor( incrementer,y,640,1 )glClearColor( y/256.0,0,0,1 )glClear( GL_COLOR_BUFFER_BIT )Nextincrementer+=1If incrementer=620 Then incrementer=0glDisable( GL_SCISSOR_TEST )EndEndFunction Main()Local window:=New SdlWindowwindow.Run()EndYou code is stressing the computer due to lots of canvas work. Where is the limit? Is any app having jitters? Do you have jitters with this code for example?(I don’t):
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField i:=0Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )Fullscreen=TrueEndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()For Local k:=0 To 110For Local j:=0 To 170canvas.DrawRect(-k*40-90+i+80*j,5+k*40,40,40)NextNexti+=1If i=80 Then i=0canvas.Color=Color.Blackcanvas.DrawText( "Hello World! FPS:"+App.FPS,50+Width/2,50+Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndThis had changed some months ago. I think it’s to avoid calling uninitialized fields..
If you read the December blog post, there’s a explanation on how to use mojo/mojo3d with pure opengl drivers. It could help your need of a perfectly running machine!?
Cool that you go to the R-Pi way..
-
AuthorPosts