// Called in game every step to render each Entitiy in game public void Draw() { OnDraw?.Invoke(); // Clear the screen. Console.Clear(); RL.ClearBackground(Color.BLACK); // Length = size of the screen. char[,] display = new char[_sizeX, _sizeY]; foreach (Entity e in _entities) { // Position each Entity's icon in the display. int x = (int)e.XAbsolute; int y = (int)e.YAbsolute; if (x >= 0 && x < _sizeX && y >= 0 && y < _sizeY) { display[x, y] = e.Icon; } } // Render the display grid to the screen. for (int i = 0; i < _sizeY; i++) { for (int j = 0; j < _sizeX; j++) { Console.Write(display[j, i]); foreach (Entity e in _tracking[j, i]) { if (e.Sprite == null) { continue; // Skips this item in _tracking } // RL.DrawTexture(e.Sprite, (int)(e.X * Game.SizeX), (int)(e.Y * Game.SizeY), Color.PURPLE); // Texture Texture2D texture = e.Sprite.Texture; // Position float positionX = e.Sprite.XAbsolute * Game.UnitSize.x + Game.UnitSize.x / 2; float positionY = e.Sprite.YAbsolute * Game.UnitSize.y + Game.UnitSize.y / 2; Raylib.Vector2 position = new Raylib.Vector2(positionX, positionY); // Rotation float rotation = e.Rotation * (float)(180.0f / Math.PI); // Scale float scale = e.Sprite.Size; // Draw RL.DrawTextureEx(texture, position, rotation, scale, Color.PURPLE); } } Console.WriteLine(); } foreach (Entity e in _entities) { //Call the Entity's Update events e.Draw(); } // Console.Write("Say Oi Boi: " + counter); }
// Call the Entity's OnStart event public void Start() { // Checks to see if the Delegate has something in it. OnStart?.Invoke(); _started = true; Hitbox = new AABB( new Vector3(XAbsolute - 0.5f, YAbsolute - 0.5f, 1), new Vector3(XAbsolute + 0.5f, YAbsolute + 0.5f, 1)); }
// int counter = 0; public void Start() { OnStart?.Invoke(); foreach (Entity e in _entities) { if (!e.Started) { e.Start(); } } _started = true; }
// Call the Entity's OnDraw event public void Draw() { OnDraw?.Invoke(); Hitbox.Draw(Color.LIME); }