Turn Based Help Needed

I'm trying to create a game that involves two players taking turns. The game has a top down point of view. The playing area is divided into two halves, with little passage ways inside of the center dividing wall. Each turn is comprised of shooting an actor in hopes of stopping inside a specific area on the opposite side of the center wall. If the actor begins on a players own side and doesn't pass into the other side the turn should change to the other player. If the shot does pass through the center wall and to the other side the same player will receive an extra shot. If the puck begins on the opponents side only one shot is taken and then the turn changes. I've created boolean Game attributes called "hometurn-which determine who's turn it is", "extra shot-for if a bonus shot is earned", "homedefensezone- for determining if the actor is on the hometurns own side", "awaybonusshotarea-for the area that must be reached for the home team to earn an extra shot", and "goalarea-for determining if play should be reset to its original position". However I cannot get home turn to alternate between shots, and I cannot get the game to award bonus shots. How do I remedy this?Thanks,

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Try this:

    [puck Actor]
    When self.motion.linear velocity.X=0 AND self.motion.linear velocity.Y=0
    When self.position.Y greater than or equal to game.halfwaypointY
    Change Attribute game.WhoseTurn to (game.WhoseTurn+1)%2

    When game.WhoseTurn=0
    [rules for player 1]

    When game.WhoseTurn=1
    [rules for player 2]


    It's a start... you'll have to figure out the condition for the other player (e.g. self.position.Y<game.halfwayY) and a bit more, but see where that takes you.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • rrosario007rrosario007 Member, PRO Posts: 15
    Ok I've figure out how to change turns and how to change the attribute a separate attribute "bottom half" or "top half" to true. However, when I shoot the actor from its original location the attribute "bottom half" becomes false as soon as it leaves the bottom half. I need to record this attribute value and apply another rule that includes colliding or overlapping with another actor.

    Meaning if "bottom half" is true while the shot is being aimed, AND it collides with the other actor "bonus zone", Then the original player's shot remains the same. Otherwise the players turn switches.
    Does that make sense?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It sounds like you need to rethink your booleans. Maybe have a game.LaunchedFromBottom that changes to true when the puck is launched but doesn't change back until after the player's turn is over.

    You also might consider other ways to do this. You can have a condition Y>450 (or whatever value) and check that to see if the puck is in the top of bottom half. Or you can have invisible (Change Attribute self.color.alpha to 0) actors that cover each half and then have a boolean (game.TouchingTopHalf) that changes to true when the puck is touching it and Otherwise changes to false.

    I find it helpful to make a chart of the values I need, for example:

    LaunchedFromBottom TouchingBottomHalf TouchingTopHalf PlayersTurn
    true true false 1
    true false true 2

    If you're still having trouble, post your chart (and maybe your rules as well) and we can figure out what to do differently.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.