mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Re-added mousefix :(, camera can now be flown around if it's not attached to a game object, tweaked Player initial jump velocity.
This commit is contained in:
@@ -17,4 +17,4 @@ DEPENDENCIES
|
|||||||
opengl-bindings
|
opengl-bindings
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.6
|
1.17.1
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class IMICFPS
|
|||||||
include GLU
|
include GLU
|
||||||
|
|
||||||
attr_accessor :x,:y,:z, :field_of_view, :pitch, :yaw, :roll, :mouse_sensitivity
|
attr_accessor :x,:y,:z, :field_of_view, :pitch, :yaw, :roll, :mouse_sensitivity
|
||||||
attr_reader :game_object
|
attr_reader :game_object, :broken_mouse_centering
|
||||||
def initialize(x: 0, y: 0, z: 0, fov: 70.0, distance: 100.0)
|
def initialize(x: 0, y: 0, z: 0, fov: 70.0, distance: 100.0)
|
||||||
@x,@y,@z = x,y,z
|
@x,@y,@z = x,y,z
|
||||||
@render_pitch = 20.0
|
@render_pitch = 20.0
|
||||||
@@ -22,6 +22,9 @@ class IMICFPS
|
|||||||
@true_mouse = Point.new(Gosu.screen_width/2, Gosu.screen_height/2)
|
@true_mouse = Point.new(Gosu.screen_width/2, Gosu.screen_height/2)
|
||||||
@mouse_sensitivity = 20.0
|
@mouse_sensitivity = 20.0
|
||||||
@mouse_captured = true
|
@mouse_captured = true
|
||||||
|
@mouse_checked = 0
|
||||||
|
|
||||||
|
@broken_mouse_centering = ARGV.join.include?("--disable-mousefix") ? false : true
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_to(game_object)
|
def attach_to(game_object)
|
||||||
@@ -90,6 +93,14 @@ class IMICFPS
|
|||||||
if @mouse_captured
|
if @mouse_captured
|
||||||
position_camera if @game_object
|
position_camera if @game_object
|
||||||
|
|
||||||
|
if @broken_mouse_centering
|
||||||
|
if @mouse_checked < 3
|
||||||
|
@mouse_checked+=1
|
||||||
|
@true_mouse.x, @true_mouse.y = self.mouse_x, self.mouse_y
|
||||||
|
end
|
||||||
|
return unless @mouse_checked > 2
|
||||||
|
end
|
||||||
|
|
||||||
@yaw-=Float(@true_mouse.x-self.mouse_x)/(@mouse_sensitivity*@field_of_view)*70 unless @game_object
|
@yaw-=Float(@true_mouse.x-self.mouse_x)/(@mouse_sensitivity*@field_of_view)*70 unless @game_object
|
||||||
@game_object.y_rotation+=Float(@true_mouse.x-self.mouse_x)/(@mouse_sensitivity*@field_of_view)*70 if @game_object
|
@game_object.y_rotation+=Float(@true_mouse.x-self.mouse_x)/(@mouse_sensitivity*@field_of_view)*70 if @game_object
|
||||||
|
|
||||||
@@ -98,10 +109,44 @@ class IMICFPS
|
|||||||
@render_pitch = @render_pitch.clamp(-90.0, 90.0)
|
@render_pitch = @render_pitch.clamp(-90.0, 90.0)
|
||||||
@pitch = @pitch.clamp(-90.0, 90.0)
|
@pitch = @pitch.clamp(-90.0, 90.0)
|
||||||
|
|
||||||
|
free_move unless @game_object
|
||||||
|
|
||||||
self.mouse_x, self.mouse_y = Gosu.screen_width/2.0, Gosu.screen_height/2.0
|
self.mouse_x, self.mouse_y = Gosu.screen_width/2.0, Gosu.screen_height/2.0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def free_move
|
||||||
|
relative_y_rotation = (@yaw + 180)
|
||||||
|
relative_speed = 0.5
|
||||||
|
|
||||||
|
if button_down?(Gosu::KbUp) || button_down?(Gosu::KbW)
|
||||||
|
@z+=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
@x-=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
end
|
||||||
|
|
||||||
|
if button_down?(Gosu::KbDown) || button_down?(Gosu::KbS)
|
||||||
|
@z-=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
@x+=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
end
|
||||||
|
|
||||||
|
if button_down?(Gosu::KbA)
|
||||||
|
@z+=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
@x+=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
end
|
||||||
|
|
||||||
|
if button_down?(Gosu::KbD)
|
||||||
|
@z-=Math.sin(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
@x-=Math.cos(relative_y_rotation * Math::PI / 180)*relative_speed
|
||||||
|
end
|
||||||
|
|
||||||
|
if button_down?(Gosu::KbSpace)
|
||||||
|
@y+=relative_speed
|
||||||
|
end
|
||||||
|
if button_down?(Gosu::KbLeftShift) || button_down?(Gosu::KbRightShift)
|
||||||
|
@y-=relative_speed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def button_up(id)
|
def button_up(id)
|
||||||
case id
|
case id
|
||||||
when Gosu::KbLeftAlt
|
when Gosu::KbLeftAlt
|
||||||
|
|||||||
@@ -142,10 +142,11 @@ class IMICFPS
|
|||||||
end
|
end
|
||||||
if @jumping && !@falling
|
if @jumping && !@falling
|
||||||
if button_down?(Gosu::KbSpace)
|
if button_down?(Gosu::KbSpace)
|
||||||
@y_velocity+=(2*15)*delta_time
|
@y_velocity = 1.5
|
||||||
@falling = true if @y_velocity >= 2
|
@falling = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@y+=@y_velocity*delta_time
|
@y+=@y_velocity*delta_time
|
||||||
|
|
||||||
@y = @floor if @y < @floor
|
@y = @floor if @y < @floor
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ OpenGL Shader Language Version: #{glGetString(GL_SHADING_LANGUAGE_VERSION)}
|
|||||||
|
|
||||||
Camera pitch: #{@camera.pitch.round(2)} Yaw: #{@camera.yaw.round(2)} Roll #{@camera.roll.round(2)}
|
Camera pitch: #{@camera.pitch.round(2)} Yaw: #{@camera.yaw.round(2)} Roll #{@camera.roll.round(2)}
|
||||||
Camera X:#{@camera.x.round(2)} Y:#{@camera.y.round(2)} Z:#{@camera.z.round(2)}
|
Camera X:#{@camera.x.round(2)} Y:#{@camera.y.round(2)} Z:#{@camera.z.round(2)}
|
||||||
|
Compensating faulty mouse centering? #{@camera.broken_mouse_centering}
|
||||||
#{if @camera.game_object then "Actor X:#{@camera.game_object.x.round(2)} Y:#{@camera.game_object.y.round(2)} Z:#{@camera.game_object.z.round(2)}";end}
|
#{if @camera.game_object then "Actor X:#{@camera.game_object.x.round(2)} Y:#{@camera.game_object.y.round(2)} Z:#{@camera.game_object.z.round(2)}";end}
|
||||||
Field Of View: #{@camera.field_of_view}
|
Field Of View: #{@camera.field_of_view}
|
||||||
Mouse Sesitivity: #{@camera.mouse_sensitivity}
|
Mouse Sesitivity: #{@camera.mouse_sensitivity}
|
||||||
|
|||||||
Reference in New Issue
Block a user