PandA-2024.02
|
Go to the source code of this file.
Data Structures | |
struct | _obj_description |
struct | _entity |
struct | _brick |
Macros | |
#define | WINDOW_WIDTH 640 |
Breakout game ported to the PandA framework by Fabrizio Ferrandi on April 11th 2016. More... | |
#define | WINDOW_HEIGHT 480 |
#define | FRAMES_PER_SECOND 60 |
#define | FRAME_RATE 1000/FRAMES_PER_SECOND |
#define | YELLOW_COLOR 6 |
#define | RED_COLOR 4 |
#define | BLUE_COLOR 1 |
#define | GREEN_COLOR 2 |
#define | WHITE_COLOR 7 |
#define | BLACK_COLOR 0 |
#define | BRICK_SCREEN_BUFFER_X 41 |
#define | BRICK_SCREEN_BUFFER_Y 30 |
#define | NUM_ROWS 6 |
#define | NUM_COLS 9 |
#define | MAX_BRICKS NUM_ROWS*NUM_COLS |
#define | PLAYER_Y 430 |
#define | BRICK_WIDTH 62 |
#define | BRICK_HEIGHT 16 |
#define | PADDLE_WIDTH 32 |
#define | PADDLE_HEIGHT 8 |
#define | BALL_DIAMETER 8 |
#define | PLAYER_SPEED 2 |
#define | BALL_SPEED_MODIFIER 4 |
#define | BALL_SPEED_Y 2 |
#define | NUM_LIVES 5 |
#define | NUM_LEVELS 3 |
#define | LEFT 0 |
#define | RIGHT 1 |
#define | UP 2 |
#define | DOWN 3 |
#define | sgn(x) ((x<0)?-1:((x>0)?1:0)) |
Typedefs | |
typedef struct _obj_description | obj_description |
typedef struct _entity | entity |
typedef struct _brick | brick |
Functions | |
unsigned char | convert_char_digit_2_sseg (char c) |
void | line (int x1, int y1, int x2, int y2, unsigned int color) |
void | rect (int left, int top, int right, int bottom, unsigned int color) |
void | circle (int x0, int y0, int radius, unsigned int color) |
void | rect_fill (int left, int top, int right, int bottom, unsigned int color) |
void | output_score () |
_Bool | check_wall_collisions (entity *entity, unsigned char dir) |
_Bool | check_ball_collisions () |
void | move_ball () |
void | bricks_initialization () |
void | game_initialization () |
_Bool | get_game_input () |
_Bool | check_point_in_rect (int x, int y, obj_description *rect) |
_Bool | change_level () |
_Bool | manage_brick_collision (int index) |
_Bool | check_brick_collisions () |
void | manage_loss () |
_Bool | manage_ball () |
_Bool | game_main_loop () |
void | main () |
Variables | |
entity | player |
entity | ball |
int | lives |
int | level |
int | num_bricks |
brick | bricks [MAX_BRICKS] |
int | timer |
static unsigned char | level_hits [NUM_LEVELS][MAX_BRICKS] |
#define BALL_DIAMETER 8 |
Definition at line 48 of file main.c.
Referenced by check_brick_collisions(), and game_initialization().
#define BALL_SPEED_MODIFIER 4 |
Definition at line 54 of file main.c.
Referenced by manage_ball().
#define BALL_SPEED_Y 2 |
Definition at line 55 of file main.c.
Referenced by get_game_input().
#define BLACK_COLOR 0 |
Definition at line 24 of file main.c.
Referenced by bricks_initialization(), check_brick_collisions(), game_initialization(), game_main_loop(), and manage_brick_collision().
#define BLUE_COLOR 1 |
Definition at line 21 of file main.c.
Referenced by bricks_initialization(), and game_main_loop().
#define BRICK_HEIGHT 16 |
Definition at line 41 of file main.c.
Referenced by bricks_initialization().
#define BRICK_SCREEN_BUFFER_X 41 |
Definition at line 27 of file main.c.
Referenced by bricks_initialization().
#define BRICK_SCREEN_BUFFER_Y 30 |
Definition at line 28 of file main.c.
Referenced by bricks_initialization().
#define BRICK_WIDTH 62 |
Definition at line 40 of file main.c.
Referenced by bricks_initialization().
#define FRAME_RATE 1000/FRAMES_PER_SECOND |
Definition at line 16 of file main.c.
Referenced by game_main_loop().
#define GREEN_COLOR 2 |
Definition at line 22 of file main.c.
Referenced by bricks_initialization(), and manage_brick_collision().
#define LEFT 0 |
Definition at line 64 of file main.c.
Referenced by check_wall_collisions(), get_game_input(), and move_ball().
Definition at line 33 of file main.c.
Referenced by bricks_initialization(), check_brick_collisions(), and game_main_loop().
#define NUM_COLS 9 |
Definition at line 32 of file main.c.
Referenced by bricks_initialization().
#define NUM_LEVELS 3 |
Definition at line 61 of file main.c.
Referenced by change_level().
#define NUM_LIVES 5 |
Definition at line 58 of file main.c.
Referenced by game_initialization(), and manage_loss().
#define NUM_ROWS 6 |
Definition at line 31 of file main.c.
Referenced by bricks_initialization().
#define PADDLE_HEIGHT 8 |
Definition at line 45 of file main.c.
Referenced by game_initialization().
#define PADDLE_WIDTH 32 |
Definition at line 44 of file main.c.
Referenced by game_initialization().
#define PLAYER_SPEED 2 |
Definition at line 51 of file main.c.
Referenced by game_initialization(), and get_game_input().
#define PLAYER_Y 430 |
Definition at line 36 of file main.c.
Referenced by game_initialization().
#define RED_COLOR 4 |
Definition at line 20 of file main.c.
Referenced by bricks_initialization(), and manage_brick_collision().
#define RIGHT 1 |
Definition at line 65 of file main.c.
Referenced by check_wall_collisions(), get_game_input(), and move_ball().
#define WHITE_COLOR 7 |
Definition at line 23 of file main.c.
Referenced by game_main_loop().
#define WINDOW_HEIGHT 480 |
Definition at line 12 of file main.c.
Referenced by change_level(), game_initialization(), game_main_loop(), manage_ball(), and manage_loss().
#define WINDOW_WIDTH 640 |
Breakout game ported to the PandA framework by Fabrizio Ferrandi on April 11th 2016.
The original code has been taken from http://www.aaroncox.net/tutorials/arcade/BRICKBreaker.html The game was designed by Nolan Bushnell, Steve Wozniak, and Steve Bristow. History of Breakout game can be found at this link: https://en.wikipedia.org/wiki/Breakout_%28video_game%29
Definition at line 11 of file main.c.
Referenced by change_level(), check_wall_collisions(), game_initialization(), game_main_loop(), manage_ball(), and manage_loss().
#define YELLOW_COLOR 6 |
Definition at line 19 of file main.c.
Referenced by bricks_initialization(), game_main_loop(), and manage_brick_collision().
typedef struct _obj_description obj_description |
void bricks_initialization | ( | ) |
Definition at line 306 of file main.c.
References BLACK_COLOR, BLUE_COLOR, BRICK_HEIGHT, BRICK_SCREEN_BUFFER_X, BRICK_SCREEN_BUFFER_Y, BRICK_WIDTH, symmetry::col, _brick::color, GREEN_COLOR, _obj_description::h, index, level, level_hits, MAX_BRICKS, num_bricks, NUM_COLS, _brick::num_hits, NUM_ROWS, RED_COLOR, symmetry::row, _brick::screen_location, _obj_description::w, _obj_description::x, _obj_description::y, and YELLOW_COLOR.
Referenced by change_level(), game_initialization(), and manage_loss().
_Bool change_level | ( | ) |
Definition at line 431 of file main.c.
References bricks_initialization(), _obj_description::h, level, num_bricks, NUM_LEVELS, _entity::screen_location, _obj_description::w, WINDOW_HEIGHT, WINDOW_WIDTH, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by manage_brick_collision().
_Bool check_ball_collisions | ( | ) |
Definition at line 242 of file main.c.
References _obj_description::h, _entity::screen_location, _obj_description::w, _obj_description::x, _obj_description::y, and _entity::y_speed.
Referenced by manage_ball().
_Bool check_brick_collisions | ( | ) |
Definition at line 508 of file main.c.
References BALL_DIAMETER, BLACK_COLOR, check_point_in_rect(), _obj_description::h, manage_brick_collision(), MAX_BRICKS, _entity::screen_location, top(), _obj_description::w, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by manage_ball().
_Bool check_point_in_rect | ( | int | x, |
int | y, | ||
obj_description * | rect | ||
) |
Definition at line 422 of file main.c.
References _obj_description::h, _obj_description::w, _obj_description::x, and _obj_description::y.
Referenced by check_brick_collisions().
_Bool check_wall_collisions | ( | entity * | entity, |
unsigned char | dir | ||
) |
Definition at line 216 of file main.c.
References LEFT, RIGHT, _entity::screen_location, _obj_description::w, WINDOW_WIDTH, _obj_description::x, and _entity::x_speed.
Referenced by get_game_input(), manage_AI(), and move_ball().
void circle | ( | int | x0, |
int | y0, | ||
int | radius, | ||
unsigned int | color | ||
) |
Definition at line 162 of file main.c.
References plot(), _obj_description::x, and _obj_description::y.
Referenced by game_main_loop().
unsigned char convert_char_digit_2_sseg | ( | char | c | ) |
Definition at line 103 of file main.c.
References test_panda::table.
Referenced by output_score().
void game_initialization | ( | ) |
Definition at line 366 of file main.c.
References BALL_DIAMETER, BLACK_COLOR, bricks_initialization(), get_ticks(), _obj_description::h, level, lives, NUM_LIVES, PADDLE_HEIGHT, PADDLE_WIDTH, PLAYER_SPEED, PLAYER_Y, rect_fill(), _entity::screen_location, timer, _obj_description::w, WINDOW_HEIGHT, WINDOW_WIDTH, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by main().
_Bool game_main_loop | ( | ) |
Definition at line 635 of file main.c.
References ball, BLACK_COLOR, BLUE_COLOR, circle(), _brick::color, FRAME_RATE, get_game_input(), get_ticks(), _obj_description::h, manage_ball(), MAX_BRICKS, output_score(), player, rect(), rect_fill(), _entity::screen_location, _brick::screen_location, timer, _obj_description::w, WHITE_COLOR, WINDOW_HEIGHT, WINDOW_WIDTH, _obj_description::x, _obj_description::y, and YELLOW_COLOR.
Referenced by main().
_Bool get_game_input | ( | ) |
Definition at line 394 of file main.c.
References BALL_SPEED_Y, btn_ctrl(), BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_UP, check_wall_collisions(), LEFT, PLAYER_SPEED, RIGHT, _entity::screen_location, _obj_description::x, and _entity::y_speed.
Referenced by game_main_loop().
void line | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
unsigned int | color | ||
) |
Definition at line 110 of file main.c.
References abs, plot(), sgn, _obj_description::x, and _obj_description::y.
Referenced by CopyFile(), BasicBlocksProfiling::Exec(), Parameter::GetFileFormat(), CompilerWrapper::GetSystemIncludes(), XilinxBackendFlow::parse_DSPs(), XilinxBackendFlow::parse_timing(), polybench_flush_cache(), PragmaParser::recognize_call_point_hw_pragma(), PragmaParser::recognize_omp_pragma(), rect(), rect_fill(), pragma_manager::setGenericPragma(), throw_error(), throw_warning(), Translator::write_to_latex(), SynthesisTool::xload_scripts(), and XilinxBackendFlow::xparse_map_utilization().
void main | ( | void | ) |
Definition at line 670 of file main.c.
References game_initialization(), and game_main_loop().
_Bool manage_ball | ( | ) |
Definition at line 592 of file main.c.
References BALL_SPEED_MODIFIER, check_ball_collisions(), check_brick_collisions(), _obj_description::h, lives, manage_loss(), move_ball(), _entity::screen_location, _obj_description::w, WINDOW_HEIGHT, WINDOW_WIDTH, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by game_main_loop().
_Bool manage_brick_collision | ( | int | index | ) |
Definition at line 454 of file main.c.
References BLACK_COLOR, change_level(), _brick::color, GREEN_COLOR, index, num_bricks, _brick::num_hits, RED_COLOR, and YELLOW_COLOR.
Referenced by check_brick_collisions().
void manage_loss | ( | ) |
Definition at line 577 of file main.c.
References bricks_initialization(), _obj_description::h, level, lives, num_bricks, NUM_LIVES, _entity::screen_location, _obj_description::w, WINDOW_HEIGHT, WINDOW_WIDTH, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by manage_ball().
void move_ball | ( | ) |
Definition at line 266 of file main.c.
References check_wall_collisions(), LEFT, RIGHT, _entity::screen_location, _obj_description::x, _entity::x_speed, _obj_description::y, and _entity::y_speed.
Referenced by manage_ball().
void output_score | ( | ) |
Definition at line 196 of file main.c.
References convert_char_digit_2_sseg(), level, lives, and sevensegments_ctrl().
Referenced by game_main_loop().
void rect | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom, | ||
unsigned int | color | ||
) |
Definition at line 154 of file main.c.
References line().
Referenced by game_main_loop(), tree_helper::GetRecordTypeName(), tree_helper::GetTemplateTypeName(), and tree_helper::GetTypeName().
void rect_fill | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom, | ||
unsigned int | color | ||
) |
Definition at line 187 of file main.c.
References line().
Referenced by game_initialization(), and game_main_loop().
entity ball |
Definition at line 96 of file main.c.
Referenced by game_main_loop().
brick bricks[MAX_BRICKS] |
int level |
Definition at line 98 of file main.c.
Referenced by ASLAP::add_constraints_to_ALAP(), ASLAP::add_constraints_to_ASAP(), bfs(), bricks_initialization(), weak_dominance::calculate_weak_dominance_info(), xml_child::CGetDescendants(), change_level(), ASLAP::compute_ALAP_fast(), ASLAP::compute_ALAP_worst_case(), ASLAP::compute_ASAP(), Loops::DetectIrreducibleLoop(), game_initialization(), mux_connection_binding::input_logic(), main(), manage_loss(), ScheduleWriter::operator()(), output_score(), MemoryInitializationWriterBase::PrintStatus(), and ASLAP::update_ALAP().
|
static |
Definition at line 278 of file main.c.
Referenced by bricks_initialization().
int lives |
Definition at line 97 of file main.c.
Referenced by game_initialization(), manage_ball(), manage_loss(), and output_score().
int num_bricks |
Definition at line 99 of file main.c.
Referenced by bricks_initialization(), change_level(), manage_brick_collision(), and manage_loss().
entity player |
Definition at line 95 of file main.c.
Referenced by game_main_loop().
int timer |
Definition at line 101 of file main.c.
Referenced by game_initialization(), and game_main_loop().