How do I make a tennis-like game with a centered barrier

0 favourites
  • 6 posts
From the Asset Store
JBoB Sound Studio Casual SFX "Casual Tennis Sound" Pack contain royalty-free stock sound effects.
  • Hi,

    I want to create a game where you can play "tennis" against a friend. The players can move freely on their own site. So now I'm having trouble with the centered line, which makes it impossible to move the one player to site on the other player BUT makes it possible for the ball to pass through this line.

    I've read some threads about a similar problem, where the physic-behavior was the answer... But I didn't understand how to solve my problem.

    Thanks for your help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • you maybe need to look into isometric or fake 3d since your ball wold need to jump over the net and fall down from a top down almost prespective however its easier to just use Q3d plugin and make the hole thing in 2d by using 3d physics and engine

  • Your opening-post raises a lot of questions..

    The top two on my list are:

    1- Is your game top-down, viewed from the side or isometric?

    2- Which movement-behaviour are you using for your players and which behaviour for your ball?

  • sorry for the lack of informations, but thank you both for your reply.

    i was lying sick in my bed and was so tired and did'nt wrote a good post. sorry for that.

    to your questions:

    1.) the game is top-down. on the left site player 1 and right player 2

    2.) player-behaviour: 8 direction (player 1 moved with WASD)

    ball-behaviour: bullet

    screenshot:

    http://www.directupload.net/file/d/4001/h47bud52_jpg.htm

    player 1 is blue, player 2 is orange.

    the "ball" is red.

    my point is:

    how do i make the ball pass trough the slightly transparant green barrier in the middle of the screen, but keep the players away from getting on the oppenents site?

    the green barrier can't have the "solid"-behaviour, because the ball can't fly trough it...

    any suggestions?

    • You could clamp the players x and y
    • You could use background sprites and only move player if overlapping
    • You could use is overlapping at offset and stop the player from moving closer

    So many options to do this..

  • Place the players right next to the green barrier on opposite sides, and measure their x values.

    You could insert the following events, and this is assuming that Player1 is on the right side and Player2 is on the left:

    Player1 >> X > (whatever the x value that you measured) | Player1 >> Set X to (whatever the x value that you measured)

    Do the same thing with Player2, but make it "X < " instead of "X > ".

    Does that help?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)