Marcio Teixeira
5 years ago
committed by
Scott Lahteine
11 changed files with 458 additions and 287 deletions
@ -0,0 +1,38 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* Based on Sprinter and grbl. |
||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#pragma once |
||||
|
|
||||
|
#include "types.h" |
||||
|
|
||||
|
#define BRICK_ROWS 4 |
||||
|
#define BRICK_COLS 16 |
||||
|
|
||||
|
typedef struct { |
||||
|
uint8_t balls_left, brick_count; |
||||
|
uint16_t bricks[BRICK_ROWS]; |
||||
|
int8_t paddle_x, hit_dir; |
||||
|
fixed_t ballx, bally, ballh, ballv; |
||||
|
} brickout_data_t; |
||||
|
|
||||
|
class BrickoutGame : MarlinGame { public: static void enter_game(), game_screen(); }; |
||||
|
|
||||
|
extern BrickoutGame brickout; |
@ -0,0 +1,62 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* Based on Sprinter and grbl. |
||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#pragma once |
||||
|
|
||||
|
#include "types.h" |
||||
|
|
||||
|
#define INVASION_SIZE 3 |
||||
|
|
||||
|
#if INVASION_SIZE == 3 |
||||
|
#define INVADER_COLS 5 |
||||
|
#elif INVASION_SIZE == 4 |
||||
|
#define INVADER_COLS 6 |
||||
|
#else |
||||
|
#define INVADER_COLS 8 |
||||
|
#undef INVASION_SIZE |
||||
|
#define INVASION_SIZE 5 |
||||
|
#endif |
||||
|
|
||||
|
#define INVADER_ROWS INVASION_SIZE |
||||
|
|
||||
|
#define INVADER_COL_W 14 |
||||
|
#define INVADER_H 8 |
||||
|
#define INVADER_ROW_H (INVADER_H + 2) |
||||
|
|
||||
|
typedef struct { int8_t x, y, v; } laser_t; |
||||
|
|
||||
|
typedef struct { |
||||
|
pos_t pos; |
||||
|
uint8_t cannons_left; |
||||
|
int8_t cannon_x; |
||||
|
laser_t bullet[10], laser, explod; |
||||
|
int8_t dir, leftmost, rightmost, botmost; |
||||
|
uint8_t count, quit_count, blink_count; |
||||
|
uint8_t bugs[INVADER_ROWS], shooters[(INVADER_ROWS) * (INVADER_COLS)]; |
||||
|
int8_t ufox, ufov; |
||||
|
bool game_blink; |
||||
|
int8_t laser_col() { return ((laser.x - pos.x) / (INVADER_COL_W)); }; |
||||
|
int8_t laser_row() { return ((laser.y - pos.y + 2) / (INVADER_ROW_H)); }; |
||||
|
} invaders_data_t; |
||||
|
|
||||
|
class InvadersGame : MarlinGame { public: static void enter_game(), game_screen(); }; |
||||
|
|
||||
|
extern InvadersGame invaders; |
@ -0,0 +1,30 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* Based on Sprinter and grbl. |
||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#pragma once |
||||
|
|
||||
|
#include "types.h" |
||||
|
|
||||
|
typedef struct { pos_t pos; } maze_data_t; |
||||
|
|
||||
|
class MazeGame : MarlinGame { public: static void enter_game(), game_screen(); }; |
||||
|
|
||||
|
extern MazeGame maze; |
@ -0,0 +1,38 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* Based on Sprinter and grbl. |
||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#pragma once |
||||
|
|
||||
|
#include "types.h" |
||||
|
|
||||
|
typedef struct { |
||||
|
int8_t snake_dir, // NESW
|
||||
|
foodx, foody, |
||||
|
food_cnt, |
||||
|
old_encoder; |
||||
|
pos_t snake_tail[50]; |
||||
|
fixed_t snakex, snakey; |
||||
|
uint8_t head_ind; |
||||
|
} snake_data_t; |
||||
|
|
||||
|
class SnakeGame : MarlinGame { public: static void enter_game(), game_screen(); }; |
||||
|
|
||||
|
extern SnakeGame snake; |
@ -0,0 +1,46 @@ |
|||||
|
/**
|
||||
|
* Marlin 3D Printer Firmware |
||||
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
* |
||||
|
* Based on Sprinter and grbl. |
||||
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
* |
||||
|
*/ |
||||
|
#pragma once |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
typedef struct { int8_t x, y; } pos_t; |
||||
|
|
||||
|
// Simple 8:8 fixed-point
|
||||
|
typedef int16_t fixed_t; |
||||
|
#define FTOP(F) fixed_t((F)*256.0f) |
||||
|
#define PTOF(P) (float(P)*(1.0f/256.0f)) |
||||
|
#define BTOF(X) (fixed_t(X)<<8) |
||||
|
#define FTOB(X) int8_t(fixed_t(X)>>8) |
||||
|
|
||||
|
class MarlinGame { |
||||
|
protected: |
||||
|
static int score; |
||||
|
static uint8_t game_state; |
||||
|
static millis_t next_frame; |
||||
|
|
||||
|
static bool game_frame(); |
||||
|
static void draw_game_over(); |
||||
|
static void exit_game(); |
||||
|
public: |
||||
|
static void init_game(const uint8_t init_state, const screenFunc_t screen); |
||||
|
}; |
Loading…
Reference in new issue