דילוג לתוכן
מבחן 10 שאלות

Game Programming Logic

שאלות 10

מפתח התשובות מוצג למורים מחוברים.

  1. רב־ברירהתוכנה

    Variables in a game score

    A game programmer writes code that stores the player's current score and increases it by 10 each time the player collects a coin. Which programming concept is being used to hold the changing score value?

    1. A conditional branch

    2. A loop counter only

    3. A constant that can never change

    4. A variable


    Think about a named storage location whose stored value can be updated while the program runs.
  2. רב־ברירהתוכנה

    Loop repeating game actions

    A game must move an enemy 5 steps to the left, one step per frame. Which control structure is most appropriate for repeating the movement step exactly 5 times?

    1. A switch statement with no cases

    2. A for loop

    3. A variable declaration

    4. An if statement


    Consider which structure is designed to repeat a block of code a known number of times.
  3. רב־ברירהתוכנה

    Conditional logic for player health

    In a game, the code should end the game when the player's health is less than or equal to zero, and otherwise continue playing. Which construct implements this decision?

    1. A variable named health

    2. A while loop with no condition

    3. A function call to draw the background

    4. An if-else statement


    Think about the structure that chooses between two different paths depending on whether a condition is true or false.
  4. רב־ברירהתוכנה

    Combining loops and conditions

    A game loop runs once per frame while the game is active. Inside it, the program checks whether a player has touched a power-up and, if so, sets a boolean variable named hasShield to true. What is the best description of the role of the game loop?

    1. It declares the data type of hasShield

    2. It repeatedly executes the game logic until the game ends

    3. It converts the boolean value into a string

    4. It runs only once and then the program exits


    Consider how a game keeps updating and checking state over and over during play.
  5. נכון / לא נכוןתוכנה

    Variables in Game State

    In game programming, a variable that stores the player's score must be reset to its original value each time the game restarts, otherwise the old score would carry over into the new game.

    1. True

    2. False


    Think about what should happen to a player's progress when a new game begins.
  6. נכון / לא נכוןתוכנה

    Loops and Conditions in Game Loops

    A typical game loop checks the game state on every frame, and a while loop that continues as long as the game is running is commonly used to implement this behaviour.

    1. True

    2. False


    Consider how a game keeps updating the screen repeatedly until the player quits.
  7. השלמהתוכנה

    Looping through a list of enemies

    A _____ loop checks every enemy in a list once.

    forwhileswitchrepeat

    Think of the loop type that is designed to run a fixed number of times, once for each item in a collection.
  8. השלמהתוכנה

    Boolean variables and conditional statements

    A _________ variable holds only true or false, and an _________ statement runs one block of code when it is true and another when it is false.

    stringbooleanintegerswitchwhileif-else

    The first blank names the data type that stores only two possible values; the second blank names the decision structure with two branches.
  9. שאלה פתוחהתוכנה

    Tracing a while loop that moves a sprite

    A game stores a sprite's travelled distance in the variable distance, starting at 0, and its speed in the variable speed, set to 12. The code runs this loop: while distance < 50: distance = distance + speed. After the loop finishes, what is the value of distance? Give only the number.


    Trace each pass of the loop by hand and write down the value of distance after every pass. Stop when the condition distance < 50 is no longer true.
  10. שאלה פתוחהתוכנה

    Why game state must be stored in variables and updated each frame

    Explain in two or three sentences why a game stores a player's position in a variable and updates that variable inside the game loop on every frame, instead of setting the position once at the start of the program.


    Think about what happens to a variable's value between frames, and what the game loop repeats on each frame.

פרטים

Covers variables, loops and conditions as used in building simple video game mechanics.
מקצועות
תוכנה
קהל יעד
תיכון · כיתות י׳–י״ב
רמת קושי
6 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
נוצר באמצעות AI
Claude Haiku 5.5
נוצר

תגובות

  1. אין תגובות עדיין.
© כל הזכויות שמורות