Computer Programmer - the RPG
Let's say that I have created a role-playing game in which people play computer programmers with different skills and abilities. I know! Brilliant idea! I am going to make a mint!
Let's say that each character could have the following characteristics:
Name | Dragos the Security Guru | |
---|---|---|
Typing | 5 | Random die roll from 1-6 |
Spelling and Grammar | 3 | Random die roll from 1-6 |
Modularizes Code | 6 | Random die roll from 1-6 |
Problem Solving | 2 | Random die roll from 1-6 |
Awesome with CSS | 2 | Random die roll from 1-6 |
Coding Style | 6 | Random die roll from 1-6 |
An example
When I put all of this together, I can get this:
Please enter a name for your character:
Your character:
Saving your work
Download the
template
and rename it: "3.05H-CharacterGenerator-LastName.html
".
The assignment
Use objects and functional programmming to ask the user for a character name, generate random characteristics, generate a simple character sheet, and then output the sheet.
Use whatever game system you want. Or create your own. Or make something that is a kind-hearted parody. Have fun with this.
Recommended procedure
- Read over Qualities of a Programmer again
- Plan your user interface first
- Plan your variables next paying special attention to your object variable
- Plan your separate functions input, process, and output functions. You should have a separate function for generating the character statistics and the character sheet.
- Decide on how the functions will work together in a function pipeline
-
Create your functions empty at first with only the
input parameters and return variables, like this:
function someKindOfFunction (inputVariable) {
console.log('in someKindOfFunction, inputVariable=' + inputVariable);
var outputVariable;
return outputVariable;
}
- Fill in the actual working code of the functions last of all, testing as you go.
Evaluation
-
___/10 INIT: including
- create an empty object
- use the value of an object's property to create different animation behaviours
- pass an object to a function as a parameter/argument
- use an object with multiple properties inside an animation
-
___/10 PROCESS: including
- create a function that accepts an object as an argument/parameter
-
set a delay using
setTimeout()
orsetInterval
-
use an anonymous function inside
setTimeout()
orsetInterval
- use string addition
- processes at least 5 characteristics
-
___/10 OUTPUT: including ANY FIVE of
- change the src of an element
- display information using .innerHTML
- animate using a custom duration
-
position an object using
%
instead ofpx
- animate a change in the width of an element
- animate a fade in or fade out of an element
-
___/10 STYLE: including
- honour all previous //STYLE sections
- use descriptive variable names
- break up functions into separate ones for input, processing, and output
-
uses descriptive comments to identify
and describe each function,
for example://PROCESS: this function accepts distanceUp and animates the image up that number of pixels
-
add spaces between mathematical operators,
for example:var exampleVar = 3 + 4
, notvar exampleVar=3+4
.