Fixed lighting artifacts caused by untransformed normals, added 'Scene' for holding objects for rendering, added turn table models to menus using a scene, misc other changes.

This commit is contained in:
2020-03-23 11:48:32 -05:00
parent 18a62b81cc
commit 87fcc3a05c
14 changed files with 139 additions and 48 deletions

View File

@@ -8,21 +8,25 @@ class IMICFPS
@base_color = Gosu::Color.rgb(255, 127, 0)
@background_alpha = 200
window.needs_cursor = true
@__version_text = CyberarmEngine::Text.new("<b>#{IMICFPS::NAME}</b> v#{IMICFPS::VERSION} (#{IMICFPS::RELEASE_NAME})")
@__version_text.x = window.width - (@__version_text.width + 10)
@__version_text.y = window.height - (@__version_text.height + 10)
super(*args)
end
def title(text, color = @base_color)
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15, alignment: :center)
@elements << Text.new(text, color: color, size: 100, x: 0, y: 15)
@_title = @elements.last
end
def subtitle(text, color = Gosu::Color::WHITE)
@elements << Text.new(text, color: color, size: 50, x: 0, y: 100, alignment: :center)
@elements << Text.new(text, color: color, size: 50, x: 0, y: 100)
@_subtitle = @elements.last
end
def link(text, color = Gosu::Color.rgb(0,127,127), &block)
text = Text.new(text, color: color, size: 50, x: 0, y: 100 + (60 * @elements.count), alignment: :center)
text = Text.new(text, color: color, size: 50, x: 0, y: 100 + (60 * @elements.count))
@elements << Link.new(text, self, block)
end
@@ -30,38 +34,44 @@ class IMICFPS
draw_background
draw_menu_box
draw_menu
@__version_text.draw
if window.scene
window.gl(-1) do
window.renderer.draw(window.scene.camera, window.scene.lights, window.scene.entities)
end
window.scene.draw
end
end
def draw_background
@background ||= Gosu.record(Gosu.screen_width, Gosu.screen_height) do
((Gosu.screen_height+@slope)/@size).times do |i|
fill_quad(
0, i*@size,
0, @slope+(i*@size),
window.width/2, (-@slope)+(i*@size),
window.width/2, i*@size,
Gosu::Color.rgba(@base_color.red-i*@color_step, @base_color.green-i*@color_step, @base_color.blue-i*@color_step, @background_alpha)
)
fill_quad(
window.width, i*@size,
window.width, @slope+(i*@size),
window.width/2, (-@slope)+(i*@size),
window.width/2, i*@size,
Gosu::Color.rgba(@base_color.red-i*@color_step, @base_color.green-i*@color_step, @base_color.blue-i*@color_step, @background_alpha)
)
end
((Gosu.screen_height+@slope)/@size).times do |i|
fill_quad(
0, i*@size,
0, @slope+(i*@size),
window.width/2, (-@slope)+(i*@size),
window.width/2, i*@size,
Gosu::Color.rgba(@base_color.red-i*@color_step, @base_color.green-i*@color_step, @base_color.blue-i*@color_step, @background_alpha),
-2
)
fill_quad(
window.width, i*@size,
window.width, @slope+(i*@size),
window.width/2, (-@slope)+(i*@size),
window.width/2, i*@size,
Gosu::Color.rgba(@base_color.red-i*@color_step, @base_color.green-i*@color_step, @base_color.blue-i*@color_step, @background_alpha),
-2
)
end
@background.draw(0, 0, 0)
end
def draw_menu_box
draw_rect(
window.width/4, 0,
window.width/2, window.height,
Gosu::Color.rgba(0, 0, 0, 150)
# Gosu::Color.rgba(@base_color.red+@color_step, @base_color.green+@color_step, @base_color.blue+@color_step, 200)
Gosu::Color.rgba(0, 0, 0, 150),
)
end
@@ -73,8 +83,16 @@ class IMICFPS
def update
@elements.each do |e|
e.x = window.width / 2 - e.width / 2
e.update
end
if window.scene
window.scene.update(window.dt)
end
@__version_text.x = window.width - (@__version_text.width + 10)
@__version_text.y = window.height - (@__version_text.height + 10)
end
def fill_quad(x1, y1, x2, y2, x3, y3, x4, y4, color = Gosu::Color::WHITE, z = 0, mode = :default)
@@ -125,6 +143,7 @@ class IMICFPS
end
def x; text.x; end
def x=(n); text.x = n; end
def y; text.y; end
def width; text.width; end
def height; text.height; end