aboutsummaryrefslogtreecommitdiff
path: root/Marlin/src/lcd/menu/game/invaders.h
blob: c99e6c16ae76821c1f6578bd1d76ca14658c36ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * Marlin 3D Printer Firmware
 * Copyright (c) 2020 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 <https://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;