Microsoft MakeCode

Add more inputs?

hihi,
im just exploring at the moment, looking at my options - i want to make a tiny little game, but the kind of game i want requires more inputs. i want to make a tiny twin-stick shooter.
obviously it wont work if i wanted to share it with others, but thats doesnt bother me.
is it at all possible to have more button inputs, or analog input?

You could use player 2 buttons but it only works for computers

There are combos too

so there’s no way to add more inputs, even through editing config or source files?

I do not know anything about source file though

On hardware, you can only use button combos if you don’t want to wire anything up. If you want to, you could wire some buttons up and connect them to the pins and read them in software.

If you are going to play using the computer only, you can use player 2’s controls. Press the keyboard button under the simulator while it’s running to see the keys requires to press.

oh!! so it is possible to add more buttons?
ive been trying to read up on the documentation, but i cant find anything that explicitly states i can add more inputs, or how i would even access those inputs; https://arcade.makecode.com/hardware/adding
is it just a matter of defining more GPIO pins as buttons, and then calling those extra buttons in javascript?
like this?

PIN_BTN_A = PIN_D6
PIN_BTN_B = PIN_D7
PIN_BTN_C = PIN_D8
PIN_BTN_D = PIN_D9
...
controller.A.onEvent();
controller.B.onEvent();
controller.C.onEvent();
controller.D.onEvent();
...

etc?

i also see controller.dx, is this for analog input? i can see there’s support for an accelerometer, does that mean MakeCode Arcade can do analog input?
im a fairly technical person, but programming is not my strong suit, and neither is learning new things, so im just having a bit of trouble finding where and how to do the things i want to do :sweat_smile:

controller.dx and controllee.dy should be analog.

For the hardware buttons, you would just define the inputs, and read them in a loop. I don’t really use them that much, but o think there should be events for it. Look in maker.makecode.com for examples.

And yes, on some hardware, there is support for the accelerometer.

If you add the controller extension to your project, you should get some accelerometer blocks as well as some other random sensors.

1 Like