feat: added paddle, point and ball (collision and movement)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#ifndef ELEMENTS_HPP
|
||||
#define ELEMENTS_HPP
|
||||
|
||||
struct Point {
|
||||
Point();
|
||||
int m_row;
|
||||
int m_col;
|
||||
void assign(int row, int col);
|
||||
void to_string();
|
||||
};
|
||||
|
||||
struct Paddle {
|
||||
Paddle();
|
||||
int _size;
|
||||
Point m_nodes[3];
|
||||
void get_new_pos();
|
||||
};
|
||||
|
||||
struct Ball {
|
||||
Ball();
|
||||
Point m_origin;
|
||||
int vx;
|
||||
int vy;
|
||||
void get_new_pos();
|
||||
void check_collision();
|
||||
void change_velocity(char d);
|
||||
};
|
||||
|
||||
// struct Block {
|
||||
//
|
||||
// };
|
||||
//
|
||||
#endif
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
#define GLOBALS_HPP
|
||||
|
||||
constexpr int ROW = 10;
|
||||
constexpr int COL = 10;
|
||||
constexpr int COL = 15;
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
#ifndef INPUT_HPP
|
||||
#define INPUT_HPP
|
||||
// #include "elements.hpp"
|
||||
#include "elements.hpp"
|
||||
|
||||
struct Input {
|
||||
char m_getch = ' ';
|
||||
void get_input(bool &running);
|
||||
void get_input(bool &running, Paddle &paddle);
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <array>
|
||||
#include "globals.hpp"
|
||||
// #include "elements.hpp"
|
||||
#include "elements.hpp"
|
||||
|
||||
struct Window {
|
||||
std::array<std::array<char, COL>, ROW> m_board = {};
|
||||
void update_display();
|
||||
void update_display(Paddle &paddle, Ball &ball);
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user