wip
This commit is contained in:
+2
-3
@@ -4,8 +4,8 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
|
||||||
constexpr int ROW = 15;
|
constexpr int ROW { 15 };
|
||||||
constexpr int COL = 31;
|
constexpr int COL { 31 };
|
||||||
constexpr int SIZE { 3 };
|
constexpr int SIZE { 3 };
|
||||||
|
|
||||||
struct vec2 {
|
struct vec2 {
|
||||||
@@ -26,7 +26,6 @@ struct Paddle {
|
|||||||
|
|
||||||
struct Window {
|
struct Window {
|
||||||
std::array<std::array<char, COL>, ROW> view = {};
|
std::array<std::array<char, COL>, ROW> view = {};
|
||||||
void clear_display();
|
|
||||||
void draw_display() const;
|
void draw_display() const;
|
||||||
void update_display(const vec2 &ball, const Paddle &p1, const Paddle &p2);
|
void update_display(const vec2 &ball, const Paddle &p1, const Paddle &p2);
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-8
@@ -4,13 +4,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
void Window::clear_display() {
|
|
||||||
clear();
|
|
||||||
for(auto &row : view) {
|
|
||||||
row.fill('.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::draw_display() const {
|
void Window::draw_display() const {
|
||||||
for(int i = 0; i < ROW; i++) {
|
for(int i = 0; i < ROW; i++) {
|
||||||
for(int j = 0; j < COL; j++) {
|
for(int j = 0; j < COL; j++) {
|
||||||
@@ -20,6 +13,8 @@ void Window::draw_display() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::update_display(const vec2 &ball, const Paddle &p1, const Paddle &p2) {
|
void Window::update_display(const vec2 &ball, const Paddle &p1, const Paddle &p2) {
|
||||||
|
clear();
|
||||||
|
for(auto &row : view) { row.fill('.'); }
|
||||||
view[ball.y][ball.x] = '*';
|
view[ball.y][ball.x] = '*';
|
||||||
for(auto &i : p1.nodes) {
|
for(auto &i : p1.nodes) {
|
||||||
view[i.y][i.x] = p1.symbol;
|
view[i.y][i.x] = p1.symbol;
|
||||||
@@ -68,7 +63,6 @@ void Engine::run() {
|
|||||||
p1.move();
|
p1.move();
|
||||||
p2.move();
|
p2.move();
|
||||||
on_collision_with_ball();
|
on_collision_with_ball();
|
||||||
win.clear_display();
|
|
||||||
win.update_display(ball, p1, p2);
|
win.update_display(ball, p1, p2);
|
||||||
win.draw_display();
|
win.draw_display();
|
||||||
refresh();
|
refresh();
|
||||||
|
|||||||
Reference in New Issue
Block a user