#include <iostream>
#include <cmath>
const float PI = 3.14159;
const float SPEED = 100.0f;
class MotorWheel {
public:
MotorWheel(float radius, float speed) : radius(radius), speed(speed) {
circle.setRadius(radius);
circle.setFillColor(sf::Color::Red);
circle.setOutlineThickness(5);
circle.setOutlineColor(sf::Color::Black);
circle.setOrigin(radius, radius);
}
void move(float deltaTime) {
float distance = speed * deltaTime;
float angle = distance / radius;
circle.rotate(angle * (180 / PI));
}
void draw(sf::RenderWindow &window) {
window.draw(circle);
}
private:
float radius;
float speed;
sf::CircleShape circle;
};
int main() {
sf::RenderWindow window(sf::VideoMode(800, 600), "Motor Wheel Simulation");
MotorWheel wheel(100.0f, SPEED);
sf::Clock clock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
float deltaTime = clock.restart().asSeconds();
wheel.move(deltaTime);
window.clear();
wheel.draw(window);
window.display();
}
return 0;
}