1 /**
2  * Retrograde Engine
3  *
4  * Authors:
5  *  Mike Bierlee, m.bierlee@lostmoment.com
6  * Copyright: 2014-2021 Mike Bierlee
7  * License:
8  *  This software is licensed under the terms of the MIT license.
9  *  The full terms of the license can be found in the LICENSE.txt file.
10  */
11 
12 module retrograde.game;
13 
14 import retrograde.application;
15 
16 interface Game {
17     void initialize();
18     void update();
19     void render(double extraPolation);
20     void cleanup();
21 
22     @property long targetFrameTime();
23     @property long lagFrameLimit();
24 
25     @property bool terminatable();
26     void requestTermination();
27 
28     @property string name();
29     @property string copyright();
30     @property WindowCreationContext windowCreationContext();
31 }
32 
33 
34 abstract class BaseGame : Game {
35     private bool _terminatable = false;
36     private string _gameName;
37     private string _copyright;
38 
39     public this(string gameName, string copyright = "No copyright") {
40         this._gameName = gameName;
41         this._copyright = copyright;
42     }
43 
44     public override @property long targetFrameTime() {
45         return 10L;
46     }
47 
48     public override @property long lagFrameLimit() {
49         return 100L;
50     }
51 
52     public override @property string name() {
53         return _gameName;
54     }
55 
56     public override @property string copyright() {
57         return _copyright;
58     }
59 
60     public override @property WindowCreationContext windowCreationContext() {
61         return WindowCreationContext();
62     }
63 
64     public override @property bool terminatable() {
65         return _terminatable;
66     }
67 
68     public override void requestTermination() {
69         _terminatable = true;
70     }
71 }