mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 07:32:35 +00:00
Added overlay for future fps and stats display
This commit is contained in:
@@ -106,6 +106,7 @@ require_relative "lib/scenes/turn_table"
|
||||
require_relative "lib/crosshair"
|
||||
require_relative "lib/demo"
|
||||
|
||||
require_relative "lib/overlay"
|
||||
require_relative "lib/window"
|
||||
|
||||
require_relative "lib/tools/asset_viewer"
|
||||
|
||||
@@ -14,7 +14,6 @@ class IMICFPS
|
||||
@lights = []
|
||||
|
||||
@collision_manager = CollisionManager.new(map: self)
|
||||
@renderer = window.renderer
|
||||
Publisher.new
|
||||
end
|
||||
|
||||
@@ -54,7 +53,7 @@ class IMICFPS
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen and the depth buffer
|
||||
gl_error?
|
||||
|
||||
@renderer.draw(camera, @lights, @entities)
|
||||
window.renderer.draw(camera, @lights, @entities)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
17
lib/overlay.rb
Normal file
17
lib/overlay.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class IMICFPS
|
||||
class Overlay
|
||||
include CommonMethods
|
||||
def initialize
|
||||
@text = CyberarmEngine::Text.new("")
|
||||
end
|
||||
|
||||
def draw
|
||||
Gosu.draw_rect(0, 0, 256, 20, Gosu::Color.rgba(0, 0, 0, 100))
|
||||
Gosu.draw_rect(2, 2, 256 - 4, 20 - 4, Gosu::Color.rgba(100, 100, 100, 100))
|
||||
@text.x = 3
|
||||
@text.y = 3
|
||||
@text.text = "FPS: #{Gosu.fps}"
|
||||
@text.draw
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -31,7 +31,6 @@ class IMICFPS
|
||||
@lights << @light
|
||||
|
||||
@camera = Camera.new(position: Vector.new(0, 1.5, 5), orientation: Vector.forward)
|
||||
@renderer = Renderer.new
|
||||
|
||||
label @manifest.name, text_size: 50
|
||||
label @manifest.model
|
||||
@@ -55,7 +54,7 @@ class IMICFPS
|
||||
)
|
||||
|
||||
Gosu.gl do
|
||||
@renderer.draw(@camera, [@light], @map.entities)
|
||||
window.renderer.draw(@camera, [@light], @map.entities)
|
||||
end
|
||||
|
||||
@crosshair.draw
|
||||
|
||||
@@ -1,17 +1,58 @@
|
||||
class IMICFPS
|
||||
class MapEditorTool
|
||||
class Editor < CyberarmEngine::GuiState
|
||||
|
||||
attr_reader :map
|
||||
def setup
|
||||
@map = Map.new( map_parser: @options[:map] )
|
||||
@camera = Camera.new( position: Vector.new, orientation: Vector.new(0, 90, 0) )
|
||||
# TODO: Move everything required for a playable game map
|
||||
# in a Scene or Scene3D container object
|
||||
# and refactor Game to use it.
|
||||
Publisher.new
|
||||
@map = Map.new( map_parser: @options[:map_parser] )
|
||||
@camera = Camera.new( position: Vector.new )
|
||||
@crosshair = Crosshair.new
|
||||
|
||||
@map.setup
|
||||
end
|
||||
|
||||
def draw
|
||||
window.renderer.draw(@camera, @map.entities, @map.lights)
|
||||
super
|
||||
@map.render(@camera)
|
||||
@crosshair.draw
|
||||
end
|
||||
|
||||
def update
|
||||
@camera.position.y -= 1 * window.dt
|
||||
super
|
||||
Publisher.instance.publish(:tick, Gosu.milliseconds - window.delta_time)
|
||||
@map.update
|
||||
@camera.update
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
if id == Gosu::KB_ESCAPE
|
||||
# TODO: Use Editor specific menu
|
||||
push_state(GamePauseMenu)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
InputMapper.keydown(id)
|
||||
Publisher.instance.publish(:button_down, nil, id)
|
||||
|
||||
@map.entities.each do |entity|
|
||||
entity.button_down(id) if defined?(entity.button_down)
|
||||
end
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
InputMapper.keyup(id)
|
||||
Publisher.instance.publish(:button_up, nil, id)
|
||||
|
||||
@map.entities.each do |entity|
|
||||
entity.button_up(id) if defined?(entity.button_up)
|
||||
end
|
||||
|
||||
@camera.button_up(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class IMICFPS
|
||||
push_state(ExtrasMenu)
|
||||
end
|
||||
|
||||
link "Exit" do
|
||||
link "Exit Game" do
|
||||
window.close
|
||||
end
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class IMICFPS
|
||||
@renderer = Renderer.new
|
||||
@renderer.preload_default_shaders
|
||||
@scene = TurnTableScene.new
|
||||
@overlay = Overlay.new
|
||||
|
||||
@canvas_size = Vector.new(self.width, self.height)
|
||||
|
||||
@@ -46,6 +47,7 @@ class IMICFPS
|
||||
super
|
||||
|
||||
@console.draw if @show_console
|
||||
@overlay.draw
|
||||
draw_cursor if needs_cursor
|
||||
|
||||
_canvas_size = Vector.new(self.width, self.height)
|
||||
|
||||
Reference in New Issue
Block a user