import ..body::BodyLike import ..body::Body import a.ggez @class Ship(BodyLike) { [body, rotation, mesh] static def __call(ctx, screen_width, screen_height) = { body = Body(0.5, 0.5, 0, 0, 0, 0, 1 / 35) ship_height = screen_height / 30 ship_width = screen_width / 40 mesh = ggez::MeshBuilder().polygon( [ [0, -ship_height / 2], [ship_width / 2, ship_height / 2], [0, ship_height * (-0.5 + 0.75)], [-ship_width / 2, ship_height / 2], ], ggez::WHITE, ).build(ctx) __malloc(Ship, [body, 0, mesh]) } def body(self) = self.body def update(self, ctx, elapsed_time) { self.body.update(elapsed_time) } def draw(self, ctx, screen_width, screen_height) { screen_x = self.x() * screen_width screen_y = self.y() * screen_height self.mesh.draw( ctx, dest=[screen_x, screen_y], rotation=self.rot(), ) } }