INQ241B
Mobile Apps

Review 2

A Miniature Practice Test

  1. What is a sprite?

  2. Draw what the following script will look like when it first starts.

    function main()
      var board := game→start
      var sprite 1 := create rectangle(100, 100)
      sprite 1→set pos(0, board→height / 2)
      var sprite2 := create rectangle(100, 100)
      sprite 2→set pos(board→width, board→height / 2)
      board→on every frame do
          sprite 1→set x(sprite 1→x + 10)
          if sprite 1→overlaps with(sprite 2) then
            sprite 1→set x(0)
          else do nothing end if
      end
    end function
  3. Describe how the sprites in the above script will behave when run.

  4. Create a script that uses a sprite set to add 100 rectangles to random locations on the screen. The rectangles should be animated like they are falling. That is each rectangle’s y speed should increase every frame of animation.