コンソール上でボールを反射させる
#include <iostream> #include <thread> #include <chrono> using namespace std; class Ball { public: int x, y; int width = 100; int height = 20; int d1 = 1; int d2 = 1; Ball(int startX, int startY) : x(startX), y(startY) {} void move() { x += d1; y += d2; if ((x > width) (x <= 0)) { d1 *= -1; } if (…
2024/07/25 22:40