HaxeFlixel Analog Gamepad Polar Coordinate Tank Movement
Move a simple shape around using polar coordinates with analog gamepad controls in tank style
A great starting point for game projects and game jams.
See our other HaxeFlixel Code Samples
See all of our GameDev resources
Move an Nested Sprite around using Polar Coordinate Movement with a gamepad like a tank
This is best for tank
style movement, like a top down tank shooter.
If you want even x
and y
angular movement, like a top down adventure game or a free moving space shooter (Geometry Wars style) then see this Proof of concept instead HaxeFlixel-Analog-Gamepad-Polar-Coordinate-Movement
This demo autodetects your connected usb gamepad. This project uses a usb Logitech gamepad, though other gamepads can be used if you modify the code a little, check the docs for compatible configurations:
- HaxeFlixel Gamepad guide
- Logitech Gamepad Configuration
- XBOX Gamepad Configuration
- PS3 Gamepad Configuration
- PS4 Gamepad Configuration
- OUYA Gamepad Configuration
notice how the turret "sticks" to the tank base when the base rotates
Plug in a usb gamepad. Test this proof of concept.
Controls :
- Left Analog Control Stick
x
axis - rotate the tank basey
axisup
to move forwarddown
to move in reverse (reverse has slower move speed)
- Right Analog Control Stick
x
axis - rotate the turret
Gamepads used :
Aftermarket usb gamepad, walmart link, newegg link
Logitech F310 usb gamepad - newegg link
on the back of this gamepad, there is a switch setting for x
and d
, set it to d
if it's not detected (osx)
To run this proof of concept
Setup
only need to do this once
Install OpenFL and Haxe Install HaxeFlixel
Sublime Text users, get the Haxe Plugin
Get Sublime Text Package Control
https://packagecontrol.io/installation
ctrl + shift + p
to open the Sublime Text command palette
package install
"Haxe"
Atom users, get the Haxe Plugin
ctrl + shift + p
to open the Atom command palette
install package
"Settings View: Install Packages and Themes"
Perform a search for Haxe and install the package.
Also install dependent packages:
Then search for lime and install this package too.
Other Haxe Editors
Vim users, get vaxe
Testing
Run With Sublime Text Plugin
open this project in Sublime Text
open the Main.hx
file
Choose compile target using ctrl + shift + b
Test the project using the chosen target ctrl + enter
Run With Atom
open project with Atom
in the project drawer, right-click on project.xml
and Set as active Lime/OpenFL file
open the command palette with ctrl + shift + b
and select Lime: set target
set current build target to neko (or your desired target)
command + b
or control + b
to build and test for the selected target
Run With Command Line
lime test neko