User Tag List

Results 1 to 10 of 10

Thread: Twin Stick Shooter

  1. #1
    No Products Registered

    Join Date
    Jan 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Twin Stick Shooter

    Currently I'm in the process of working on a platform shooter where the keys move the player and the mouse moves the aimer. Currently, I am attempting to add more players and hope to be able to have up to 4 human players, playing the game at once. The problem I have though is that in order for me to add other players and not make things akward (such as needing 4 keyboards and 4 mice) is to have the other players use joysticks. Unfortunitly though the joysticks only pick up ONE stick even though my gamepad has 2. I need one stick, the left, to move the player while another stick, the right, moves the aimer. Unfortunitly since I can only get MMF to pick up one stick it ends up moveing both the player and the aimer at the same time. Could someone please let me know it twin sticks is an option in MMF, and if so how to set it up correctly.

    Thank You,

    MegapiemanPHD

  2. #2
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using the joypad object instead of the built in controls.

  3. #3
    No Products Registered

    Join Date
    Jan 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have the object but I have no idea how to use it. I can place it on the frame but don't see anything to associate it with player 2's controles.

  4. #4
    Clicker Multimedia Fusion 2 Developer
    gastrop0d's Avatar
    Join Date
    Dec 2011
    Location
    Australia
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Joystick 2 object can handle up with 16 controllers with 2 analogue sticks. You poll joystick direction (indexed by controller number) and joystick distance (how far they've pushed the stick), as well as Right Joystick direction and distance. All of these are expressions, not conditions. So use Compare Two General Values condition to test the state of the controllers.

    How I handle it, is I spread 1 through all my player objects (however many players are playing, you can have the players tell the game how many are playing or you can get the number of connected controllers from the Joystick 2 object). Then I fastloop through all the player objects and basically do this:

    On Loop "getInput"
    alt value (player) == loopindex ("getInput")+1:
    set value A (player) to JoyDeg( "Joystick 2 object", LoopIndex("getInput")+1)
    set value B (player) to Distance( "Advanced Direction Object", 0, 0, JoyDistance( "Joystick 2 object", LoopIndex("getInput")+1, 0), JoyDistance( "Joystick 2 object", LoopIndex("getInput")+1, 1))/100.0

    That's a little long, but its basically grabbing the X-Axis distance and Y-Axis distance and getting the hypotenuse, ie the general distance the stick has been moved away from its centre position.

    You can then use these 2 values to move your player objects with trig. I like using Advanced Direction Object (ADO) because its convenient, essentially its:
    Always:
    Set X(player) to X(player) + GetXMovement("ADO", value A(player), valueB(player)*<max speed of player>)
    Set Y(player) to Y(player) + GetYMovement("ADO", value A(player), valueB(player)*<max speed of player>)

    Hopefully that's clear enough. You loop through all your players and store their joystick states in their respective avatars. Then you use those stored values to move the avatars. You can update the aimers in a very similar way, except polling the right joystick.

  5. #5
    No Products Registered

    Join Date
    Jan 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that the only way to do it? There is no way for MMF to pick up two sticks own its own because although I apreciate all of what you put, I don't understand any of it.

  6. #6
    Clicker Multimedia Fusion 2 Developer
    gastrop0d's Avatar
    Join Date
    Dec 2011
    Location
    Australia
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not that I'm aware of. Any of the more elaborate gamepad/controller functions require some extension or another. Joystick 2 object is the best I've seen.

    Hmm sorry; I breezed through that explanation too quickly I guess. There's several different elements that may be confusing for a newer user...

    Possible points:
    Fast Looping
    Trigonometry
    MMF Jargon (Expressions vs Conditions, etc)
    Advanced Direction Object
    Joystick 2 Object

    Is it possible you can narrow down what in particular you don't understand? I can elaborate.

  7. #7
    No Products Registered

    Join Date
    Jan 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It just seems like it is overcomplicateing things. I don't usualy go that in depth with MMF2 for the reson that after hours of working on something, it almost always dosn't work and I just end up scrapping the game. I may just have to attempt to make the other players use moo to connect over the internet on a differant computer so that they can use their mouse and keyboard. Never used moo though so I don't know if it would be easier.

  8. #8
    Clicker Multimedia Fusion 2 Developer
    gastrop0d's Avatar
    Join Date
    Dec 2011
    Location
    Australia
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is kind of a hurdle you have to jump at some point. The vast majority of objects in MMF2 rely on building expressions. The network objects Moo and Lacewing are a very similar deal, though you may not need as complex expressions (dunno it's been a loooong time since I looked at Moo).

    In regards to ending up with things that don't work and giving up: don't give up! It can be frustrating to hunt down a bug or unravel a problem, but problem solving is the #1 key skill in programming. It's like any mental faculty - you exercise it, it becomes stronger; if you retreat from chances to use it it won't develop. There are some simple techniques that you can learn that greatly help in problem solving.

    A key one is divide and conquer. If something is too big or too complex to understand, see what parts you can eliminate. If you still can't understand it see if you can break it down further. Eventually you should be left with either something that you understand, in which can you can try to build a little piece back onto it, or you end up with a single thing you don't get that you can read up on or ask someone about, so that you overcome that lack of understanding.

    In coding this generally translates into "what parts of the code can I remove/deactivate that might be causing the problem?" Keep deactivating stuff (for instance removing components of a expression, adding the Never condition to events or adding events to groups and deactivating the groups) and testing the code until you get to a point where whatever problem you're trying to solve doesn't happen anymore. Now you know exactly what point in the code you're problem begins occuring. This is the hunt.

    Anyway, bit of a ramble. More on topic: what I've shown is really not that complex when you break it down.

    You get the angle (JoyDeg) and distance (JoyDistance) of the joystick.
    You feed these into ADO with GetMovementX, GetMovementY to get the amount of distance to move on X and Y axes.
    You add these values to the position of the player's character.

    One thing you could remove to simplify it is the distance calculation. This will turn the joystick into a digital input (ON/OFF rather than 0-100%). That would look something like this:

    On Loop "getInput"
    alt value (player) == loopindex ("getInput")+1:
    set value A (player) to JoyDeg( "Joystick 2 object", LoopIndex("getInput")+1)

    Always:
    Set X(player) to X(player) + GetXMovement("ADO", value A(player), <max speed of player>)
    Set Y(player) to Y(player) + GetYMovement("ADO", value A(player), <max speed of player>)

    Another thing you could do is manually run through each player's input rather than using a loop:

    alt value (player) == 1:
    set value A (player) to JoyDeg( "Joystick 2 object", 1)

    alt value (player) == 2:
    set value A (player) to JoyDeg( "Joystick 2 object", 2)

    alt value (player) == 3:
    set value A (player) to JoyDeg( "Joystick 2 object", 3)

    alt value (player) == 4:
    set value A (player) to JoyDeg( "Joystick 2 object", 4)

    Simpler, right?

  9. #9
    No Products Registered

    Join Date
    Jan 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not realy, and I don't see how that helps. MMF2 only picks up one out of two sticks on a controler, the left one. All I want it to do is pick up both left and right. I also don't see how any of that coding even fits in. MMF2 uses checkboxes to make things simpiler instead of straight script where as everything you have put is in script form. I use MMF2 because, unlike flash, I can undersand it since I can do things without a mess of code that I don't understand (beleive me, I have tried to understand code. You eather do or don't and I don't.) If I do need to understand code just to do something as simple as having it use both analog sticks on a controler then I might as well chuck my MMF2 up on ebay.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gastrop0d's message was completely mmf2 code. I don't think you would've appreciated him posting: "Checkmark! Checkmark! 2 Checkmarks!"
    I'm sure if you read his message rather than thinking it was scripting language you'd have realized it's just textualized MMF2 commands.
    For example:
    On Loop "getInput"
    alt value (player) == loopindex ("getInput")+1:
    set value A (player) to JoyDeg( "Joystick 2 object", LoopIndex("getInput")+1)
    On Loop "getInput" is a condition for a fast loop.
    The second line is Compare 2 Global Values (== is the symbol to test equality of 2 things)
    The third line is clearly an action.

Similar Threads

  1. Game Stick?
    By UrbanMonk in forum Android Export Module Version 2.0
    Replies: 4
    Last Post: 2nd April 2013, 04:23 PM
  2. Dual Stick Shooter
    By willy in forum iOS Specific Example Files
    Replies: 15
    Last Post: 16th February 2013, 03:29 PM
  3. Mmf2 on Usb Stick
    By iamjot in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 13th December 2012, 08:38 PM
  4. Stick to object bug
    By Evilized79 in forum iOS Export Module Version 2.0
    Replies: 0
    Last Post: 1st February 2012, 05:31 PM
  5. Error: No detection on twin creation
    By Peer3000 in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 19th February 2008, 05:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •