gamnit: make `SpriteSet` public so clients can use its services
[nit.git] / lib / gamnit / gamnit.nit
index 079062d..fccf2ae 100644 (file)
@@ -18,8 +18,11 @@ module gamnit
 import app
 
 import display
+import textures
+import programs
 
 import gamnit_android is conditional(android)
+import gamnit_linux is conditional(linux)
 
 redef class App
 
@@ -38,7 +41,7 @@ redef class App
        # Core of the frame logic, executed only when the display is visible
        #
        # This method should be redefined by user modules to customize the behavior of the game.
-       protected fun frame_core do end
+       protected fun frame_core(display: GamnitDisplay) do end
 
        # Full frame logic, executed even if the display is not visible
        #
@@ -49,15 +52,13 @@ redef class App
        protected fun frame_full
        do
                var display = display
-               if display != null then frame_core
+               if display != null then frame_core(display)
 
                feed_events
        end
 
        redef fun run
        do
-               if "NIT_TESTING".environ == "true" then exit 0
-
                # TODO manage exit condition
                loop frame_full
        end
@@ -66,4 +67,19 @@ redef class App
        #
        # The implementation varies per platform.
        private fun feed_events do end
+
+       # Hook to receive and respond to `event` triggered by the user or system
+       #
+       # Returns whether or not the event is used or intercepted.
+       # If `true`, the event will not be processed further by the system.
+       # Returns `false` to intercepts events like the back key on mobile devices.
+       #
+       # The instances passed as `event` may be freed (or overwritten),
+       # right after this method returns. They should not be preserved.
+       fun accept_event(event: InputEvent): Bool do return false
+
+       # The window has been resized by the user or system
+       #
+       # The framework handles resizing the viewport automatically.
+       fun on_resize(display: GamnitDisplay) do end
 end