close

Вход

Забыли?

вход по аккаунту

?

Flash & Flex. 2012.02

код для вставкиСкачать
FFDM 2012.02
4
02/2012 (32)
Dear Readers,
February issue comes out with a little retardation but I hope that you enjoy what is inside. In this issue you will find a reviews and very interesting interview with Jakub Dvorsky – a Czech game developer and the founder of Amanita Design. From the interview made by Colin Cupp you will know what the biggest challenge early on Amanita Design for Jakub was and give some advises to game developers. If you want to create a 3D presentation in Flash Format you should read an article by Radu Ionescu who rewieved the DemoBuilder 8. If you’re looking to outline those features that make your product-presentation stand out from the competition you should have a look on this article. There is also an article excerpted from Manning Publications. In this article from chapter 10 of “Hello! Python”, author Anthon Briggs talks about extending an application using the Twiste Framework to make it interactive over the Internet. Emanuele Feronato is a familiar name to anyone who’s ever searched for something to do with Flash game development on Google. Richard Davey from photonstorm.com reviewed the book for us written by Emanuele Feronato: Flash Game Development by Example – “build 9 classic Flash games and learn game development along the way!”
With Marcelo Pires you will know how to use FlexMonkey to test your apps and how to make the aplication unit-tests. This month Marco will show you some tools which make your life easier as a developer. Read the article Developer’s Toolbox- Testing with FlexMonkey.
This & much else you‘ll find in the february Flash and Flex Developer’s Magazine. Enjoy!
Enjoy your reading
Adela Kuźniarska and FFD Team
Editor: Adela Kuźniarska adela.kuzniarska@software.com.pl
Proofreaders: Garry Schafer, Michael Jovel,Alberto Jose Argon Alvarez, Nick Middleweek, Ranjan Rajendran, Ed Werzyn
DTP Team: Ireneusz Pogroszewski ireneusz.pogroszewski@software.com.pl
Art Director: Ireneusz Pogroszewski ireneusz.pogroszewski@software.com.pl
Senior Consultant/Publisher: Paweł Marciniak
Flex/ActionScript 101 Section Editor: Marc Pires marcpiresrj@gmail.com
iPhone Development Section Editor: Ryan D’Agostino
Games Section Editor: Chris Hughes
Contributing Editors: Pedro de La Rocque, Ali Raza, Csomák Gábor
Publisher: Software Press Sp. z o.o. SK
ul. Bokserska 1 02-682 Warszawa Poland Worldwide Publishing If you are interested in cooperating with us, please contact us by e-mail: cooperation@software.com.pl
Whilst every effort has been made to ensure the high quality of the magazine, the editors make no warranty, express or implied, concerning the results of content usage.
All trade marks presented in the magazine were used only for informative purposes.
All rights to trade marks presented in the magazine are reserved by the companies which own them.
Thanks to the most active and helping beta testers:
Russell TangChoon, Lee Graham, Jassa Amir Lang, Ed Werzyn, Yann Smith-
Kielland, Justus, Csomák Gábor, Kevin Martin, Charles Wong, Ali Raza, Almog Koren, Izcoatl Armando Estanol Fuentes, Lionel Low, Michael J. Iriarte, Paula R. Mould, Rosarin Adulseranee, Sidney de Koning To create graphs and diagrams we used program by company.
Mathematical formulas created by Design Science MathType™
ATTENTION!
Distributing current or past issues of this magazine – without permission of the publisher – is harmful activity and will result in judicial liability.
DISCLAIMER!
The techniques described in our articles may only be used in private, local networks. The edi
-
tors hold no responsibility for misuse of the presented techniques or consequent data loss.
Editor’s Note
5
02/2011 (32)
CONTENTS
InBrief
8 Apache accepted Flex to its Incubator program
BY GABOR CSOMAK
The holidays have brought a bushel of new games and apps, including the first version of those famously Angry Birds using Flash Player 11 and Stage3D. If you’re all revved up and looking to build something new in the coming year, read Gabor Csomak advises!
Developer’s Toolbox
10 Testing with FlexMonkey
BY MARCO PIRES
This month Marco begins to present a set of tools that make your life easier as a developer, and show their benefits. As he involves the subsequent articles he will write about another tools and how to integrate them to have a better development workflow and your life easier. Read and learn how to use FlexMonkey to test your apps!
Flash Develop Scripting
12 Open File By Text Selection
BY KRASIMIR TSONEV
FlashDevelop is one of the most preferred editors for the flash development. Krasimir Tsonev found it helpful for writing JavaScript, HTML, CSS and PHP code as well. I just took a big project with over 1000 php files and it is a little bit difficult to open the right file, even by using the Project panel.Krasimir Tsonev is a Hard-working, designer and developer offering excellent work ethic, enthusiasm and adaptability with experience in graphic design, frontend, backend and flash/flex development.
Flash Game Dev Tip
18 Dealing With a Lack of Motivation to Finish Your Game
BY RICHARD DAVEY AND PHOTONSTORM.COM
Everyone suffers from this problem at one point or another: Yousimply can’t face the thought of working on your game. This is especially hard when making the game in your “free time”. It’s all too easy to think what the hell and double-click that Team Fortress icon instead of FlashDevelop. And even days when your head is saying let’s code! all that motivation can vanish the moment you open the source and realise that its been so long since you were last here it’s like staring at a foreign language, or a giant brick wall and you have no idea what to start first.
Hello Python!
28 Writing a Simple Chat Server
BY ANTHONY BRIGGS In this article from chapter 10 of Hello! Python, author Anthony Briggs Talks about extending an application using the Twisted framework to make it interactive over the Internet. Let’s start with the first part of our application, the protocol for our chat server. In Twisted terminology, a protocol refers to the part of your application that handles the low level details – opening connections, receiving data, and closing connections when we’re finished. You can do this in Twisted by subclassing its existing networking classes.
Interview
32 FGS 2012 Advisory Board Interview Series: Jakub Dvorský BY COLIN CUPP
This is part three in a series of interviews of the Flash Gaming Summit 2012 Advisory Board. This is your chance to get to know the folks who determine the content of Flash Gaming Summit, getting their thoughts on both the conference and the games industry in general. This week’s Advisory Board interview features Jakub Dvorský, founder of Amanita Design. In case you have been living under a rock, their game Machinarium has been a huge success on iTunes, specifically hitting #1 on the iPad. Machinarium was also a Mochis Award Show winner at FGS 2010 (Best Game Art category).
Review
36 Demo Builder 8 Create 3D Presentations in Flash Format
BY RADU IONESCU
This article is for that who has software that you would like to showcase on your website. You would like to show potential customers how it functions and its key features. Simply put, you are looking to outline those features that make your produc stand out from the competition So how should you go abou doing this? Read and know how to create 3D presentations in Flash Format.
Book Review
38 Flash Game Development by Example
BY RICHARD DAVEY
8
IN BRIEF
02/2012 (32)
Apache accepted Flex to its Incubator program
I am pleased to announce that Flex as been accepted into the Apache Incubator. The voting for a new logo is in progress. The Jira bug-tracker is up and running. The source code is in place. And the mailing list is full of messages. 36 committers and 4 mentors. Anybody can tell, that the community is excited, and 2012 will bring lots of success to Flex. If you are not already a committer, you can still help the work, or just look around at http://incubator.apache.org/flex/
.
source: The Official Flex Team Blog
Announcing Flex User Group 2012 Tour: North America Dates
Adobe is kicking off an international Flex User Group Tour to discuss recent announcements regarding Flex and the Flash Platform. These meetings will clarify any changes to Flex and Flash including updates on the runtimes and tooling. Additionally, the sessions will educate folks about the Apache process and what it takes for Flex SDK, as a project within the Apache Software Foundation, to continue to thrive. These meetings will be the best place to get accurate and up-
to-date information about anything related to Flex.
Below are the cities and dates for our first wave of visits in North America. Europe and Asia dates will be posted shortly. Please refer to individual user group sites for detailed descriptions about the Flex sessions and speakers, including information on how to register to attend. Note: This information will be posted in the coming weeks and we will update this blog post with more detailed information as it becomes available.
We hope to meet and talk with as many developers as possible – so mark the dates and we’ll see you there!
North America
• 2/13/12 – New York: New York Flex Meetup
• 2/15/12 – Boston: Boston Flex User Group
• 2/21/12 – Denver: Rocky Mountain Adobe Users Group
• 2/22/12 – Seattle: Seattle Flash User Group
• 2/29/12 – Chicago: Chicago Flex User Group
• 3/7/12 – Los Angeles: LA Flex & LA Flash User Group
• 3/8/12 – San Diego: San Diego Flash User Group
• 4/19/12 – Dallas: Dallas Flex User Group
source: The Official Flex Team Blog
2012: The Year of Gaming
The holidays have brought a bushel of new games and apps, including the first version of those famously Angry Birds using Flash Player 11 and Stage3D. If you’re all revved up and looking to build something new in the coming year, see how you can publish a car visualizer to Flash in 90 seconds with Flare3D Studio Workflow.
As we announced last year, we are investing in our Flash technologies to support the kind of innovative 3D and 2D games that developers and publishers want to deliver both in browsers and through mobile apps. To give developers access to high-performance C/C++ code, we told you we’re creating an improved, paid, fully supported release of Alchemy for production development. This new addition will be available later this year and will allow developers to publish content leveraging Alchemy technology in Flash Player 11 or AIR 3 and beyond. Meanwhile, a few months ago we introduced full GPU-accelerated graphics rendering with Stage3D, which provides 1000x faster rendering performance over the previous versions of Flash Player and AIR on the desktop. Stage3D in Flash Player already enables fluid, hardware accelerated graphics for more people in more browsers than any other web technology. And we’re now seeing exciting previews of Stage3D hardware acceleration coming for mobile devices like iPhone, iPad, and Android smartphones and tablets.
See for yourself what’s happening with the latest updates to Flash Player and AIR for gaming, and jump in on the fun by checking out the beta release of Flash Player 11.2 and AIR 3.2!
source: Adobe Flash Platform Blog
News by Gábor Csomák (@csomak)
02/2012 (32)
1
0
DEVELOPER’S TOOLBOX
D
uring the development of a big RIA as the one i’m involved with, it’s extremely important that not only developers have a set of tools to speed up development, but also all staff people. FlexMonkey is a tool that helps a lot, because it help Q&A staff define tests for an application with the advantage that they need to write any Actionscript code or deal with FlexUnit. See Figure 1. Downloading and Installing
Installing is very straightforward. Access http://
www.gorillalogic.com/flexmonkey/download
, register an account, login and download a version of the tool. I suggest that you download the latest version (version 5). See Figure 2. Installation is also super easy and self explanatory so i’ll not show the entire process here. Configuring a new project
After downloading and installing the tool, it’s time to create our first test suite. Fire up Flash/Flex Builder and create a simple project. Then open FlexMonkey and let’s Developer’s Toolbox
Hi, dudes, how are you doing ? This month i’ll begin to present a set of tools that make my life easier as a developer, and show their benefits. As I involve the subsequent articles I’ll write about another tools and how to integrate them to have a better development workflow and your life easier. So let’s get started.
What you will learn…
• Use FlexMonkey to test your apps
• application tests
What you should know…
• Minimal knowledge of testing Automate
Testing with FlexMonkey
Figure 1. Main Window
Figure 2. Creating an account
Figure 3. Project properties window
Testing with FlexMonkey
02/2012 (32)
1
1
create our first test project. In the Project Configuration window fill the information about your project as Project directory, Suite Package name and so on as shown in Figure 3. Don’t forget to choose the right SDK version. See Figure 3 and Figure 4. Adding the automation Monkey
After filling all the details about your project, drag the icon shown below the SDK version to the libs directory of your project and then show you project properties from the project menu and add the compiler arguments provided to the Additional Compiler Arguments under the Flex Compiler category. See Listing 1 and Figure 5.
Putting the Monkey to work
Now that we have all setup, compile and run the application, when your application loads in the browser, note that FlexMoney show the status CONNECTED. Now that FlexMonkey is connected to our app, just click the record button and play with the app a bit. Refer Figure 1.
When in record mode
you will se the command buffer, where FlexMonkey will display the commands as you interact with the application. When you finish the intended test, you can drag the commands to the corresponding test in testSuite. See Figure 6 and Figure 7.
Final statement
The FlexMonkey is very useful tool for automating tests as members with no programming experience can record the interaction with your application and then when it’s necessary to run the same tests again. It also generate FlexUnit tests making easy to integrate the tests with a build server.
Next month we will see another tool that helps me a lot during my day. See you.
MARC PIRES
Marc Pires is a Developer located in Brazil, during his career, he has worked in various roles such as Network Administrator, Instructor. He has a strong passion for working with and researching new technologies. Specialized on RIA, Iphone Development, Restful web services and other interesting things, he’s one of the main developers of the Esus System and is heads a startup specialized on mobile development.
Contact information: @MarcPires (Twitter) | marcpiresrj@
gmail.com | IChat: marcpiresrj@aim.com
Figure 4. Filling application details and test suite information
Listing 1. Compiler arguments
-
include
-
libraries
„
..
/libs/
automation_monkey3
.
2
.
swc
" „${lexlib}/libs/automation.swc"
„
$
{
lexlib
}
/libs/
automation_agent
.
swc
" „${lexlib}/libs/automation_dmv.swc"
Figure 5. Compiler arguments
Figure 6. Command Bufer
Figure 7. Recording interaction with application
02/2012 (32)
1
2
FLASH DEVELOP SCRIPTING
T
hat’s why I decided to invest time in solving this task and found that I can write my own C# script and run it.
The site that I have to work on has a lot of files, but they are distributed in well named folders and basically the name of every class is a combination of folder’s path plus the name of the php file. So when I see something like:
1
$component = new basic_wrapper_component_manager();
I have to open the file /basic/wrapper/component/
manager.php
. Firstly I was thinking that I will be able to solve the problem by using snippets
. My idea was to select the name of the class and call a snippet which will open the file based on the text’s selection. Then I realized that I’ll need something more, because I have to parse the string. I checked the FlashDevelop’s site and found that I can write my own macros
. They are powerful tool, but as far as I know it is not possible to manipulate the selected text as I wanted. At the end I managed to solve my problem by writing a script in C# Flash Develop Scripting:
FlashDevelop is one of the most preferred editors for the flash development. I’ve been also using it last few years. I found it helpful for writing JavaScript, HTML, CSS and PHP code as well. I just took a big project with over 1000 php files and it is a little bit difficult to open the right file, even by using the Project panel. What you will learn…
• Creating your own Macos
What you should know…
• If you want to create your own script I recommend to download the FlashDevelop’s code and explore PluginCore’s classes, properties and methods.
open file by text selection
Figure 1. Macros panel
Listing 1. The C# Code
1
using
System
;
2
using
System
.
Windows
.
Forms
;
3
using
PluginCore
;
4
5
public
class
FDScript
6
{
7
8
private
static
string
ile
;
9
private
static
string
projectPath
;
10
11
public
static
void
Execute
()
{
12
13
MessageBox
.
Show
(
"Script here"
);
14
}
15
16
}
02/2012 (32)
1
4
FLASH DEVELOP SCRIPTING
Listing 2. Basing script code
1
private
static
string
ile
;
2
private
static
string
projectPath
;
3
4
public
static
void
Execute
()
{
5
ile
= PluginBase
.
MainForm
.
CurrentDocument
.
SciControl
.
SelText
;
6
projectPath
= Path
.
GetDirectoryName
(
PluginBase
.
CurrentProject
.
ProjectPath
);
7
}
Listing 3. Example of the actual script
1
using
System
;
2
using
System
.
Windows
.
Forms
;
3
using
System
.
Text
;
4
using
System
.
Text
.
RegularExpressions
;
5
using
ScintillaNet
;
6
using
PluginCore
;
7
using
PluginCore
.
Helpers
;
8
using
System
.
IO
;
9
using
System
.
Drawing
;
10
11
public
class
FDScript
12
{
13
14
private
static
string
ile
;
15
private
static
string
projectPath
;
16
17
public
static
void
Execute
()
{
18
19
ile
= PluginBase
.
MainForm
.
CurrentDocument
.
SciControl
.
SelText
;
20
projectPath
= Path
.
GetDirectoryName
(
Plugin
Base
.
CurrentProject
.
ProjectPath
);
21
23
InputBox
(
"File name"
, "Type a ile name:"
, ref
ile
, "Ok"
, "Cancel"
);
24
}
25
if
(
ile
!= ""
)
{
26
char
[]
delimiterChars
= {
'_'
, '/'
};
27
foreach
(
char
c
in
delimiterChars
)
{
28
searchForDelimeters
(
c
);
29
}
30
// alert(projectPath + " / " + ile);
31
if
(
!
indFile
(
projectPath
, ile
))
{
32
alert
(
"File ("
+ ile
+ ") not found."
);
33
}
34
}
35
}
36
public
static
void
searchForDelimeters
(
char
delimeter
){
37
string
projectPathAddition
= ""
;
38
if
(
ile
.
IndexOf
(
delimeter
)
>= 0
)
{
39
string
[]
pathParts
= ile
.
Split
(
new
Char
[]
{
delimeter
});
40
int
numOfParts
= pathParts
.
Length
;
41
if
(
numOfParts
> 1
)
{
42
for
(
int
i
=
0
; i
<
numOfParts
-
1
; i
++
)
{
43
projectPathAddition
+= pathParts
[
i
]
+ "\\"
;
44
}
45
if
(
InputBox
(
"Found delimeter '"
+ delimeter
+ "'"
, "Found delimeter '"
+ delimeter
+ "'. Search for '"
+ pathParts
[
numOfParts
-
1
]
+ "' in:
"
, ref
projectPathAddition
, "Yes"
, "No"
)
== DialogResult
.
OK
)
{
46
projectPath
+= "\\"
+ projectPathAddition
;
47
ile
= pathParts
[
numOfParts
-
1
];
48
}
49
}
50
}
51
}
52
public
static
bool
indFile
(
string
dir
, string
ile
)
{
53
bool
result
= false
;
54
try
{
55
foreach
(
string
f
in
Directory
.
GetFiles
(
dir
, ile
+ ".?*"
))
{
56
PluginCore
.
PluginBase
.
MainForm
.
Ope
nEditableDocument
(
f
, true
);
57
result
= true
;
58
}
59
foreach
(
string
d
in
Directory
.
GetDire
ctories
(
dir
))
{
60
if
(
indFile
(
d
, ile
))
{
61
result
= true
;
62
}
63
}
64
}
catch
(
System
.
Exception
excpt
)
{
65
alert
(
excpt
.
Message
);
66
}
02/2012 (32)
1
6
FLASH DEVELOP SCRIPTING
that is called by macros. Here are all the steps that I went through:
Step 1 – creating the macros
Open the macros panel by pressing [
Ctrl + F10
]. The panel looks like on the Figure 1.
Click Add button and enter the name of your macros in the Label field. Also set a Shortcut so you can call it fast while you are coding. The real part of the macros has to be written in Entries filed. Because you have to run an external script you have to use the following command:
?
1
ExecuteScript|Development;path/to/your/ile.cs
My command looks like that:
?
1
ExecuteScript|Development;D://WORK//PROJECTS//KRASIMIR TSONEV//CODING//FLASHDEVELOP//Macros//C#//OpenFile.cs
Step 2 – creating a basic script code
The script file has to contain C# code and it has a basic structure like this: Listing 1. Don’t worry if you are not familiar with C#. You can still code with a little help from Google. Every script has to contain Execute method which is actually the starting point. I strongly recommend to check this thread in the FlashDevelop’s community forum. I followed the instructions there and downloadedSnippet Compiler which is actually pretty good simple C# editor. It also offers code completion and if you add PluginCore.dll
you will have completion of the FlashDevelop’s things. Step 3 – creating the actual script
Firstly we should get the current selected text and the current project’s directory: Listing 2. When we have this data we can parse the file variable, find the path, the name of the file and open it:
1 PluginCore.PluginBase.MainForm.OpenEditableDocument
(path/ile, true);
Listing 3. Full code of a script
67
return
result
;
68
}
69
public
static
void
alert
(
string
mess
)
{
70
MessageBox
.
Show
(
mess
);
71
}
73
Form
form
= new
Form
();
74
Label
label
= new
Label
();
75
TextBox
textBox
= new
TextBox
();
76
Button
buttonOk
= new
Button
();
77
Button
buttonCancel
= new
Button
();
78
79
form
.
Text
= title
;
80
label
.
Text
= promptText
;
81
textBox
.
Text
= value
;
82
83
buttonOk
.
Text
= labelOk
;
84
buttonCancel
.
Text
= labelCancel
;
85
buttonOk
.
DialogResult
= DialogResult
.
OK
;
86
buttonCancel
.
DialogResult
= DialogResult
.
Cancel
;
87
88
label
.
SetBounds
(
9
, 20
, 372
, 13
);
89
textBox
.
SetBounds
(
12
, 36
, 372
, 20
);
90
buttonOk
.
SetBounds
(
228
, 72
, 75
, 23
);
91
buttonCancel
.
SetBounds
(
309
, 72
, 75
, 23
);
92
93
label
.
AutoSize
= true
;
94
textBox
.
Anchor
= textBox
.
Anchor
| AnchorStyles
.
Right
;
95
buttonOk
.
Anchor
= AnchorStyles
.
Bottom
| AnchorStyles
.
Right
;
96
buttonCancel
.
Anchor
= AnchorStyles
.
Bottom
| AnchorStyles
.
Right
;
97
98
form
.
ClientSize
= new
Size
(
396
, 107
);
99
form
.
Controls
.
AddRange
(
new
Control
[]
{
label
, textBox
, buttonOk
, buttonCancel
});
100
form
.
ClientSize
= new
Size
(
Math
.
Max
(
300
, label
.
Right
+ 10
)
, form
.
ClientSize
.
Height
);
101
form
.
FormBorderStyle
= FormBorderStyle
.
Fi
xedDialog
;
102
form
.
StartPosition
= FormStartPosition
.
Ce
nterScreen
;
103
form
.
MinimizeBox
= false
;
104
form
.
MaximizeBox
= false
;
105
form
.
AcceptButton
= buttonOk
;
106
form
.
CancelButton
= buttonCancel
;
107
108
DialogResult
dialogResult
= form
.
ShowDialog
();
109
value
= textBox
.
Text
;
110
return
dialogResult
;
111
}
112
113
}
FlashDevelop scripting: open file by text selection
02/2012 (32)
1
7
The main purpose of this script was to use it in this project, but actually I found that I can use it in any other project. I decided to extend it and add additional features. Here is the full code of the script and you can download it from here
(Listing 3).
When you run the script it checks if there is any text selection. If not then open a simple input where you can write in (Figure 2).
After that the data is processed and split by using ‘_’ and ‘/’ (
searchForDelimeters method). I.e. the script is trying to guess the file’s path. Of course you can skip this by clicking the No button (Figure 3).
findFile method is used to parse all the project’s directories and search for the files based on the file’s name.
If you want to create your own script I recommend to download the FlashDevelop’s code and explore PluginCore’s classes, properties and methods.
KRASIMIR TSONEV
web designer and developer
Hard-working, designer and developer ofering excellent work ethic, enthusiasm and adaptability with experience in graphic design, frontend, backend and �ash/�ex development. Personable, friendly and eager to work and learn with others. I enjoy working in the industry and have a passion for creating and discovering new and efective digital experiences.
To see examples of my work please visit my portfolio website at http://krasimirtsonev.com
. References are available on request.
Figure 2. Simple input
Figure 3. search for the �les based on the �le’s name
Design, Technology and Cool Shit @ FITC Amsterdam 2012 FITC Amsterdam 2012 is host to more, better and different topics in design, technology and cool shit than ever before! Covering HTML5, Kinect hacking, jQuery, Unity, plus over 50 other topics, FITC Amsterdam delivers. Featuring the best and brightest in the digital space including Hoogerbrugge, Lee Brimelow, Golan Levin, Grant Skinner, Andreas Müller and many more, FITC Amsterdam showcases work which is shaping the future of the digital interactive industry.
The combination of unbelievable international presenters, incredible networking opportunities and the infamous FITC parties, all with the amazing backdrop of the city of Amsterdam, creates a stage for the unexpected.
FITC Amsterdam has a history of selling out and 2012 is on track to as well, so register early to reserve your spot!
For more information visit www.fitc.ca/amsterdam
a d v e r t i s e m e n t
02/2012 (32)
1
8
FLASH GAME DEV TIP
I
t’s all too easy to think what the hell
and double-click that Team Fortress icon instead of FlashDevelop. And even days when your head is saying let’s code
! all that motivation can vanish the moment you open the source and realise that its been so long since you were last here it’s like staring at a foreign language, or a giant brick wall and you have no idea what to start first.
There is no single solution
to fix this. It’s extremely personal. Your reasons for not wanting, or being able to code will be as varied as the number of people reading this. But as I said at the start you are not alone – so I posed the question of how to deal with it to 13 fellow game developers and collated their replies. Hopefully somewhere in these insights you’ll find a technique or suggestion that helps you out. And if you have one that you personally use, not already mentioned, please post it into the comments.
I’ll kick things off …
Richard Davey / Photon Storm
http://www.photonstorm.com
I’ve come to realise that I’ve a game development mana reserve
. When I start work on a game, my mana reserve is full. But as coding begins this reserve drops faster and faster. Sometimes if I hit a particularly troublesome spot in a game it can be enough to utterly wipe-out what reserves I had left, derailing the project entirely. But there are also the wins
. Getting a significant part of the game finished, or adding something really cool. That helps re-fill my mana reserves and keeps motivation high. It’s a constant battle. To get the game finished before enthusiasm is depleted entirely, yet to have enough wins on-route that they keep things in balance.
The wins
however cannot be artificially placed into the project. They have to be unexpected and grow almost organically as a result of working on the game. Equally the hits to my morale are never expected either. I never start coding expecting to stump my toe on a bug from hell, but it happens.
There are two issues here:
Flash Game Dev Tip
Everyone suffers from this problem at one point or another: You simply can’t face the thought of working on your game. This is especially hard when making the game in your “free time”.
What you will learn…
• How to remind yourself about coding.
What you should know…
• How to create your own game
Dealing with a lack of motivation to finish your game
You are not alone
02/2012 (32)
2
0
FLASH GAME DEV TIP
1) Having the motivation to continue working on a game
I think like a lot of people I’m most excited about a game during the very early stages of it. The feeling of bringing something to life, of getting the idea out of your head and into code – that’s a real achievement in and of itself. I enjoy the task of getting a working prototype up and running, often with really crappy code driving it. The thing to do at this stage is to try and work out for yourself if you should stop right now, and not even attempt to carry on.
Use those prototypes
There is nothing wrong in building a prototype and just leaving it at that. Of course if you’re in this for the money it’s not going to get you rich, but if like me you do this for fun then you shouldn’t feel any sense of guilt
for having made just a prototype. If by this point you recognise that your enthusiasm is on the wane already then don’t just file it away for another day, thinking you’ll come back to finish it later on. Because almost certainly it will never happen. If you don’t have the enthusiasm or excitement at the end of this stage to take the game further, then you never will.
Don’t waste it though. Think about how what you’ve made could be useful to others. Perhaps it’d serve as an interesting I made this little demo
post for your blog or a forum. Or maybe it could be turned into a tutorial for a development site with little modification. You may be surprised at the response. I’ve had people see demos
of work who suggested just one change, that radically altered the course of the game, resulting in it being finished and released. As I mentioned at the start, mana refills
can come from anywhere, sometimes the most unexpected of places.
Do something other than making games
Making complete games is hard, there’s no doubting this. Even the most simple of games still require quite tedious boot strapping to make them suitable for release. But that rush
and feeling of sheer joy you get when you finally publish doesn’t always have to come from making a game. As readers of my blog will know I work on a lot of game development projects such as my Flixel Power Tools or tutorials. I do this because I enjoy writing, but also because I remember what it was like being fresh to development – how I was a sponge, soaking up every last piece of information I could get my hands on.
There is a real thrill in authoring this type of content too, and publishing it. So you don’t feel like making a whole game? No problem – could you make a demo that showcased how to make a sprite jump from platform to platform? The scale is significantly smaller, but the end result could be extremely useful to your fellow developers. And their feedback can be enough to spur you on during the more laborious development work you need to do.
Of course the downside of all this writing is that it takes your time away from making actual games, as Ilija will attest to.
Public Beta Tests
We ran a public beta test of a game called Kingdums. We just put a build of the game onto a web page with a big feedback form below it, and shouted the URL onto twitter. It was live for a week. The feedback we got was fantastic, because it under-lined a significant flaw in the game (that was in the back of our minds anyway, but made it prominent) and reaffirmed that actually, this flaw aside, people really enjoyed playing it. Other developers use public beta tests for similar reasons – lots do it to find out if their games have bugs they’ve missed, but it doesn’t just have to be about that. Sometimes you’ll get suggestions that highlight issues you didn’t see, and sometimes it’s just a good morale boost.
It’s not just code that can be tested – you could post-
up screen shots, character bios, even basic story arcs. All things that feed back into the game overall.
Enforced Time Constraints
Some people don’t understand the point of making a game in a limited period of time. Others relish the challenge. Personally I fall somewhere in the middle. I haven’t yet had a chance to take part in something like Ludum Dare, because I have a family life that stops things like that happening over weekends. But the times that I have made a game in a limited period of time (we’ve done it 3 times now) it has always worked for the better. Todo lists get cut down dramatically. Only the essential game aspects are given attention, and the time limitation really does focus your mind. Try it, it may appeal to you.
FlashDevelop scripting: open file by text selection
02/2012 (32)
2
1
Using a To-Do List
You’ll see this suggestion raised time and again by the other devs below. Ilija and I use the free softwareWunderlist. I like the fact I can add items from my iPhone or PC and have it all sync-up properly. We don’t have lists for prototypes, only for games deep in development. I find it pointless starting a list with make an enemy manager
, that feels too early-on in the process for us.
2) Dealing with “getting stuck” while coding
This is the easiest to solve. If you have a coding problem, then you ask for help. If you don’t work in an environment where you can ask fellow coders for suggestions, then there are hundreds of really great game dev communities online. And you should join one and really participate with it. Help out other people suffering problems you may already solved, and post your problems up there also. More often than not someone will help, or at least direct you onto the right path that leads to solving the problem anyway. If you can’t solve the issue within a couple hours of trying, and can’t think of another way to approach it
, then you need a bring a second brain into the equation. The longer you delay in asking for help, the more chance you have of never finishing.
Don’t feel guilty
You’re only human. Human’s need a fine balance between work, rest and play. And developers are terrible at balancing those three elements. There’s a famous producer graph showing Price – Speed – Quality
, with the mantra that you can only ever have 2 of those 3 things. So Speed + Quality comes at the expensive of Price
, or Low Price + Speed means low Quality
.
I feel that developers do the same with Coding – Resting – Playing
. By Playing
I mean taking time out from coding: watching a movie, spending time with your significant other, reading a book, playing Xbox, etc. Too much coding but the right amount of sleep usually means you give-up your play
time. If you’re burning the candle at both ends, holding down an intensive day job and then coding all night, your Rest and Play can be sacrificed. If when you sit at your computer you find the code just isn’t flowing then stop. Don’t battle it, don’t trudge through. Just stop and do something else entirely (ideally non-computer based). Then try again the next day. If you’ve been working like mad all week, getting a few hours sleep a night, then pay off that sleep debt.
Development is a roller-coaster of highs and lows. If you recognise you’re on a coding streak then enjoy it and use it to your advantage, but when it ends (and it will end) switch track quickly and work on something else. Then switch back again. The quicker you learn to recognise your moods
the more useful you can make them. I’m not perfect at this yet, not by a long shot. I still have lots of unfinished
games, indeed the artwork I used to illustrate my text above is all taken from games I’ve not yet finished, and there are plenty more. But I never sit idle. I do at least work and release. If I’m not making a game, I’ll write, and if I’m not writing I’ll help out in a forum. If I’m not in there maybe I’ll be playing a little Counter Strike. The point is that I feel I do balance them well, one doesn’t over-power the other. I just wish I had more hours in the day.
That’s me done with, now onto 13 other developers for their views on this subject …
John Cotterell
I make a point of working on something every day, even if only for a few minutes, that way I’m always making some kind of progress, and it keeps you in the habit of doing something so that when you are motivated you get a shitload done.
When I’ve lost motivation on commercial work I break work down into studpily small steps – import assets, add method to class, email project manager, etc. That keeps the momentum going and keeps the big picture hidden away from view, which is sometimes what you want.
02/2012 (32)
2
2
FLASH GAME DEV TIP
Flow is a subject every game developer should familiarise themselves with – it has so much relevance to us as it’s crucial to great game design, as well as it is for getting the job done. http://en.wikipedia.org/wiki/
Flow_(psychology)
I rarely find myself in that state as a developer, but I do occasionally have good days, and time really does fly by when you’re in that state of mind
.
Bas / Bits of Bas
http://www.bitsofbas.com/
I’m on several customer monster projects and I’m dragging myself from deadline to deadline since the beginning of February, working from 07:00 to 21:00 on weekdays. Weekends maybe 9:00 to 15:00. As you can imagine my motivation is in pretty bad shape and I don’t even remember what it was that made me think it was a good idea taking on this huge amount of projects
.
The three things that keep me sane:
• My to-do list. Stop myself from thinking and just go do the frigging next point on the list.
• Knowing there will be a nice amount of sure
money (instead of sponsor maybe
money) waiting for me at the end of the ride that will allow me to take a long summer holiday and pave the road to starting my own projects again.
• Surely when looking back after a couple of months, I will be proud of my creations. Looking at the bright side always helps.
As for my own projects, all these help:
•
Choosing a game-play you REALLY like. That keeps me entertained.
•
Go for SMALL games if you know your motivation is a liability.
•
A decent GDD or to-do list. Moving from point to point. Keep yourself in line.
•
Working in a (small) team. When my mate does all the graphics, I can’t bring myself to saying I don’t feel like going on any more.
•
Don’t start several projects at once. It’s like a treat for myself; Once I finish this game, I can go on and pick a new one!
Sudden drops in motivation might be solved by: Doing an (even worse) chore in the house, snacking, going out for a walk / shopping, posting to a friendly forum
.
Olli / Gaming Your Way
http://www.gamingyourway.com
“
I usually don’t have to motivate myself there, although, our current in-house project is dragging for 9 month now. It got WAY bigger than first imagined (way better too) The thing that keeps me going on that one: the todo list (producteev.com and astrid/android) AND the knowledge that it’ll be done more or less soon.
On personal projects it’s a different matter …
I’m working on two things right now: crystalis and the quite complex hellstrom. On both games it’s the todo list (see above) and the fact that I enjoy working with c#/Unity/3d. The one thing that distracts me is my wife, though. Otherwise I’d be working more on the games.
She constantly tells me that if I feel that I need to work on my games more I can do it – but as girls are there is a certain “but you better don’t” attached to it. Luckily she’s the manager of a venue and does at least one night shift per week
.
Editors Note
Olli touches on a real issue here – that of family life getting in the way
and the real feeling of guilt that devs endure when they are desperate to escape
and just geek-out for a while. There’s no denying that we love our families, and enjoy spending time with our wives and children. But for most geeks I know there is a real need to get away from it all, even for a short period of time, and create or do something constructive on their computer. This is worthy of a whole article in itself.
Julian / LongAnimals
http://www.longanimalsgames.com
• Think of the money, and how crap your old age will be if you don’t save up.
• Don’t take too long over a project.
Iain Lobb
http://www.iainlobb.com/
If you’re not feeling the project, the best thing to do is just break it down into micro-tasks and tick them off one by one. At this level it’s pretty brainless so I’ll sometimes stick on a DVD or podcast while I work on client stuff. For 02/2012 (32)
2
4
FLASH GAME DEV TIP
personal / indie projects, the best thing for me seems to be to have a very small scope at the start. Scope will obviously grow/creep as the project develops, but at least by starting small you aren’t setting yourself up for failure. The other really important thing for all projects is to have the artwork first. This gives me a much better vision of the finished product and keeps me motivated to keep working. If you’re developing with grey boxes it can make it seem like finishing is impossible.
Squize / Gaming Your Way
http://www.gamingyourway.com
Picking a game I’m panting to play. Very rarely I’ve pandered to what I thought the market would want, and those games have become such a slog because they’re not always a game I’m really into. If I’m writing a game for myself, which is what personal projects should be, then it’s because I really want to play that game.
Split the boring stuff up. There’s always some parts of every project which are just donkey work no matter how fun working on the overall game is. If I know I’m going to spend a day doing something which makes me die a little inside, I budget the next day to do something fun, usually eye-candy related (This why I often hear “You’ve put particles in there? But, but the game doesn’t work”).
Personal pride. This may seem a little trite, but it’s very valid. We’ve worked so fucking hard to ensure that our games are of a certain standard, that we’re perceived a certain way, that we try and maintain those levels even if it means re-doing things to match our own expectations and no one else’s. We’re our own worse critics, and this is why we’ve only done one “Game in a day” as we just can’t add the levels of love we want in that time scale (Obviously there is always a compromise, but if your expectations are high you compromise less).
Getting others on board. If you want to give up smoking, or lose some weight, you tell people so you can’t back out without looking like a dick. The same applies with games, show people stuff early and often and it removes the chance of it becoming vapourware as you really don’t want to look bad after giving it large.
For me working on only one project at a time helps so much. It brings focus to it, and it stops a cross pollination of ideas between projects which always leads to feature creep (I’ve just added something sweet to game A, hang on, that could work in game B if I just alter…).
The hidden bonus to this is that during the vinegar strokes of a project you’ve got a brand new one to look forward to, rather than having more slog / donkey work on another one (You forget about all that at the start of a project, if you didn’t you wouldn’t make games. It’s like forgetting just how painful child birth is).
For client games it’s slightly different, there for me it’s about making the client love our work so much that they slide off their chair after a cum explosion. It’s not for the re-hire, that’s never really appealed, that’s like going to the same prostitute twice, it’s about making the client feel good about themselves for picking the right team, that we’ve hit the project and hit it hard. This is how we fucking roll client bitches, this is what you get when you go gyw. That and obviously the silly money
.
Editors Note
Pure Shakespeare Squize, pure Shakespeare.
Ali / Alillm.com
http://www.alillm.com
I actually find that when I get bored of a project and want to start something else, it’s best to just give in and start the new project. If I don’t, I will constantly have it on my mind and I won’t get anywhere with the original project anyway. After a few days of working on the new project, my enthusiasm for it will have worn off a bit and it’s much easier to convince myself that finishing the original project is the best use of my time.
A positive side effect is that once I’ve finished the original project, I already have a good foundation for my next game waiting for me so I don’t have to start with a blank canvas.
Also, to-do lists are of course a big help, especially in the final stages where it’s just a case of adding all of the boring bits
.
FlashDevelop scripting: open file by text selection
02/2012 (32)
2
5
Chris Houston / Utinni Games
http://www.utinnigames.com
I find a useful thing with todo lists is at the end of the day you can look down and go “great, I’ve done those bits” and tick them off. You get to see what progress you’ve made, where often if you’re head-down in a big project it it starts to feel like it’s not going anywhere.
These days I usually have two lists, a “headlines” list and a “bugs” list. The headlines are the “Add Baddies” kinda things, while the bugs are the little nasties that crop up along the way. When the bugs list gets longer than the headlines, I do them all before going back to the nice bits.
Something else I’ve realised recently is that all project have their ups and downs. The fun bits and the boring bits, the parts that motivate you to work till the early morning, and the bits where you can’t be arsed to even look at it. But giving up or abandoning projects at the low parts mean you don’t get to the next good bit
.
Chris Underwood / Deeperbeige
http://deeperbeige.com
Motivation on contract stuff is pretty much never a problem for me. I can turn down projects I don’t like the sound of much, so I’m likely to be at least a bit interested in it. There’s a pot of cash waiting at the end, and people checking up on your progress all the time. That sounds cold and cynical, but it’s not. I’m motivated to give my clients the best value I can for their dosh, and I never want to build bad games (although sometimes I do – and why is another lengthy subject).
Private games are a different matter. With no externally enforced deadline, nobody harassing you to get it done, and with the latest blockbuster games installed on the work machine too, it’s all too easy to wander. The best defence I’ve found is brain-momentum. If you can get in that state of flow where you do pure work and don’t even notice the time go by, you’re on a winner. The hard part is getting there, but all you have to do is try hard a lot. It’s like getting a big heavy boulder rolling. It takes a lot of effort to get moving, but when it does it’s unstoppable. The trick for me is to muster enough willpower to force myself to do the hard slog bit at the start. I just have to force myself to get on with it.
Sometimes I’ll need to clear down other stuff first, or it’ll keep knocking me out of the zone. Get those important emails sent. Make up those invoices. Do the washing up. Watch the latest episode of Mythbusters and complete that latest game. Then be ruthless. Then get on with it. No excuses. No breaks. Open Flash and do at least an hour of gazing at code or tweaking level designs or something. Doesn’t really matter what in terms of getting momentum going, so pick something easy and fun. Once you’ve got brain-momentum going, the rest just falls into place automatically.
Dave Munsie / Munsie Games
http://munsiegames.com
I used to have severe motivation (a.d.d?) problems. Like most people I learned to take things in much smaller steps. Otherwise I really don’t have any motivation problems, because if I don’t work… I don’t make money
.
Tony / Tonypa
http://www.tonypa.pri.ee
I don’t do contract work so it only leaves the games I make because making games is fun. Since there is no money involved, only fun-part, I stop the project as soon it is not fun anymore. Which happens a lot. Over the years I would say I only finish 1 out of 10 games.
I don’t even enjoy coding too much. Most fun is to imagine how something could work, usually at half-
sleep. Sitting down and writing the code for it to work is interesting only as far it improves or changes the first idea. Something went wrong in the code but it creates new and interesting gameplay – scrap the original idea and go for this instead. For me making games is a lot 02/2012 (32)
2
6
FLASH GAME DEV TIP
like painting or writing novel, its a creative process where you have some vague idea about what you would like to create but process itself is the main reason to do it.
One thing I have noticed is to never start on graphics too early. If the game is not fun using only boxes and circles then it will not be fun with robots-zombie-
vampires either. So I tend to stick with boxes and circles for a very long time, sometimes getting used to those so much that I never bother putting proper graphics into game.
Rob James / robotJAM
http://www.robotjam.com
I think it really helps on projects working fulltime with another person, me and the other guys generally spend most of the time kicking each other into getting stuff done, and on non contract jobs theres the added motivation the faster you get it done the more profitable it is.
I always find I hate the first few days of a project, but I know that after that we’ll have a decent prototype done and the middle part of the project is always the best. Its the end which I really hate as you think its done and it always takes a while to finally kill them off.
We generally move onto lists in the last week of a project and just knock them off one at a time
.
Ilija Melentijevic / Photon Storm
http://ilkke.blogspot.com
I use lots of methods to tackle lots of related problems, so I’ll just spill it all, and you try and make sense of it. A long time ago I too had trouble with starting things. Typical procrastination stuff, you do nothing for so long and then you feel like you have to do something epic to make up for it, and that only makes it harder, etc.
For me the trick was to just start doing anything. Not do it for the sake of completing it but for the sake of enjoying the process. I would just take a pen and draw something and it wouldn’t matter if it was good or bad. The point was to remember why I love doing it in the first place. We all sort of chose to do what we like to do, and when you forget that, you have to shed the things that make it not fun anymore and start over.
Another trick is to deliberately do things slowly. It helps separate the process from the goal, which in turn helps me to not be impatient and wish I’ve already completed something. I also employ this tactic when I have to wash the dishes or similar. I just start doing it and after a while it’s magically done.
All in all this would boil down to ‘making time stop’ for lack of a better description. I find that going to the office every day and clicking on thousands of links people send me each day makes me lose the grip on my time, and then I try to just stop and sort of be in the moment, in the ‘now’. It’s like there’s a big noisy machine out there and you can’t hear your own thoughts because of all the noise it makes.
I do suffer from being used to doing what I’m passionate about. I think this is very important in life and I don’t want to regret not doing it later. The drawback is that I start a zillion things and take on a zillion projects and thus lose focus and disintegrate. When I get passionate about the next thing, the thing I’m working on is of course not finished yet and so I just leave it there. Ultimately the right thing to do.
There are however times when I’m not in love with any project in particular and this is the time I use for making progress on the things that I’ve left hanging. I make lists, I put files and folders out on the desktop to FlashDevelop scripting: open file by text selection
02/2012 (32)
2
7
remind me of their existence. It also helps to to a tiny bit of work done whenever you have a little bit of time. These fragments add up very quickly.
Sometimes I just think about the amount of work I do when I’m being paid for it (full time or freelance), and think about how I should be able to work for myself even better. I tell myself it’s humiliating to not be able to get myself to do things that I feel are the only ones really worth doing.
Also, here’s something a friend once told me: ”In a few years time, nobody will know how easy or hard it was for you, if you were tired, or ill or if somebody close to you had passed away. All that is left is what you’ve done.”
The trick for me is to have mantras such as these, thoughts that snap me out of the everyday slipstream and remind me how each day is special, how I am special (since we are all different, thus special) and that I should be doing things that only I can do instead of wasting time on the net or in front of the TV, or *shudder* watching series. Or playing games that are not the absolute best games I’ve ever played. Of course, one has to unwind now and then, but we usually end up being too lax on ourselves instead the other way around.
Let me try to wrap up this chaotic rant with something practical: I find it helps to keep track of what I’ve already RICHARD DAVEY AND PHOTONSTORM.COM
Photon Storm are Richard Davey and Ilija Melentijevic. This is our place on the web where we publish our HTML5 and Flash games, artwork and tutorials. We like writing about all facets of game development and sharing cool links now and again.
For my day job I’m the Technical Director of Aardman Digital, the online department within Aardman Animations – most famously known for Wallace and Gromit, Shaun the Sheep and Creature Comforts. Part of the work our department does is to create games and online experiences based around our key brands.
Prior to joining Aardman I spent years working in the games industry for a �ne company called The Game Creators. They produce software that allows anyone to create decent games on the PC with relative ease. I’m still in close contact with the guys there and will be blogging about anything exciting I see on their horizon.
I consider myself a hardcore gamer, and have always loved gaming since I saw my �rst ever Atari 2600. I’m also an Atari otaku. The Atari ST holding a special place in my heart, which is why I built this site dedicated to it. So if my code experiments have a seriously “retro” �avour to them, that is why!
done, it makes me feel powerful and thus less prone to procrastination. Even a very simple method like Pomodoro Technique does wonders
.
a d v e r t i s e m e n t
2
8
HELLO PYTHON!
02/2012 (32)
Hello! Python
2
9
02/2012 (32)
W
e’ll build a simple chat server so we can log in and play a game with other people via the Internet. Normally these games are referred to as MUDs, which stands for multiuser dungeons. Depending on the person creating them, MUDs can range from fantasy hack-
and-slash to science fiction, and players can compete or cooperate to earn treasure, points or fame.
We’ll use a framework called Twisted, which contains libraries for working with many different networking protocols and servers. Getting started
The first step is to install Twisted and get a test application running. Twisted comes with installers for Hello! Python
Hello! Python
By Anthony Briggs
In this article from chapter 10 of Hello! Python
, author Anthony Briggs Talks about extending an application using the Twisted framework to make it interactive over the Internet.
You may also be interested in…
Excerpted from
For source code, sample chapters, the Online Author Forum, and other resources, go to
http://www.manning.com/briggs/
Writing a Simple Chat Server
Figure 1. Installing Twisted on Windows
2
8
HELLO PYTHON!
02/2012 (32)
Hello! Python
2
9
02/2012 (32)
receiving data, and closing connections when we’re finished. You can do this in Twisted by subclassing its existing networking classes (Listing 1).
#1 ChatProtocol is like Telnet
For our chat server, we’ll be using Twisted’s StatefulTelnetProtocol
. It takes care of the low-level line parsing code, which means that we can write our code at the level of individual lines and not have to worry about whether we have a complete line or not.
#2 Override connectionMade
We’re customizing our protocol by overriding the built-in connectionMade method. This will get called by Twisted for each connection the first time that it’s made.
#3 A new connection
We’re just taking care of a bit of housekeeping here – storing the client’s IP address and informing everyone who’s already connected of the new connection. We also store the new connection so that we can send it broadcast messages in the future.
Windows (Figure 1) and Macintosh, which are available from the Twisted homepage at http://twistedmatrix.com
. If you’re using Linux, there should be packages available through your package manager.
The installer will pop up a window as it compiles things but, once you see the window on the right in Figure 1, Twisted is installed!
The only other thing that you need is a telnet application. Most operating systems come with one built in, and there are many free ones that you can download. I normally use PuTTY, which is available for Windows.
Our application
We’ll now write our simple chat server. It’s a little more complex than Hello World, but we can extend this program and use it for gaming. Open a new file and save it as something like chat_server.py
.
Let’s start with the first part of our application, the protocol for our chat server. In Twisted terminology, a protocol refers to the part of your application that handles the low level details – opening connections, Listing 1. A simple chat server protocol
from
twisted
.
conch
.
telnet
import
StatefulTelnetProtocol
#
1
class
ChatProtocol
(
StatefulTelnetProtocol
)
: #
1
def
connectionMade
(
self
)
:
#
2
self
.
ip
= self
.
transport
.
getPeer
().
host
#
3
print
"New connection from"
, self
.
ip
#
3
self
.
msg_all
(
#
3
"New connection from %s"
% self
.
ip
,
#
3
sender
=
None
)
#
3
self
.
factory
.
clients
.
append
(
self
)
#
3
def
lineReceived
(
self
, line
)
: #
4
line
= line
.
replace
(
‘\
r
’, ‘‘
)
print
(
"Received line: %s from %s"
%
#
4
(
line
, self
.
ip
))
#
4
self
.
msg_all
(
line
, sender
=
self
)
#
4
def
connectionLost
(
self
, reason
)
:
#
5
print
"Lost connection to"
, self
.
ip
#
5
self
.
factory
.
clients
.
remove
(
self
)
#
5
def
msg_all
(
self
, message
, sender
)
:
#
6
self
.
factory
.
sendToAll
(
#
6
message
, sender
=
sender
)
#
6
def
msg_me
(
self
, message
)
:
#
6
message
= message
.
rstrip
()
+ ‘\
r
’
#
6
self
.
sendLine
(
message
)
#
6
3
0
HELLO PYTHON!
02/2012 (32)
#4 Handle data
The Telnet protocol class provides the lineReceived method, which gets called whenever a complete line is ready for us to use (whenever the person at the other end hits the return key). In our chat server, all we need to do is send whatever’s been typed to everyone else who’s connected to the server. The only tricky thing that we need to do is to remove any line feeds; otherwise, our lines will overwrite each other when we print them.
#5 Close the connection
If the connection is lost for some reason – either the client disconnects or is disconnected by us, connectionLost will be called so that we can tidy things up. In our case, we don’t really need to do much, just remove the client from our list of connections so that we don’t send them any more messages.
#6 Convenience methods
To make our code easier to follow, I’ve created the msg_all
and msg_me
methods, which will send out a message to everyone and just us, respectively. msg_all
takes a sender attribute, which we can use to let people know who the message is coming from.
So that takes care of how we want our program to behave – how do we link it in to Twisted? We use what Twisted refers to as a Factory, which is responsible for handling connections and creating new instances of ChatProtocol for each one. You can think of it as a switchboard operator – as people connect to your server, the Factory creates new Protocols and links them together – something like Figure 2. So how do we do this in Twisted? Easy. See Listing 2.
#1 A ChatFactory?
A Factory is object-oriented terminology for something that creates instances of another class. In this case, it’ll create instances of ChatProtocol
.
#2 Talking to everyone
The ChatFactory is the natural place to store the data shared between all of the ChatProtocol instances. The sendToAll method is responsible for sending a message to each of the clients specified within the clients list. As you saw in Listing 1, the client protocols are responsible for updating this list whenever they connect or disconnect.
#3 Wiring everything together
The final step is to let Twisted know about our new protocol and factory. We do this by creating an instance of ChatFactory
, binding it to a particular port with the listenTCP method Figure 2. A factory creating protocols
Listing 2. Connecting up our protocol
from
twisted
.
internet
.
protocol
import
ServerFactory
#
1
from
twisted
.
internet
import
reactor
#
3
...
class
ChatFactory
(
ServerFactory
)
:
#
1
protocol
= ChatProtocol
#
1
def
__init__
(
self
)
: self
.
clients
= []
#
2
def
sendToAll
(
self
, message
, sender
)
:
#
2
message
= message
.
rstrip
()
+ ‘\
r
’
#
2
for
client
in
self
.
clients
:
#
2
if
sender
:
#
2
client
.
sendLine
(
#
2
sender
.
ip
+ ": "
+ message
)
#
2
else
:
#
2
client
.
sendLine
(
message
)
#
2
print
"Chat server running!"
#
3
reactor
.
listenTCP
(
4242
, factory
)
#
3
reactor
.
run
()
#
3
Hello! Python
and then starting Twisted with a call to its main loop, reactor.run()
. I’ve chosen 4242 as the port to listen to. It doesn’t matter too much which one you use, as long as it’s something above 1024 so that it doesn’t interfere with the existing network applications.
If you save that program and run it, you should see the message Chat server running
! If you connect to your computer via telnet on port 4242 (usually by typing telnet localhost 4242
), you should see something like Figure 3.
It may not seem like much, but we’ve already got the basic functionality of our MUD server going. Now we’re ready to start connecting a game to the network.
Summary
We learned how to set up a chat server so we can log on and interact with other game players on the Internet. We first set up the protocol for our chat server and then we linked it to Twisted, which contains libraries for working with many different networking protocols and servers.
Figure 3. Our chat server is running
a d v e r t i s e m e n t
3
2
INTERVIEW
02/2012 (32)
Introduce yourself- who are you, how big is your team, and how do you participate in the Flash games industry?
My name is Jakub Dvorský, I’m visual artist and game designer. In 2003 I founded the studio Amanita Design, which is now nine employees strong. We are focused mostly on developing independent games (built in Flash) but sometimes also on other projects like films, music videos or some experimental stuff.
What did you do before? How did you first get into the Flash games industry? Tell us about your path.
I grew up on 8bit computers and started making my own games when I was 15 on my first PC, I was in grammar school at that time. Later I went to the Academy of Arts in Prague to study animated film. When I was finishing the academy I created my first Flash game (Samorost) as my thesis project and later the same year founded Amanita Design.
What has been your proudest moment since joining the Flash gaming community?
I’m most proud of assembling our team – a bunch of great friends, professionals and passionate creators.
What was your biggest challenge early on with Amanita Design? How does that compare to the types of challenges you face today?
When I started making Flash games I was alone so the biggest challenge was programming – I was doing FGS 2012 Advisory Board Interview Series: Jakub Dvorský
FGS 2012 Advisory Board Interview Series
This is part three in a series of interviews of the Flash Gaming Summit 2012 Advisory Board. This is your chance to get to know the folks who determine the content of Flash Gaming Summit, getting their thoughts on both the conference and the games industry in general. This week’s Advisory Board interview features Jakub Dvorský, founder of Amanita Design. In case you have been living under a rock, their game Machinarium has been a huge success on iTunes, specifically hitting #1 on the iPad. Machinarium was also a Mochis Award Show winner at FGS 2010 (Best Game Art category).
For more information on Flash Gaming Summit, including passes, speaking, or award show nomination information please visit the conference website.
3
4
INTERVIEW
02/2012 (32)
it myself which was very tough for me even on a basic level, my head is just chaotic for this kind of work. Nowadays we have a couple of excellent programmers so the biggest challenge is probably game design, more specifically how to make a game entertaining, challenging, accessible, new and original.
Do you have any recommendations or advice for game developers who are trying to make a multi-platform “hit” game? What should they be focused on?
The game must definitely be fresh, distinctive and original and at the same time perfectly executed and polished. Sounds easy right? :)
What is it that you love the MOST about the Flash games industry?
It’s easy to create a simple game and publish it on the web or as an app, so any idea can be quickly transformed into a real game and can be played by thousands of people all around the world. This is really great because you can immediately see if it works or not and you can also improve your game according to the feedback you get from your players.
What do you like the least?
The bugs in Flash.
How has the industry changed since you fist joined?
The whole scene has changed, it was a completely different world when I started with Flash games. When I was searching the web for interesting interactive stuff, there were just a few really good websites and only a couple of games worth mentioning, nowadays there are tens of thousands of games, experimental interactive projects, art projects, websites and portals.
The theme for FGS 2012 is “Maximize Your Game”. How do you think Flash game developers are maximizing their games today? What could they be doing better / differently?
I’ll be repeating myself but I think the developers should try to be more original and brave, they should experiment more with art, game mechanics, narrative approaches and with the whole medium which is still unexplored and waiting for young adventurers who wants to create something really new.
Where do you see the Flash games industry going? What’s in store for the future?
A more interesting question to to me is “where is the games industry is going”? I think the future of the games industry is extremely bright because the medium will be broader and more serious in many ways. I see really big potential for creative people from various disciplines from artists, writers, designers and musicians to programmers and engineers.
What part of Flash Gaming Summit do you enjoy or look forward to the most?
The best part of almost every game conference or festival is always meeting other developers and players in person.
In your opinion, why should people come out to FGS 2012? What should they expect from the conference?
Similarly to my previous answer answer, the most valuable part of conferences for me is meeting some interesting people in person. It’s sometimes much more influential than weeks of reading, surfing or watching videos on the web.
Thanks for your thoughts and insights Jakub, see you at FGS 2012!!
COLIN CUPP
Colin is the Product Marketing Manager at Mochi Media. So what does that mean? That means that internally at Mochi he is an advocate for developers and publishers, and externally he talks about products and features. When he is not working or traveling to a far-of land, he enjoys the simple things in life like camping, hiking, Net�icking, and playing games. Yes, Net�icking is an activity.
02/2012 (32)
3
6
REVIEW
S
imply put, you are looking to outline those features that make your product stand out from the competition. So how should you go about doing this?
Tired of using screen recorder tools that create dreary, outdated 2D presentations? (We knew it)
That’s where we have the solution.
Demo Builder allows you to take your presentations to a whole new level. More specifically, Demo Builder gives you the ability to enhance your presentations with stunning 3D effects to better focus customers’ attentions to the key aspects of your software.
These 3D effects create the “Wow” effect you need—and which keeps customers glued to their screens. You have worked hard, so let Demo Builder do your product justice. It deserves the attention!
Now Demo Builder 8 allows you to create your 3D presentation in as easy as 1-2-3 (record, edit, publish).
Simply start the recorder and take the actions you want to show in your desired application. Demo Builder captures everything automatically.
After recording, you may either have Demo Builder automatically Demo Builder 8
If you are reading this then you probably have software that you would like to showcase on your website. You would like to show potential customers how it functions and its key features. Create 3D Presentations in Flash Format
RADU IONESCU
I work for Tanida, heading its Customer Relations department. At Tanida, we take all customer feedback seriously. It is my duty to see that these requests be carried out, as best as possible. I centred the article around the 3D abilities of Demo Builder because these are what our customers are most concerned about today.
Figure 1. Radu Ionescu, proud member of the Tanida Team
add these 3D effects or you can choose to manually insert these. In fact, once the recording is done, with only one click you can export a complete 3D presentation in Flash, H264, AVI, WMV or MP4 format.
Could we make it any easier …. ?
To learn more, please visit our web site:
http://demo-builder.com/index.html?src=ffd1
02/2012 (32)
3
8
BOOK REVIEW
E
manuele Feronato
is a familiar name to anyone who’s ever searched for something to do with Flash game development on Google. The tutorials he publishes on his blog
are as ubiquitous as the platform itself. They provide nuggets of code usually meaty enough to accomplish the task at hand. Be it creating a Match-3 knock-off, a landscape generator or showcasing a new library. The complexity never really leaves the shallow end of the pool, which I suspect is the main reason beginners flock to his site.
But with a book you leave the safety zone of this isjust enough
behind. When people have put down good money, the expectation levels are rightly higher. So it was with intrigue that I started reading Flash Game Development by Example
. It covers the creation of 9 games across 300+ pages, which is an average of 30 pages each. Probably 28 more than he uses on his web site I was curious what this extra space would provide.
The first game we make is Concentration or Pairs
, the classic card game. Everything is done in the Flash IDE at a size of 550 x 400, and it leads you step-by-
step through creating an FLA, creating your Main.as, entering a trace statement to prove it compiles and then explaining what imports and packages are. The explanation for the Sprite package for example is This class allows us to display graphics
. That’s true, and while I’m not expecting a detailed explanation at this level I did expect a little more. Emanuele then starts creating the game, kicking off with a loop to make an Array of 20 tiles. Every single line of code is explained – rapidly jumping through AS3 syntax as it goes. It’s as if the single line of source for (var i:uint=0; i<NUMBER_OF_
TILES; i++)
caused Emanuele to stop and realise he had better explain what a uint, a constant and a for loop is before he can carry on.
The problem with this approach is you forget what it was you were building as you try to deal with a rapid onslaught of new information. And it doesn’t let-up. By page 19 the game is dealing with adding a Fisher-Yates shuffle algorithm. A quick trip back to the Flash IDE creates some tiles, and more code starts displaying them and adding event listeners for clicks. By page 31 you’re deep in the realm of indexOf Array checks, event.currentTarget magic value access and modulo operations. Nearly every line of code is still being explained but the pace is borderline frantic. And just like that, it ends. The game is complete, a few homework assignments are given to you and we’re on to Chapter 2.
Chapter 2 is about building Minesweeper. So multi-
dimensional arrays and iterative scanning for mines. It also contains probably my favourite quote in the whole book:
Just think about a function like a mad witch. You give her some strange stuff such as bat wings and lizard tails, and after making something mysterious she gives you a potion to turn someone into a frog. The great thing is once you’ve made your functions (witch) you don’t need to know how they do the magic anymore
.
I would probably rather have had a potion that turned me into a frog than this. For a book that was so carefully explaining, albeit in brief, what a boolean was a few pages ago, it has now descended into the realms of spaghetti. It makes my head hurt just looking at it. Even a seasoned developer would have to waste a few precious minutes deciphering it, so I’ve no idea what Flash
Authors:
Emanuele Feronato
Publisher:
PACKT.
ISBN:
1849690901
Language:
English
Pages:
288 Pages
Website:
http://www.flashgamedevbook.com/
Game Development by Example
Flash Game Development by Example
a total beginner will take away. Ironically in Chapter 3 (building a Connect 4 game) he concentrates on splitting code up to make it as readable as possible.
The Connect 4 game starts to bring in motion (the pieces sliding down), and has a good section on planning the graphics so everything is the right size and all fits. The illustrations are almost more useful than the source code as they convey a meaning, explanation and result in one shot, and they continue to be great through-out the rest of the book. The chapter wraps-up by adding AI to the game, both random and defensive play methods. This is a nice touch as it could easily have been left out.
Chapter 4 creates a slightly pimped-out Snake clone. Teaching you how to using the Point class and calculate distance between display objects through a Manhattan Distance check. It makes a point of not using an Array for what is a very tile-based game. It feels like a strange choice of game to demonstrate this, but the final game actually works. The source is again full of short-cuts and abbreviations that sprinkle on the magic, obscuring clarity in the process. Even the ENTER_FRAME event has been reduced to onEnterFr
(enter the French?) but once more the illustrations come to its rescue: Figure 1.
In my mind the above is actually more useful than the code that does it. I do wonder if there’s a potential game development book idea here – where it’s just a series of illustrations like the above that all lead to a finished game. With zero source code at all making it language agnostic!
Back to the book… Chapter 5 builds Tetris, with all graphics generated via AS3 and the trusty Array restored back into service. Tetris is one of those games that is quite a bit harder to code than it appears when Listing 1. Code taken from the function it teaches you to make:
if
(
mineField
[
row
][
col
]
==
0
)
{
for
(
var
ii
:
int
=-
1
; ii
<=
1
; ii
++
)
{
for
(
var
jj
:
int
=-
1
; jj
<=
1
; jj
++
)
{
if
(
ii
!=
0
||
jj
!=
0
)
{
if
(
tileValue
(
row
+
ii
,
col
+
jj
)
!=
9
)
{
if
(
tileValue
(
row
+
ii
,
col
+
jj
)
!=-
1
)
{
loodFill
(
row
+
ii
,
col
+
jj
);
}
}
}
}
}
� � � � � � � � � � � � �
a d v e r t i s e m e n t
02/2012 (32)
4
0
BOOK REVIEW
you play it. But the chapter does a good job of covering the raw basics. The pieces move whole tiles at a time, which removes that damn, let’s quickly slide this bit over there
last-minute decision you were allowed to make on the Gameboy version. It’d be nicer if the pieces dropped and slid smoothly, but the way the game is coded that wouldn’t be an easy change.
Chapter 6 finally see’s us creating an arcade game: Astro-Panic! Basically a Space Invaders styled shooter with slightly more dynamic alien movements. It’s a fun little game, looks nice and is full of action. Other than a small section dipping into the realms of trigonometry to handle movement vectors I can’t help but feel this would have been a much more interesting first game to make than Concentration was.
The remaining chapters of the book deal with creating clones of Bejewelled, Puzzle Bobble and Ball Balance (one of Emanuele’s own games). It all ends with some recommended web site links before leaving you outside in the cold staring at the Index. The new games introduce a few new features but mostly deal with getting the game mechanics correct using what you’ve already been taught.
It’s as if the book is trying to fulfil two tasks: teaching a beginner how to make games, and teaching them the fundamentals of AS3 at the same time. I can’t help but feel it should have lived up to the title and focused specifically on just making the games themselves. There are multiple good AS3 reference books out there, and while the explanations of AS3 syntax and features in here are just about adequate, they barely brush the surface and often use very beginner unfriendly Figure 2. FlashGame Astro Panic Example
RICHARD DAVEY
terminology. It’s also here that I feel Emanuele should have been given a native English speaking proof reader (and if he had one, then a more thorough one!) because there are lots of times where it’s obvious he’s struggling to clearly explain in English what something is. Simple grammatical things that should have been picked up and corrected.
If you have at least a bit of AS3 knowledge under your belt, or are a fan of his blog posts, then you should get on ok with this book. The process of breaking the game down into logical components, and the way in which he puts it together almost iteratively, is excellent. I’m a big fan of the show and tell
approach, where you make small changes, but lots of them, and let the reader witness the results of those changes for themselves.
If you are a seasoned AS3 developer then I think you can still get a little, because the approach to the game design and logic is mostly sound, and you’ll have the ability to totally re-code the source into something more readable! Personally I have issues with the source code. The variable naming, short-cuts taken and deeply nested constructs frighten the hell out of me. If I was shown this sort of code by a developer applying for a job in our team I’d politely file them away under the last resort
pile. For me source code is at its most useful when you can read it like a good book, and that’s certainly not something you’re going to learn here.
If you’ve already got a few Flash games under your belt then the majority of this book will be academic to you, but I suspect you aren’t the target audience. Basically if you like the sort of code and tutorials you find on his blog, you’ll like the book. If you don’t, you won’t! I applaud Emanuele for having written this, and I hope it inspires beginner developers who’d love to get into Flash game coding. I just hope they supplement it with some of the AS3 heavy-weights like the ActionScript 3 Cookbook
or Advanced ActionScript 3 Animation
as well, which offer the level of depth they will truly need, and dare I say it, slightly more elegant code in the process.
Figure 1. FlashGame Snake Example
�����������������������������������������������������
����������������������������������
���������
���������
�������������
������
�
�
�
�
����������������������
��������
� ����������
��
�
�� �����
�����
�������������� �����
������������������������
�����������������������
�����������������������
��������
�������������������
�������������������������������������������������������
��������������������������������������������������������
�
����������������������������������
� ��������������
������������������������������
��
��������������������
�����������������������������
���
���
��������������������������
�����������������������������������������
�
��
��������������������������
�������������������������������������
�������������������������������������������������������
��������������������������������
�����������������������������������
�����
��������
���������
�������
������
�������
����
������
����
�������
���
�����
�����
��������
������
������
������
�����
�����
�������
��������
�����
����
�����
������
�
���������
�������
����
�
��
��������
����
���
����
������
�����
������
�������
�������
�������
�������
����
�������
���
�������
����
������
�����
�����
�����
������
�����
�������
����
������
�����
���
��
����
�����
����
������
�������
������������������������������
������������������
����������������
������������������������
��������������
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
������������������������������������
�������������������������������
�
�����������������
�������������������������
�
��������������������������
�������� ������������������
���������������������
����������������������������������������������
���������������������������������������������
����������������������
�����������������������������������������������
�����������������������������������������������
�������������������������������������������������
������������������
����������������������������
������������������������������������������������
����������������������������������������������
�������������������������
� ���������������������������������������������������
������
��������� ����
����������������������
��
�� �����
������
��������������������������������
��������
�
���������������������������������������
�
�������������������������������������������������������������������������������������������������������������������������
��������������
���������
�����������������������
���������������������������
Документ
Категория
Информатика
Просмотров
307
Размер файла
6 979 Кб
Теги
flash, flex, adobe
1/--страниц
Пожаловаться на содержимое документа