Home
Fusion 2.5+
Firefly+
Tutorials+
Videos+
Guides & Tips+
Extensions
Versions
Teaching


Making a game for 2 players

Making a game for 2 players

This tutorial was written by:
Kjetil Nossum (Popcorn)

Ok, now you should know the basics of how to do objecthandling in TGF2. Let's go back to the frame editor! Select Frame Editor from the View menu, or click on its icon. Since this will be a Pong game, we want some paddles for the players to control. So, do like you did when you added the ball. In the same gfx library you should see a nice collection of paddles. Drag one of them into the play area.

 

 

You see that it's angled a little different than we want. Pong should be played left – right, so we need to change the angle of the paddle. There are several ways we can do that. I'll show you one of them. Doubleclick the paddle. You will be presented with the screen below:

 

 

Click on the Rotate button. I drew a little arrow in there to show you were it is. Now you see some new buttons. Click on the 90 degrees button to rotate the object 90 degrees. You'll see that the object has rotated. Click OK to go back to the Frame Editor. Now the paddle should be correct.

 

We want two paddles. You could drag one more, but we want to clone the first one. To clone an object, rightclick on it and click on Clone Object. Click OK in the new window.

 

Now you have two identical objects. But they are two different objects, they just looks the same. Place the objects where you want them to be.

 

 

We want to assign movements to these objects so that they can be controlled by the players. Since both paddles should have the same type of movement, it's fastest to select both at once. Click on one of them, then hold shift while you click on the other one. In the Movement Properties, set its movement type to Eight Directions.
We don't want all the eight directions, so you have to deselect the ones you don't want. We only want the paddles to move up and down.

 

After you've done this you can test the game. Press F7. Do you notice that you can control both players with the arrow keys? This is because both the paddles are set to be controlled by Player 1. To change this go back to the Frame Editor and click on the paddle to the right. In its Movement Properties you'll see that it's set to Player 1. Change this value to 2.

 

If you test the game again you will still see that you move both players with the arrow keys. This is because you have to define the control for player 2 yourself. In the Workspace toolbar, click on your game's icon. The Workspace toolbar is the one at the far left of the screen. Now select the Runtime Options Tab, as shown in the picture below, and click on the big Edit button at the right of the Default Controls text.

 

 

The black crosses tells you that all players are assigned to the keyboard. Click on the cross below Player 2. If you have Joysticks attached to your PC, you can chose that instead. But I chose Keyboard controls. Then just select which buttons to use for Player 2. You only need to select Up and Down buttons for this game.

 

 

Ok, test your game again. You can now control each player with different keys. But the game isn't totally working, is it? No, the ball are just bouncing around and not even noticing our paddles. It's time to go back into the Event Editor!

 

Make a new condition. Rightclick the ball and select Collisions / Another object.

 

 

Select one of the paddles. We want the ball to bounce. Since we allready have a bounce action, simply drag that action down to the new condtion. Or you can add the bounce action manually like the last time.

  • (Small ball 3) leaves the play area

(Small ball 3) : Bounce

  • Collision between (Small ball 3) and (Bat 1)

(Small ball 3) : Bounce

Test the game. The ball will now bounce when it touches the paddle. But we want it to bounce when it touches the other paddle too. So do the same thing for that one. A trick is to drag the event you just made down to event 3. Then just doubleclick on the Paddle icon and select the other paddle instead.

  • Collision between (Small ball 3) and (Bat 2)

(Small ball 3) : Bounce

If that's done correctly the ball should now bounce while colliding with both paddles.




Spread the word!



You can share this document using the following buttons.




Submit your own User Tip