summaryrefslogblamecommitdiffstats
path: root/src/snake.h
blob: 3adc301c9cbe35026c1997d78b2a010356d2c0cf (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                 
                 



                  
            

            

              
 
              

        

                     
                        


                            

                     
                        

       





                                                 
 
                        




                                   
                                                                           



                     

                          


      
#ifndef _SNAKE_H_
#define _SNAKE_H_

#include <QList>
#include <QPoint>
#include <QTimer>

class QWidget;
class QPaintEvent;

class Snake;

struct Cell;
struct Ball;
struct Paddle;

class GameCore
{
private:
    QWidget *_widget;
    QTimer *_t;
    int _width, _height;
    QList<Snake*> _snakes;
    QList<Ball*> _balls;
    QList<Paddle*> _paddles;
    int _deaths;
    qint64 _lastMeal;
    const Cell **_field;

public:
    const Cell *field(int x, int y) const {
        return _field[x + _width * y];
    }
    void setField(int x, int y, const Cell *val);

    GameCore(QWidget *widget);

    virtual ~GameCore();

    void paint(QPaintEvent *event);

    void addFood();

    void scanDir(Snake *snake, int x, int y, const Cell* &what, int &dist);

    void addSnake();

    void initField();

    void pauseAndResume();
};

#endif