wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Game Development Newton

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a key principle of game design?

a)

Static gameplay with no room for improvement.

b)

Complex storylines that confuse players.

c)

Overly simplistic mechanics that lack depth.

d)

Engaging gameplay that balances challenge and skill.

2.

Which JavaScript keyword is used to declare a variable?

a)

var, let, const

b)

define

c)

initialize

d)

assign

3.

What method is used to draw on a canvas in JavaScript?

a)

getContext('2d')

b)

drawCanvas('2d')

c)

getDrawingContext('2d')

d)

createContext('2d')

4.

How do you listen for a key press event in JavaScript?

a)

document.addEventListener('click', function(event) { /* handle key press */ });

b)

document.addEventListener('keypress', function(event) { /* handle key press */ });

c)

window.addEventListener('keydown', function(event) { /* handle key press */ });

d)

document.onkeypress = function(event) { /* handle key press */ };

5.

What is the purpose of a game loop?

a)

To manage player accounts and profiles.

b)

To create a storyline for the game.

c)

The purpose of a game loop is to manage the continuous updating and rendering of a game.

d)

To handle network connections for multiplayer games.

6.

Which method is commonly used for collision detection in games?

a)

Ray tracing

b)

Pathfinding

c)

Texture mapping

d)

Bounding box collision detection

7.

What does the 'this' keyword refer to in JavaScript?

a)

The 'this' keyword is a reserved word that cannot be used in functions.

b)

The 'this' keyword always refers to the global object.

c)

The 'this' keyword refers to the current execution context or the object that is calling the function.

d)

The 'this' keyword refers to the first argument passed to a function.

8.

Which function is used to clear the canvas?

a)

resetCanvas

b)

clearRect

c)

drawRect

d)

fillCanvas

9.

What is the role of sprites in game design?

a)

Sprites are the main programming language used in game development.

b)

Sprites are responsible for game physics calculations.

c)

Sprites are used to create sound effects in games.

d)

Sprites serve as visual representations of characters and objects in game design.

10.

How can you change the background color of a canvas?

a)

Apply 'canvas.style.background = 'color';'

b)

Set 'canvas.backgroundColor = 'color';'

c)

Use 'context.setBackgroundColor('color');'

d)

Use 'context.fillStyle = "color";' and 'context.fillRect(0, 0, canvas.width, canvas.height);'.

11.

What is the purpose of requestAnimationFrame in a game loop?

a)

To manage game state transitions.

b)

To handle user input more efficiently.

c)

To increase the frame rate of the game.

d)

To optimize rendering and create smooth animations in a game loop.

12.

Which event is triggered when the mouse is clicked?

a)

click

b)

mouse-over

c)

double-click

d)

right-click

13.

What is the difference between 'let' and 'var' in JavaScript?

a)

'let' can be redeclared in the same scope, while 'var' cannot.

b)

'let' is function-scoped and 'var' is block-scoped.

c)

The main difference is that 'let' is block-scoped and 'var' is function-scoped.

d)

'let' is used for global variables, while 'var' is used for local variables.

14.

How do you check if two rectangles collide in a game?

a)

Check if A.right > B.left, A.left < B.right, A.bottom > B.top, and A.top < B.bottom.

b)

Check if A.left < B.left and A.right > B.right.

c)

Check if A.top == B.bottom and A.bottom == B.top.

d)

Check if A.width + B.width < A.left + B.right.

15.

What is the purpose of the 'update' function in a game loop?

a)

To process game logic and update the game state.

b)

To manage sound effects and music.

c)

To handle user input and controls.

d)

To display graphics on the screen.

16.

Which method is used to draw text on a canvas?

a)

writeText

b)

fillText

c)

drawText

d)

renderText

17.

What is an event listener in JavaScript?

a)

A variable that stores event data.

b)

A method that creates new elements in JavaScript.

c)

An event listener is a function that responds to specific events on a target element in JavaScript.

d)

A property that defines the style of an element.

18.

How do you stop the default action of an event?

a)

Use event.preventDefault() in the event handler.

b)

Use event.stopPropagation() in the event handler.

c)

Call event.cancel() to prevent the default action.

d)

Set event.defaultPrevented to true.

19.

What is the significance of frame rate in game development?

a)

Frame rate is significant as it determines the smoothness of gameplay and responsiveness, affecting player experience.

b)

Frame rate is irrelevant in single-player games.

c)

Higher frame rates lead to longer loading times.

d)

Frame rate only affects the graphics quality of a game.

20.

How can you create a simple animation using JavaScript?

a)

Manipulate the DOM directly without any functions.

b)

Use 'requestAnimationFrame' to create a loop that updates the element's properties for animation.

c)

Use CSS transitions for animation effects.

d)

Set a fixed interval with 'setInterval' for updates.