0% found this document useful (0 votes)
16 views

Game Dev 1

The document contains a sample midterm exam for a game programming course. It has 3 questions - the first with multiple choice questions about game engines and programming, the second asks to write pseudocode for a flipping bottle behavior script, and the third explains code that generates a circular arrangement of cubes and asks to sketch the resulting scene.

Uploaded by

Salman Farhat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Game Dev 1

The document contains a sample midterm exam for a game programming course. It has 3 questions - the first with multiple choice questions about game engines and programming, the second asks to write pseudocode for a flipping bottle behavior script, and the third explains code that generates a circular arrangement of cubes and asks to sketch the resulting scene.

Uploaded by

Salman Farhat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Faculty of Arts & Sciences

Department of Computer Science


CMPS 297V—Game Programming
Sample Midterm

Student name:

Question 1 [30 pts]: Choose one answer for each.

1. The following is a part of the game engine code:


a) Isolate the game from the hardware on which it is running
b) Network communication and synchronization for multiplayer games
c) Collision detection and response
d) All of the above

2. To make the game independent of the speed of the system on which it runs:
a) Use higher level libraries
b) Use mathematical optimization functions
c) Use a time step proportional to frame rate
d) Use a time step inversely proportional to frame rate

3. The words that best describe a game loop:


a) An infinite loop that processes input if any, updates the states of the objects and renders.
b) An infinite loop that keeps prompting the user for input
c) A loop that runs every clock cycle of the GPU
d) All of the above

4. With game engines:


a) You own the main game loop and call into the library
b) An engine owns the loop and calls into your code
c) You write a monolithic program without using libraries
d) None of the above

5. Declaring a variable "speed" public will allow:


a) Setting its value from the Unity editor
b) Directly changing its value from another script by writing speed = 10;
c) Declaring it as a global variable shared by all scripts
d) All of the above

6. To have an object A destroyed when it hits another object B, it is essential that:


a) Both must have RigidBody components
b) Both must have collider components
c) Both must have OnCollisionEnter methods in their scripts
d) Both must contain calls to the Destroy method
7. In a system that runs at 60 frames per second the time between each screen refresh is:
a) 33.3 ms
b) 16.6 ms
c) 22.2 ms
d) 40.5 ms

8. Which of the following is true about a camera?


a) It always provides a perspective projection of the scene on the screen
b) It has a position in space coordinates
c) It has a position in screen coordinates
d) None of the above

9. To move a player humanoid in a forward motion by distance X:


a) transfom.position = transform.position + X * transform.forward
b) transfom.position = transform.position + X * Vector3.forward
c) transform.position += X * Vector3.forward;
d) All of the above

10. To rotate an object 15 degrees round the x axis


a) transform.eulerAngles.x = 15
b) transform.rotation.x = 15
c) transform.eulerAngles = new Vector3(15, 0, 0);
d) transform.Rotate(15, 0, 0);

Page 2 of 6
Question 2 [35 pts]: Write the pseudocode of a script that does the following:

1. Create a cylinder and a cube. Position and scale as shown in the figure.

2. Implement a flip-the-bottle behavior:


i- When the user clicks on the cylinder, it elevates (moves upwards) for a predefined distance
ii- Then it starts flipping and moving downwards
iii- It lands on the platform and stops

Page 3 of 6
Page 4 of 6
Question 3 [35 pts]: Explain what the following code is doing. Draw a rough sketch of the scene after
this code runs.
void Start()
{
float radius = 10;
int n = 20;
float d_alpha = 360f / n;
float alpha = 0;
for (int i = 0; i < n; i++){
alpha += d_alpha;
Quaternion rotateAround = Quaternion.Euler(0, alpha, 0);
Vector3 disp = rotateAround * (Vector3.right * radius);
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.localScale = new Vector3(3, 1, 1);
cube.transform.Rotate(0, alpha, 0);
cube.transform.position = disp;
}
}

Page 5 of 6
Page 6 of 6

You might also like