About Monkey 2 › Forums › Monkey 2 Programming Help › How do you put Data in the code?
Tagged: Data
This topic contains 3 replies, has 3 voices, and was last updated by
cocon 2 years, 5 months ago.
-
AuthorPosts
-
November 17, 2016 at 1:23 pm #5149
In Blitz I would use Data 0,0,0 ect
In Monkey I would use the arrays to set up fields of data.
In Monkey2 I have not found a way yet on how to include/edit data for for instance a tilemap or brushes.
I also noticed that you can not use + to split strings so I was not able to create data in strings with that.
Is there already something I am missing? Or is something coming or does something need to be requested?
A small example of a 3 by 3 field of data would be cool:)
November 17, 2016 at 1:48 pm #5150I’ve just had a big array like
Monkey12345global boxVerts:Float[] = New Float[]('// vert // UV-0.5, -0.5, -0.5, 0.0, 0.0,...snip...-0.5, -0.5, -0.5, 0.0, 0.0)just tidy it away in another file and import it
failing that you could just load the data png etc via the appropriate module see: http://monkey2.monkey-x.com/mx2-docs/std-std-graphics-pixmap-load/#comment-158
November 17, 2016 at 2:00 pm #5152I just did this. Seems to work to.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField m:= New String[3]Method New()m[0] = "000"m[1] = "010"m[2] = "000"End MethodMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender() ' Activate this method'canvas.Clear(Color.White)For Local y:=0 To 2For Local x:=0 To 2canvas.Color = Color.Blackcanvas.DrawRect(x*32+100,y*32+100,32,32)If m[y][x] = 48 Thencanvas.Color = Color.Greencanvas.DrawText("X",x*32+100,y*32+100)End IfIf m[y][x] = 49 Thencanvas.Color = Color.Bluecanvas.DrawText("X",x*32+100,y*32+100)End IfNextNext' if key escape then quitIf Keyboard.KeyReleased(Key.Escape) Then App.Terminate()End MethodEnd ClassFunction Main()New AppInstanceNew MyWindowApp.Run()End FunctionI want to keep certain code projects in a single text file so I can put it online on blogs and github and such.
November 17, 2016 at 9:09 pm #5172Very cool, is there any command to parse numbers from binary? How about creating a binary array?
-
AuthorPosts
You must be logged in to reply to this topic.