Forum Replies Created
-
AuthorPosts
-
For me it makes sense because the default constructor is the initialization. And every base ‘typed’ objects should be initialized properly..
But sometimes it not logical, in the following example the new(i:int) from base does not call default constructor but new(i:int) from extended does…
Dunno what to think about this[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142[crayon-5cba9ce4e9063386200926 inline="true" ]Class baseMethod New()Print "base new"'general initilisation for all base objectsEnd MethodMethod New(i:int)' virtual not necessary with new !?Print "base new"+iEnd MethodMethod amethod() VirtualPrint "base method"End MethodEnd ClassClass extended Extends baseMethod New() overridePrint "extended new"End MethodMethod New(i:int) overridePrint "extended new"+iEnd MethodMethod amethod() OverridePrint "extended method"End MethodEnd ClassFunction Main()Local b:base = New base(7)Print "-----"Local e:extended = New extended(1)Print "-----"Local b2:base = New base()Print "-----"Local e2:extended = New extended()Print "-----"b.amethod()Print "-----"e.amethod()Print "-----"End FunctionHi
I’ve had a quick look on pyro2, it looks great!
I was using ignitionX before switching to MX2. In that framework there was a poly-line collision type that I could not see on pyro2.
Is it somewhere? Do you plan to add it to pyro2? (it was my most used collision type, way faster than pixel-perfect).Is there any gitHub I can fork? I’d like to test some mods on it..
Indeed
Yes and no ;P, but i thought that it would create a full copy so the pass by value would be consistent..
In my experience the order of fastness is:
1-primitive
2-struct field
3-struct propertyso avoid properties if it is not necessary
I played along with optimisation in this example: https://github.com/abakobo/learn_monkey2/tree/master/julia
The most optimised version I could get is not using structs because primitives where faster..
In the struct_non_optim example you can try 3 different manners to use structs with 3 very different speeds (by uncommenting/commenting). Field being the fastest one.And here a little bit of code to illustrate the speed difference between struc and class with a simple object case:
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107[crayon-5cba9ce4f2fe9738206400 inline="true" ]#Import "<std>"Using std..Struct structorField x:IntField y:IntMethod New(a:Int,b:Int)x=ay=bEndMethod Add:Int()Return x+yEndEndClass classorField x:IntField y:IntMethod New(a:Int,b:Int)x=ay=bEndMethod Add:int()Return x+yEndEndFunction adds:int(a:Int,s:structor)Return a+s.Add()EndFunction addc:Int(a:Int,c:classor)Return a+c.Add()EndGlobal ii:=2000Global jj:=2000Function Main()Local t:IntLocal ta:IntLocal add:IntLocal c:classorLocal s:structorta=Millisecs()For Local j:=0 until jjFor Local i:=0 until iis=New structor (i+1,j+1)add=s.Add()Repeatadd=add+s.Add()Until add>2000000NextNextt=Millisecs()-taPrint "time struct: "+tta=Millisecs()For Local j:=0 Until jjFor Local i:=0 Until iic=New classor (i+1,j+1)add=c.Add()Repeatadd=add+c.Add()Until add>2000000NextNextt=Millisecs()-taPrint "time class: "+tta=Millisecs()For Local j:=0 until jjFor Local i:=0 until iis=New structor (i+1,j+1)add=s.Add()Repeatadd=adds(add,s)Until add>2000000NextNextt=Millisecs()-taPrint "time struct tru func (by value): "+tta=Millisecs()For Local j:=0 Until jjFor Local i:=0 Until iic=New classor (i+1,j+1)add=c.Add()Repeatadd=addc(add,c)Until add>2000000NextNextt=Millisecs()-taPrint "time class tru func (by ref): "+tEndOnline based is sometimes very usable to me.
For me that kind of wiki is a great kind of resource:
http://wiki.osdev.org/Main_Page.
This example is covering one of the most difficult thing to do in development/coding and is still readable.IMHO a wiki is the way to go for tutorials, language reference, beginner manual, specific manuals…
Modifying/adding the code of ‘#rem monkeydoc’ to get valuable infos is a bit problematic because it would need to fork mark’s repo and constantly update his work to get community work usable with F1. Though doable with some manual commits sometimes?
Or maybe linking F1 search to another base manual.The example of litehtml is one of the worst situation because there is no in-code ‘///’ docs.
For chipmunnk there is some ‘///’ docs doxygen style but c2mx2 is not copying them to ‘#rem monkeydoc’. I suppose it’s possible but don’t know how clanglib works.So creating a struct and passing it around instead of primitives is basically the same as both the primitives and structs are “pass by value”.
Yep. And using Structs is generaly a bit faster than classes as it is put on the stack and not on the heap.
The main doc weakness is IMO the language reference. Because some part of it are on the blog or even in forum answers.
A wiki would be a great community initiative. I’m in. I already made some little examples about externals and other things like that.
And making such doc is probably the best way to learn/master the language.
My dream doc is a doc with as much running examples as possible..Directory not found often means that the path is too long.
Try to put you dir not too far from the root dir of you disk..Do you have a github repo or another sharing method?
I’d like to try it and maybe report to mark if I can find something…Eeeks. That kind of bit shifting is so ugly..
With a fast look I see that oldseed is sometimes a short and sometimes a uint.. Is it normal?
In that kind of code we are supposed to see only unsigned things don’t we? (index i signed too)how close to blitzmax is it going to be? I never used monkey one as Max still works but struts
I never used Max…
and there is a precompiled lib could I bring this into monkey2? as I couldn’t get it to work with max
Theoretically Yes but it may require a lot of work depending on the size and complications you’ll encounter
from the docs:
System Imports
System files are files that are generally provided with the compiler toolset, and that the compiler and/or linker are configured to find automatically. Monkey2 recognizes the following system file types:
System file type suffix————System file type
.o, .obj, .a, .lib—————–Static library.
.so, .dll, .dylib——————Dynamic library.
.framework————————-MacOS framework.
.h, .hh, .hpp———————-C/C++/Objective C header.
.monkey2—————————Monkey2 module.also has any one redone the nehe tuts yet
Don’t know for Nehe but some people played with Opengl/monkey2 if you look in the formus..
For basic Monkey2 there’s this one :
https://github.com/Pakz001/Monkey2examplesAnd the bananas, examples in the official monkey2 releases (I think there’s some opengl stuff in there?):
https://github.com/blitz-research/monkey2/tree/master/bananasI also put most of my learning examples in a repo but it’s just some specific little things, some for external calls:
https://github.com/abakobo/learn_monkey2There isn’t much for now. Most of what I learnt was with these or by reading most of the posts on this forum. When I have more time I hope I can start some tutos with examples and stuffs because MX2 needs it! But i’m not into GL. I like monkey because it’s at higher level than openGL..
Looks like Mark has seen your Post..
https://github.com/blitz-research/monkey2/commit/f76ff5d1097cbce36b4fcc704c68436b789aeb77
Maybe this is more of a math question than a M2 question: Is there a way to obtain the current scale factor from an existing AffineMat3?
I have the following AffineMat3 Extension for my own use:
[/crayon]Monkey12345678910111213141516171819202122232425262728293031323334[crayon-5cba9ce5191e1356446399 inline="true" ]Struct AffineMat3<T> ExtensionMethod GetScale:Vec2f()Local sxsq:=Pow(Self.i.x,2)+Pow(Self.i.y,2)Local sysq:=Pow(Self.j.x,2)+Pow(Self.j.y,2)If sxsq=sysq 'to gain calculation time because I generaly use 1:1 scalesLocal sc:=Sqrt(sxsq)Return New Vec2f (sc,sc)ElseReturn New Vec2f (Sqrt(sxsq),Sqrt(sysq))EndifEndMethod GetRotation:Float()Local f:Float=Self.j.y 'to prevent integer division giving integerIf f<>0Return ATan(-Self.i.y/f)ElsePrint "Matrix is not a valid transform, could not get Rotation" 'should throw instead of print ..?Return 0.0EndifEndMethod GetTranslation:Vec2<T>()Return Self.t ' a bit basic but it makes all three methods being a logical groupEndEndIt’s Based on this answer: http://stackoverflow.com/questions/4361242/extract-rotation-scale-values-from-2d-transformation-matrix
But I had to change the rotation sign for Axis convention reasons I suppose.
If you use only 1:1 scales you will have a consistent GetScale() value whatever transforms order you make. If not then the length of the scale will be consistent but you won’t be able to find your original scale if you made a rotation in the “wrong” order..
So “USER” has to be converted to a cstring
looks like it’s implicitly converting on this side
On Windows “USERNAME” is working..
Note that
[/crayon]Monkey123[crayon-5cba9ce51cebb117214033 inline="true" ]Local variable:libc.char_t Ptr = libc.getenv(value)can be declared simply by
[/crayon]Monkey123[crayon-5cba9ce51cec0700459123 inline="true" ]Local variable:= libc.getenv(value) -
AuthorPosts