User Tools

Site Tools


resources_for_tetris

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources_for_tetris [2022/05/09 11:49] frchrisresources_for_tetris [2022/05/23 16:43] (current) frchris
Line 1: Line 1:
 **Tetris resources** **Tetris resources**
 +
  
 The basic falling item, with a Key Listener: The basic falling item, with a Key Listener:
-<code>+<code java>
 import java.awt.Color; import java.awt.Color;
 import java.awt.Font; import java.awt.Font;
Line 89: Line 90:
  
 } }
 +</code>
 +
 +You may wish to make a Shape class which has an ArrayList<Rectangle> which will have a draw method, an. 
 +
 +
 +<code>
 +
 +import java.awt.Color;
 +import java.awt.Graphics;
 +import java.awt.Rectangle;
 +import java.util.ArrayList;
 +public class Shape
 +{
 +     private int x,y, size;
 +     private ArrayList<Rectangle> boxes;
 +     private Color color;
 +     Shape(int x, int y, int[] xPoints, int[] yPoints)
 +     {
 +    this.x=x;
 +    this.y=y;
 +    int n = xPoints.length;
 +    color = Color.RED;
 +    boxes = new ArrayList<Rectangle>();
 +     }
 +     public void draw(Graphics g)
 +     {
 +   
 +    for (Rectangle r:boxes) {
 +    g.setColor(color);
 +    g.fillRect(r.x, r.y, r.width, r.height);
 +    g.setColor(Color.BLACK);
 +    g.drawRect(r.x, r.y, r.width, r.height);
 +     
 +    }
 +     
 +     
 +     }
 +}
 +
 </code> </code>
  
resources_for_tetris.1652111359.txt.gz · Last modified: 2022/05/09 11:49 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki