OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXAMPLES_PONG_PONG_MODEL_H_ | 5 #ifndef EXAMPLES_PONG_PONG_MODEL_H_ |
6 #define EXAMPLES_PONG_PONG_MODEL_H_ | 6 #define EXAMPLES_PONG_PONG_MODEL_H_ |
7 | 7 |
8 #include "ppapi/cpp/rect.h" | 8 #include "ppapi/cpp/rect.h" |
9 #include "ppapi/cpp/size.h" | 9 #include "ppapi/cpp/size.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int dx; | 112 int dx; |
113 int dy; | 113 int dy; |
114 }; | 114 }; |
115 | 115 |
116 class PongModelDelegate { | 116 class PongModelDelegate { |
117 public: | 117 public: |
118 /** Called when the score changes, whether due to PongModel::SetScore, or | 118 /** Called when the score changes, whether due to PongModel::SetScore, or |
119 * when a player scores. */ | 119 * when a player scores. */ |
120 virtual void OnScoreChanged() = 0; | 120 virtual void OnScoreChanged() = 0; |
121 /** Called only when a player scores, not when the score is changed | 121 /** Called only when a player scores, not when the score is changed |
122 * programatically. */ | 122 * programmatically. */ |
123 virtual void OnPlayerScored() = 0; | 123 virtual void OnPlayerScored() = 0; |
124 }; | 124 }; |
125 | 125 |
126 class PongModel { | 126 class PongModel { |
127 public: | 127 public: |
128 explicit PongModel(PongModelDelegate* delegate); | 128 explicit PongModel(PongModelDelegate* delegate); |
129 | 129 |
130 void SetCourtSize(const pp::Size& size); | 130 void SetCourtSize(const pp::Size& size); |
131 void SetScore(int left_score, int right_score); | 131 void SetScore(int left_score, int right_score); |
132 void ResetPositions(); | 132 void ResetPositions(); |
(...skipping 11 matching lines...) Expand all Loading... |
144 PongModelDelegate* delegate_; // Weak pointer. | 144 PongModelDelegate* delegate_; // Weak pointer. |
145 PaddleModel left_paddle_; | 145 PaddleModel left_paddle_; |
146 PaddleModel right_paddle_; | 146 PaddleModel right_paddle_; |
147 BallModel ball_; | 147 BallModel ball_; |
148 pp::Rect court_; | 148 pp::Rect court_; |
149 int left_score_; | 149 int left_score_; |
150 int right_score_; | 150 int right_score_; |
151 }; | 151 }; |
152 | 152 |
153 #endif // EXAMPLES_PONG_PONG_MODEL_H_ | 153 #endif // EXAMPLES_PONG_PONG_MODEL_H_ |
OLD | NEW |