mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Cleanup
This commit is contained in:
@@ -63,6 +63,7 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
model.update
|
||||||
end
|
end
|
||||||
# Do two Axis Aligned Bounding Boxes intersect?
|
# Do two Axis Aligned Bounding Boxes intersect?
|
||||||
def intersect(a, b)
|
def intersect(a, b)
|
||||||
|
|||||||
@@ -21,21 +21,21 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
|
|
||||||
if button_down?(Gosu::KbUp) || button_down?(Gosu::KbW)
|
if button_down?(Gosu::KbUp) || button_down?(Gosu::KbW)
|
||||||
@z+=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
|
||||||
@x-=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
|
||||||
end
|
|
||||||
if button_down?(Gosu::KbDown) || button_down?(Gosu::KbS)
|
|
||||||
@z-=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
@z-=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
@x+=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
@x+=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
end
|
end
|
||||||
if button_down?(Gosu::KbA)
|
if button_down?(Gosu::KbDown) || button_down?(Gosu::KbS)
|
||||||
@z+=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
@z+=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
@x+=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
@x-=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
end
|
end
|
||||||
if button_down?(Gosu::KbD)
|
if button_down?(Gosu::KbA)
|
||||||
@z-=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
@z-=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
@x-=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
@x-=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
end
|
end
|
||||||
|
if button_down?(Gosu::KbD)
|
||||||
|
@z+=Math.sin(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
@x+=Math.cos(@y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
end
|
||||||
|
|
||||||
if button_down?(Gosu::KbLeft)
|
if button_down?(Gosu::KbLeft)
|
||||||
@y_rotation-=relative_speed*100
|
@y_rotation-=relative_speed*100
|
||||||
@@ -44,17 +44,13 @@ class IMICFPS
|
|||||||
@y_rotation+=relative_speed*100
|
@y_rotation+=relative_speed*100
|
||||||
end
|
end
|
||||||
|
|
||||||
@y-=relative_speed if button_down?(Gosu::KbC) || button_down?(Gosu::KbLeftShift)
|
@y-=relative_speed if button_down?(Gosu::KbC) || button_down?(Gosu::KbLeftShift) unless @y <= 0
|
||||||
@y+=relative_speed if button_down?(Gosu::KbSpace)
|
@y+=relative_speed if button_down?(Gosu::KbSpace)
|
||||||
|
|
||||||
|
@y = 0 if @y < 0
|
||||||
# distance = 2.0
|
# distance = 2.0
|
||||||
# x_offset = distance * Math.cos(@bound_model.y_rotation)
|
# x_offset = distance * Math.cos(@bound_model.y_rotation)
|
||||||
# z_offset = distance * Math.sin(@bound_model.y_rotation)
|
# z_offset = distance * Math.sin(@bound_model.y_rotation)
|
||||||
model.x = @x
|
|
||||||
model.y = @y
|
|
||||||
model.z = @z
|
|
||||||
|
|
||||||
# model.y_rotation = (@y_rotation)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ class IMICFPS
|
|||||||
class Skydome < GameObject
|
class Skydome < GameObject
|
||||||
def setup
|
def setup
|
||||||
bind_model(ModelLoader.new(type: :obj, file_path: "objects/skydome.obj", game_object: self))
|
bind_model(ModelLoader.new(type: :obj, file_path: "objects/skydome.obj", game_object: self))
|
||||||
p model.class
|
|
||||||
# raise "Skydome scale: #{self.scale}" unless self.scale == 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,5 +3,10 @@ class IMICFPS
|
|||||||
def setup
|
def setup
|
||||||
bind_model(ModelLoader.new(type: :obj, file_path: "objects/tree.obj", game_object: self))
|
bind_model(ModelLoader.new(type: :obj, file_path: "objects/tree.obj", game_object: self))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def update
|
||||||
|
# super
|
||||||
|
# @y_rotation+=0.005
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class IMICFPS
|
|||||||
|
|
||||||
def initialize(file_path:, game_object:)
|
def initialize(file_path:, game_object:)
|
||||||
@game_object = game_object
|
@game_object = game_object
|
||||||
@x, @y, @z = game_object.x, game_object.y, game_object.z
|
update
|
||||||
@scale = game_object.scale
|
|
||||||
@file_path = file_path
|
@file_path = file_path
|
||||||
@file = File.open(file_path, 'r')
|
@file = File.open(file_path, 'r')
|
||||||
@material_file = nil
|
@material_file = nil
|
||||||
@@ -88,6 +87,11 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
$window.number_of_faces+=self.faces.size
|
$window.number_of_faces+=self.faces.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@x, @y, @z = @game_object.x, @game_object.y, @game_object.z
|
||||||
|
@scale = @game_object.scale
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ class IMICFPS
|
|||||||
@delta_time = Gosu.milliseconds
|
@delta_time = Gosu.milliseconds
|
||||||
@number_of_faces = 0
|
@number_of_faces = 0
|
||||||
@draw_skydome = true
|
@draw_skydome = true
|
||||||
@skydome = Skydome.new(scale: 0.1, backface_culling: false, auto_manage: false)
|
@skydome = Skydome.new(scale: 0.02, backface_culling: false, auto_manage: false)
|
||||||
Tree.new(x: 1, y: 0, z: -5)
|
Tree.new(x: 1, y: 0, z: -5)
|
||||||
p ObjectManager.objects.map {|o| o.name}
|
p ObjectManager.objects.map {|o| o.name}
|
||||||
# Model.new(type: :obj, file_path: "objects/tree.obj", z: -5)
|
# Model.new(type: :obj, file_path: "objects/tree.obj", z: -5)
|
||||||
# Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6)
|
# Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6)
|
||||||
# Model.new(type: :obj, file_path: "objects/sponza.obj", scale: 1, y: -0.2)
|
# Model.new(type: :obj, file_path: "objects/sponza.obj", scale: 1, y: -0.2)
|
||||||
# @terrain = Terrain.new(size: 20)
|
@terrain = Terrain.new(size: 20)
|
||||||
|
|
||||||
@camera = Camera.new(x: 0, y: -2, z: 1)
|
@camera = Camera.new(x: 0, y: -2, z: 1)
|
||||||
@player = Player.new(x: 1, y: 0, z: -10)
|
@player = Player.new(x: 1, y: 0, z: -10)
|
||||||
@@ -56,7 +56,7 @@ class IMICFPS
|
|||||||
light.draw
|
light.draw
|
||||||
end
|
end
|
||||||
@camera.draw
|
@camera.draw
|
||||||
@skydome.draw# if @skydome.renderable
|
@skydome.draw if @skydome.renderable
|
||||||
glEnable(GL_DEPTH_TEST)
|
glEnable(GL_DEPTH_TEST)
|
||||||
|
|
||||||
ObjectManager.objects.each do |object|
|
ObjectManager.objects.each do |object|
|
||||||
|
|||||||
Reference in New Issue
Block a user