Game Design Hw1

Variables:

1.

very simple, just create variable and Debug.Log them out:

2.

The tricky part is to insert the variables as string in the story text elegantly, without using too much + operator:

therefore I use the operator in the code:

IF statement:

I combined the 3 car speed control tasks together in one program

when pressing w the car accelarates, when pressing s it decelarates

when the speed is positive the state is moving

when the speed is negative the state is reverse

when the -0.001 < speed < 0.001 speed will become 0 and state = stop

speed limited to -100 ~ 100, reaching the boundary will cause the state to become overspeed

To enable keyboard input, I used the special function in unity GetAxis()

To have a reasonable update rate of data, I used Time.deltatime

Switch

  1. color

Very simple, not much to say.

2.  change weapon

I feel like it is easier to implemnt it usinf IF, because I googled that it is not quite easy to detect arbitary keyboard input and tell what is the key in unity.

Array

  1. change color

2. change color by tag

For loop

1.

I feel the most difficlut part is to put the camera at the right position so that it can see all the cubes

2.

function

I put the three tasks together:

press w to move

press space tgo change color

press s to measure distance

Leave a Reply