Forum Replies Created
-
AuthorPosts
-
I’m lovin’ it! 
Random thoughts and ideas – Posting #4
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113[crayon-5cb9b54fdc894167665957 inline="true" ]If [expression][statements]ElseIf [expression][statements]Else[statements]EndIfIf [expression] Then [statement]If [expression] Then [statement] Else [statement]' If you want to allow 'Then' for blocks:If [expression] Then [end-of-line][statements]EndIf'' Multiple statements in single-liners (separated by comma)?'If [expression] Then [statement1], [statement2], [statement3]If [expression] Then [statement1], [statement2], [statement3] Else [statement1], [statement2], [statement3]'' multiple [statement] separated by comma is a [statement-list]'If [expression] Then [statement-list]If [expression] Then [statement-list] Else [statement-list]'' Same for For..Next'For local value:=Eachin valuessum+=valueNext [opt:var]For local value:=Eachin values Do [statement-list]For local value:=Eachin values Do sum+=valueFor local value:= 1 To 10 Do sum+=value ' [statement-list]For local value:= 1 To 10 Do sum+=valueFor local value:= 10 DownTo 1 Do sum+=value'' While..Wend'While [expression][statements]WendWhile [expression] Do [statement]While [expression] Do [statement1], [statement2], [statement3]' becomes:While [expression] Do [statement-list]While function()=0 Do count+=1'' 'Do' and 'Repeat''' (same thing with different linguistics for supporting differentiated thinking' and enunciation/phrasing -> freedom of mind to express thoughts in code)'Do [end-of-line][statements]While [expression]Do [end-of-line][statements]Until [expression]Do [end-of-line][statements]ForeverDo [statement] While [expression]Do [statement] Until [expression]Do [statement] ForeverDo [statement1], [statement2], [statement3] While [expression]Do [statement1], [statement2], [statement3] Until [expression]Do [statement1], [statement2], [statement3] ForeverDo [statement-list] While [expression]Do [statement-list] Until [expression]Do [statement-list] ForeverRepeat [end-of-line][statements]While [expression]Repeat [end-of-line][statements]Until [expression]Repeat [end-of-line][statements]ForeverRepeat [statement] While [expression]Repeat [statement] Until [expression]Repeat [statement] ForeverRepeat [statement1], [statement2], [statement3] While [expression]Repeat [statement1], [statement2], [statement3] Until [expression]Repeat [statement1], [statement2], [statement3] ForeverRepeat [statement-list] While [expression]Repeat [statement-list] Until [expression]Repeat [statement-list] ForeverIt would be really nice if we can compile some guidelines when structs are preferred over classes and when not. I’m struggling with that kind of stuff.
For flexibility, you can duplicate everything. CPoint/SPoint, etc.
Sometimes you want to use a specific type as Struct on stack,
other times as garbage-collected Class-Pointer.MX2 classes are always used as/with pointers in C++,
so no struct on stack. And the pointer is added to the Garbage Collector.
Beside that, AFAIK the only difference between struct/class in C++
is the default access specifier (struct is all public by default).Mark Sibly wrote:
You can’t. The render canvas is ‘special’, and I want to make sure it’s state is not changed behind my back, and that I can change it on the fly if necessary (ie: you may not always get the same canvas in ‘OnRender’) for future features.
So, if the canvas doesn’t preserve all states, it would be:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455Namespace test#Import "<std>"#Import "<mojo>"Using std..Using mojo..#Import "assets/sprites.png"#Import "assets/arcade.ttf"Class MyTest Extends WindowField i:ImageField myFont:FontMethod New()' this sets title. no other way to do this.'Super.New("Test!!!")Title = "Test!!!" ' Title is a property in class Windowi = Image.Load("asset::sprites.png")' Check for NullIf i <> Nulli.Handle = New Vec2f(0.0, 0.5)Endif'Later in MX2, the Null-Check would be as easy as that:' i?.Handle = New Vec2f(0.0, 0.5)ClearColor=New Color( 1,1,0 )myFont = Font.Load( "asset::arcade.ttf", 10 )End MethodMethod OnRender( canvas:Canvas ) Overridecanvas.Font = myFontApp.RequestRender()End MethodEnd ClassFunction Main:Void()New AppInstanceNew MyTestApp.Run()End FunctionTry something like this…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960Namespace test#Import "<std>"#Import "<mojo>"Using std..Using mojo..#Import "assets/sprites.png"#Import "assets/arcade.ttf"Class MyTest Extends WindowField initialized:BoolField i:ImageMethod New()' this sets title. no other way to do this.'Super.New("Test!!!")Title = "Test!!!" ' Title is a property in class Windowi = Image.Load("asset::sprites.png")' Check for NullIf i <> Nulli.Handle = New Vec2f(0.0, 0.5)Endif'Later in MX2, the Null-Check would be as easy as that:' i?.Handle = New Vec2f(0.0, 0.5)ClearColor=New Color( 1,1,0 )End MethodMethod Init(canvas:Canvas)canvas.Font = Font.Load( "asset::arcade.ttf", 10 )initialized = TrueEnd MethodMethod OnRender( canvas:Canvas ) OverrideIf Not initialized Then Init(canvas)App.RequestRender()End MethodEnd ClassFunction Main:Void()New AppInstanceNew MyTestApp.Run()End Functionwiebow:
Your ‘Field canvas:Canvas’ is not initialized by using ‘New’
or a getter function/method. Means ‘canvas’ is Null, and you
write to canvas.FontIf ‘i = Image.Load()’ returns Null, accessing ‘i.Handle’ would
also crash (at least if they are Classes, not so with Structs).wiebow:
Mollusk is for Windows and Mac OS X. Don’t know why not Linux.RetroRusty:
Mollusk works with MX2 already.
Debug mode doesn’t work currently, and MX2 debugger is still in development,
but otherwise Mollusk is good for editing and running MX2 codes.
AFAIK grudlux is already working on the next version.What about adding DownTo (additional to ‘Step -1’)?
[/crayon]Monkey1234567891011[crayon-5cb9b55004888949510239 inline="true" ]Function Main()For Local x:Int = 5 DownTo 1Print xNextFor Local y:Int = 10 DownTo 0 Step 2Print yNextEnd[/crayon]Monkey123456789101112[crayon-5cb9b5500488e955523416 inline="true" ]Function Main()Local:Int x,yFor x = 5 DownTo 1Print xNextFor y = 10 DownTo 0 Step 2Print yNextEnd -
AuthorPosts