Forum Replies Created
-
AuthorPosts
-
December 7, 2017 at 6:50 pm in reply to: Free way to donate to your favorite content creators #12195
Well worth being an early adopter on some of these new crypto’s I think. Lots of scams out there though so you have to be careful, BAT looks ok though and a good idea. Another one I was keeping an eye on is fundrequest (https://fundrequest.io/), which will be a way of being paid to solve issues on github and stack exchange. So if there’s an issue or feature request on monkey2 github then multiple people can raise money to get it implemented if that’s a priority for them. Could be great for open source projects.
Patreon’d, keep up the good work
This is really cool!
I have an issue on MacBook when using a second monitor. The IDE displays fine on the laptop but if I drag the window onto the monitor then it gets clipped (see attachment). I guessing this is something to do with the fact that the displays have different resolutions, the MacBook is retina 2880 x 1800 and the monitor is 2560 x 1440.
Let me know if there’s a specific place in the code I can take a look and help debug if needed.
Attachments:
That’s really interesting, something worth bearing in mind when optimising. Here’s a modified version where each bunny image is put into it’s own separate stack and drawn one after the other. I get over 230k before the fps goes lower than 60. Does have the disadvantage in that one type of bunny (red in this case) gets drawn over the top of the others but that’s where you’d switch to an atlas if that was an issue I guess.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132Namespace bunnies' Load up the assets#Import "assets/wabbit_alpha.png"#Import "assets/wabbit_alpha2.png"#Import "assets/wabbit_alpha3.png"#Import "assets/wabbit_alpha4.png"' Load up imports#Import "<std>"#Import "<mojo>"Using std..Using mojo..Const VWIDTH:=1024Const VHEIGHT:=768Class Bunnymark Extends WindowField frames: Int = 1Field elapsed: Int = 1Field bunnies:Stack<Bunny>[] = New Stack<Bunny>[4]Field images:Image[] = New Image[](Image.Load("asset::wabbit_alpha.png"),Image.Load("asset::wabbit_alpha2.png"),Image.Load("asset::wabbit_alpha3.png"),Image.Load("asset::wabbit_alpha4.png") )Field lastMilli := Millisecs()Method New()Super.New("Bunnymark", VWIDTH, VHEIGHT, WindowFlags.Resizable )Local tmpimage:=Floor( random.Rnd( 3 ))For Local i:=0 Until bunnies.Lengthbunnies[i] = New Stack<Bunny>EndEndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender() ' Activate this methodIf Keyboard.KeyReleased(Key.Escape) Then App.Terminate()Local bunnycount:IntFor Local s:=Eachin bunniesFor Local bunny:=Eachin sbunny.Update()bunny.Draw(canvas)bunnycount+=1NextNext'elapsed += Millisecs() - lastMilli'Local avg := 1000/( ( elapsed /Float(frames)) ) '- not recquired anymore thanks to App.FPScanvas.Color = Color.Whitecanvas.DrawRect( 0, 0, VWIDTH, 25 )canvas.Color = Color.Blackcanvas.DrawText("The Bunnymark ( " + bunnycount + " )",0,0)canvas.DrawText(" FPS: " + App.FPS, 300, 0 ) ' App.FPS suggested by abakobo#rem frames += 1If frames > 100 ' makeshift FPS counter not necessaryframes = 1elapsed = 1EndiflastMilli = Millisecs()#endEnd MethodMethod OnMouseEvent( event:MouseEvent ) OverrideIf event.Type = EventType.MouseDownLocal _len := 0If event.Button = MouseButton.Left_len = 10Elseif event.Button = MouseButton.Right_len = 10000Elseif event.Button = MouseButton.Middle_len = -100End' Extra functionality ( RightButton / Middle ) added by @therevillsLocal tmpimage:IntFor Local i:=1 Until _len + 1tmpimage = Floor( random.Rnd( 3 ))bunnies[ tmpimage ].Add( New Bunny( Mouse.X, Mouse.Y, images[ tmpimage ] ) )EndEndEnd MethodEndClass BunnyField x: FloatField y: FloatField xspeed: FloatField yspeed: FloatField texture: ImageGlobal gravity := 0.5Method New( x: Float, y: Float, texture:Image )Self.x = xSelf.y = ySelf.texture = texturexspeed = random.Rnd( 10 )EndMethod Update:Void( )yspeed += gravityy += yspeedx += xspeedIf y >= VHEIGHTy = VHEIGHTyspeed = -random.Rnd( 35 )EndifIf x < 0 Or x > VWIDTHxspeed *= -1x = Clamp(x, 0.0, Float(VWIDTH) )EndifEndMethod Draw(canvas:Canvas)canvas.DrawImage( texture, x, y )EndEndFunction Main()New AppInstanceNew BunnymarkApp.Run()End FunctionHmm, this seems very slow to me. I tried it and it only got to 4-5k before the frame rate started to drop which doesn’t seem right. After a bit of experimenting if I changed it to only draw one type of bunny I got up to 200k at 60fps. Surely something must be amiss here under the hood? Or is it to do with drawing different textures? Maybe try with the bunnies packed into a single sprite sheet. Maybe mojo can be optimised here somehow?
Thanks Nerobot/Mark, I guess I should look into doing it via a theme instead then, that looks like the cleanest way of doing it.
And yes I noticed that F1 doesn’t always show the docs (sometimes it does work though)
Thanks nerobot. I was just trying to do this in code like:
Monkey123Local newStyle := filemenu.Style.Copy()newStyle.Font = SCEditor.Robotofilemenu.Style = newStyleCan you do it like that? I tried on the menu and menu bar but nothing changed. I know the font is loaded ok because the same code is working on the render view.
Thanks, I had seen that thread but didn’t notice the stuff about layout. So basically use a flag for the initial layout, that’s fair enough.
Still haven’t worked out this though: How do I change the font of the menus? I can change the font of other views ok using styles but the same method doesn’t seem to be working for menus.
Is there an event that I can hook into that I can initialise certain things after the width and height of the view has been calculated?
At the moment if I try and set something up where I need to know the calculated width and height of the view I can’t put it in New() because width and height are both 0 at that point. OnLayout seems to be called every frame. I’ll also need something like OnResize for when the window/view is resized. Or is it just a case of checking manually if the width/height have changed?
Edit: sorry might have lot’s of questions about mojox! How do I change the font of the menus? I can change the font of other views ok using styles but the same method doesn’t seem to be working for menus.
Thanks Mark, that makes a bit more sense now.
After a bit of experimenting, this seemed to work ok:
Monkey1MainView.AddView(WorldDoc, "left", "100%")If I used “100%” with “top” then that would work but the height would be set to the height of the window, not the remaining space. Not sure how you get it to set the height to the remaining space only. Not specifying any size at all meant the size was basically 0. Don’t know if that’s correct behaviour or not or if there’s some other things that I’m missing.
The font for the 2 was Mr Dafoe from google fonts btw incase you want to use it. For smaller icons I was thinking you could just write m2 as well.
That’s really cool that you can embed it like that
Doesn’t slow down here but it would be cool if you could send a sleep mode to it when not in view similar to twitter and video embeds.
Only just saw this thread but just thought I’d say I concur!
-
AuthorPosts
