renaming
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
#ifndef ELEMENTS_HPP
|
||||
#define ELEMENTS_HPP
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
struct Point;
|
||||
struct Paddle;
|
||||
struct Block;
|
||||
struct Ball;
|
||||
Paddle create_new_paddle(Point** buffer, int starting_array_index, int size, int row, char symbol);
|
||||
Ball create_new_ball(Point** buffer, int buffer_index, int default_vx, int default_vy, int row, int col, char symbol);
|
||||
Block** create_block_buffer(int starting_array_index, int starting_symbol, int rows, int cols, int length);
|
||||
void rasterize_buffer(Point** buffer, Block** block_buffer, int offset);
|
||||
void trim_block_buffer_on_collision(Point** buffer, int buffer_size, Block** block_buffer, int &block_buffer_size, Ball &ball);
|
||||
void cleanup(Block** block_buffer, int block_buffer_size);
|
||||
bool is_block_buffer_empty(Block** block_buffer, int block_buffer_size);
|
||||
|
||||
enum Direction {
|
||||
LEFT = -1,
|
||||
RIGHT = 1,
|
||||
NONE = 0,
|
||||
};
|
||||
|
||||
struct Point {
|
||||
Point() : m_row(0), m_col(0) {};
|
||||
Point(int row, int col, char symbol) : m_row(row), m_col(col), m_symbol(symbol) {};
|
||||
Point(int row, int col, int symbol) : m_row(row), m_col(col), m_symbol(symbol) {};
|
||||
int m_row;
|
||||
int m_col;
|
||||
char m_symbol;
|
||||
void assign(int row, int col);
|
||||
};
|
||||
|
||||
struct Ball {
|
||||
Ball(int default_vx, int default_vy) : vx(default_vx), vy(default_vy) {};
|
||||
~Ball();
|
||||
Point* m_origin;
|
||||
int vx;
|
||||
int vy;
|
||||
void determine_new_position(int &paddle_lives, int reset_ball_x, int reset_ball_y);
|
||||
void change_velocity(char d);
|
||||
};
|
||||
|
||||
struct Paddle {
|
||||
Paddle(int size) : _size(size), m_hearts(3) {};
|
||||
~Paddle();
|
||||
int _size;
|
||||
int m_hearts;
|
||||
Point** m_nodes;
|
||||
enum Direction m_direction;
|
||||
void determine_new_position(Point* (*board)[COL]);
|
||||
void check_collision(Ball &ball);
|
||||
};
|
||||
|
||||
struct Block {
|
||||
Block();
|
||||
Block(int size, int row, int col, char symbol);
|
||||
~Block();
|
||||
int _size;
|
||||
Point** m_nodes;
|
||||
bool check_collision(Ball &ball);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
struct vec2;
|
||||
struct Paddle;
|
||||
struct Block;
|
||||
struct Ball;
|
||||
Paddle create_new_paddle(vec2** buffer, int starting_array_index, int size, int row, char symbol);
|
||||
Ball create_new_ball(vec2** buffer, int buffer_index, int default_vx, int default_vy, int row, int col, char symbol);
|
||||
Block** create_block_buffer(int starting_symbol, int rows, int cols, int length);
|
||||
void rasterize_buffer(vec2** buffer, Block** block_buffer, int offset);
|
||||
void trim_block_buffer_on_collision(vec2** buffer, const int buffer_size, Block** block_buffer, const int block_buffer_size, Ball &ball);
|
||||
void cleanup(Block** block_buffer, int block_buffer_size);
|
||||
bool is_block_buffer_empty(Block** block_buffer, int block_buffer_size);
|
||||
|
||||
enum Direction { LEFT, RIGHT, NONE };
|
||||
|
||||
struct vec2 {
|
||||
vec2() : y(0), x(0) {};
|
||||
vec2(int row, int col, char symbol) : y(row), x(col), m_symbol(symbol) {};
|
||||
int x, y;
|
||||
char m_symbol;
|
||||
void assign(int row, int col);
|
||||
};
|
||||
|
||||
struct Ball {
|
||||
Ball(int default_vx, int default_vy) : vx(default_vx), vy(default_vy) {};
|
||||
~Ball();
|
||||
vec2* m_origin;
|
||||
int vx;
|
||||
int vy;
|
||||
void determine_new_position(int &paddle_lives, int reset_ball_x, int reset_ball_y);
|
||||
void change_velocity(char d);
|
||||
};
|
||||
|
||||
struct Paddle {
|
||||
Paddle(int size) : _size(size), m_hearts(3) {};
|
||||
~Paddle();
|
||||
int _size;
|
||||
int m_hearts;
|
||||
vec2** m_nodes;
|
||||
enum Direction m_direction;
|
||||
void determine_new_position(vec2* (*board)[COL]);
|
||||
void check_collision(Ball &ball);
|
||||
};
|
||||
|
||||
struct Block {
|
||||
Block();
|
||||
Block(int size, int row, int col, char symbol);
|
||||
~Block();
|
||||
int _size;
|
||||
vec2** m_nodes;
|
||||
bool check_collision(Ball &ball);
|
||||
};
|
||||
|
||||
// class Engine {
|
||||
//
|
||||
// };
|
||||
+2
-5
@@ -1,10 +1,7 @@
|
||||
#ifndef INPUT_HPP
|
||||
#define INPUT_HPP
|
||||
#include "elements.hpp"
|
||||
#pragma once
|
||||
#include <engine.hpp>
|
||||
|
||||
struct Input {
|
||||
int m_getch;
|
||||
void get_input(bool &running, enum Direction &dir);
|
||||
};
|
||||
|
||||
#endif // INPUT_HPP
|
||||
|
||||
+4
-8
@@ -1,14 +1,10 @@
|
||||
#ifndef WINDOW_HPP
|
||||
#define WINDOW_HPP
|
||||
|
||||
#pragma once
|
||||
#include <engine.hpp>
|
||||
#include "globals.hpp"
|
||||
#include "elements.hpp"
|
||||
|
||||
struct Window {
|
||||
Point* m_board[ROW][COL] = {};
|
||||
vec2* m_board[ROW][COL] = {};
|
||||
void clear_display();
|
||||
void draw_display(int fps);
|
||||
void update_board(Point** buffer, int buffer_size);
|
||||
void update_board(vec2** buffer, int buffer_size);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user