Flock of Birds (boids) With Class and operation overloading takes too much mem lazarus / 70-OpenGL ---------------------------------------------------------------------- Dzandaa · 2023-12-04 11:39 Hi This is a demonstration showing a Flock of Birds based on Boids artificial life program created by Craig Reynolds. Using OpenGL, work on Linux and Windows. https://en.wikipedia.org/wiki/Boids Have fun. B-> ---------------------------------------------------------------------- Dzandaa · 2023-12-04 15:56 Hi again, I realize that I Didn't manage well operator overloading with a Class (memory eating!!!) This version is just using records. B-> ---------------------------------------------------------------------- cdbc · 2023-12-04 16:08 Hi Memory eating... You think  The first version just "bricked" my lappy  Regards Benny ---------------------------------------------------------------------- Dzandaa · 2023-12-04 16:30 Hi, @cbdc I'm very sorry for that!!! I didn't find any example with operator overloading in a class. Just overloading of Records. The problem come with vector2u. If anybody have an example with overloading operators in classes, I'm interested (Form based application) Example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i operator + (const V1: Vector2; Val: Single): Vector2;begin//      result.X := V1.X + Val; // <-- Solution one crashes because result is not initialized.//      result.Y := V1.Y + Val; exit(Vector2.Create(V1.X + Val, V1.Y + Val)); // Solution 2 works but didn't free the memoryend;  B-> ---------------------------------------------------------------------- MarkMLl · 2023-12-05 13:08 "Bricked"? Rendered indistinguishable from a boat anchor? Surely not... :-) @Dzandaa You should have put "boids" in the subject line: I'm sure I'm not the only person around here who'd understand the allusion. I remember when this was first discussed in the late 80s, and always find myself thinking of it when I see something like the Rutan Ares. MarkMLl