Colliding-Mice / player.h
player.h
Raw
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QGraphicsPixmapItem>
#include<QGraphicsScene>
#include "score.h"



class player : public QObject,public QGraphicsPixmapItem   //player class inherits from QObject and QGraphicsPixmapItem
{
   Q_OBJECT
public:
  explicit player(QPixmap pixmap, Score* score);   //player constructor
  void keyPressEvent(QKeyEvent * event);           //function that recognizes key presses


public slots:
  void advanced();   //function that is used to incerase the score and delete mice when the player collides with them
private:
  int l_key = 0;    //keys that are used to alternate between sprites, which makes the cat look like it is walking
  int r_key = 0;
  int d_key = 0;
  int u_key = 0;
  Score* myscore;   //variable that holds score pointer that is passed to player
};

#endif // PLAYER_H