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

Just started using Construct 2? Post your questions here

Post » Tue May 26, 2015 8:33 pm

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.
B
4
Posts: 5
Reputation: 225

Post » Wed May 27, 2015 8:10 am

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
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301

Post » Wed May 27, 2015 9:39 am

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?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 28, 2015 5:58 pm

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?
B
4
Posts: 5
Reputation: 225

Post » Thu May 28, 2015 11:49 pm

- 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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jun 03, 2015 2:43 pm

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?
Life is good. Have another piece of chocolate.
B
15
S
3
G
1
Posts: 28
Reputation: 1,123


Return to Beginner's Questions

Who is online

Users browsing this forum: Lordreef and 0 guests