Forum Replies Created
-
AuthorPosts
-
I try to visualize it and learn by mx2 codes.
And found this text about a array with struct
<div class=”post-text”>struct
An array of values v encoded by a struct (value type) looks like this in memory:
vvvv
class
An array of values v encoded by a class (reference type) look like this:
pppp
..v..v…v.v..
where p are the this pointers, or references, which point to the actual values v on the heap. The dots indicate other objects that may be interspersed on the heap. In the case of reference types you need to reference v via the corresponding p, in the case of value types you can get the value directly via its offset in the array.
</div>
I don’t see it yet haha, I know the point about a reference and non reference.
So a struct don’t cost memory because it will reset after a loop, and will use only memory when it is used by me inside a loop ?
While a Class Field is used from the beginning till the end of the program.
Look at this not working example
Normally I want to keep a postion X and Y and update this every loop.
Is it better/faster to keep it in a struct.Monkey1234567891011121314151617181920212223242526Class MojoTest Extends WindowField posX:Float ' it cost memory nowMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()' posX is still using memory' lot of code hereLocal blaX:Float ' decl. is using memoryLocal inst:=New TheStruct ' (decl.) only at this point a struct is using memoryinst.posX=MOUSEX()blaX=MOUSEX() ' only at this point a Local is using memory (same as struct)posX=MOUSEX() ' reference to the memory and update the valueEndStruct TheStructField posX:FloatEndEndCan I say, A Struct acts just a Local but you can store Fields inside them.
It is only using memory when you declare them, and it is resetting after a loop.If you want to use a variable in multiple classes then maybe you can make a global struct.
And maybe the struct will use memory if a function is using the global struct, but mostly not.Would be cool if someone explain the need about structs.
When do you need them and are the a lot faster then a class ?With my background using C# and python,monkey1,javascript,nodejs I never needed them.
http://monkey2.monkey-x.com/language-reference/
To declare a struct:
Struct Identifier
[/crayon]Monkey1[crayon-5cb9e31dda02d771909902 inline="true" ] ...Struct members...End
A struct can contain consts, globals, fields, methods, functions and other user defined types.
Structs are similar to classes, but differ in several important ways:
- A struct is a ‘value type’, whereas a class is a ‘reference type’. This means that when you assign a struct to a variable, pass a struct to a function or return a struct from a function, the entire struct is copied in the process. —– what does this mean ?
- Stucts are statically typed, whereas classes are dynamically typed.
- Struct methods cannot be virtual.
- A struct cannot extend anything.
Feng shui
I total agree with you except I do need a little more then just program.
For example that correct nice font in the editor, or that background color and syntax color.These things make it (for me) more fun to program.
But at the root level, its the idea of making (program) that thing you want.
(using a good documentation / forum with feedback)Example please, is it slow Device proof ?
I want to try something new, a fresh start using mx2.
But as you can see I had some trouble with getting the most important thing oke, fps.
is the way mx2 handle a render/update setframerate the same ?
I hope that someone create (maybe mark) a good tutorial about
deltatime / framerate / oprender / update in MX2
A year ago I was using this for Monkey1 but I don’t know what now the best use is using MX2
https://github.com/Regal-Internet-Brothers/deltatime
Some tests using deltatime with huge ‘strange’ things
http://www.monkey-x.com/Community/posts.php?topic=9918&post=107293&view=all#107293
I’m new at using git, and now i’m wondering what will happen with the modified files by AdamStrange.
Is he using the latest ted source using pull , and can he / access to upload/overwrite the official Ted source ?
Or will this be a source at his git only, so there are now two versions about ted ?
This would be weird because Mark is the ‘boss’ about Ted and can make fast changes.
When he make a change , then the other ted is not oke anymore.Or will this live as a fork within the official source ?
yep working
* coming
I forget to say
.tree-leaf .tree-leaf-text {
/* margin-left: 8px; */
/* line-height: 2em; */
}so its only:
.tree-leaf .tree-expando.expanded {}
.tree-leaf .tree-leaf-text {}
.tree-leaf .tree-expando {
color: #9B4DCA;
cursor: pointer;
float: left;
}Ah I see now, I had many files inside a directory and din’t see that there was already a monkey2 (very old one)
now its working oke.
I see that TED2 is not alive anymore in this release, you can’t do everything once
“/Users/gcmartijn/Downloads/monkey2/bin/mx2cc_macos” makeapp -target=Desktop -config=Debug “/Users/gcmartijn/Downloads/monkey2-master/tests/monkey/classes.monkey2”
MX2CC monkey2 compiler V0.001
sh: tmp.txt: Permission denied
Can’t find gcc – please install gcc tools or update your bin/env.txt file
Done.
no still the same problem.
Its just to let you know about this.***** Rebuilding modules *****
MX2CC V0.002
***** Making module ‘monkey’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/monkey/monkey.buildv002/desktop_release_macos/monkey.a***** Making module ‘libc’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/libc/libc.buildv002/desktop_release_macos/libc.a***** Making module ‘miniz’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/miniz/miniz.buildv002/desktop_release_macos/miniz.a***** Making module ‘hoedown’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/hoedown/hoedown.buildv002/desktop_release_macos/hoedown.a***** Making module ‘stb-image’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/stb-image/stb-image.buildv002/desktop_release_macos/stb-image.a***** Making module ‘stb-truetype’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/stb-truetype/stb-truetype.buildv002/desktop_release_macos/stb-truetype.a***** Making module ‘std’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/std/std.buildv002/desktop_release_macos/std.a***** Making module ‘gles20’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/gles20/gles20.buildv002/desktop_release_macos/gles20.a***** Making module ‘sdl2’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/sdl2/sdl2.buildv002/desktop_release_macos/sdl2.a***** Making module ‘sdl2-mixer’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/sdl2-mixer/sdl2-mixer.buildv002/desktop_release_macos/sdl2-mixer.a
MX2CC V0.002***** Making module ‘monkey’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/monkey/monkey.buildv002/desktop_debug_macos/monkey.a***** Making module ‘libc’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/libc/libc.buildv002/desktop_debug_macos/libc.a***** Making module ‘miniz’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/miniz/miniz.buildv002/desktop_debug_macos/miniz.a***** Making module ‘hoedown’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/hoedown/hoedown.buildv002/desktop_debug_macos/hoedown.a***** Making module ‘stb-image’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/stb-image/stb-image.buildv002/desktop_debug_macos/stb-image.a***** Making module ‘stb-truetype’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/stb-truetype/stb-truetype.buildv002/desktop_debug_macos/stb-truetype.a***** Making module ‘std’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/std/std.buildv002/desktop_debug_macos/std.a***** Making module ‘gles20’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/gles20/gles20.buildv002/desktop_debug_macos/gles20.a***** Making module ‘sdl2’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/sdl2/sdl2.buildv002/desktop_debug_macos/sdl2.a***** Making module ‘sdl2-mixer’ *****
Parsing…
Semanting…
Translating…
Compiling….
Archiving /Users/gcmartijn/Downloads/monkey2-master/modules/sdl2-mixer/sdl2-mixer.buildv002/desktop_debug_macos/sdl2-mixer.a***** Rebuilding mx2cc *****
MX2CC V0.002
***** Building app ‘/Users/gcmartijn/Downloads/monkey2-master/src/mx2new/mx2cc.monkey2’ *****
Parsing…
Semanting…
Translating…
Compiling….
Linking /Users/gcmartijn/Downloads/monkey2-master/src/mx2new/mx2cc.buildv002/desktop_release_macos/mx2cc.app/Contents/MacOS/mx2cc
MX2CC V0.002
Usage: mx2cc makeapp|makemods|makedocs [-run] [-clean] [-verbose] [-target=desktop|emscripten] [-config=debug|release] source|modules…
MX2CC V0.002***** Doccing module ‘monkey’ *****
Parsing…
Semanting…***** Doccing module ‘libc’ *****
Parsing…
Semanting…***** Doccing module ‘std’ *****
Parsing…
Semanting…
gcmartijn:src gcmartijn$ “/Users/gcmartijn/Downloads/monkey2/bin/mx2cc_macos” makeapp -target=Desktop -config=Debug “/Users/gcmartijn/Downloads/monkey2-master/tests/monkey/classes.monkey2”MX2CC monkey2 compiler V0.001
sh: tmp.txt: Permission denied
Can’t find gcc – please install gcc tools or update your bin/env.txt fileI thought everyone uses a release, found here:
https://github.com/blitz-research/monkey2/releases
Going to download this now
https://github.com/blitz-research/monkey2/archive/master.zip
maybe its better to delete that release version to keep only one download link.
Its readable and fresh
keep it for now
-
AuthorPosts