Forum Replies Created
-
AuthorPosts
-
You can see already what is offered: monkey2\modules\mojo3d\tests.
However keep in mind that making a game is not all about the graphics, you will have to think of the code design and game design generally and then use the graphics in order to create the “VIEW” layer which will define how the game looks.
Hi, when I used C# for some applications I had to use this function: Application.EnableVisualStyles() in order to have visual styles. Here is something mentioned about this: https://stackoverflow.com/questions/4308503/how-to-enable-visual-styles-without-a-manifest. I think that libui wants to instruct the linker on using the manifest file:
https://github.com/andlabs/libui/search?p=1&q=WIN32&type=&utf8=%E2%9C%93I see that the linux GUI depends on GTK and it needs the GTK source (#include <gtk/gtk.h>), perhaps this means GTK library will have to be included as well along with it’s dependencies (like cairo for graphics and others). If it brings too much weight to the module, perhaps for just this special occasion Linux can rely on shared libraries instead.
I don’t know if it would be better roll with the formatting capabilities of the standard library, just to save effort. But any other than that, this code has lots of potential to be customized for further uses or be extended for more string processing capabilities, it acts also as an educational project.
Good finding!
Some information regarding on how Monkey2 builds stuff, there are two ways, one is to build-everything-from-source situation and the other is to include the native shared libraries which are distributed with the final application. Consider these example for more inspiration:
Example of having sources: monkey2\modules\chipmunk
Example of having shared libraries (which deals with the multiplatform libraries): monkey2\modules\openalI don’t know about specifically the pros and cons of building either from source or from libraries. By default you would consider that building everything from source is the way to go, unless you literally can’t mess with the source such as dealing with protected (OS libraries) or proprietry (where you can’t use the source).
Regarding some of your notes from github…
DLL must be in Root dir (possible to integrate instead?)
For doing such integration, there are third party tools to help with that, however monkey has either one way or the other. Search for: “pack exe with dll together”, you should see tools like “ExeBundler” etc… But this choice would be more of a matter according to how people want to ship the application.
(Class uiControl) Should be a struct I guess? Is in C source…
But classes (like buttons etc.) can’t extend structs…I don’t have enough knowledge about this but there various example how is done in the modules. Use AstroGrep (the application) and search these regular expressions, to see how to match a native datatype to the monkey datatype.
Class.+=
Struct.+=Such an example can be this one: Class aiScene Extends Void=”const aiScene” (aiScene is a C struct in cexport.h)
Where you have Monkey2 declare a class, but map it to a native struct, sweeeeet!I updated the example to include struct and classes.
Also testing the Monokai theme…
The pros and cons would have to be considered.
It looks good, runs smoothly too.
Good one.
Interesting,
I did not know about it, switching to it.
Another choice would be OpenCV. From what I see for achieving such functionality, only a handful of commands would be required, which makes it a relatively feasible effort within a short period of time.
https://docs.opencv.org/3.0-alpha/modules/videoio/doc/reading_and_writing_video.html
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.htmlMonkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#Import "<std>"#Import "<libc>"Using std..Using libcFunction Main()' about the sizes' the size of a floatLocal vFloat:Float = 1.0Print("size of float is " + sizeof(vFloat)) ' this is 4' from now on the sizeof function can be wrapped inside the ArrayExtensions class' this is only for syntactic reasons of providing a streamlined APIPrint("size of float is " + ArrayExtensions.SizeInBytes(vFloat))Print("")' some disambiguation about array sizesLocal aFloat:Float[] = New Float[] (1.0, 2.0, 4.0, 5.0, 10.0, 30.0)Print("size of the data type of the array is " + sizeof(aFloat)) ' this is 4, it means the size of the datatypePrint("size of the n-dimension of an array is " + aFloat.GetSize(0)) ' this is 6, it means the # of the elements in a dimensionPrint("")' calculating the size of the array like this byteSize * numberOfElements' in this case the result is 24 (which means 4bytes * 6elements)Print("size of float array is " + ArrayExtensions.SizeInBytes(aFloat))Print("")' finding the sizes of a struct or a classLocal scolor := New SColorLocal ccolor := New CColorPrint("struct size is " + ArrayExtensions.SizeInBytes(scolor)) ' this is 4 (because 4fields * 1byte)Print("class size is " + ArrayExtensions.SizeInBytes(ccolor)) ' this is 4 againPrint("")' testing arrays of a struct and a classLocal asColor := New SColor[] (New SColor, New SColor, New SColor, New SColor)Local acColor := New CColor[] (New CColor, New CColor, New CColor, New CColor)Print("size of struct array " + ArrayExtensions.SizeInBytes(asColor)) ' it's 16Print("size of class array " + ArrayExtensions.SizeInBytes(acColor)) ' the sameEnd' Built in types cannot be extended otherwise it would be implemented as an extension' Struct @Array<T> ExtensionStruct ArrayExtensions AbstractFunction SizeInBytes<T>:Int(item_:T)Return sizeof(item_)EndFunction SizeInBytes<T>:Int(array_:T[])Return array_.Length * sizeof(array_)EndEndStruct SColorField R:ByteField G:ByteField B:ByteField A:ByteEndClass CColorField R:ByteField G:ByteField B:ByteField A:ByteEndThanks Pakz for posting it, this will worth the study.
Nerobot, perhaps for full physics capabilities the chipmunk will be better.
Or perhaps a combination of custom arcade physics and real physics, would produce very interesting results. There is something weird in arcade physics that are very useful and efficient. I had tried many tests in Processing Box2D with hacks and tuning to achieve that arcade feeling, and not even close enough to the result needed.
Also I have seen earlier that Diddy2 framework has a platform example in the works, check it out or ask TheRevils for more information.
I found a third way of inverting the Y axis. However visually it would not make sense because it will turn graphics upside down. But if you take this concept and perform the transformations using Matrix object the calculations will be applied only to values.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField angle:Double = 0Field stp:Double = Pi/180.0Method New()Super.New("",800,600)EndMethod OnRender(canvas:Canvas) OverrideApp.RequestRender()canvas.PushMatrix()canvas.Translate(200,200)canvas.DrawText(angle + "", 0, 0)canvas.Rotate(angle)canvas.DrawLine(0,0,100,0)canvas.PopMatrix()canvas.PushMatrix()canvas.Translate(500,200)canvas.DrawText(angle + "", 0, 0)canvas.DrawLine(0,0,Cos(angle)*100, -Sin(angle)*100)canvas.PopMatrix()canvas.PushMatrix()canvas.Translate(250,400)canvas.DrawText(angle + "", 0, 0)canvas.Scale(1, -1)canvas.DrawLine(0,0,Cos(angle)*100, Sin(angle)*100)canvas.PopMatrix()angle+=stpIf angle > TwoPiangle-=TwoPiEndEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndJanuary 22, 2018 at 12:37 pm in reply to: derived class as argument for base class and other rules for inheritance #13166I updated the previous post to include the code sample.
January 21, 2018 at 11:54 am in reply to: derived class as argument for base class and other rules for inheritance #13141This one seems to have a link to an object instance somewhere in memory, but the displayed value is Null.
Monkey123456789101112Class AEndClass B Extends AEndFunction Main()Local a := New ALocal b := Cast<B>(a)Print(Typeof(b) = Typeof<Object>)Print(b = Null)EndHowever trying overloading the To operator makes the program behave correctly.
Monkey12345678910111213Class AMethod To:B()Local b := New Bb.b = Self.aReturn aEndClass BMethod To:A()Local a := New Aa.a = Self.bReturn aEndHowever I know that the point of the post is to stress test the compiler (I am not trying to patch the code example). But other than that you would consider that as a programming practice, super-casting is always ambiguous, because most of the times you can’t be sure how the derived type translates to their parent.
As a point of reference in C# language this operation is not permitted. So perhaps Monkey would introduce the same restriction, to promote more formal and strict habits.
Monkey123456789101112131415161718class A{}class B : A{}class MainClass{public static void Main(string[] args){var a = new A();var b = (B)a; // <-- This won't happen...// System.InvalidCastException has been thrown// Unable to cast object of type 'TestSuperCasting.A' to type 'TestSuperCasting.B'.}} -
AuthorPosts