コミット
諏訪子 <suwako@076.moe>、2025-11-25 20:11
コミット 755b579d01e541e37ce2ea3ae2743add50422e5a
・ファイルを見る
18個のファイル、+507 -0
追加
Makefile
| @@ -0,0 +1,15 @@ | ||
| 1 | +NAME=brickbreaker | |
| 2 | +# Linux、Haiku、かIllumos = /usr、FreeBSDかOpenBSD = /usr/local、NetBSD = /usr/pkg | |
| 3 | +PREFIX=/usr/local | |
| 4 | +CC=clang++ | |
| 5 | +CFLAGS=-I${PREFIX}/include -L${PREFIX}/lib | |
| 6 | +LDFLAGS=-lSDL2 -lSDL2_mixer -lSDL2_ttf | |
| 7 | +FILES=main.cc src/ball.cc src/brick.cc src/render.cc | |
| 8 | + | |
| 9 | +all: | |
| 10 | + ${CC} ${CFLAGS} -o ${NAME} ${FILES} ${LDFLAGS} | |
| 11 | + | |
| 12 | +clean: | |
| 13 | + rm -f ${NAME} | |
| 14 | + | |
| 15 | +.PHONY: all clean |
追加
README.md
| @@ -0,0 +1,32 @@ | ||
| 1 | +# ブリックブレイカー | |
| 2 | + | |
| 3 | +7つレベルがあり、レベルを上がるとより難しくなります。\ | |
| 4 | +「YOU WIN」と表示されたら、ハイスコアを教えて下さいね。(´・ω・`) | |
| 5 | + | |
| 6 | +## 音楽 | |
| 7 | +[Stas Gavrikさんより](https://youtube.owacon.moe/playlist?list=PLyc7oozhSJMytXF1eWMUAU2zl84W0Nkqg) | |
| 8 | + | |
| 9 | +## 勉強点 | |
| 10 | +* BGM | |
| 11 | +* オブジェクト指向プログラミング | |
| 12 | +* オブジェクトを非表示にする事 | |
| 13 | + | |
| 14 | +## ソフト | |
| 15 | +* SDL2 | |
| 16 | +* SDL2_mixer | |
| 17 | +* SDL2_ttf | |
| 18 | + | |
| 19 | +## Linux | |
| 20 | +```sh | |
| 21 | +make | |
| 22 | +``` | |
| 23 | + | |
| 24 | +## \*BSD | |
| 25 | +```sh | |
| 26 | +gmake | |
| 27 | +``` | |
| 28 | + | |
| 29 | +## Illumos | |
| 30 | +```sh | |
| 31 | +gmake PREFIX=/usr | |
| 32 | +``` |
追加
ass/1.ogg
バイナリファイル
追加
ass/2.ogg
バイナリファイル
追加
ass/3.ogg
バイナリファイル
追加
ass/4.ogg
バイナリファイル
追加
ass/5.ogg
バイナリファイル
追加
ass/6.ogg
バイナリファイル
追加
ass/7.ogg
バイナリファイル
追加
font.ttf
バイナリファイル
追加
main.cc
| @@ -0,0 +1,76 @@ | ||
| 1 | +#include <SDL2/SDL.h> | |
| 2 | +#include <SDL2/SDL_ttf.h> | |
| 3 | +#include <SDL2/SDL_mixer.h> | |
| 4 | +#include <iostream> | |
| 5 | + | |
| 6 | +#include "src/render.hh" | |
| 7 | +#include "src/ball.hh" | |
| 8 | +#include "src/player.hh" | |
| 9 | +#include "src/brick.hh" | |
| 10 | + | |
| 11 | +int main(void) { | |
| 12 | + Render r; | |
| 13 | + Player p(r); | |
| 14 | + Ball bl(r, p); | |
| 15 | + Brick br(r); | |
| 16 | + | |
| 17 | + if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { | |
| 18 | + std::cout << "SDL_Init()に失敗" << '\n'; | |
| 19 | + return -1; | |
| 20 | + } | |
| 21 | + | |
| 22 | + if (SDL_CreateWindowAndRenderer(r.width, r.height, 0, &r.window, &r.renderer) < 0) { | |
| 23 | + std::cout << "SDL_CreateWindowAndRenderer()に失敗" << '\n'; | |
| 24 | + SDL_Quit(); | |
| 25 | + return -1; | |
| 26 | + } | |
| 27 | + | |
| 28 | + if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { | |
| 29 | + std::cout << "Mix_OpenAudio()に失敗" << '\n'; | |
| 30 | + SDL_DestroyRenderer(r.renderer); | |
| 31 | + SDL_DestroyWindow(r.window); | |
| 32 | + SDL_Quit(); | |
| 33 | + return -1; | |
| 34 | + } | |
| 35 | + | |
| 36 | + SDL_SetWindowTitle(r.window, "ブリックブレイカー"); | |
| 37 | + | |
| 38 | + TTF_Init(); | |
| 39 | + r.font = TTF_OpenFont("font.ttf", r.fontsize); | |
| 40 | + if (!r.font) { | |
| 41 | + std::cout << "フォントを読込に失敗" << '\n'; | |
| 42 | + SDL_DestroyRenderer(r.renderer); | |
| 43 | + SDL_DestroyWindow(r.window); | |
| 44 | + Mix_CloseAudio(); | |
| 45 | + SDL_Quit(); | |
| 46 | + return -1; | |
| 47 | + } | |
| 48 | + | |
| 49 | + static int lastTime = 0; | |
| 50 | + br.resetBricks(r, p, bl); | |
| 51 | + | |
| 52 | + while (r.running) { | |
| 53 | + r.lastFrame = SDL_GetTicks(); | |
| 54 | + if (r.lastFrame >= lastTime + 1000) { | |
| 55 | + lastTime = r.lastFrame; | |
| 56 | + r.fps = r.frameCount; | |
| 57 | + r.frameCount = 0; | |
| 58 | + } | |
| 59 | + | |
| 60 | + if (!r.gameover) { | |
| 61 | + r.update(r, p, bl, br); | |
| 62 | + } | |
| 63 | + r.input(p); | |
| 64 | + r.render(p, bl, br); | |
| 65 | + } | |
| 66 | + | |
| 67 | + TTF_CloseFont(r.font); | |
| 68 | + SDL_DestroyRenderer(r.renderer); | |
| 69 | + SDL_DestroyWindow(r.window); | |
| 70 | + SDL_Quit(); | |
| 71 | + Mix_FreeMusic(r.music); | |
| 72 | + Mix_CloseAudio(); | |
| 73 | + TTF_Quit(); | |
| 74 | + | |
| 75 | + return 0; | |
| 76 | +} |
追加
src/ball.cc
| @@ -0,0 +1,9 @@ | ||
| 1 | +#include "ball.hh" | |
| 2 | + | |
| 3 | +void Ball::resetBall(Render &r, Player &p) { | |
| 4 | + p.player.x = (r.width / 2) - (p.player.w / 2); | |
| 5 | + Ball::ball.y = p.player.y - (p.player.h * 4); | |
| 6 | + Ball::yvelocity = Ball::ballspeed / 2; | |
| 7 | + Ball::xvelocity = 0; | |
| 8 | + Ball::ball.x = r.width / 2 - (Ball::size / 2); | |
| 9 | +} |
追加
src/ball.hh
| @@ -0,0 +1,30 @@ | ||
| 1 | +#ifndef BALL_H | |
| 2 | +#define BALL_H | |
| 3 | + | |
| 4 | +#include <SDL2/SDL.h> | |
| 5 | +#include <iostream> | |
| 6 | + | |
| 7 | +#include "player.hh" | |
| 8 | + | |
| 9 | +class Ball { | |
| 10 | + public: | |
| 11 | + float ballspeed = 8.0f; | |
| 12 | + int size = 16; | |
| 13 | + | |
| 14 | + float xvelocity; | |
| 15 | + float yvelocity; | |
| 16 | + | |
| 17 | + SDL_Rect ball; | |
| 18 | + | |
| 19 | + void resetBall(Render &r, Player &p); | |
| 20 | + | |
| 21 | + Ball(Render& r, Player& p) { | |
| 22 | + ball.y = p.player.y - (p.player.h / 2); | |
| 23 | + yvelocity = ballspeed / 2; | |
| 24 | + xvelocity = ball.x = 0; | |
| 25 | + ball.w = ball.h = size; | |
| 26 | + ball.x = r.width / 2 - (size / 2); | |
| 27 | + } | |
| 28 | +}; | |
| 29 | + | |
| 30 | +#endif |
追加
src/brick.cc
| @@ -0,0 +1,67 @@ | ||
| 1 | +#include <SDL2/SDL.h> | |
| 2 | +#include <SDL2/SDL_mixer.h> | |
| 3 | +#include <SDL2/SDL_ttf.h> | |
| 4 | +#include <iostream> | |
| 5 | + | |
| 6 | +#include "render.hh" | |
| 7 | +#include "player.hh" | |
| 8 | +#include "ball.hh" | |
| 9 | +#include "brick.hh" | |
| 10 | + | |
| 11 | +void Brick::resetBricks(Render &r, Player &p, Ball &bl) { | |
| 12 | + srand(static_cast<unsigned int>(time(nullptr))); | |
| 13 | + r.c1r = rand() % 256; | |
| 14 | + r.c1g = rand() % 256; | |
| 15 | + r.c1b = rand() % 256; | |
| 16 | + r.c2r = rand() % 256; | |
| 17 | + r.c2g = rand() % 256; | |
| 18 | + r.c2b = rand() % 256; | |
| 19 | + r.c3r = rand() % 256; | |
| 20 | + r.c3g = rand() % 256; | |
| 21 | + r.c3b = rand() % 256; | |
| 22 | + r.c4r = rand() % 256; | |
| 23 | + r.c4g = rand() % 256; | |
| 24 | + r.c4b = rand() % 256; | |
| 25 | + r.c5r = rand() % 256; | |
| 26 | + r.c5g = rand() % 256; | |
| 27 | + r.c5b = rand() % 256; | |
| 28 | + r.c6r = rand() % 256; | |
| 29 | + r.c6g = rand() % 256; | |
| 30 | + r.c6b = rand() % 256; | |
| 31 | + | |
| 32 | + | |
| 33 | + if (r.level > 1) { | |
| 34 | + Mix_HaltMusic(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + std::string music = "ass/" + std::to_string(r.level) + ".ogg"; | |
| 38 | + r.music = Mix_LoadMUS(music.c_str()); | |
| 39 | + if (Mix_PlayMusic(r.music, -1) < 0) { | |
| 40 | + std::cout << "OGGファイルのエラー:" << Mix_GetError() << '\n'; | |
| 41 | + r.running = false; | |
| 42 | + TTF_CloseFont(r.font); | |
| 43 | + SDL_DestroyRenderer(r.renderer); | |
| 44 | + SDL_DestroyWindow(r.window); | |
| 45 | + SDL_Quit(); | |
| 46 | + Mix_CloseAudio(); | |
| 47 | + TTF_Quit(); | |
| 48 | + } | |
| 49 | + | |
| 50 | + for (int i = 0; i < Brick::col * Brick::row; i++) { | |
| 51 | + Brick::bricks[i] = 1; | |
| 52 | + } | |
| 53 | + | |
| 54 | + bl.size -= 2; | |
| 55 | + bl.ballspeed += 1.4f; | |
| 56 | + p.player.w -= 1.4f; | |
| 57 | + p.player.x = (r.width / 2) - (p.player.w / 2); | |
| 58 | + bl.ball.y = p.player.y - (p.player.h * 4); | |
| 59 | + bl.yvelocity = bl.ballspeed / 2; | |
| 60 | + bl.xvelocity = 0; | |
| 61 | + bl.ball.x = r.width / 2 - (bl.size / 2); | |
| 62 | +} | |
| 63 | + | |
| 64 | +void Brick::setBricks(int i) { | |
| 65 | + Brick::brick.x = (((i%Brick::col) + 1) * Brick::gaps) + ((i%Brick::col) * Brick::brick.w) - (Brick::gaps/2); | |
| 66 | + Brick::brick.y = Brick::brick.h * 3 + (((i%Brick::row) + 1) * Brick::gaps) + ((i%Brick::row) * Brick::brick.h) - (Brick::gaps/2); | |
| 67 | +} |
追加
src/brick.hh
| @@ -0,0 +1,31 @@ | ||
| 1 | +#ifndef BRICK_H | |
| 2 | +#define BRICK_H | |
| 3 | + | |
| 4 | +#include <SDL2/SDL.h> | |
| 5 | +#include <iostream> | |
| 6 | + | |
| 7 | +#include "render.hh" | |
| 8 | +#include "player.hh" | |
| 9 | +#include "ball.hh" | |
| 10 | + | |
| 11 | +class Brick { | |
| 12 | + public: | |
| 13 | + int col = 7; | |
| 14 | + int row = 5; | |
| 15 | + int gaps = 16; | |
| 16 | + | |
| 17 | + bool bricks[7*5]; | |
| 18 | + | |
| 19 | + SDL_Color color = {255, 255, 255}; | |
| 20 | + SDL_Rect brick; | |
| 21 | + | |
| 22 | + void resetBricks(Render &r, Player &p, Ball &bl); | |
| 23 | + void setBricks(int i); | |
| 24 | + | |
| 25 | + Brick(Render& r) { | |
| 26 | + brick.w = (r.width - (gaps * col)) / col; | |
| 27 | + brick.h = 22; | |
| 28 | + } | |
| 29 | +}; | |
| 30 | + | |
| 31 | +#endif |
| @@ -0,0 +1,25 @@ | ||
| 1 | +#ifndef PLAYER_H | |
| 2 | +#define PLAYER_H | |
| 3 | + | |
| 4 | +#include <SDL2/SDL.h> | |
| 5 | +#include <iostream> | |
| 6 | + | |
| 7 | +#include "render.hh" | |
| 8 | + | |
| 9 | +class Player { | |
| 10 | + public: | |
| 11 | + SDL_Rect player, lives; | |
| 12 | + | |
| 13 | + int score = 0; | |
| 14 | + int scoreMultiplier = 1; | |
| 15 | + int livesCount = 3; | |
| 16 | + | |
| 17 | + Player(Render& r) { | |
| 18 | + player.h = 12; | |
| 19 | + player.y = r.height - player.h - 32; | |
| 20 | + player.w = r.width / 4; | |
| 21 | + player.x = (r.width / 2) - (player.w / 2); | |
| 22 | + } | |
| 23 | +}; | |
| 24 | + | |
| 25 | +#endif |
| @@ -0,0 +1,170 @@ | ||
| 1 | +#include "render.hh" | |
| 2 | +#include "ball.hh" | |
| 3 | +#include "player.hh" | |
| 4 | +#include "brick.hh" | |
| 5 | + | |
| 6 | +#define PI 3.14 | |
| 7 | + | |
| 8 | +void Render::gameOver(Player &p, Brick &br, bool winner) { | |
| 9 | + if (winner) { | |
| 10 | + Render::winner = true; | |
| 11 | + } else { | |
| 12 | + Render::winner = false; | |
| 13 | + } | |
| 14 | + | |
| 15 | + Render::gameover = true; | |
| 16 | + Mix_HaltMusic(); | |
| 17 | +} | |
| 18 | + | |
| 19 | +void Render::write(Player &p, Brick &br, std::string text, int x, int y) { | |
| 20 | + SDL_Surface *surface; | |
| 21 | + SDL_Texture *texture; | |
| 22 | + const char* t = text.c_str(); | |
| 23 | + surface = TTF_RenderText_Solid(Render::font, t, br.color); | |
| 24 | + texture = SDL_CreateTextureFromSurface(Render::renderer, surface); | |
| 25 | + | |
| 26 | + p.lives.w = surface->w; | |
| 27 | + p.lives.h = surface->h; | |
| 28 | + p.lives.x = x - p.lives.w; | |
| 29 | + p.lives.y = y - p.lives.h; | |
| 30 | + | |
| 31 | + SDL_FreeSurface(surface); | |
| 32 | + SDL_RenderCopy(Render::renderer, texture, NULL, &p.lives); | |
| 33 | + SDL_DestroyTexture(texture); | |
| 34 | +} | |
| 35 | + | |
| 36 | +void Render::update(Render &r, Player &p, Ball &bl, Brick &br) { | |
| 37 | + if (p.livesCount <= 0) { | |
| 38 | + gameOver(p, br, false); | |
| 39 | + } | |
| 40 | + | |
| 41 | + if (SDL_HasIntersection(&bl.ball, &p.player)) { | |
| 42 | + double rel = (p.player.x + ((float)p.player.w/2)) - ((float)bl.ball.x + ((float)bl.size/2)); | |
| 43 | + double norm = rel / ((float)p.player.w/2); | |
| 44 | + double bounce = norm * (5*PI/12); | |
| 45 | + | |
| 46 | + bl.yvelocity = -bl.ballspeed * cos(bounce); | |
| 47 | + bl.xvelocity = bl.ballspeed * -sin(bounce); | |
| 48 | + p.scoreMultiplier = 1; | |
| 49 | + } | |
| 50 | + | |
| 51 | + if (bl.ball.y <= 0) { | |
| 52 | + bl.yvelocity = -bl.yvelocity; | |
| 53 | + } | |
| 54 | + if (bl.ball.y + bl.size >= Render::height) { | |
| 55 | + bl.yvelocity = -bl.yvelocity; | |
| 56 | + p.livesCount--; | |
| 57 | + bl.resetBall(r, p); | |
| 58 | + } | |
| 59 | + if (bl.ball.x <= 0 || bl.ball.x + bl.size >= Render::width) { | |
| 60 | + bl.xvelocity = -bl.xvelocity; | |
| 61 | + } | |
| 62 | + bl.ball.x += bl.xvelocity; | |
| 63 | + bl.ball.y += bl.yvelocity; | |
| 64 | + if (p.player.x < 0) { | |
| 65 | + p.player.x = 0; | |
| 66 | + } | |
| 67 | + if (p.player.x + p.player.w > Render::width) { | |
| 68 | + p.player.x = Render::width - p.player.w; | |
| 69 | + } | |
| 70 | + | |
| 71 | + bool reset = true; | |
| 72 | + for (int i = 0; i < br.col*br.row; i++) { | |
| 73 | + br.setBricks(i); | |
| 74 | + | |
| 75 | + if (SDL_HasIntersection(&bl.ball, &br.brick) && br.bricks[i]) { | |
| 76 | + br.bricks[i] = 0; | |
| 77 | + p.score += 100 * p.scoreMultiplier; | |
| 78 | + p.scoreMultiplier++; | |
| 79 | + | |
| 80 | + if (bl.ball.x >= br.brick.x) { | |
| 81 | + bl.xvelocity = -bl.xvelocity; | |
| 82 | + bl.ball.x -= 1; | |
| 83 | + } | |
| 84 | + if (bl.ball.x <= br.brick.x) { | |
| 85 | + bl.xvelocity = -bl.xvelocity; | |
| 86 | + bl.ball.x += 1; | |
| 87 | + } | |
| 88 | + if (bl.ball.y <= br.brick.y) { | |
| 89 | + bl.yvelocity = -bl.yvelocity; | |
| 90 | + bl.xvelocity = -bl.xvelocity; | |
| 91 | + bl.ball.y -= 1; | |
| 92 | + } | |
| 93 | + if (bl.ball.y >= br.brick.y) { | |
| 94 | + bl.yvelocity = -bl.yvelocity; | |
| 95 | + bl.xvelocity = -bl.xvelocity; | |
| 96 | + bl.ball.y += 1; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | + if (br.bricks[i]) { | |
| 101 | + reset = false; | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + if (reset) { | |
| 106 | + Render::level++; | |
| 107 | + if (r.level > 7) { | |
| 108 | + gameOver(p, br, true); | |
| 109 | + } else { | |
| 110 | + br.resetBricks(r, p, bl); | |
| 111 | + } | |
| 112 | + } | |
| 113 | +} | |
| 114 | + | |
| 115 | +void Render::input(Player &p) { | |
| 116 | + SDL_Event e; | |
| 117 | + const Uint8 *keystates = SDL_GetKeyboardState(NULL); | |
| 118 | + | |
| 119 | + while (SDL_PollEvent(&e)) { | |
| 120 | + if (e.type == SDL_QUIT) { | |
| 121 | + Render::running = false; | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + if (keystates[SDL_SCANCODE_Q]) Render::running = false; | |
| 126 | + if (!Render::gameover) { | |
| 127 | + if (keystates[SDL_SCANCODE_LEFT]) p.player.x -= Render::xpos; | |
| 128 | + if (keystates[SDL_SCANCODE_RIGHT]) p.player.x += Render::xpos; | |
| 129 | + } | |
| 130 | +} | |
| 131 | + | |
| 132 | +void Render::render(Player &p, Ball &bl, Brick &br) { | |
| 133 | + SDL_SetRenderDrawColor(Render::renderer, 0x00, 0x00, 0x00, 255); | |
| 134 | + SDL_RenderClear(Render::renderer); | |
| 135 | + | |
| 136 | + Render::frameCount++; | |
| 137 | + Render::timerFPS = SDL_GetTicks() - Render::lastFrame; | |
| 138 | + | |
| 139 | + if (Render::timerFPS < (1000/60)) { | |
| 140 | + SDL_Delay((1000/60) - Render::timerFPS); | |
| 141 | + } | |
| 142 | + | |
| 143 | + SDL_SetRenderDrawColor(Render::renderer, 255, 255, 255, 255); | |
| 144 | + SDL_RenderFillRect(Render::renderer, &p.player); | |
| 145 | + SDL_RenderFillRect(Render::renderer, &bl.ball); | |
| 146 | + write(p, br, "SCORE: " + std::to_string(p.score), Render::width, Render::fontsize*1.5f); | |
| 147 | + write(p, br, "LIVES: " + std::to_string(p.livesCount), 130, Render::fontsize*1.5f); | |
| 148 | + write(p, br, "LEVEL: " + std::to_string(Render::level), 130, Render::fontsize*3.5f); | |
| 149 | + | |
| 150 | + if (Render::gameover) { | |
| 151 | + if (Render::winner) write(p, br, "YOU WIN", Render::width/2+Render::fontsize, Render::height/2); | |
| 152 | + else write(p, br, "YOU LOSS", Render::width/2+Render::fontsize, Render::height/2); | |
| 153 | + } | |
| 154 | + | |
| 155 | + for (int i = 0; i < br.col*br.row; i++) { | |
| 156 | + SDL_SetRenderDrawColor(Render::renderer, c1r, c1g, c1b, 255); | |
| 157 | + if (i%2 == 0) SDL_SetRenderDrawColor(Render::renderer, c2r, c2g, c2b, 255); | |
| 158 | + if (i%3 == 0) SDL_SetRenderDrawColor(Render::renderer, c3r, c3g, c3b, 255); | |
| 159 | + if (i%4 == 0) SDL_SetRenderDrawColor(Render::renderer, c4r, c4g, c4b, 255); | |
| 160 | + if (i%5 == 0) SDL_SetRenderDrawColor(Render::renderer, c5r, c5g, c5b, 255); | |
| 161 | + if (i%6 == 0) SDL_SetRenderDrawColor(Render::renderer, c6r, c6g, c6b, 255); | |
| 162 | + | |
| 163 | + if (br.bricks[i]) { | |
| 164 | + br.setBricks(i); | |
| 165 | + SDL_RenderFillRect(Render::renderer, &br.brick); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + SDL_RenderPresent(Render::renderer); | |
| 170 | +} |
| @@ -0,0 +1,52 @@ | ||
| 1 | +#ifndef RENDER_H | |
| 2 | +#define RENDER_H | |
| 3 | + | |
| 4 | +#include <SDL2/SDL.h> | |
| 5 | +#include <SDL2/SDL_ttf.h> | |
| 6 | +#include <SDL2/SDL_mixer.h> | |
| 7 | +#include <iostream> | |
| 8 | + | |
| 9 | +class Player; | |
| 10 | +class Ball; | |
| 11 | +class Brick; | |
| 12 | + | |
| 13 | +class Render { | |
| 14 | + public: | |
| 15 | + bool running, gameover, winner; | |
| 16 | + int frameCount, timerFPS, lastFrame, fps = 0; | |
| 17 | + | |
| 18 | + int width = 620; | |
| 19 | + int height = 720; | |
| 20 | + int fontsize = 16; | |
| 21 | + int xpos = 9; | |
| 22 | + int level = 1; | |
| 23 | + | |
| 24 | + // 色 | |
| 25 | + int c1r, c1g, c1b; | |
| 26 | + int c2r, c2g, c2b; | |
| 27 | + int c3r, c3g, c3b; | |
| 28 | + int c4r, c4g, c4b; | |
| 29 | + int c5r, c5g, c5b; | |
| 30 | + int c6r, c6g, c6b; | |
| 31 | + | |
| 32 | + SDL_Window *window; | |
| 33 | + SDL_Renderer *renderer; | |
| 34 | + TTF_Font* font; | |
| 35 | + Mix_Music* music; | |
| 36 | + | |
| 37 | + void update(Render &r, Player &p, Ball &bl, Brick &br); | |
| 38 | + void input(Player &p); | |
| 39 | + void render(Player &p, Ball &bl, Brick &br); | |
| 40 | + | |
| 41 | + Render() { | |
| 42 | + winner = false; | |
| 43 | + gameover = false; | |
| 44 | + running = true; | |
| 45 | + } | |
| 46 | + | |
| 47 | + private: | |
| 48 | + void gameOver(Player &p, Brick &br, bool winner); | |
| 49 | + void write(Player &p, Brick &br, std::string text, int x, int y); | |
| 50 | +}; | |
| 51 | + | |
| 52 | +#endif |