Hello,
I love Gideros. Until now, each time I have a problem, there is a solution. And the problems I had, I basically created them by lack of skill or lack of knowledge
I do not consider myself as a good programmer. I am a hobby programmer, meaning a bad one! However, I do have creative ideas, and I have reasonable art/photoshop skills. It means that with enough time and effort, I can achieve my game dev goals alone.
Since 20 years, I usually argue that math above middle school level is rather useless in daily life. Now that I am making a 2D game, I kinda regret this statement. I have to relearn everything the hard way. So I started and continue to do so. I figured out a lot of things. But time could have been more efficiently spent if most of the classic geometry needs would have been baked already in the Gideros distribution. When you have a job and a family, time is really precious.
Classic examples would be different kind of sprite motions, basic collision formula or some of the functions available
here. And we can think about more...
Yes, I know: this is the proof there is already a lot of resources online. But I also think that delivering maybe an optimized version of these functions would give potentially Gideros a boost in productivity and popularity by attracting more beginners.
Gideros is a heaven for good programmers. It gives them a lot of control. But I think, it would cost not so much in elbow grease to make it better for less skilled ones. The classic problems, most of you have already faced them and solved them. And probably you did it in a better way that any newcomer could think about! Don't let them reinvent the wheel(especially an oval one)! Why not reunite these well-thought solutions in a plugin, set of plugins, or directly in the distribution?
Comments
Likes: SinisterSoft, oleg
Like @hgy29 said, the maths at this type of simplicity are usually custom per game. For example: One of the routines showed having to get the square root to find the distance, this is an expensive operation. If you are doing something like seeing which object is nearest then you don't have to do this bit at all.
There are useful math functions - eg atan2, etc that help with the type of things you linked to. We also added some operators to Gideros so you don't need to use deg or rad, see: https://wiki.giderosmobile.com/index.php/Trigonometry_Conversion_Operators
https://deluxepixel.com
That said, if you would like to make a Lua plugin for these then I'm sure others may welcome it. If you look in the allplugins folder within the Gideros program files folder you will see an example of some Lua plugins. See the VirtualPad and Chroma plugins...
https://deluxepixel.com
- length (a vector length)
- distance (distance between two points, in 2D or in 3D)
- normalize (divide a vector by its length)
- raycasting, that is intersection between a line and some basic shapes (circle, line, polys)
Likes: SinisterSoft, antix
You can create your own function library and then use it.
Many examples are posted on the forum:
http://forum.giderosmobile.com/categories/code-snippets
For collisions in the game, you better use the bump plugin
https://wiki.giderosmobile.com/index.php/Bump
On this page below you will find the examples of collisions you need
https://github.com/kikito/bump.lua
I wrote a bit about game physics in my blog, but I don't write in English
https://simartinfo.blogspot.com/p/blog-page_89.html
You can check the collision between 2 sprites without a plugin with the following function:
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
I do not think I am the right person to establish a list, simply because my experience is limited: I did not even finish yet my 1st project!
Look: if I would not dig in the forum, I would never have written the distance formula this way:
d = ((x2-x1)(x2-x1) + (y2-y1)(y2-y1))^0.5
but I would have kept it like this instead:
d = math.sqrt((x2-x1)^2 + (y2-y1)^2)
And to find the closest sprite to a given one(which is another very common need), I think it would have taken an eternity for me to realize that the square root was not mandatory in this formula!
However, you guys have coding and game developing experience that I will never have. At the end of the day, you know way better than me what should be implemented and how to implement it. Here I am just sharing an experience that led to an idea.
Now it's up to you!
Likes: SinisterSoft
Fragmenter - animated loop machine and IKONOMIKON - the memory game
- inside (check if a point is inside, outside or on the dge of a shape)
- edge (get the nearest point on the edge of a shape)
Likes: antix
https://deluxepixel.com
sortedByDistanceTable=SortDistance(x,y,{{obj1.sprite,obj1.x,obj1.y},{obj2.sprite,obj2.x,obj2.y}},realDistanceFlag)
sortedByDistanceTable would then be a table that had the obj.sprite pointers and the distance for each subtable, sorted. The realDistanceFlag is used to decide if they need to be square rooted or not.
A nearest(x,y,{{obj1.sprite,obj1.x,obj1.y},{obj2.sprite,obj2.x,obj2.y}}) function could return just the nearest object - no need for a sort - just compare to current nearest.
https://deluxepixel.com
Likes: antix
Likes: antix, MoKaLux
Likes: MoKaLux, SinisterSoft, Dafb
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: MoKaLux