Zmeika
простая аркадная игра
 Указатель Классы Пространства имен Файлы Функции Переменные Определения типов Перечисления Страницы
GameScreen.hpp
См. документацию.
1 /*
2  * This file is part of AV Orchid.
3  * Copyright (c) 2013, Dmitri R. Kuvshinov <evetro.here@gmail.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
22 #pragma once
23 
24 #include <functional> // std::function
25 
26 #include "Screen.hpp"
27 #include "ViewModelBase.hpp"
28 
29 
31 class GameScreen : public AScreen
32 {
33 public:
34 
35  GameScreen();
36  ~GameScreen() override;
37 
39  typedef std::function<void(Score)> GameOverHandler;
40 
43  {
44  doGameOver = handler;
45  }
46 
48  bool isPaused() const;
49 
50 protected:
51 
52  void onSelect() override;
53  void onIdle() override;
54  void onDisplay() override;
55  void onChar(unsigned char code, int mouse_x, int mouse_y) override;
56  void onSpecialKey(int code, int mouse_x, int mouse_y) override;
57  void onMouse(int button, int mouse_x, int mouse_y) override;
58 
59 private:
60 
61  // копирование объектов экрана запрещено
62  GameScreen(const GameScreen&);
63  GameScreen& operator=(const GameScreen&);
64  class Game *impl; // pimpl
65  GameOverHandler doGameOver;
66 };