Javascript canvas game development, closure or prototype? - closures

I planning on building a small javascript-canvas game, on the style of Space Invaders and I've been reading about object-oriented programming.
Since I would like to follow best practices in game development, what would you advise: using closures to ensure capsulation but the trade off would be performance(or so I've read) or use prototypes?

if you are working on a bigger canvas project you should use prototypes, but for a small project like space invaders the code shouldn't get too messy and closures would be fine

Related

Sprite Kit and IOS Development

Just a few questions which I can't find answers to anywhere:
To code games for IOS using Sprite Kit, do you also need to know Objective-C or Swift?
Can you code high quality games without knowing Objective-C or Swift?
Thanks!
SpriteKit is an Apple framework developed for Objective-C / Swift application. So, yes you'll need at least some code basics notions.
"Yes". You might be able to develop game with Unity2D for example, but that would include using another language to write your scripts.
I'll try to expand a little bit previous answer.
SpriteKit is an Apple framework developed for 2D/3D games. It uses Swift or Objective-C. Advantage of using this is that you can be 100% sure that this game will work flawlessly on iOS devices. Disadvantage is that you are locked only to iOS devices. If you have 0 knowledge of Swift or Objective-C, and you wish only to develop for iOS, I would choose Objective-C. It seems a little harder to learn and understand, but compared to Swift to it seems that Objective-C is still (and will be for long time) superior to Swift. Although, it just be my personal preference, because I truly hate Swift. (You can achieve same things in both languages) :)
I started this way, I do not regret.
You can develop games and apps for iOS without knowledge of Objective-C or Swift. You can use programs like Unity, Unreal engine, Corona, Cocos2D/3D. However these programs require learning another language to write your game (c++ or something else). You can also use GameSalad for 2D games. It requires 0 coding, many things are drag and drop, but you do need to understand logic behind it. For example, it wouldn't be programming but it would be coding :)
GameSalad is easy to learn, fun as well, but forget that you will be able to create any serious game logic or more advanced game than 2D platform one. I tried it, but very soon changed to Objective C and XCode.
If you decide to go with learning actual language (which I would strongly suggest), I would recommend either Objective-C or to learn Ionic software. Ionic uses javascript, but when you learn how to make games/apps you can easily distribute it to ANY platform: iOS, Windows mobile, Android...XCode is better software, but learning Ionic has huge advantage, and that is single click to deploy app on any platform.
Good luck.

Porting android code into objective C

I have an android game thats basically completed and I want to start porting it to iOS.
I'm completely foreign to objective c and I have no idea where to start. In android I have a surface view, canvas, and a game loop which draws and posts the canvas. What's the iOS equivalent?
First, be very careful of trying to transliterate between languages. You can't just pick up Java idioms and "do the same thing" on iOS in many cases. Many things are done with a completely different approach (threading is a major example; drawing is often done differently as well). You should spend some time learning the platform first or you'll get something that "almost" works and chase bugs and performance problems forever.
That said, the tool you probably want to study is Cocos2D which is a very good 3rdparty toolkit for building 2D games on iPhone. This is generally a much better approach than trying to build it up from scratch and should have a lower learning curve for game dev.
It's difficult to know how you should port without knowing the nature of your game but most iOS games are written in OpenGL which is very extendable. It has some optimization tricks that can play a big role in how you architect your rendering pipeline though.
If you decide to go with OpenGL you should check out this Stanford talk presented by NGMoco on how to do this...
http://www.youtube.com/watch?v=VNr5I3ZRecE

Done Some 2D Game Design, Now Want To Move To 3D

I have used PyGame for a while now, and quite enjoyed doing so, but only 2D experience is not going to cut it when I apply for video game jobs, and besides, I have a number of ideas I want to try out in 3D. What 3D library should I go into first? I was considering Irrlicht, which will also force me to work on my C++ again, but I was also looking towards XNA, as it would be cool to write 360 games. Any suggestions?
You can try Unity3D http://unity3d.com/. In the fall they released their engine for free that is cross platform (Mac, Win and possible Linux) and it can also be targeted for iPhone and web browser and is starting to build an open community and looks promising.
I've done some XNA stuff and the Unity tools look pretty good in comparison making it easier to get content into your games.
In my opinion, going with Irrlicht or OGRE is a good idea. It will help you get back in touch with C++ and experiment with 3D without making it too easy. It is a good idea to learn XNA as well and build a few 3D game prototypes there.
Summary: Do both, eventually. Learn OpenGL/DirectX later.
All the best.
XNA Game Studio is a fantastic framework and let's users jump into creating games quite quickly if you are comfortable with the .NET Framework.
However, if you decide that you want to move to the 3D world, you have 1 more dimension to take into consideration and it makes things exponentially harder. Simple collision detection, isn't so simple anymore. However, with the vast amount of information available for XNA Game Studio, you should find yourself getting to grips with the 3rd dimension quite quickly.
If you haven't done the whole Nehe type tutorials, it's probably best to play with the API, so that you get comfortable with it.
Create a Triangle
Spin the Triangle
Color the Triangle
Load some assets (models and textures) and render them
Try your hand at Alpha Blending
Take into consideration that XNA Game Studio does not have a fixed function pipeline and you will have to use Shaders (HLSL).
I have personally used Irrlicht, Ogre3d, Unity & Xna. Because you want to do this to help for when you apply for jobs in the game industry in my opinion I would suggest Irrlicht as you will want to work on your c++ skills. I also suggest Irrlicht as it is a 3D engine not a specific game engine which will allow you to work on your physics and maths skills as well which are highly sought after in the games industry.
I would suggest avoiding Unity if you are looking for experience to take to industry as it is a package that handles a lot for you and as such could limit your learning.
Ogre3D is a viable option as it is similar to Irlicht, maybe look into the tools available to help you make a choice between those two.
Xna is another interesting choice, it will give you a lot of chances to learn as Irrlicht could and there are a huge amount of resources to help you learn but at the same time you lose the c++ experience that comes with irrlicht.

