master
ブランチ master
Tetris / src / tetris.cc
3.6 KB、126行 生 Blame 履歴
1/**
2Copyright (c) テクニカル諏訪子
3
4Permission is hereby granted to any person obtaining a copy of the software
5Tetris (the "Software") to use, modify, merge, copy, publish, distribute,
6sublicense, and/or sell copies of the Software, subject to the following conditions:
7
8 1. **Origin Attribution**:
9 - You must not misrepresent the origin of the Software; you must not claim
10 you created the original Software.
11 - If the Software is used in a product, you must either:
12 a. Provide clear attribution in the product's documentation, user interface,
13 or other visible areas, **OR**
14 b. Pay the original developers a fee they specify in writing.
15 2. **Usage Restriction**:
16 - The Software, or any derivative works, dependencies, or libraries
17 incorporating it, must not be used for censorship or to suppress freedom of
18 speech, expression, or creativity. Prohibited uses include, but are not
19 limited to:
20 - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
21 ideas, or objective reality.
22 - Tools or systems designed to restrict access to information or
23 artistic works.
24 3. **Notice Preservation**:
25 - This license and the above copyright notice must remain intact in all copies
26 of the source code.
27
28THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
29INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
30PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
32CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
33OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34*/
35#include <tetris/tetris.hh>
36#include <tetris/scene/title.hh>
37#include <tetris/scene/gamemain.hh>
38#include <tetris/scene/gameover.hh>
39
40namespace tetris {
41 scene::Title g_Title;
42 scene::GameMain g_GameMain;
43 scene::GameOver g_GameOver;
44
45 void Game::Init(Game *game) {
46 isRunning = true;
47 isChangeScene = false;
48
49 switch (m_CurScene) {
50 case Scene::Title:
51 g_Title.Init(game);
52 break;
53 case Scene::GameMain:
54 g_GameMain.Init(game);
55 break;
56 case Scene::GameOver:
57 g_GameOver.Init(game);
58 break;
59 }
60 }
61
62 void Game::FuncUpdate() {
63 switch (m_CurScene) {
64 case Scene::Title:
65 g_Title.FuncUpdate();
66 break;
67 case Scene::GameMain:
68 g_GameMain.FuncUpdate();
69 break;
70 case Scene::GameOver:
71 g_GameOver.FuncUpdate();
72 break;
73 }
74 }
75
76 void Game::DrawUpdate() {
77 switch (m_CurScene) {
78 case Scene::Title:
79 g_Title.DrawUpdate();
80 break;
81 case Scene::GameMain:
82 g_GameMain.DrawUpdate();
83 break;
84 case Scene::GameOver:
85 g_GameOver.DrawUpdate();
86 break;
87 }
88 }
89
90 void Game::Close() {
91 switch (m_CurScene) {
92 case Scene::Title:
93 g_Title.Close();
94 break;
95 case Scene::GameMain:
96 g_GameMain.Close();
97 break;
98 case Scene::GameOver:
99 g_GameOver.Close();
100 break;
101 }
102
103 m_CurScene = m_NextScene;
104 }
105
106 void Game::SetNextScene(Scene scene) {
107 m_NextScene = scene;
108 isChangeScene = true;
109 }
110
111 Scene Game::GetCurrentScene() {
112 return m_CurScene;
113 }
114
115 u32 Game::GetScore() {
116 return g_GameMain.GetScore();
117 }
118
119 u16 Game::GetLines() {
120 return g_GameMain.GetLines();
121 }
122
123 u16 Game::GetLevel() {
124 return g_GameMain.GetLevel();
125 }
126} // namespace tetris