master
ブランチ master
BrickBreaker / src / ball.hh
543 B、32行 生 Blame 履歴
1#ifndef BALL_H
2#define BALL_H
3
4#include <SDL2/SDL.h>
5#include <iostream>
6
7#include "player.hh"
8
9class Ball {
10 public:
11 float ballspeed = 8.0f;
12 int size = 16;
13
14 float xvelocity;
15 float yvelocity;
16 float xvelSave;
17 float yvelSave;
18
19 SDL_Rect ball;
20
21 void resetBall(Render &r, Player &p);
22
23 Ball(Render& r, Player& p) {
24 ball.y = p.player.y - (p.player.h / 2);
25 yvelocity = ballspeed / 2;
26 xvelocity = ball.x = 0;
27 ball.w = ball.h = size;
28 ball.x = r.width / 2 - (size / 2);
29 }
30};
31
32#endif