Game Dev Review (No Vocab)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/42

flashcard set

Earn XP

Description and Tags

Saving Future Husband Part 2

43 Terms

1
New cards
<p>When does a Compile error happen?</p>

When does a Compile error happen?

Before the program runs

2
New cards
<p>When does a Runtime error happen?</p>

When does a Runtime error happen?

While the program runs

3
New cards
<p>When does a Warning happen?</p>

When does a Warning happen?

At compile time, but it still builds

4
New cards
<p>What does int code hold?</p>

What does int code hold?

Whole numbers

5
New cards
<p>What does float code hold?</p>

What does float code hold?

Decimals (Unity's default)

Note: The f matters. 5.5 is a double. float speed = 5.5; won't compile — write 5.5f

6
New cards
<p>What does double code hold?</p>

What does double code hold?

Decimals, more precise (C#'s default)

7
New cards
<p>What does bool code hold?</p>

What does bool code hold?

True or false

8
New cards
<p>What does char code hold?</p>

What does char code hold?

One character, single quotes

9
New cards
<p>What does string code hold?</p>

What does string code hold?

Text, double quotes

10
New cards

What's the difference between a compile error and a runtime error?

A compile error stops the program from building; a runtime error happens while it runs.

11
New cards

Why won't float speed = 2.5; compile?

2.5 is a double; a float literal needs 2.5f.

12
New cards

What does 17 % 5 evaluate to?

2.

13
New cards

int total = 10; int count = 4; float avg = total / count; — what is avg, and how do you fix it?

2.0, because 10 / 4 is integer division. Fix: float avg = (float)total / count; → 2.5

14
New cards
<p>What is this an example of?</p>

What is this an example of?

if / else if / else — checked top to bottom. The first true condition wins, and the rest are skipped.

Note: Order matters. If you checked health < 25 first, a player with 0 health would print "Critical" — that condition is also true, and it came first.

15
New cards
<p>What is this an example of?</p>

What is this an example of?

Combining Conditions.

16
New cards
<p>What is this an example of?</p>

What is this an example of?

Switch — choose one path from many possible values of one variable:

Note: Each case ends with break. default runs when nothing else matches. (break inside a switch is the one place course standards allow it.)

17
New cards

In an if / else if / else chain, how many blocks can run?

Exactly one.

18
New cards

What's wrong with checking score > 50 before score > 90 when assigning grades?

A score of 95 matches > 50 first and never reaches the > 90 check.

19
New cards
<p>What is this an example of?</p>

What is this an example of?

for — when you know how many times

Note: Three parts: start (int i = 0) · keep going while (i < 5) · after each trip (i++)

20
New cards
<p>What is this an example of?</p>

What is this an example of?

while — when you don't know how many times. It repeats as long as its condition is true.

21
New cards
<p>What is this an example of?</p>

What is this an example of?

do-while — runs at least once, then checks.

22
New cards
<p>What is this an example of?</p>

What is this an example of?

Infinite loops. If the condition never becomes false, the loop never ends — and in Unity, the editor freezes

Note: Every while loop needs something inside it that moves it toward stopping.

Off-by-one errors. i <= 5 runs six times (0 through 5). i < 5 runs five. Be deliberate.

23
New cards

How many times does for (int i = 2; i < 8; i++) run?

6 — for i = 2, 3, 4, 5, 6, 7.

24
New cards

When would you choose while over for?

When you don't know in advance how many times it needs to run.

25
New cards
<p>What is this an example of?</p>

What is this an example of?

An array holds a fixed number of values of one type.

26
New cards
<p>What is this an example of?</p>

What is this an example of?

Index from 0. The last index is always Length - 1.

Note: Out of range is a runtime error: scores[5] → IndexOutOfRangeException. There is no index 5 in an array of length 5.

27
New cards
<p>What is this an example of?</p>

What is this an example of?

Default values: int/float elements start at 0, bool at false, and string or object elements at null — an empty slot.

28
New cards
<p>What is this an example of?</p>

What is this an example of?

Arrays are reference types. The variable holds an arrow to the array.

29
New cards

An array has Length 8. What are its first and last indexes?

0 and 7.

30
New cards

What does new string[4] contain right after it's created?

Four nulls — slots exist, but nothing is in them.

31
New cards
<p>What is this an example of?</p>

What is this an example of?

The template: A traversal visits every element of an array, usually in order. Almost every array task is a traversal plus one small job done at each element.

Note: Use i < Length, never i <= Length. The second one reaches an index that doesn't exist.

32
New cards
<p>What is this an example of?</p>

What is this an example of?

Traversals, Pattern 1 — Visit every element

33
New cards

What is this an example of?

34
New cards

What is this an example of?

35
New cards

What is this an example of?

36
New cards
37
New cards
38
New cards
39
New cards
40
New cards
41
New cards
42
New cards
43
New cards