Monkey Game Development Beginner's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Monkey Game Development Beginner's Guide Create monetized 2D games deployable to almost any platform wnload from Wow! eBook <www.wowebook.com> o Michael Hartlef D BIRMINGHAM - MUMBAI Monkey Game Development Beginner's Guide Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: April 2012 Production Reference: 1130412 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-203-8 www.packtpub.com Cover Image by J.Blaminsky ([email protected]) Credits Author Project Coordinator Michael Hartlef Alka Nayak Reviewers Proofreader Nikolas Kolm Aaron Nash Meri Morganov Indexer Acquisition Editor Hemangini Bari Kartikey Pandey Graphics Lead Technical Editor Manu Joseph Shreerang Deshpande Production Coordinator Technical Editors Melwyn D'Sa Apoorva Bolar Arun Nadar Cover Work Melwyn D'Sa Priyanka S Copy Editor Brandt D'Mello About the Author Michael Hartlef has been into game development for a long long time, starting in 1984, at the early age of 18, with this great hobby called developing computer games, on the Commodore C64. After developing for this machine, he has worked on most other well-known computers, such as the Amiga 1000 and 500, the Atari 1024 STFm, and of course various PCs. These days it is mostly his iMac that he uses. Over the years, he has become very knowledgeable about general and specific concepts for developing games and has worked on a large range of game development tools/ programming languages, such as thinBasic, Delphi, 3D GameStudio, Blitz3D, BlitzMax, DarkBasic Pro, App Game Kit (AGK), Corona SDK, and of course, Monkey! Besides working on games, Michael has developed various add-ons for tools such as command library extensions and programming editors. During the day, Michael works for a utility company where he maintains the billing system (SAP IS-U). Michael is also the founder of an independent game developer startup called Whitesky Games (http://www.whiteskygames.com). There, he spends a lot of his spare time working on game development tools (IndeED), add-ons and games for friends and clients, and his own projects. First, I'd like to thank my wonderful wife Katherine and my great son Marc Justin for having so much patience with me during the time of writing this book and giving me all the support I needed. Without you guys, I would not have made it. I love you! Also, I would like to thank the people at PacktPub for giving me the opportunity to write this book, which has been a great experience in my life. Next, I send a big thank you to Jayant Varma from Oz Apps, who hinted to me that PacktPub was looking for an author for this book. Also, I want to thank Lee Bardsley from GameLab3D for being my friend and talk buddy. And finally, a big thank you goes to Mark Sibly, the creator of Monkey, for providing such an awesome tool for the people and me. About the Reviewers Nikolas Kolm has been active as a Level Designer, World Builder, and Interactive Storyteller for a long time, in capacities ranging from community Mod projects, to student work, to indie production. During this time, he has gathered a lot of experience in different editors and production settings, most commonly the Unreal Editor, the NWN2 Toolset, and the Dragon Age Toolset as well as Game Maker, and recently, Unity 3D. During his time along with the Mod team responsible for a persistent world server for Neverwinter Nights 2, Nikolas was responsible for the creation of interesting areas and levels for players to traverse and live in, which needed to adhere to a common theme with the rest of the world, and also had to offer challenges for groups of players out for an adventure. This included setting up encounters with enemies, setting up the ambient effects, creating dialogue for scripted encounters, and ensuring that the area supported the environmental storytelling of the module. While working on the indie title AVOID, as Lead Game Designer, Niko also had to fill in as Level Designer from time to time, which allowed him to practice his skills with the Unity editor. It also allowed him to work in a leadership capacity with a team of over 30 other team members, to experience a complete production cycle. His unique background, living in Japan, traveling the world, and studying many cultures and history, has given him a wealth of experience from which to draw when designing believable characters, dramatic encounters, and immersive worlds. Meri Morganov has been playing video games for most of her life and has always wondered what the magic behind them was. She took game programming courses at the Art Institute of Vancouver to learn more on the topic and worked with big student groups to make games. From high-level scripting to low-level programming, she worked hard to learn the art of the trade. After college she has been working on indie projects with friends and small companies. She loves working in teams and staying in close contact with her teammates to get the job done right. Unity3D and Visual Studio have been her favorite tools to use. I'd like to thank my teachers and friends who made it possible for me to learn such a great skill. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Chapter 1: Monkey—Huh? 7 Game development for the rest of us 8 Cross-platform development 8 Compiler or translator? 8 The Monkey toolbox 9 Time for action – installing Monkey 10 Please welcome… Monk 10 MSERVER—Monkey's own web server 11 Let's have a little playtime 12 Time for action – playing Pirate TriPeaks 12 Time for action – playing Surviball 14 Playing to have fun, playing to study 15 So let's go for something big? No! 15 The alternative 15 Time for action – read the manual 16 The Trans tool and the supported target platforms 16 HTML5 16 FLASH 17 iOS 17 Android 17 XNA 17 GLFW 18 The Monkey standard modules 18 Lang 18 Lists 18 Map 19 Math 20 Random 21 Set 21 Stack 22 Table of Contents Mojo – The 2D framework/modules 22 App 23 Audio 23 Graphics 23 Input 23 Monkey is extendable 23 Your own modules 23 Native source odec 23 Third-party modules 24 Your own targets 24 Your game is easily portable 24 Summary 25 Chapter 2: Getting to Know your Monkey—a Trip to the Zoo 27 Call the Monk and start praying—the Monkey IDE 28 Why learn about Monk? 28 Starting up Monk 28 Monk's user interface 29 The toolbar 29 The code editor area 29 The info box 29 Time for action – opening a sample script 30 Where is my navi? 31 Time for action – navigating to the Main() function 32 Save... save... save! 32 Time for action – saving a script 32 Projects—bringing in some organization 33 Time for action – creating a ojectpr 33 The Monkey programming language 34 wnload from Wow! eBook <www.wowebook.com> o Time for action – Monkey's Hello orldW 34 D Running your first script in a browser 35 Our first little game... PONGO 36 Time for action – the basic structure of oury game 36 Pongo's data structure 38 Time for action – adding some data fields 38 Time for action – rendering the game field 39 Time for action – drawing the ball and the paddles 40 Time for action – player paddle movement 41 Time for action – moving the enemy paddles 42 Time for action – moving the ball 43 Time for action – controlling the ball with the player's paddle 45 Time for action – letting the enemy paddles tfigh back 46 Time for action – acting on the different game modes 48 [ ii ] Table of Contents Exporting your game as an HTML5 website 51 One more thing..