About Monkey 2 › Forums › Monkey 2 Development › First Impressions
This topic contains 16 replies, has 7 voices, and was last updated by
Simon Armstrong 2 years, 10 months ago.
-
AuthorPosts
-
June 19, 2016 at 7:44 am #1168
After having my first afternoon of monkey2 programming I have come to the following conclusions.
- I need an editor with % $ and and # keys mapped to :Int :String and :Float macros
- I must learn to type brackets for every command invocation
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105#Import "<std>"#Import "<mojo>"Using std..Using mojo..Global instance:AppInstanceClass VPaint Extends WindowField image:ImageField canvas1:CanvasField mousex:IntField mousey:IntField framecount:IntMethod New(title:String)Super.New(title,640,340)image=New Image(2048,2048,TextureFlags.Dynamic)canvas1=New Canvas(image)canvas1.Alpha=0.5ClearColor=Color.BlackEndMethod OnRender( display:Canvas ) OverrideApp.RequestRender()If framecount=0Endifcanvas1.Flush()display.DrawImage( image, 0,0)framecount+=1EndMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownSelect event.KeyCase Key.Escapeinstance.Terminate()Case Key.F1Fullscreen = Not FullscreenEndEndEndMethod FatLine(x:Int,y:Int,x1:Int,y1:Int)Local fat:Int=3If Not canvas1 ReturnLocal verts:=New Float[8]Local dy:Int=y1-yLocal dx:Int=x1-xLocal len:Float=Sqrt(dx*dx+dy*dy)Local q:Float=fat/lenverts[0]=x+dy*qverts[1]=y-dx*qverts[2]=x1+dy*qverts[3]=y1-dx*qverts[4]=x1-dy*qverts[5]=y1+dx*qverts[6]=x-dy*qverts[7]=y+dx*qcanvas1.DrawPoly(verts)EndMethod OnMouseEvent(event:MouseEvent ) OverrideLocal mx:IntLocal my:Intmx=event.Location.Xmy=event.Location.YFatLine(mousex,mousey,mx,my)' Print "OnMouseEvent mx="+mx+" my="+mymousex=mxmousey=myEndEndGlobal title:String="VPaint 0.0"Function Main()Print titleinstance = New AppInstanceNew VPaint(title)App.Run()End'Method DrawIndexedPrimitives : Void ( order:Int, count:Int, vertices:Float[], texcoords:Float[], indices:Int[], material:Material=Null )June 19, 2016 at 8:30 am #1170Part 2, structs aren’t primitives, even though you can do operations on them without initialisation you need to new instances before they actually work.
June 19, 2016 at 8:52 am #1171something is wrong here
/Users/simon/Desktop/m1.monkey2 [23] : Error : Type ‘std.graphics.Color’ has no member named ‘Brown’
June 19, 2016 at 12:35 pm #1172Talking about Ted2, the hotkey I am missing a lot is CTRL + D to duplicate a line.
Visual Studio also has the nice feature to copy the whole line when you press CTRL + C and nothing is selected.
I also showed monkey2 to someone and he disliked the fact that the [x] for closing documents does not stand out little more. It’s pretty much atom like but for a person not used to might be worth making it a little more visible. It is also not noticable which file is currently opened which could become a little confusing when the project grows larger.
June 19, 2016 at 3:40 pm #1176Speaking of ted2, has it disappeared? Just went to try and build it/try it, but src/ted2 doesn’t exist!
June 19, 2016 at 4:06 pm #1177The version I am using is the one from the christmas demo, just copied the ted2.exe and bin/ted2.exe.
Mark said somewhere that one could use ted1 also esp. because it has the debug buttons.
June 19, 2016 at 5:03 pm #1178Personally, I thing Ted 2 is awful. There, I said it. I am using sublime text with a new language file. Works like a charm!
June 20, 2016 at 1:11 am #1184I am having way more fun than expected and am now laying down catmull interpolated mouse movements in my vpaint project. Latest source here:
https://github.com/nitrologic/m2
June 20, 2016 at 2:53 pm #1190Does anyone know of any IDE’s that either support now or will support MX2 soon? I know there is TED 2 and Mollusk, but what others are being worked on? Would be good to have some choice when MX2 is released.
June 20, 2016 at 9:03 pm #1192I need an editor with % $ and and # keys mapped to :Int :String and :Float
You may wanna try using := for variable assignments, like:
Monkey1234Field name := "Object" 'This is a stringField speed := New Vec2f 'This is a Vec2<Float>Field health := 100 'This is an IntField damage := 10.0 'This is a FloatJune 20, 2016 at 9:15 pm #1193Thanks Ethernaut, style improvement ahead.
:= could be the new monkey2 emoticon
Regarding the IDE, I started the week (yesterday NZT) thinking I can make it through a week with Monkey-X Ted. I need to navigate to errors and no sign of debugger so I suspect I am in need of an upgrade.
Would prefer to be using monkey2 native editor as it blew me away watching Mark coding on it / in it earlier in the year.
and starting to wonder if I want cursor keys to perhaps ignore white/brown space.
:= monkey2
June 20, 2016 at 11:23 pm #1194Of course when you use type inference like this you always have to assign a default value to the variable, but I feel like that is actually easy to understand when you look at someone else’s code.
Oh, and I’ve been using Mollusk as the IDE. Doesn’t officially support M2 yet, but it works pretty well already.
June 21, 2016 at 1:17 am #1195I got sidetracked and wanted to find out how modules worked.
First Box2D test successful!
Monkey123456789101112131415161718#Import "<std>"#Import "<mojo>"#Import "<box2d>"Using std..Function Main()Print "monkey2 box2d test"Local down:=New box2d.b2Vec2(0,20)Local world:=New box2d.b2World(down)Local g:=world.GetGravity()Print "gravity="+g.x+","+g.yEndJune 21, 2016 at 3:10 am #1197Cool!
Is it a mx2 version of box2d or an externed version?
Since MX2 can import C++ files, it might be better to use 3rd party libs in their native form:
https://github.com/erincatto/Box2D
June 21, 2016 at 4:05 am #1198Yes, I am using original C++ source.
-
AuthorPosts
You must be logged in to reply to this topic.