Jump to content

Prototyping/design: How do you test multipole control schemes?


Cronos72
 Share

Recommended Posts

I was just curious how others prototyping process works. Right now I am working on something and I want to try different control schemes. i am finding it rather cumbersome. Basically I write new logic and fix every where that breaks.
I try to write my stuff as modular as possible but perhaps there is some godly programming paradigm that I am unaware of? Maybe a functional approach would be better with phaser 2?

Link to comment
Share on other sites

Try to isolate pieces and create API for each of your 'pieces' which dictates how they 'chat' to each other. For example, movement in a top-down 2d game could consist of 4 simple messages i.e Up, Down, Left and Right, somewhere in your code a message is dispatched with a direction and somewhere else in your code is listening for these messages and responds accordingly (this is the Publisher/Subscriber design pattern, sometimes called an Observer).

If you have a mechanism like the above then you can play with different ways of triggering those messages i.e. buttons on screen, reacting to swipes, keyboard entry, voice entry, accelerometer etc etc just change the code but ensure it dispatches these messages. You might not want pub/sub but you can achieve the same by calling specific functions, or even by attaching specific callbacks (or promises, for example) to your UI layer code (reacting to user input is UI realm stuff).

This communication protocol (whatever you choose) defines an API for that part of your code. This could be as simple as creating a `UserInputManager` class which handles this, or, just a load of functions. How you structure things is still up to you, you just need to try to keep code isolated and creating an API for various objects/classes is a way of doing this (sometimes called an Interface in other languages).

If you get really good at this you can switch out entire parts of your application similar to how Phaser lets you choose between different Physics implementations. You can even let the user choose which of these methods to use via a settings screen (for example).

There is a lot of information out there about how to do this sort of thing, maybe search for Black Box coding i.e. you create a function called `GatherUserInput` that takes no input parameters and returns a string, this string defines what the user has done and is mapped to a finite array of possible choices (for example), from here on out you don't need to know anything about how the `GatherUserInput` function works, you only care that it returns a string saying what has happened and then you respond to that string however you see fit. (this example uses a function but you can use the exact same theory for pub/sub i.e. event emitters and callbacks and a host of other mechanisms).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...