Tutorial: U-Fight

The Games Factory / Multimedia Fusion Tutorials

Welcome to the fourth issue of our tutorial series on how to create a game with The Games Factory or Multimedia Fusion. In this issue we are going to create a submarine scrolling game.

If you have never used The Games Factory or Multimedia Fusion before, we highly suggest that you follow the Chocobreak tutorial. You can find this tutorial inside the program under the help menu then tutorial.  That tutorial explains all of the inner working of the game creation software.

Explore the ocean and destroy the enemy ships with your torpedos.

Step 1. Installing the graphic library.

First we need to install the the library of graphics into the libs folder of Multimedia Fusion or The Games Factory. Please download the following installer : www.clickteam.com/creation_materials/U-Fight.exe
Run this installer after it has been downloaded and. select the product you are using. It will copy the library in the Tutorial section of the library and also create a U-Fight directory in your installation folder.

Step 2. Creating the frame.

We are going to program a scrolling game : the frame must be larger than the display window. Create a new application by clicking on the "New" icon in the toolbar. Click on "1" in the storyboard editor window to open the frame and display its properties in the property explorer. Enter 1280x480 in the first line of the explorer ("Size") and validate the entry with the Return key.



Step 3. Dropping the objects.

Open the "U-Fight" library in the library window. It should be available in the Objects/Tutorial folder if you have installed the libraries in step 1.
Drop the following objects :


Step 4. The ships movements.

We are now going to make the ships move. Click on the "WarShip01S" object to display its properties in the property explorer, locate and select the "Movements" tab. Choose "Bouncing ball" in the Type property combo box. Our boat will not bounce like a ball, but we are going to use the properties of this movement.
Set the Speed to 18, then click on the "Initial direction" property, and only select the right direction.
Do the same for the other boats. The lower the boat, the faster the speed. The boat facing on the left will have their initial direction set to the left. Don’t hesitate to test the game to see how fast the ships are moving.



Step 5. Setting the properties of the boats.

The boats are going to be created outside the visible section of the ocean. To increase the speed of your games our software tools have a default behavior of destroying the objects far from the display window area. You have to change the properties to it not to destroy the objects outside of the display window area.
Click on each one of the boats to display its property in the property explorer. Locate and click on the "Runtime Options" tab in the explorer. Now find the property named "Destroy object if too far from frame" and uncheck it. Select "No" in the combo box of the next property ("Inactivate if too far from frame"). Doing this will keep the boats active, even if they are far from the display window.


Step 6. Creating the moving boats.

Now click on the "Event editor" icon in the toolbar. Enter the following events. Every second, we draw a random number. If the number is greater than 93, we create a boat. We have to put it in the back of the display list, so that it does not appear on the top of the periscope. The next event makes sure the boat is destroyed when it reaches the end of the display (otherwise it would continue exist out of the frame, slowing down the game).

Step 7. Creating the other boats.

We still have three other boats to create using the same technique. Enter the following events to achieve this :

Step 8. The periscope.

You can launch the game now. You should see the boats moving to the left or the right in the periscope. We are now going to enter the movement of the periscope. Go back to the frame editor (by clicking on its icon in the toolbar). Click on the periscope object to display its properties in the property explorer. Locate the "Movements" tab in the explorer and click on it. Choose the "Eight directions" movement in the "Type" property.

Click on the "Initial direction" property, and select only directions to the left and right.


Step 9. The scrolling.

Lets make the game scroll. Go back in the event editor, and enter the following events. The first line makes sure the periscope does not get out of the screen. The second actually makes the scrolling, by synchronising the center of the frame with the periscope.
If you try the game now, you can move the periscope to the left or right with the arrow keys.


Step 10. The submarine torpedo.

Go back in the frame editor and drop in the frame the "Torpedo_Player" object. Drop it in the bottom of the screen, close to the periscope object but on the right of it. Now click on this object to display its properties in the property explorer.
Choose the "Path" movement in the "Type" property. You now must enter a straight-line movement, from bottom to top. Enter it in several chunks, and make sure the speed decreases as it moves to the top of the screen (it must be fast at first, then slower and slower).
The object must move throughout the height of the screen and give the impression to disappear in the horizon. This movement must be synchronised with the animations.


Step 11. Shooting the torpedo.

Once the movement of your torpedo defined, move the it out of the game area (so that it does not appear wher the game starts). Go back in the event editor and enter the following events. You will remember that we limit the number of torpedos to one. This will increase the difficulty of the game.
We also play a sound when we shoot the torpedo : you will find this sound in the "Tutorials\U-Fight" folder of your Multimedia Fusion or Games Factory installation directory.


Step 12. Collisions.

We have to handle the collisions between the torpedo and the ships. The following events acheive this task for the first boat.


Step 13. Collisions with the other boats.

The previous event were simple : detection of the collisions, destruction of the boat, and playing a sound. Here are the events to enter for the other boats.

Step 14. Enemy torpedo.

The enemy boats must also shoot at us. Go back to the frame editor, and drop on the surface of the sea, the object named "torpedo_ennemy" a small object (do not loose track of it in the editor!). For the submarine torpedo, choose a path movement for this object, and enter a straight-line movement from top to bottom. The object must accelerate as it gets close to the bottom of the screen, giving the impression it gets closer to us. The movement must be synchronised with the animation.


Step 15. Enemy fire.

Enter the following events to make the enemy ships shoot at us. You will notice that we test the position of the boat to make sure it does not shoot when it lays in an unaccessible area of the screen.


Step 16. Destroying the torpedo.

When the submarine torpedo reaches the enemy torpedo, both must be destroyed. This is done with this simple event :

Step 17. Torpedo has reached its target.

When the torpedo reaches the end of its path, it means that it has reached its destination and that our submarine is destroyed. We must subtract one to the number of lives and play an explosion sound.


Step 18. End of the game.

The game must end when the number of lives reaches zero. This can be done with this simple event :


Step 19. Enhancing the game.

The game should work now. You have to pay attention to the enemy torpedoes to stay alive. A few suggestions to enhance the game :

You can of course add a title and high-score screen to the game (you will find the objects ready in the library).

Thank you for following this tutorial. It has shown you how to create a scrolling game, and make sure the objects stay active even when far from the frame, how to define a complex path movement, how to create objects at random times, how to handle collisions and more.

Graphics by Oliver Pearl - www.oliverpearl.com