java programming session 2. objectives to design a range of different blocks to create the code for...
TRANSCRIPT
Java Programming
Session 2
Objectives
• To design a range of different ‘blocks’
• To create the code for these blocks
• To test that each block rotates correctly
• To alter the code to select random blocks
Block Rotation 1
piece_Toppiece_Leftpiece_Bottompiece_Right
Block Rotation 2
piece_Toppiece_Leftpiece_Bottompiece_Right
Block Coding
piece_Top { BLUE , BLUE , NONE }, { BLUE , NONE , NONE }, { BLUE , NONE , NONE }
piece_Left { BLUE , BLUE , BLUE }, { NONE , NONE , BLUE }, { NONE , NONE , NONE }
piece_Bottom { NONE , NONE , BLUE }, { NONE , NONE , BLUE }, { NONE , BLUE , BLUE }
piece_Right { NONE , NONE , NONE }, { BLUE , NONE , NONE }, { BLUE , BLUE , BLUE }
Fitting Blocks Together
Remember that the shapes you make must fit together without leaving gaps
Some shapes are more difficult to fit together than others
Don’t make a shape that will be impossible for the person playing the game
Tasks:
• Design a piece
• Modify the code
• Test the piece rotates well
• Keep doing this until you have lots of good pieces.
• Switch to random piece generation and try it out.