mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Use fonts everywhere, misc. tweaks
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
class IMICFPS
|
||||
class CameraController
|
||||
include CommonMethods
|
||||
|
||||
|
||||
def initialize(mode: :fpv, camera:, entity:)
|
||||
# :fpv - First Person View
|
||||
# :tpv - Third Person View
|
||||
@mode = mode
|
||||
@camera = camera
|
||||
@entity = entity
|
||||
|
||||
|
||||
@distance = 4
|
||||
@origin_distance = @distance
|
||||
@constant_pitch = 0
|
||||
|
||||
@constant_pitch = 20.0
|
||||
|
||||
window.mouse_x, window.mouse_y = window.width / 2, window.height / 2
|
||||
|
||||
|
||||
@true_mouse = Point.new(window.width / 2, window.height / 2)
|
||||
@mouse_sensitivity = 20.0 # Less is faster, more is slower
|
||||
@mouse_captured = true
|
||||
@mouse_checked = 0
|
||||
end
|
||||
|
||||
|
||||
def distance_from_object
|
||||
@distance
|
||||
end
|
||||
@@ -32,7 +32,7 @@ class IMICFPS
|
||||
def vertical_distance_from_object
|
||||
distance_from_object * Math.sin(@constant_pitch)
|
||||
end
|
||||
|
||||
|
||||
def position_camera
|
||||
if defined?(@entity.first_person_view)
|
||||
if @entity.first_person_view
|
||||
@@ -45,7 +45,7 @@ class IMICFPS
|
||||
x_offset = horizontal_distance_from_object * Math.sin(@entity.orientation.y.degrees_to_radians)
|
||||
z_offset = horizontal_distance_from_object * Math.cos(@entity.orientation.y.degrees_to_radians)
|
||||
|
||||
eye_height = @entity.bounding_box.max.y
|
||||
eye_height = @entity.normalize_bounding_box.max.y
|
||||
|
||||
@camera.position.x = @entity.position.x - x_offset
|
||||
@camera.position.y = @entity.position.y + eye_height
|
||||
@@ -53,10 +53,10 @@ class IMICFPS
|
||||
|
||||
@camera.orientation.y = 180 - @entity.orientation.y
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
position_camera
|
||||
|
||||
|
||||
if @mouse_captured
|
||||
delta = Float(@true_mouse.x - self.mouse_x) / (@mouse_sensitivity * @camera.field_of_view) * 70
|
||||
@camera.orientation.y -= delta
|
||||
@@ -73,7 +73,7 @@ class IMICFPS
|
||||
@true_mouse.x, @true_mouse.y = window.mouse_x, window.mouse_y
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def button_down(id)
|
||||
case id
|
||||
when Gosu::KB_LEFT_ALT, Gosu::KB_RIGHT_ALT
|
||||
@@ -84,7 +84,7 @@ class IMICFPS
|
||||
window.needs_cursor = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def button_up(id); end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user