Zax Tutorials: Part 2

Have You always dreamed of creating your own games? There is tutorial – how to start doing that.
In this part we’re creating full “Pong World” game, with five levels, multiplayer section, etc.

Part 2

Something, that You may not understand.

Introduction

Hi and hello, today we’re gonna finish Our “PONG”, enhance it. We are starting with that, what we’ve done in Part 1, so open Your project in MMF2. Test it. Um, it sucks… There’s even no menu..! Right… Menu…

Creating Menu

Ok, how to create it? We’re going to open Storyboard Editor (”Ctrl+B”). Click on “2″. There will appear frame number 2. Drag it to frame number 1 to swap their places. Now click once on title “Frame 2″ and change it to “Main Menu”. Double click on that white frame. You will see Main Menu’s Frame Editor.

I already created some images, You can use it, if You want.

Title animation:

Ok, so save that images on Your hard drive, insert objectactive, import tit1.png and select import as animation. All frames will be imported. You also have to select transparent color to 255, 255, 255 (white).

Now the buttons, first create new active and import “Quick Game” button (always remember about transparent color):

Then right-click on that active, clone object, OK. Double-click on that clone and import next image:

And the last button here, exit button:

It should look like my screen:

Ok, so test it. Pretty cool, but there’s no fade in. We could just go to the frame settings and select the fade, but then animation of title doesn’t start before the fade end. Create new active, fill it with black color. Now go to properties, “Size / Position”, X and Y set to 0, Width to 640, Height to 480. At “Settings” set Fade Out to fade (or the other, but this is the best, i think…). Go to Event Editor (”Ctrl+E”) and create new condition – Start of Frame at storyboard controls. Now what thing will happen at start of frame? The black active destroy. So right-click on frame under it and press “Destroy”. Save and test. Ok, go back to the Frame Editor (”Ctrl+M”). While creating menu, we don’t need that “black something”, so let’s move it out from Main Menu frame. Just drag that object out. Ok, now let’s animate the buttons.

Ok, what to do with this images? First rename the objects to make creating easier.

Quick Game = QG

Adventure = AD

Exit = Exit

PONG World = title

“black something” = fade

Ok, renaming done. Now double-click on QG and go to the shooting animation. Import here the “flashing Quick Game” picture. Ah, almost forgot, You have to select loop in “Direction Options” of both animations (stopped and shooting). It will change animation on mouse-over event. Do the same with all three buttons.

Now create new object, “Counter”. In settings change “Initial Value” to 1, “Minimum Value” to 1, “Maximum Value” to 3 and at Display Options unchecked must be “Visible at start”.

Save and go to the Event Editor. New conditionCounterCompare the counter to a value…

Here will be equal 1. And what effect of this event? QGAnimationChangeAnimation sequence…

Change it to “Shooting”. Now do the same with AD and Exit, but change animation to “Stopped”.

Ok, now drag event 2 to new condition, change “Equal 1″ to “Equal 2″.

And here QG=Stopped, AD=Shooting, Exit=Stopped.

Drag event 3 to new condition, change “Equal 2″ to “Equal 3″.

In event 4 QG=Stopped, AD=Stopped, Exit=Shooting.

Now create new conditionmouse&keyboardThe keyboardupon pressing “Down Arrow”

Copy the last event and change it to “Up Arrow”. In “Down Arrow” event CounterAdd to counter1, in “Up Arrow” CounterSubtract from counter1.

Save and test. Cool, huh? :D But it’s still not finished. Go to Frame Editor and clone counter, then back to the Event Editor. Create 7th condition as “Upon pressing “Enter”", then drag “Counter = 3″ event to number 7, not to “Upon pressing “Enter”", to “7″. Ok, effect = storyboard controlsend the application. Then drag 7 to 8 and in condition “Counter = 3″ change 3 to 1. In effect of event 8 delete “End the application”, set Counter to 1 and set Counter 2 to 2. Ah, and one more thing in Event Editor now. First make another copy of event 7 and change there “Counter = 3″ to “Counter = 2″. Then add to events 2,3,4,7,8,9 condition (right-click on numberadd a new condition) “Counter 2 = 1″. This is important! Now go to Frame Editor and double-click on QG.

In jumping import

Alright, go back to the Event Editor. Delete unwanted “End the application” at the last event, then in event 8, under Exit choose VisibilityMake object invisible. Save and test. Ok, almost working. Copy 2,3,4 as new conditions and change there “Counter 2=1″ to “Counter 2=2″ and in effect of these events change every “Stopped” to “Jumping” and every “Shooting” to “Falling”. Save and test. Works, but when “Two Players” are choosed and we press down – “cursor” disappear until we press up. So let’s fix it. Delete every effect at the last event. Now add “Set Counter to 2″ here. Works! And now we want to make escape as “back” button. So click new condition, set it to “Upon pressing “Escape”". And add new condition to that event – “Counter 2 = 2″.

Now at event 13 choose that effects: “Set Counter to 1″, “Set Counter 2 to 1″, “Exit – Reappear”. Save and test. Pretty cool!

Now we’re at the Storyboard Editor (”Ctrl+B”).

