Game Programming Test 1

How much do you know about Game Programming with lite-C? Take the test to find out! Hint: Have a good look at the code snippets. Sometimes the code doesn't do what it seems to do!

Your name: (for certificate & high score)

1. Which of the following variable definition lines produces a syntax error?

1 var _9_lives, _7_lives = 7;
2 var nine_lives = 9, seven_lives = 7;
3 var NineLives = 0
4 var NINELIVES;


2. Which value is the variable x set to in the following program?


function foo(a,b)
{
   return (a + b);
}

void main()
{
   var x = foo(3,foo(1,2));
}


1 0
2 3
3 6
4 Nothing - the script has a syntax error.


3. What happens in the following program? beep(); is an engine function that plays a sound.


function foo()
{
   beep();
   return(1);
}

void main()
{
   on_a = foo();
}

1 When I press [A], the program will play a sound and exit.
2 Whenever I press [A], the program will play a sound.
3 The program will play a sound at start and will crash when I press [A].
4 The program will play a sound and then exit.


4. What must be written in the script for displaying the image "image.tga" on the screen, without additional code?

1 BMAP* image = "image.tga";
2 PANEL* p = { bmap = "image.tga"; flags = SHOW; }
3 BMAP* image; PANEL* p = { bmap = image; flags = SHOW; }
4 BMAP* image = "image.tga"; PANEL* p = { bmap = image; }


5. A panel button does not react on a mouse click. What can be the reason?

1 The button is not completely inside the panel area .
2 The panel overlaps another panel with the same layer.
3 The button has no assigned function.
4 All of the above.
5 None of the above.


6. The simple action below freezes the computer. Why is this happening?


action rotate_entity()
{
  while (1)
  {
    my.pan += 3 * sin(time_step);
  }
  wait (1);
}

1 You can’t use sin(time_step) inside a loop.
2 You have not assigned the action to an entity.
3 The action isn't freezing the computer.
4 None of the above.


7. You've changed the value of a variable in your script, but it shows still the old value when running the program. What could be the reason?

1 You were editing another version of the file, which is placed in another folder.
2 The value of the variable is set somewhere else in your code as well.
3 Your script loads a game state that was saved before you changed the value.
4 All of the above.
5 None of the above.


8. A panel with pos_x = 100 and pos_y = 200 has a button definition that starts with (50, 30, ... . What is the button distance from the upper left corner of the engine window?

1 150, 230.
2 50, 30.
3 300, 80.
4 100, 200.


9. The OVERLAY flag used for panels:

1 Is the only way to make parts of the panel image transparent.
2 Sets the transparency factor of the panel image.
3 Also affects button images on the panel.
4 Makes the panel appear on top of all the other panels.


10. The digits element can display:

1 Global variable values.
2 Text.
3 Images from a bitmap.
4 All of the above.


11. If you want to move an entity upwards:

1 Increase its z coordinate.
2 Move it in the direction of its tilt angle.
3 You must use the c_move instruction.
4 You must reset its angles and then increase its z coordinate.


12. The statement: level_load(NULL);

1 - loads a level named "NULL".
2 - allows us to call ent_create without creating a level.
3 - loads a level that doesn't exist yet and must be created later.
4 - produces a syntax error.


13. Billboards are sprites that stand upright and face the camera all the time. We create them this way:

1 We just place them in the level with all angles at 0.
2 We give them a small roll angle (such as 0.1).
3 We give them a pan and tilt angle that faces the camera.
4 Only Gamestudio Pro can create billboards.


14. An entity in our level can be controlled:

1 With an action assigned to it.
2 With a pointer.
3 With a function from another entity.
4 All of the above.


15. When the following function is called, does it produce a beep?


function compare_values( )
{
  var a = 1.99;
  var b = 2;
  if (a = b)
    beep( );
}

1 Yes - the var precision is limited, so for the computer 1.99 is the same as 2.
2 No - a and b are different.
3 Yes - the if (..) condition is true.
4 No - the if (..) condition is false.


16. A piece of code that checks if the player is alive and has got enough bullets could look like this:

1 if ((health > 0) && (ammo > 0)) ...
2 if ((health > 0) || (ammo > 0)) ...
3 if ((health > 0) & (ammo > 0)) ...
4 if ((health > 0) | (ammo > 0)) ...


17. A camera that looks downwards (a bird’s eye view) must use:

1 A positive pan angle.
2 A negative tilt angle.
3 A positive tilt angle.
4 The ISOMETRIC flag.


18. The statement: c_move (me,nullvector,vector(5*time_step,0,0),GLIDE);

1 Moves the entity forward.
2 Moves the entity along the x axis.
3 Lets the entity glide along the floor.
4 Adds 5*time_step to the current speed of the entity.


19. The following action:


action animate_guard( )
{
  var percentage = 0;
  while(1)
  {
    ent_animate(me,"stand",percentage,0);
    wait(1);
  }
}

1 Animates the guard in a loop.
2 Plays a one-shot animation.
3 Has a syntax error.
4 Doesn't do anything.


20. Unlike a local variable, a global variable can:

1 Be changed by pressing [Tab].
2 Be observed with the debugger.
3 Be used by all functions of the script.
4 All of the above.