Question
The seven tetrominos: they can be also named by the letter they resemble. The figure shows I (light blue), J (dark blue), O (yellow), L
The seven tetrominos: they can be also named by the letter they resemble. The figure shows I (light blue), J (dark blue), O (yellow), L (orange), T (purple), S (green), Z (red). Your Java program should randomly choose a tetromino shape, a random color for this shape, and a random location within the frame, and displays it on the screen. Then, the program can terminate after a while or wait until the user closes the window.
Create a TetrisViewer class Create a TetrisComponent (should include a method paintComponent and a method setTetromino(/* shape, color */). In the TetrisViewer class, randomly choose a tetromino and its color (use java.util.Random). Set this information in the TetrisComponent. Hint: You will use RGB color system, so you can create three random integers between 0-255 to create a random color. Display the frame and component (in a random location (random x and y coordinate point)). ** You will be displaying one random tetromino only (do not bother to create more objects in one run) ** We are not developing the whole game, so you should not worry about creating multiple different objects and fitting them on the screen... or other specifications of the Tetris game. Our goal is to create one random object only. **Hint: You will use the Rectangle component and locate for square together to create different tetrominos.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started