Game Programming Specific questions Flashcards Preview

Web Technologies > Game Programming Specific questions > Flashcards

Flashcards in Game Programming Specific questions Deck (16)
Loading flashcards...
1
Q

What game engines for HTML5 are there?

A
Phaser
Three.js
Crafty
Gamemaker
Construct
Easel
Impact
Cocos2d
2
Q

What are some of the issues with using JavaScript as a game programming language?

A

One of the biggest ones is the garbage collector. You have to manage your assets really well. Think about pooling objects, and reusing objects. It doesn’t run as fast as native on devices - so performance has to be thought about. “How do I write this function in the most performant way”.

On mobiles too - the eco system isn’t as developed as say it is for native games. The toolsets aren’t as developed.

3
Q

What are some of the good reasons to use JavaScript for game developement?

A

It’s a very flexible, expressive language, I find it easy and quick to get ideas down on the computer, especially when compared with C++ / C.

Probably teh biggest reason though is that it’s cross platform. Probably one of the most cross platform langaues around today. You can write a game for web and port it to a phone in a matter of minutes (if you have thought ahead of course).

4
Q

What are some of the issues you face when making mobile games?

A

You definitely have to think about how to handle the different screen sizes. Apple were pretty good for a while, but then they changed the number of formats we have to target - so we have all these different screen resolutions, pixel densities - with varying support for HTML5.

Android in particular - their browsers on the android devices just haven’t been that performant with canvas.

There is of course the issue of interface, you have a touch interface rather than a mouse or controller - so it becomes necessary to think about how someone will interact with the game. How best to make use of that type of control - I think that’s why we’ve seen some compelling single touch games.

5
Q

How can you mitigate the issue with screen size?

A

Well, there is no one best solution - I think it depends heavily on what the game needs. But for instance, you could simply scale the canvas based on the window.innerWidth / innerHeight of the device. This will give you a game that fits everytime.

But there are some issues with that - you now have a stretched canvas - along with all the assets. If you are only targeting a specific device range where the screens are similar that might be fine.

Otherwise, you can scale it in one direction - for instance, if you have a side scroller, you might scale it so the top and bottom and fit the screen, but the edges are off the edge of the screen. This adds some complexity as you have to make sure you have some safe areas on the game screen. .

There is of course the issue with input - because you’ve scaled the screen you have to map your inputs to the actual game size (Your in-game coordinate system should stay mapped to the width height of the canvas).

I guess one other way you can do it is scale the canvas so that the widest side of the canvas is fits the screen width - then you center the canvas on scree. You get black bars that way, but the game is preserved as intended. Might be useful for a pinball game or something like that.

6
Q

How do you find bitbucket / git for gamedevelopment?

A

I think it’s find for smaller scale game development. It’s probably not suited for something like a large console game where you might be doing constant integrations with large binaries. But for mobile and web style games - it’s a pretty good fit.

7
Q

What are teh different methods for storage in a game on a phone?

A

Since the games are usually packaged within a browser, you can use the same API that web developers use. The storage api. window.localStorage, window.sessionStorage - it just gives you a key value pair, but it’s pretty useful.

There is of course cloud storage.

If you are using Cordova - then you get the webstorage interface, and there is also access to a web sql interface for more complex data.

8
Q

What kind of issues do you have to deal with on a phone?

A

There are a number of challenging issues on phone you have to deal with that are different to traditional consoles.

There’s batteries (i.e. batteries can run out - you also have to make sure your game doesn’t drain batteries too fast)

Rotating screens,

Other events occuring (such as messaging, phone calls)

Low power modes

Normally the phone API will give you those evnets, and you can access most if not all of them through Cordova or other solutions like Cocoon.

Normally you have to make sure you do things like suspend the game properly - you might save state or something like that - as when the user switches apps, there is no guarantee your app won’t be garbage collected.

9
Q

Are in app purchases important?

A

It depends on the game - but for all the apparent animosity towards in app purchases, they still make up on the more significant money earners in the top 100 chart on the app store. I think it’s above 50% still.

I think the key is to make sure it offers a perceived value. At EA we did some work into this (again at Kixeye on the web) - and we found that people didn’t mind paying for in app purchases if it offers value.

For instance a new hat for your game character that is purely cosmetic usually is not good value (unless you are making a dress up game) - but if the hat changed the gameplay in some tangible and fun way - that’d be a worth while purchase.

10
Q

How do you implement in app purchases on mobile?

A

I’ll speak to apple since that’s the one I know better.

You have to first create the assets that the person will purchase - through the app store. You have to give it a name, an image, a SKU etc. Then you can create a sandbox to test it out.

If you are using cordova - you’d need to add the in app purchase plugin to the project.

You can then use the store api - which is mostly event based. You register a bunch of products that you are selling (which matches the app store) and you setup callbacks based on what events happen (i..e updating of the items in the store). For exaxmple there is the store/when/approved event.

store.when(“100 coins”).approved(function())

This allows you to react to the sale of a specific item occuring.

11
Q

How does facebook authentication work?

A

You’ll need to use OAuth to get authenticated by Facebook. in high level terms, the third party app redirects the user to facebook where the user approves the user of the app - a token is then generated that is sent back to the app, which is subsequently used to grant authentication.

12
Q

What is a game loop?

A

It’s the driver of a game. This is where all the movement, input processing, AI calculations, graphics and so forth are handled. The loop is called around 60 times a second and therefore you have about 17 milliseconds per frame in which to accomplish what you need to do to make the game smooth.

13
Q

What is FPS?

A

Frames per second, or the number of frames that are output by the game to the display per second. You want this to be as high as possible - for the smoothest animation. HTML5 canvas attempts to draw at around 60fps, or 17 ms per frame.

But this can be variable, so for most movement / animation, you would use a delta to determine how far the object should move on the next frame.

14
Q

How would you handle time based animation?

A

Work out the delta - time since last frame - Multiply that by the speed and then add that to the current position. This can be done with either straight up arithmetic, or vector multiplication.

The only thing to keep in mind with this method is that if you pause the game, the delta will get really large - so you need to react to this (blur / focus events) and reset the delta when you regain focus.

15
Q

What are some common errors in JavaScript programming?

A

Forgetting how semicolon insertion works (i.e. the return statement), losing the ‘this’ value. Getting truthiness wrong, and not spotting coercion issues. Forgetting that null can be an object when testing with typeof.

Case sensitivity - JavaScript is case sensitive, but you can do some weird things, like if you try to access a variable on an object, and you misspell it, it will “fail” silently.

16
Q

What are the differences between bitmap and vector art?

A

Bitmap art is a representatin of the art tha tis made up of individual pixels. Itt can’t be scaled very well, it’s large on disk, but it’s pretty cheap to draw.

Vectors on the otherhand are mathematical representations of images, and can be scaled infinitely - they are also (usually) pretty small on disk. However, they are pretty expensive to draw to screen.

Vectors would be ideal for mobile, as it would mean only one assets for all devices. But they are currently pretty poor in performance.