Rename “Frame 1″ to “Quick Game – Single Player”, then enter it. Go to Event Editor. We want some difference in every Quick Game. So delete “Play music”/”Play sample” effect at “Start of Frame” event. Right-click under “Special conditions”Change a global valueSetRetrieve data from an objectSpecialGenerate a random.

And what You need to change here. “Enter base number<” change to “8″. Then OK.

(On image it’s 1, but it have to be 8)

Then create new conditionSpecialCompare to a global value. Change “Equal” to “Greater” and “0″ to “7″.

Right-click on that event and select “OR operator (logical)”. Then new condition – Global Value A < 2.

And the same effect – Set Global Value A to Random(8). Now under Opponent change in effect “+5″ and “-5″ to “+Global Value A” and “-Global Value A”. Now create new conditionspecialCompare to a global value. Change “Equal” to “Lower or equal” and 0 to 4. Now add to this event new condition – run this even once.

And first effect here will be “Play Music…”. It’s 1/3 of possible musics in our random game. Next effect is Active PictureNew Picture. OK, now create other possibilities with “Global Value A = 5″ and “Global Value A =6″.

Save and test. Cool! :D Go to Frame Editor and double-click Opponent. In Image Editor press “View hot spot” tool (”H”), then press:

Do the same with “Action point” tool (”Q”). Then right-click on OpponentAlign in FrameVert Center.

Single Player Quick Game almost done! Go to the Storyboard Editor (”Ctrl+B”). Create new frame here and name it “Single Player QG Scores”. Enter it. Create new active object, fill it black. Resize it that way:

Create new active, an eclipse filled with black color. Name it Ball. Go to Ball propertiesmovementset it to bouncing ball. Directions – Up, Down. # of angles – 8. Randomizer – 0. Security – 0. Go to “Single Player – Quick Game” frame and copy PlayerSC and OpponentSC. Paste them into “Single Player QG Scores”. Do that also with opponent, but paste him out of frame. Now create new static text, at properties uncheck “Border” set text align to “Center” and in Text Options check “Bold”. You can write anything inside that text, I’ve “Match’s end!”, but that don’t matter. Go to the Event Editor. Create bouncing for the ball (test position and collision events). Now, new condition, PlayerCompare to player’s scoreRetrieve…(always remember to delete that unwanted “0″)Player 2Value of scorechange “Equal” to “Lower”OK. So we’ve got the event what means that Opponent wins. Let’s write it to Player. Static TextSet text”Computer Wins!”. And let’s play a little sound effect here. Okay, now repeat that, but change “Equal” to “Greater” and write “Player Wins!”. And one more time do the same, this time leave alone “Equal” and write “Draw…”. Now add to that three events “Run this event once”. And create event “Upon pressing “Enter”" with effect: set both players score to 0, jump to main menu(storyboard controlsjump to framemain menu). Should look like:

Save and test. Now go to “Quick Game – Single Player” Event Editor. Create event “Score of Player 1 = 9 or Score of Player 2 = 9″ and in effect set jump to frame 3. Now go to “Main Menu” Event Editor and click on New Condition. Create here “Upon pressing “Enter”" + “Counter = 1″ + “Counter 2 = 2″. And effect set to jump to frame 2. Save and test.

Seems that it works : ). I promised to finish this PONG World in this part, but I’m too slow, sorry… : P

Last thing that I’m gonna show You: multiplayer. So go to the Storyboard Editor(”Ctrl+B”).

Clone our “Quick Game – Single Player” frame and rename the clone to “Quick Game – Multiplayer”. Now enter that new frame and go to Opponent properties. Go to movement and set Directions and Initial Directions to Up and Down. Try movement. Ok, move to the Event Editor. Drag 1st event to “New condition”. Double-click on Player at last event and change it to Opponent. Now under Opponent object, in the last event, select bounce event. Right-click at number 7 (in 7th event) and choose delete. Do that again. OK, test that frame (F7). Fine, but I’m moving both of them… So at the event “Start of Frame”, under Player 2Player ControlSet Key. At the handle of new window we can see intructions (0=up, 1=down…) so click OK and press “W” to set it as “Up” button for player 2. Do the same for down(1). Ok, we can move Player 1 with Up and Down, Player 2 with W and S. It’s done! But what about score frame? Go to Storyboard Editor, clone “Single Player QG Scores” and rename the clone to “Multiplayer QG Scores”. Enter it. Now go to the Event Editor and change text “Player wins!” to “Player 1 wins!” and “Computer wins!” to “Player 2 wins!”. Now go to “Quick Game – Multiplayer” Event Editor and make sure that the jump is to the right place.

Storyboard screen:

The last thing: go to “Main Menu” Event Editor and clone the last event. Change in the clone “Counter = 1″ condition to “Counter = 2″ and effect “jump to frame 2″ change to “jump to frame 4″. Save and test it all(F8). There is one error, but we can fix it. In event 8, under timer set effect to Set timer. Set it to 00″-00. Add new condition to event 14 – “Is the timer greater…” and set it to 0 seconds, 25/100. Save and test it all(F8).

This part is done, go to “Main Menu” Frame Editor, click once on fade and in “Size / Position” Change X and Y to 0. Go back to the Event Editor and setup some music to menu. And here we are, at the end of Part 2… ; )

Leave Your Response