レポジトリ種類: Mercurial

#ifndef BALL_H
#define BALL_H

#include <SDL2/SDL.h>
#include <iostream>

#include "player.hh"

class Ball {
  public:
    float ballspeed = 8.0f;
    int size = 16;

    float xvelocity;
    float yvelocity;

    SDL_Rect ball;

    void resetBall(Render &r, Player &p);

    Ball(Render& r, Player& p) {
      ball.y = p.player.y - (p.player.h / 2);
      yvelocity = ballspeed / 2;
      xvelocity = ball.x = 0;
      ball.w = ball.h = size;
      ball.x = r.width / 2 - (size / 2);
    }
};

#endif