Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Adaptive controls

This thread is locked; no one can reply to it. rss feed Print
Adaptive controls
Vieira
Member #16,926
December 2018

I am here again, ;D ;D ;D
One last doubt about my menu, :-X

I wanted to know if I have to create a part where the player can enter with the key to manually choose the control of the character and the game, my idea was to play also with a usb control. ..
However, my game has parts where you have to write something on the screen, so I had the idea of creating a virtual keyboard, such as consoles, mapping each square and when the player clicked or pressed some part of the keyboard, it recognized as letter.

Is it a good idea to do this virtual keyboard manually or are there other ways?
How would I create a menu where the player r can enter with the key to choose manually the control of the character and the game? ???

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Rodolfo Lam
Member #16,045
August 2015

If you go the virtual keyboard way, try using one of the already made GUI frameworks for Allegro, such as Eagle or AllegroFlare. It can get a little bit on the complex side of things if you need to ask.

As a general recommendation it is always ok to start small with games and work your way from there. Have something playable before focusing on this. Allegro only cares about drawing your stuff, not how you make it work. All complexity and functionality in your game, you provide it. Good luck!

ZoriaRPG
Member #16,714
July 2017
avatar

Don't use a mouse-based virtual keyboard, or worse, a NES-style character entry thing.

Give your game an engine state (I use byte TypingMode), and if that mode == KB_ENTRY (or TypingMode&1), then you are receiving text. Otherwise, you are receiving control input.

Pressing a special key, such as F1, could toggle the mode.

I use ag4, not ag5, so I'm unsure how polling has changed, but every game loop, based on your KB ms polling, you'd read the entire KB and either (1) mapthose keys to characters in a string (or char buffer), or (2) accept that key as a press for a control button (such as up, down, A, B, X, Y); all based on one simple bit.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

ZoriaRPG said:

I use ag4, not ag5, so I'm unsure how polling has changed, but every game loop, based on your KB ms polling, you'd read the entire KB

Polling is dead, thank the MCP. Allegro 5 is based on events. You get event based input. You never poll, because you don't need to. You get every key exactly when it is pressed and when it is released, from which you can derive every single kind of state between open, pressed, held, or released.

Go to: