note
	description: "[
							A GAME_HAPTIC_EFFECT that play on a periodic strength.
							A periodic effect consists of a wave-shaped effect that
							repeats itself over time. Example:
		
							button         period
							press          |     |
							  ||      __    __    __    __    __    _
							  ||     |  |  |  |  |  |  |  |  |  |   magnitude   __ Offset
							  \/     |  |__|  |__|  |__|  |__|  |   _
							    -----
							      |
							    delay          phase >>
							
							-------------------------------------
							              length
							===================================================
							                      interval
	]"
	author: "Louis Marchand"
	date: "Tue, 03 Mar 2015 14:16:22 +0000"
	revision: "2.0"

class 
	GAME_HAPTIC_PERIODIC_EFFECT

inherit
	GAME_HAPTIC_EFFECT_INFINITE_LENGTH

	GAME_HAPTIC_EFFECT_ENVELOPE

create 
	make_sine,
	make_square,
	make_triangle,
	make_sawtooth_up,
	make_sawtooth_down

feature {NONE} -- Initialization

	make_sine
			-- Initialization of Current using a sine periodic effect
			--   __      __      __      __
			--  /  \    /  \    /  \    /
			-- /    \__/    \__/    \__/
		do
			make
			set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_sine.as_natural_16)
		end

	make_square
			-- Initialization of Current using a square periodic effect
			--  __    __    __    __    __
			-- |  |  |  |  |  |  |  |  |  |
			-- |  |__|  |__|  |__|  |__|  |
		do
			make
			set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_leftright.as_natural_16)
		end

	make_triangle
			-- Initialization of Current using a triangle periodic effect
			--   /\    /\    /\    /\    /\
			--  /  \  /  \  /  \  /  \  /
			-- /    \/    \/    \/    \/
		do
			make
			set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_triangle.as_natural_16)
		end

	make_sawtooth_up
			-- Initialization of Current using a sawtooth periodic effect opened at the bottom
			--   /|  /|  /|  /|  /|  /|  /|
			--  / | / | / | / | / | / | / |
			-- /  |/  |/  |/  |/  |/  |/  |
		do
			make
			set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_sawtoothup.as_natural_16)
		end

	make_sawtooth_down
			-- Initialization of Current using a sawtooth periodic effect opened at the bottom
			-- \  |\  |\  |\  |\  |\  |\  |
			--  \ | \ | \ | \ | \ | \ | \ |
			--   \|  \|  \|  \|  \|  \|  \|
		do
			make
			set_type ({GAME_SDL_EXTERNAL}.sdl_haptic_sawtoothdown.as_natural_16)
		end
	
feature -- Access

	direction: GAME_HAPTIC_DIRECTION assign set_direction
			-- The orientation that the force of Current come from
		require
			exists: exists
		do
			create Result.make_by_pointer ({GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_direction (specific_item))
		end

	set_direction (a_direction: GAME_HAPTIC_DIRECTION)
			-- assign direction with the values of a_direction
		require
			exists: exists
		do
			direction.copy (a_direction)
		ensure
			is_assign: direction ~ a_direction
		end

	length: NATURAL_32 assign set_length
			-- Duration of Current (in millisecond)
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_length (specific_item)
		end

	set_length (a_length: NATURAL_32)
			-- Assign length with the value of a_length
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_length (specific_item, a_length)
		end

	delay: NATURAL_16 assign set_delay
			-- delay before starting Current (in millisecond)
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_delay (specific_item)
		end

	set_delay (a_delay: NATURAL_16)
			-- Assign delay with the value of a_delay
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_delay (specific_item, a_delay)
		end

	interval: NATURAL_16 assign set_interval
			-- how soon before effect can be triggered again (in millisecond)
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_interval (specific_item)
		end

	set_interval (a_interval: NATURAL_16)
			-- Assign interval with the value of a_interval
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_interval (specific_item, a_interval)
		end

	period: NATURAL_16 assign set_period
			-- Time (in millisecond) between two wave.
		require
			exists: exists
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_period (specific_item)
		end

	set_period (a_period: NATURAL_16)
			-- Assign period with the value of a_period
		require
			exists: exists
			period_valid: a_period <= 32767
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_period (specific_item, a_period)
		ensure
			is_assign: period = a_period
		end

	magnitude: INTEGER_16 assign set_magnitude
			-- peak value; if negative, equivalent to 180 degrees extra phase shift
		require
			exists: exists
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_magnitude (specific_item)
		end

	set_magnitude (a_magnitude: INTEGER_16)
			-- Assign magnitude with the value of a_magnitude
		require
			exists: exists
			magnitude_valid: a_magnitude <= 32767
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_magnitude (specific_item, a_magnitude)
		ensure
			is_assign: magnitude = a_magnitude
		end

	offset: INTEGER_16 assign set_offset
			-- Mean value of the wave
		require
			exists: exists
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_offset (specific_item)
		end

	set_offset (a_offset: INTEGER_16)
			-- Assign offset with the value of a_offset
		require
			exists: exists
			offset_valid: a_offset <= 32767
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_offset (specific_item, a_offset)
		ensure
			is_assign: offset = a_offset
		end

	phase: NATURAL_16 assign set_phase
			-- Time (in millisecond) between two wave.
		require
			exists: exists
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_phase (specific_item)
		end

	set_phase (a_phase: NATURAL_16)
			-- Assign phase with the value of a_phase
		require
			exists: exists
			phase_valid: a_phase <= 32767
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_phase (specific_item, a_phase)
		ensure
			is_assign: phase = a_phase
		end

	fade_in_level: NATURAL_16 assign set_fade_in_level
			-- level at the start of the fade in
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_attack_level (specific_item)
		end

	set_fade_in_level (a_fade_in_level: NATURAL_16)
			-- Assign fade_in_level with the value of a_fade_in_level
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_attack_level (specific_item, a_fade_in_level)
		end

	fade_in_length: NATURAL_16 assign set_fade_in_length
			-- length of the fade in
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_attack_length (specific_item)
		end

	set_fade_in_length (a_fade_in_length: NATURAL_16)
			-- Assign fade_in_length with the value of a_fade_in_length
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_attack_length (specific_item, a_fade_in_length)
		end

	fade_out_level: NATURAL_16 assign set_fade_out_level
			-- level at the start of the fade out
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_fade_level (specific_item)
		end

	set_fade_out_level (a_fade_out_level: NATURAL_16)
			-- Assign fade_out_level with the value of a_fade_out_level
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_fade_level (specific_item, a_fade_out_level)
		end

	fade_out_length: NATURAL_16 assign set_fade_out_length
			-- length of the fade out
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_periodic_fade_length (specific_item)
		end

	set_fade_out_length (a_fade_out_length: NATURAL_16)
			-- Assign fade_out_length with the value of a_fade_out_length
		do
			{GAME_SDL_EXTERNAL}.set_sdl_haptic_periodic_fade_length (specific_item, a_fade_out_length)
		end
	
feature {NONE} -- Implementation

	specific_item: POINTER
			-- Internal pointer that is specific to a certain type of Current
			-- Note that item only point to a C union.
		do
			Result := {GAME_SDL_EXTERNAL}.get_sdl_haptic_effect_periodic (item)
		end
	
end -- class GAME_HAPTIC_PERIODIC_EFFECT

Generated by ISE EiffelStudio