Why am I getting 'not defined' in my console?

Hey guys I’m making a tetris game and right now I wanna test a fuction that checks to see if the piece has collided with the wall. Except it says my collision function is not defined?

That would be this section of code:

//create an array to hold all of the tetrominos
const pieces = [
	[Z, 'red'],
	[S, 'limegreen'],
	[T, 'yellow'],
	[O, 'blue'],
	[L, '#b938ff'],
	[I, 'cyan'],
	[J, 'orange']
]

The console is right, for Z, S, T, and so forth aren’t defined anywhere.

The tetriminos.js file from the Tetris-JavaScript project provides definitions for those variables.

My bad I actually have them defined in the tetromino.js file I just don’t have it on the fiddle, since I can onlyu put one js file there. I forgot this would create a problem rendering the actual tetromino pieces to the board. Here, I moved the all the tetromino arrays to the tetris.js file so you can now see the main issue I’m having https://jsfiddle.net/6nsjktgm/1/

Compare your code with the code in the GitHub repo, and you’ll easily find the reason why.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.