About Monkey 2 › Forums › Monkey 2 Development › Constant slowdowns
This topic contains 3 replies, has 2 voices, and was last updated by
Jesse
2 years ago.
-
AuthorPosts
-
April 6, 2017 at 6:07 pm #7739
I updated to the latest build of Monkey2 and I am getting weird slowdowns on my Macbook it happens when I move the mouse in and out of the game window. I don’t know if this is just on my MacBook or on all OS’s. Can some body try this code and tell me if it does it in their system as well?
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135[crayon-5cb9cb43ad3ff135778191 inline="true" ]Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField land:LandMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )SwapInterval = 0land = New Land()land.Speed = .1EndMethod OnRender( canvas:Canvas ) Overrideland.Update()App.RequestRender()land.Render(canvas)EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndClass CameraField pos:Vec2fField width:FloatField height:FloatMethod New(x:Float,y:Float,widht:Float,height:Float)pos = New Vec2f(x,y)End MethodEnd ClassClass LandField pos:Vec2fField land:Float[]Field tileHeight:Int = 64Field n:Int = 0Field dir:Float = Rnd(-2,2)Field dur:Int = Rnd(1,2)Field stp:Float = Rnd(-2,2)Field posy:Float = 32.0Field index:Float = 0Field terrainWidth:Float = 5000Field stripWidth:Float = 4Field viewWidth:Float = 160Field minHeight:Float = 28Field terrainOffset:FloatField shift:Float = 20.0Field speed:FloatField counter:IntField done:BoolField temp:floatMethod New()land = New Float[terrainWidth]Init()End MethodMethod Init()terrainOffset = terrainWidth - shiftpos = New Vec2f(0,384)posy = 48.0For Local i:Int = 0 Until terrainWidthIf i < terrainOffsetposy+=stpIf posy < minHeight posy = minHeightIf posy > (tileHeight-minHeight) posy = (tileHeight - minHeight)dur -= 1.0If dur <= 0.0dir = Rnd(-3,3)dur = Rnd(1,5)stp = Rnd(-1,1)EndifElseIf stp > 0If posy < 48.0posy += stpEndifElseif stp < 0If posy > 32.0posy += stpEndifEndifEndifland[i] = posyNextdone = Falsespeed = 0End methodProperty Speed:Void(spd:Float)speed = spdEndMethod Update:void()index = (index + speed)index = index Mod land.LengthEnd MethodMethod Render:Void(canvas:Canvas)canvas.Color= New Color(0,.47,0)For Local i:Float = 0 Until viewWidthLocal n:Float = land[(index+i) Mod land.Length]canvas.DrawRect(i*stripWidth,pos.y+n,stripWidth,tileHeight-n)If n >= viewWidthExitEndifNextEnd MethodEnd ClassApril 6, 2017 at 6:32 pm #7741Hey, it runs ok for me, no slowdown when moving the mouse cursor in and out of the window.
On linux here, using xubuntu 16.04.
April 6, 2017 at 8:41 pm #7744Thanks for testing it. Do you have the latest from Github either the Development or the Master version?
I think it has to do with the printing of the mouse events to the console. I will remove the print from the Touch input files to see if it solves it.
I will report back.
April 6, 2017 at 9:48 pm #7745Yea, that was it.
-
AuthorPosts
You must be logged in to reply to this topic.