3D Game Programming

(C. Jardin) #1
Let’s start by breaking simple things that the ICE Code Editor can tell us
about.

2.3 Debugging in ICE: The Red X


A red X next to your code means ICE sees a problem that will stop your code
from running. Let’s write some really bad JavaScript to demonstrate this.
Enter the following line below START CODING ON THE NEXT LINE.

bad()javascript

That’s some bad JavaScript!


Are you wondering why? It’s bad because you should never have a word come
after the parentheses. If you write code like this, ICE will show a red X next
to the line with the problem to indicate that line has to be fixed. Moving the
mouse pointer over the red X will display the actual error message, such as
“missing ; before statement.”

ICE won’t tell you that you put words after the parentheses. All it knows is
that parentheses should be at the end of the line, and here that wasn’t the
case. When it detected the line wasn’t finished, it triggered an error to warn,
“Hey! You forgot the semicolon at the end of the line!” It’s up to us to figure
out where the line should end.

Some things to check in your code when you see a red X:



  • Did you forget a semicolon?

  • If you don’t see a problem on the red X line, look at the previous line, as
    well. ICE can’t always tell where the problem begins and may be off by
    one or two lines.


2.4 Debugging in ICE: The Yellow Triangle


Unlike a red X, a yellow triangle showing up to the left of your code is not a
show-stopper. Your code will probably run even if lines in your code are
marked with yellow triangles, but it may not run correctly. It is best to get rid
of those triangles as they come up.

report erratum • discuss

Debugging in ICE: The Red X • 19


Prepared exclusively for Michael Powell

Free download pdf