Lecture 5 - Collisions and C

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

What is the purpose of function prototypes in C?

Function prototypes inform the compiler about a function's name, return type, and parameters before its actual definition is encountered.

2
New cards

What is the significant outcome of collision detection in 1D?

A collision occurs when the right side of one square is greater than the left side of another and vice versa.

3
New cards

How do you detect a collision in both X and Y directions?

A collision is detected when both (x1 + s1 > x2 && x2 + s2 > x1) and (y1 + s1 > y2 && y2 + s2 > y1) are true simultaneously.

4
New cards

What are the two types of files in C and their purpose?

Source files (.c) contain the actual code, while header files (.h) contain declarations and include statements.

5
New cards

What does the 'extern' keyword do in C?

The 'extern' keyword allows the declaration of a global variable without initializing it, letting the linker find the variable's definition in another file.

6
New cards

What does a static variable in C signify?

A static variable retains its value between function calls and exists for the duration of the program.

7
New cards

What is a preprocessor macro in C?

A preprocessor macro is a fragment of code defined with '#define' that gets replaced by the preprocessor before compilation.

8
New cards

What is the difference between interpreted and compiled languages?

Interpreted languages execute code at runtime via an interpreter, while compiled languages generate machine-specific executable code before runtime.

9
New cards

What are global variables in terms of scope?

Global variables are visible everywhere within a program, except for static variables which limit visibility to the file they're defined in.

10
New cards

What happens to function and block-level variables without the static keyword?

They are allocated space on the call stack and their initial value is indeterminate (whatever was there previously in memory).