Forum Replies Created
-
AuthorPosts
-
This would be very nice if they are added to the language. Thanks Mark.
My estimation on this, is that in the first step, tuples would be used to model interesting structured arrays – which is the essential part. The next step would be how these tuples can managed in terms of usage and syntax such as initialization, assignments, operations – which are language constructs for ease of use.
My approach on this would be to implement Tuples as library and not as language constructs, because this can introduce competing paradigms. This way you will be able to do tuple things but in a more controlled fashion, the bounds will be clear and they can be accessed through the library.
Languages as Swift or Kotlyn have functional concepts embedded in them so they need tuples in more fundamental levels, The FP paradigm assumes to abstract datatypes from functions and rely on type signatures instead. Tuples are used to signify the type signatures. Where in Monkey2 I don’t think that there is such to go too functional, the program designs can be managed differently, as OO or modular.
Monkey1234567instead of writing:var a = 1var b = 2var c = 3you can write:var (a, b, c) = (1, 2, 3)This file browser looks very useful. If you plan to release anything drop a line here.
This brings me an idea of capturing this turning this touchtest into a nice component.
This is a rough sketch I made of the design to get an idea of where is going, when I will actually start doing mobile I will return to this thread and post an update. For more information I will also examine other engines just to clear things out and avoid any confusion on the API.
Monkey1234567891011121314151617181920212223242526272829Class GestureInputMethod Update()' does every sort of update here' such as how many active touches' and what state are they are inEndProperty IsFingerUp:Bool ' any finger up assuming 1Method IsFingerUp:Bool(amount:Int) ' how many fingers (1 or many)Property IsFingerDown:Bool ' any finger down assuming 1Method IsFingerDown:Bool(amount:Int) ' how many fingers (1 or many)Field TouchState:Bool[5] ' keeping touch state of all touchesField PrevTouchTime:Double[5] ' keeping the timing of all touchesProperty OnFingerUp:Void() ' a callback for when finger is upProperty OnFingerDown:Void() ' a callback for when finger is downProperty IsGesturePinch:Bool() ' pinchingProperty IsGestureDoubleTap:Bool() ' double tappingFunction IsGestureDoubleTapWith(fingers:Int) ' double tapping with how many fingersField TouchDragSpeed:Vec2f ' how fast is the touch dragProperty IsSwipe:Bool() ' if swipe happensProperty SwipeSpeed:Vec2f ' how fast was the swipeProperty SwipeDirection:String ' converting swipe to angle and return id (U/D/L/R)EndI tried something but I did not get any results, whoever wants to continue the search I will mention the details.
I went to mojo3d.graphics.mesh and I added this method (after the TransformVertices):
Monkey123456789101112131415Method TransformVertex(index:Int, position:Vec3f)If index > 0 Or index < _vbuffer.LengthReturnEndLocal matrix := New AffineMat4f(position)Local vertices := Cast<Vertex3f Ptr>(_vbuffer.Data)Local cofactor := matrix.m.Cofactor()vertices[index].position=matrix * vertices[index].positionvertices[index].normal=(cofactor * vertices[index].normal).Normalize()vertices[index].tangent.XYZ=(cofactor * vertices[index].tangent.XYZ).Normalize()_vbuffer.Invalidate()_dirty|=Dirty.BoundsEndThen I did a rebuild:
Monkey1mx2cc_windows makemods mojo3dAnd then at the “makequad” example I added this on the update loop.
Monkey123Local position := New Vec3f(0, 0, 0)position.X = Sin(Now()) * 100_model.Mesh.TransformVertex(0, position)Unfortunately I did not get any results, but this is how it should be done. Once I get more familiar with the inner workings of the Mojo3D I will know better, but this is the first time I every looked at it.
From what I think, the “Enabled” field can be controlled by configuration, the trigger is actually where the input is updated.
Interesting bit of code, I will use it as well.
From what I guess (based on similar threads) Mark wants to avoid syntactic sugar additions (unless they are mostly essential) in order to keep the parser thin and lightweight, perhaps I might be mistaken.
If the feature won’t make to the parser API hacks can be used for sure. This concept is based on factory patterns – to encapsulate the logic of creating stuff.
In the example below, the motivation is to pack variables into an array and return the array. The function overloading works like a dream here because it makes things very simple – a similar approach was used in the Tuples example I made earlier.
In this case if you dislike the API naming, perhaps other more meaningful names can be found, perhaps even extending the std Array class to form a smooth integration.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#Import "<std>"Using std..Class Params AbstractFunction Create<T>:T[](item1:T)Return New T[] (item1)EndFunction Create<T>:T[](item1:T, item2:T)Return New T[] (item1, item2)EndFunction Create<T>:T[](item1:T, item2:T, item3:T)Return New T[] (item1, item2, item3)EndFunction Create<T>:T[](item1:T, item2:T, item3:T, item4:T)Return New T[] (item1, item2, item3, item4)EndFunction Create<T>:T[](item1:T, item2:T, item3:T, item4:T, item5:T)Return New T[] (item1, item2, item3, item4, item5)EndEndFunction RunCommand(tokens:String[])Local command := ""For Local t := Eachin tokenscommand += t + " "NextPrint(command)EndFunction Main()' the default way' RunCommand(New String[] ("Start", "Level"))' RunCommand(New String[] ("Create", "Player", "RandomPosition"))' RunCommand(New String[] ("Create", "Enemy", "LotsOfThem", "100", "Robots"))' RunCommand(New String[] ("Timer", "Start"))' RunCommand(New String[] ("Begin", "Countdown", "GameLogic", "3"))' with paramsRunCommand(Params.Create("Start", "Level"))RunCommand(Params.Create("Create", "Player", "RandomPosition"))RunCommand(Params.Create("Create", "Enemy", "LotsOfThem", "100", "Robots"))RunCommand(Params.Create("Timer", "Start"))RunCommand(Params.Create("Begin", "Countdown", "GameLogic", "3"))EndWhich g++ version do you have?
For example:
Monkey12345g++ -v...gcc version 5.3.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)nerobot said:
Similar feature is right inside of Ted2Go IDE [to clean the buildv directories]
It works if you have a .buildv right inside project folder. So you can’t clean modules inside of ‘monkey2’ project. I can add recursive search if needed.It seems that once a directory is imported as a Project the command can be triggered from right click context menu in the Project tab. It does the trick however perhaps there could be room for improvement.
a) It seems by GUI design the functionality is related to the right click context menu. This will allow me to import first the directory and then trigger the clean command (I will assume recursive search exists). Perhaps there could be also another alternative way to use the tool in a more project-independent way.
b) Having a recursive function might be useful. For example I might open a massive directory that contains many monkey2 projects.
c) If you are interested to attach this utility in the IDE feel free to do so, if you find it good. Perhaps by throwing an entry in the main menu, it will show this GUI to be used accordingly, alternatively activating the project clean command from the Project tab might still present this GUI but initialized with the appropriate values.
d) A note to myself I might consider later on to add the option to include .project directories or not as well in the deletion process.
No need to respond to this message, do anything you like.
Thanks for the feedback.
If you have any suggestions let me know.
nerobot: I will respond to the Ted2Go thread for more information.
Did you do the the same implementation more or less?
If you have any ideas for improvements let me know.
Can monkey support gestures? I have not tried mobile yet.
Oh, I see! So this assignment statement is really important from what it seems.
Another question is how can I send the struct to a function for updating?
This currently does not work:
Monkey12345678910111213141516171819202122232425262728293031323334#Import "<std>"Using std..Function Main()Local items := New List<Vec2f>For Local n := 0 Until 10items.Add(New Vec2f(Rnd(1,10), Rnd(1,10)))NextPrintItems(items)ResetItems(Varptr items)PrintItems(items)EndFunction ResetItems(items:List<Vec2f> Ptr)Local iter := items->All()While Not iter.AtEnditer.Current.X = 0iter.Current.Y = 0iter.Bump()EndEndFunction PrintItems(items:List<Vec2f>)Print("Items")For Local i := Eachin itemsPrint(i)NextEndI had created this character a few months ago to be used in a game but I decided to change the theme instead.
Now for me is unusable but if is needed somewhere else let me know.
Attachments:
September 12, 2017 at 9:22 pm in reply to: Using 'private facades' to accessing protected members #10436Is this an actual design pattern?
I tried to make a simple example to understand it better.
Monkey1234567891011121314151617181920212223#Import "<std>"Using std..Class MessageProperty Content:String()Return _contentEndProtectedField _content:StringEndClass MessageChanger Extends Message AbstractFunction Set(message:Message, content:String)message._content = contentEndEndFunction Main()Local m := New MessageMessageChanger.Set(m, "Hello World")Print(m.Content)EndI had this question for quite some time, how to control the access of class contents by certain restrictions, this seems to do the trick nicely. However the only bummer -as I think of it- is that the Changer class needs to inherit from the actual object, I hope that there won’t be any problem with creating such inheritance.
-
AuthorPosts
