import javax.swing.plaf.ColorUIResource;
import java.util.ArrayList;
public class flappyBird implements ActionListener, MouseListener, KeyListener {
public static flappyBird flappyBird;
public final int width = 1200 ; //width of display 1200
public final int height = 800; //height of display
public Renderer renderer;
public Rectangle bird; //creates the bird
public ArrayList<Rectangle> columns; //creates the columns
JFrame jframe = new JFrame(); //creates a instance of new window
Timer timer = new Timer(20, this); //creates a timer for game 20
renderer = new Renderer();
bird = new Rectangle(width/2 - 10, height/2 - 10, 20, 20);
columns = new ArrayList<Rectangle>();
jframe.setTitle("flappy bird only way worse");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //closes whem x is clicked
jframe.setSize(width, height);
jframe.addMouseListener(this);
jframe.addKeyListener(this);
jframe.setResizable(false);
public static void main(String[] args) {
flappyBird = new flappyBird();
public void addColumn(boolean start){
int colHeight = 50+rand.nextInt(300);
//randomly generate columns
columns.add(new Rectangle(width + colWidth+ columns.size() * 300, height - colHeight-150, colWidth, colHeight));
columns.add(new Rectangle(width + colWidth + (columns.size()-1) * 300, 0, colWidth, height - colHeight-space));
columns.add(new Rectangle(columns.get(columns.size()-1).x + 600, height - colHeight-150, colWidth, colHeight));
columns.add(new Rectangle(columns.get(columns.size()-1).x, 0, colWidth, height - colHeight-space));
public void paintColumn(Graphics g, Rectangle column){
g.fillRect(column.x,column.y, column.width, column.height);
//and yes the bird is a rectangle
//chill out I'm a high school student creating this in their free time, not pixar
bird = new Rectangle(width/2 - 10, height/2 - 10, 20, 20);
public void repaint(Graphics g) {
//System.out.println("test");
g.setColor(ColorUIResource.blue); //background
g.fillRect(0, 0, width, height);
g.setColor(Color.yellow); //bird
g.fillRect(bird.x, bird.y, bird.width, bird.height);
g.setColor(Color.gray); //ground
g.fillRect(0, height-150, width,150 );
g.setColor(Color.green); //grass
g.fillRect(0, height-150, width,20 );
for (Rectangle column: columns){
g.setFont(new Font("Comic Sans", 1, 100));
g.drawString("Click to play!", 200, height/2 - 50);
g.drawString("Game Over!", 250, height/2 - 50);
if(!gameOver && started){
g.drawString(String.valueOf(score), width/2 -25, 100);
public void actionPerformed(ActionEvent e) {
//AH SHIT I FORGOT TO SUBMIT STUFF FOR TODAY
//it iterates through columns i dunno standard for loop stuff
//i should add a regular expression
//never mind, I forgot that I'm stupid
//Im also too stupid for that
//It could be worse, at least it's not a while loop
for(int i= 0; i < columns.size(); i++){
Rectangle column = columns.get(i);
//maybe later I'll make it better
if(ticks % 2 == 0 && yMotion < 15){
for(int i= 0; i < columns.size(); i++){
Rectangle column = columns.get(i);
if(column.x + column.width < 0){
for(Rectangle column: columns){
if(column.y == 0 &&bird.x + bird.width / 2 > column.x + column.width/2 - 10 && bird.x + bird.width/2 < column.x + column.width/2 + 10){
if(column.intersects(bird)){
bird.x = column.x - bird.width;
bird.y = column.y - bird.height;
}else if (bird.y < column.height){
if(bird.y > height - 150 || bird.y < 0){
if(bird.y + yMotion >= height - 150){
bird.y = height - 150 - bird.height;
public void mouseClicked(MouseEvent e) {
public void mousePressed(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
public void mouseEntered(MouseEvent e) {
public void mouseExited(MouseEvent e) {
public void keyTyped(KeyEvent e) {
public void keyPressed(KeyEvent e) {
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_SPACE){
import javax.swing.*;
import java.awt.*;
public class Renderer extends JPanel {
protected void paintComponent(Graphics g){
super.paintComponent(g);
flappyBird.flappyBird.repaint(g);
}
}