Any Resources for Pure Actionscript 3 Games?

What resources (books or website/tutorials) are available, that cover game development using pure Actionscript 3 code? By pure, I mean not using Flash CS4 and its timeline, and not using Flex MXML components. Everything done using only Actionscript code.
In another question, I asked about using certain objects of the Flex SDK for simple games, and the consensus was that I shouldn't use it at all, but only Actionscript for a game. Sounds reasonable, but the books/website tutorials that I have found on the subject of games, all use AS3 in the context of Flash CS4. They assume your objects will be movieclips, with timelines, etc.
I realize that you can learn game programming from books in other languages, and/or ignore the Flash aspect of AS3 books. I guess what I'm looking for, is whatever information is specific to AS3, such as best practices for AS3-only games, how to make architectural/design decisions, etc. If it exists, anyway :)
You may want to take a look at Flixel.
What is flixel?
flixel is a completely free collection of Actionscript 3 files that helps organize, automate, and optimize Flash games; an object-oriented framework that lets anyone create original and complex games with thousands of objects on screen in just a few hours.
Flixel is licensed under the MIT license and the site has quite a few tutorials to get you started.
Flash Adventure Game Tutorial
series shows you how to create a
Flash adventure game with Flex and
ActionScript.
FlexFighters
shows you how to make a shoot'em'up
with Flex and ActionScript.
This is a tutorial series that shows you how to make a 3D Flash game with Flex and Away3D
A site that is basically all about using just pure AS3 and that now has game tutorials centered around his pure AS3 game making library is www.actiontad.com.
Your games may be smaller using only AS3 and the SDK, but you loose the ability to animate with a timeline, animations made with the timeline in Flash will perform better, than say sticking a whole bunch of .pngs together, which is a technique actiontad uses, but that site is coming into it's own now with the library he recently released, if pure AS3 game making is your thing it's worth a look.
If you want to deploy your games on mobile (iOS/Android) you should take advantage of Starling (http://gamua.com/starling/), 2D rendering engine built on top of Stage3D, which gives you GPU raw power.

Can the UDK be used for non-game projects?

This is a pretty basic question. I am wondering if the Unreal Development Kit can be used for something other than games, specifically a light show simulator and editor. The site says:
Unreal Engine 3 has been used by game developers, researchers, television studios, machinima directors, artists and students. If you have an idea that needs to be brought to life in a game engine, UDK is for you.
But I have the feeling that it is more game oriented. For my hobby project, I would like to be able to create light show simulations with rotating/moving lasers/lights of changing color, synchronized to sound/music. I would also like to develop an GUI editor for this, preferably in C#, but if it's not possible to access the rendering functionality of the engine from C#, then C++/Qt should suffice. The editor would be used to design the simulation, which would then be rendered/played out in real time.
I guess my base, general question is: can the Unreal Development Kit be used for something like this, not necessarily game related? Or should I go with my original option of Ogre3D, which just focuses on rendering and 3D graphics as far as I know.
EDIT: Just saw this page which again mentions:
Can I create any kind of game with UDK?
Absolutely. UDK is the perfect solution for any kind of virtual world you wish to create, from racing games to simulations.
So my question is now simply: Would I be able to access the renderer or other functionality of my resulting code to integrate it into an editor for my simulator? I guess a simpler, more relatable analogy would be, if I wrote a game, would I be able to write my own level/character/etc. editor for it? And how would I do so? Yes, I know that the UDK comes with editors already, but I mean if I want to make my own.
Thanks! I appreciate any answers :)
The UDK only permits you to play with script (Unreal Script) and not with native code (c++). So more complicated projects or integrations are very difficult without the full c++ source code. But if you will re-use the editor (UnrealED) for your project and make you simulation based upon unreal you can do it.
I'm pretty well oriented in what Unreal Engine can do, and answer to your question is yes and no ;)
Yes, you can create your own actors that will be rotating/moving and emitting light. But won't be able to create your own custom editor around UE's rendered. Frankly I don't see why you would need one - Unreal Editor has all the tools needed to design and execute light show simulation (and much more) - all you need to do is to get familiar with those tools.
One thing you could do in external editor (except, of course, for textures, sounds, models, etc) is create some custom setup in saved to text files, and later read in those files in unreal script - it allows it.
"I guess a simpler, more relatable analogy would be, if I wrote a game, would I be able to write my own level/character/etc. editor for it?"
Yes, you can make your own characters and maps. You shouldn't have any need to make your own editor though, the given editor should be enough.
Although you might not have access to the C++ source code, there is a lot that can be done using Unrealscript. Check out all the entries to the Make Something Unreal contest, they were all done using tools available in the UDK.

Resources