Programming games: Preparation guide for mid-term



Programming games: Preparation guide for mid-term

1. Re-read lecture notes (HTML/JavaScript).

2. Define the programming concepts: variable, function, and array. Describe uses in the class projects.

3. Describe the use of the different bracketing symbols in HTML/JavaScript: ( and ), { and }, [ and ], and < and >.

4. Define the programming terms: event and event handling. Describe examples in the class projects.

5. What is the representation in binary of the (decimal) numbers: 5, 55, 164, 2011? What is the representation in decimal of the binary numbers: 1010, 1111110?

6. What is the representation in hexadecimal of the (decimal) numbers: 5, 55, 164, 255, 1011? Describe using colors what would be the color of #CC0022, #00FFCF.

7. Given that the ASCII representation for A is 01000001 and B is 01000010, then write how the string ABAA would appear in memory.

8. Write the JavaScript function for the simple calculation for a credit card of the new balance for the next month based on inputs: currentBalance, newPurchases, annualInterest, payment. Now add in a minimum payment requirement using parameters minPayment, fee.

9. Describe using a JavaScript expression and in words what is meant by compound interest.

10. Write the HTML and JavaScript for a coin toss in which the coin is biased towards heads 60% of the time.

11. Write the HTML for an image tag named "pet" holding an image file named "cat.jpg". Write a javascript function that will make the image in that image tag be "dog.jpg".

12. Write the code to make a call to the function move() every 200 milliseconds. (Hint: this is a single line.) How many times/second is this? What would the number be for once every 3 seconds?

13. Write the HTML5 JavaScript for drawing a blue rectangle outline 100 pixels wide, 40 pixels tall, at the left side of the canvas, in the middle vertically (canvas is 600 by 400 pixels). Assume the variable ctx holds the context.

14. Describe the effect of putting a var statement (for example, var total; ) inside a function definition versus outside a function definition.

15. Write a JavaScript switch statement that will display alert boxes with the number of days in the month based on the value of a variable mon holding a name for a month. This requires calling the alert function with an appropriate string. Assume it is not a leap year. Think “30 days has September, …”

16. Write a function that draws an image held in an Image variable flower on the canvas at the position x and y.

17. Write the code that will compare variables income and expenses. If income is greater than expenses, set the variable mood to be "happy"; otherwise set it to be "miserable".

18. Write the code for a form that has a submit button with label "Enter", and 2 input fields of type text. Put text before each of the text fields indicating First Name and Last Name. Make the action on hitting the submit button to be "return enternames();"

19. Describe three ways to specify color for fill and stroke and give the commands.

20. Describe the use of a single = sign versus two equal signs: ==.

21. What do each of these operators do: +, -,*, /, %, the combination of ? and :, &&, ||,==,!=.

22. Write the JavaScript for a for-loop that adds up the values in an array named grades.

23. Write the code in HTML5 JavaScript to draw a smiley face on top of a stick figure (you can use rectangles for the body, 2 arms and 2 legs).

24. Describe the new semantic elements in HTML5? What are the advantages?

25. Write the code to set up a call to the function named toss when the player clicks the mouse on the canvas. Assume the canvas has been defined in the body with id=”canvas” and the variable canvas1 has been set:

canvas1 = document.getElementById(“canvas”);

Hint: this is one line (one statement).

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches