[font=arial][color=rgb(34,34,34)]First, the input model is modeled after the Gamepad. Thus, I just read the values of the Gamepad, and assign them to input. Just one small translation. The Gamepad returns the horizontal and vertical axis for each Joystick. Right now, I only care about the Left Joystick. I find using the Direction and Magnitude more useful from a Joystick. So I translate the Horizontal and Vertical to Direction and Speed using arctan2 and the Pythagorean Formula. In total, I have the variables [/color][/font][font='courier new'][color=rgb(34,34,34)]input_attack input_jump input_pause input_back input_horizontal input_vertical[/color][/font][font=arial][color=rgb(34,34,34)], as well as [/color][/font][font='courier new'][color=rgb(34,34,34)]input_direction[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]input_speed[/color][/font][font=arial][color=rgb(34,34,34)]. Append [/color][/font][font='courier new'][color=rgb(34,34,34)]_previous _pressed[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]_released[/color][/font][font=arial][color=rgb(34,34,34)] for the rest of the input model.
[font=arial][color=rgb(34,34,34)]Let's deal with the easy one first, [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_[/color][/font][font=arial][color=rgb(34,34,34)]. First, I check if [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_id[/color][/font][font=arial][color=rgb(34,34,34)] still exist, if not [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_id=-1[/color][/font][font=arial][color=rgb(34,34,34)], else [/color][/font][font='courier new'][color=rgb(34,34,34)]input_attack=true[/color][/font][font=arial][color=rgb(34,34,34)], and that is it. I do store [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_x[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_y[/color][/font][font=arial][color=rgb(34,34,34)] for future use, but that is all that works right now. The left is more difficult since it will model a Joystick. First, the same thing, if [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_id[/color][/font][font=arial][color=rgb(34,34,34)] still exist or not. If it is not, [/color][/font][font='courier new'][color=rgb(34,34,34)]vb_id=-1[/color][/font][font=arial][color=rgb(34,34,34)]. Here is where it gets complicated. If [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_id[/color][/font][font=arial][color=rgb(34,34,34)] exist, I check if [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_origin=true[/color][/font][font=arial][color=rgb(34,34,34)]. If it doesn't, [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_origin=true[/color][/font][font=arial][color=rgb(34,34,34)]. Additionally, [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_origin_x[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_origin_y[/color][/font][font=arial][color=rgb(34,34,34)] are stored as well. This is done on the first step [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_id[/color][/font][font=arial][color=rgb(34,34,34)] exist. It represents the neutral position of the joystick. If [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_origin==true[/color][/font][font=arial][color=rgb(34,34,34)], I skip this step. Next, as long as [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_id[/color][/font][font=arial][color=rgb(34,34,34)] exist, I store its [/color][/font][font='courier new'][color=rgb(34,34,34)]x[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]y[/color][/font][font=arial][color=rgb(34,34,34)] position in [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_x[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]vj_y[/color][/font][font=arial][color=rgb(34,34,34)]. Now I have two vectors, one for the origin, and the current Touchpoint. I then subtract the current from the origin and I get the same angle and distance the current and origin vectors have with the origin and vector (0,0). This vector is stored in the temporary variables [/color][/font][font='courier new'][color=rgb(34,34,34)]horiz[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]vert[/color][/font][font=arial][color=rgb(34,34,34)]. Each one is limited to be no greater than 60 and no less than -60, then I divide it by 60 to get value between -1 and 1. I assign this value to [/color][/font][font='courier new'][color=rgb(34,34,34)]input_horizontal[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]input_vertical[/color][/font][font=arial][color=rgb(34,34,34)]. Now, I can find [/color][/font][font='courier new'][color=rgb(34,34,34)]input_direction[/color][/font][font=arial][color=rgb(34,34,34)] and [/color][/font][font='courier new'][color=rgb(34,34,34)]input_speed [/color][/font][font=arial][color=rgb(34,34,34)]the same way as always. At this point, the Virtual Joystick is functional, but I wanted to try something extra.
Previous Entry
Update 004 - Animation ... and some News
Next Entry
Update 005.2 Pause, Menu and Perspective.
Advertisement
Latest Entries
Nearly done with the Re Write
3489 views
Update 005.2 Pause, Menu and Perspective.
1340 views
Update 004 - Animation ... and some News
1199 views
Update 003 - Pause and Menu
974 views
Update 002 - Indoor and Outdoors
1201 views
Update 001 - Isometric Perspective
1447 views
Website is Functionally finished
1289 views
At GDC
856 views
Advertisement