Your first game
Why, hello there! Today I'm going to teach you how to make a simple game. This is the next step when it comes to learning MMF2. Before reading on, you should have the following knowledge (all of which is taught in Please login to see this link.):
You should know how to create a new game/application.
You should know how to insert an object.
You should know how to make an object move using one of the built-in movements.
You should know how to start the frame.
You should know how to go to the event editor.
You should know how to stop an object from moving outside of your game/application's window.
If you already know all of this, then you should be ready to continue. If you only know how to do some of these, or you don't know how to do any of them at all, I suggest you go to Please login to see this link., which will teach you all of those.
So, if you are ready, let's begin!
#0: Open up MMF2.
#1: Create a new game/application.
#2: Go to the frame editor by clicking the button with a 1 on it.
#3: Insert two active objects.
Have you wondered how to make an object have your own graphics? Well, I'm about to show you how to edit an object's graphic.
#1: Right-click on the object you want to edit (in this case, it's the second object you inserted).
#2: Click on "Edit".
It should bring up a screen that looks something like this:
Please login to see this attachment.
The checkered pattern behind the object may have different colors, so you don't need to pay attention to their color.
Now, in order to make things easier, zoom in using the slider that is circled in the screenshot below:
Please login to see this attachment.
After zooming in, it should look more like this:
Please login to see this attachment.
I'm using a lot of images, huh? Anyway, so now to editing the object's graphic:
#1: Select the rectangle tool (circled in the screenshot below):
Please login to see this attachment.
#2: Select the filled rectangle option (circled in the screenshot below):
Please login to see this attachment.
#3: In the opacity box, change the opacity to something between 25-75 (the higher the number, the more the color will change).
#4: Select any color you want (I recommend red).
#5: Click and drag from one corner of the object to another (it helps to start and end slightly outside of the object's graphic).
After doing that, your diamond will appear to be colored closer to the color you selected.
If you don't change the opacity, it simply draws a rectangle/square in the place you clicked and dragged over. This will be the enemy in the game. Click the OK button.
Now, how are you going to have multiple enemies without having repetitive code? It's simple: We duplicate the object. What does this do? It creates multiple instances (basically, copies) of the object. The copies use the same code as the original copy of the object, so you don't need redundant code in order to have them all do the same thing. There are other ways to copy the object, but duplicate is what we will use here. To duplicate an object, you:
#1: Right-click on the object that you want to duplicate (in this case, it's the one you just edited).
#2: Select duplicate.
Doing that brings up this window:
Please login to see this attachment.
Change the number of rows (actually, columns) to something between 3 and 5, and press okay.
This will create 3, 4, or 5 duplicates of the object, depending on how many you set it to. That should be plenty for our game, though you can make more duplicates of the enemy later if you want to. Before placing the enemies, we need to place the player in the proper position so that you can know where to place the enemies. In this case, we want the player in the center of the screen. To place an object in the center of the screen, you:
#1: Right-click on the object you want to place in the center (In this case, the object that hasn't been edited.)
#2: Move your mouse over "Align in frame".
#3: Click on horizontal center.
#4: Repeat steps 1-3, only click on vertical center instead of horizontal center on step 3.
Now the player should be in the center of the frame. Now you can click and drag the enemies to various places on the frame. The white area represents the area of the frame that will show up in the window when you run the frame, so make sure to place them fully inside of it. Make sure to place the enemies far away from the player to give them some time to react.
Before we give the objects movements and go to the event editor, we should name our objects. To do that, you:
#1: Right-click on the object you want to re-name.
#2: Click on Rename.
#3: Type in the name you want ("Player" for the player, "Enemy" for the enemies).
You should now have all of them named. Next up, we give the objects movements. You already know how to do that, so I'll just tell you which objects should have what movements.
The player should have the eight direction movement. Set the speed to anything you want.
The enemies should have the bouncing ball movement. Make sure they are slower than the player, even if only a little bit slower.
That's it for the movement. Now it's time to go to the event editor! You should already know how to go there. If you forgot, then it's by clicking on this button:
Please login to see this attachment.
Got that? That is the button you need to click.
Now let's see if you remember how to stop an object from moving outside of the frame. Do you? If you do, then code that for the player and enemies (make sure to use bounce on both the player and the enemies instead of stop).
If you don't, then I'll give you a quick refresher.
#1: Click on the "New condition" button.
#2: Right-click on the player object.
#3: Move your mouse over the "Position" sub-menu.
#4: Click on "Test position of "Player"".
#5: Select the arrows shown in the picture below:
Please login to see this attachment.
#6: Click OK.
#7: Right-click the box that lines up with both the player and your new condition.
#8: Move your mouse over the "Movement" sub-menu.
#9: Click on "Bounce".
#10: Repeat steps 1-9, only with the enemies instead of the player.
Now the objects won't go outside of the frame. Next up, you need to make the enemies bounce off of each other.
The process of making objects bounce off of each other is very similar to making them bounce off of the sides. To do that, do the above (with only the enemies), only remove step ten, and replace steps 3-5 with these steps:
#3: Move your mouse over "Collisions".
#4: Click on "Another object".
#5: Click on the enemy object.
Now the enemies should be able to bounce off of each other.
Now you need to make the player able to lose. To do that, first you make another frame. To do that, you:
#1: Right-click on the game/application on the workspace toolbar.
Please login to see this attachment.
This is the workspace toolbar. Right-click on the part of it that is highlighted in blue. Also, this is the last picture.
#2: Click "New frame".
This will create a new frame. Double-click on the new frame to go to the frame editor for that frame.
Now you will need to insert two objects. Instead of inserting two active objects, insert the following two types, one of each:
Button
Highscore
Okay?
Once you are done, place the highscore object in the center of the frame (using the method I have already mentioned).
Then re-size the button. Make it 640 pixels wide. After that, center it horizontally, then, right-click on the button again. Instead of clicking on "Vertical center", click "Bottom". This will place it at the bottom of the frame. Now that you are done with that, go to the event editor.
The cool thing about the high score object is that it's automatic: It will automatically ask for the player's name
The button object will take you back to the first frame, which will start the game again.
Anyway, now for the code:
#1: Click on "New condition".
#2: Right-click on the button object.
#3: Click on "Button clicked?"
#4: Right-click on the box under the object that looks like a chessboard with a knight.
#5: Click "Previous frame".
#6: Right-click on the box under the object that looks like a joystick with a 1 on it.
#7: Move your mouse over the "Score" sub-menu.
#8: Click on "Set score".
#9: Leave it at "0". This is so that the score is reset before playing again.
Just so you know, the object that looks like a chessboard with a knight is called the "Storyboard object". It's important for going from one frame to another, as well as other things. Things like scrolling are also done by that object (there is already Please login to see this link., so I won't cover it in depth here).
The object that looks like a joystick with a 1 on it is called the player object (which is why I haven't been referring to the player as the player object). This is used to handle things like joystick controls, lives, and score. Very important for games.
Now go back to the frame editor for the second frame.
Click on the button object, and look at its properties.
Find the one that has "Empty" in it. Change it to "Play again".
The second frame is now complete.
Now go back to the first frame. Insert a "Score" object. Place it in the upper-left corner.
We're almost done here, okay?
Go to the event editor.
#1: Click "New condition".
#2: Right-click on the object that looks like a clock.
#3: Click on "Every".
#4: Leave it as it is (this will make it every 1 second).
#5: Right-click on the box that lines up with both the object that looks like a joystick with a "1" on it and the new condition.
#6: Move your mouse over the "Score" sub-menu.
#7: Click on "Add to score".
#8: Type "1" (without the quotation marks) in the area that says "0".
The object that looks like a clock is called the timer object, just so you know.
Now you have your score system. Last, but not least, you need to make the player lose when they touch an enemy.
#1: Click "New condition".
#2: Right click on the player.
#3: Move your mouse over the collisions sub-menu.
#4: Click on "Another object".
#5: Click on the enemy, then click okay.
#6: Right-click on the box that lines up with both your new event and the Storyboard object.
#7: Click on "Next frame".
Now, before we're done, how about you try your game?
Click on the button circled in the picture below. It's the run application button.
Please login to see this attachment.
Sorry about the poor cropping job I did here.
The difference between running the frame and running the application? When running the frame, you only test that one frame. It will close the game/application as soon as the game/application would normally go to the next frame. Run application starts from the first frame no matter what, and runs it exactly how it would run when it's built. Quite the big difference, huh?
That's it! Your game should now be complete. If you want, you can mess around with it more, or you can just wait for my next tutorial. Speaking of which, it will cover the built-in objects (like the storyboard object and the player object). If you have any requests for a future tutorial, just let me know (through PM or in a post on this thread, whichever one you prefer). The finished game is attached, though it may look slightly different from how it looks for you due to the amount of customization is allowed in this (you got to place the enemies wherever you wanted, as well as choosing the color to use for editing the enemy).
To recap what you learned:
You learned how to edit objects graphics.
You learned how to duplicate objects.
You learned how to make objects bounce off of each other.
You learned how to create a new frame.
You learned how to make a highscore board.
You learned how to make a windows-style button.
You learned how to go from one frame to another
You learned how to make a scoring system.
And you learned how to run the application.
That's quite a bit, isn't it? Next time, I will cover the built-in objects.