This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
game-project/source/world/rigid.d
Ludovic 'Archivist' Lagouardette fc534fd8e1 Handle rendering of Rigids
2023-10-02 15:03:07 +02:00

25 lines
No EOL
789 B
D

module world.rigid;
import world.world_object;
import world.screen;
import raylib;
import std.conv;
class Rigid : WorldObject {
Texture2D sprite;
override void render(float) {
if(IsTextureReady(sprite)){
// Get position
int drawX = to!int(Screen.px_width*(position.x + hitbox.x - Screen.x)/Screen.width);
int drawY = to!int(Screen.px_height*(position.y + hitbox.y - Screen.y)/Screen.height);
float scale = Screen.px_height/Screen.height;
// Culling
if(drawX > Screen.width || drawX + sprite.width*scale < 0) return;
if(drawY > Screen.height || drawY + sprite.height*scale < 0) return;
DrawTextureEx(sprite, Vector2(drawX, drawY), 0, scale, Colors.WHITE);
}
}
}