Download Flappy Bird for android| flappy bird online game apk files| flappy bird download know Keywords:: flappy bird game. Game flappy bird cho java. Jul 26, 2014 - This course will cover everything from basic Java to Android game development. James Cho, lead developer at Kilobolt Studios. Learn how to make your own Flappy Bird clone using a powerful game development.
PermalinkJoin GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Download Game Flappy Bird Cho Java Free
0 contributors
Zing Me
/* |
* To change this template, choose Tools | Templates |
* and open the template in the editor. |
*/ |
packageflappybird; |
importjava.awt.Image; |
importjava.awt.Rectangle; |
importjava.awt.event.ActionEvent; |
importjava.awt.event.ActionListener; |
importjava.awt.event.KeyEvent; |
importjava.awt.event.KeyListener; |
importjava.io.File; |
importjava.io.IOException; |
importjava.util.ArrayList; |
importjavax.imageio.ImageIO; |
importjavax.swing.JFrame; |
importjavax.swing.JOptionPane; |
importjavax.swing.JPanel; |
importjavax.swing.Timer; |
/** |
* |
* @author User |
*/ |
publicclassFlappyBirdimplementsActionListener, KeyListener { |
publicstaticfinalintFPS=60, WIDTH=640, HEIGHT=480; |
privateBird bird; |
privateJFrame frame; |
privateJPanel panel; |
privateArrayList<Rectangle> rects; |
privateint time, scroll; |
privateTimer t; |
privateboolean paused; |
publicvoidgo() { |
frame =newJFrame('Flappy Bird'); |
bird =newBird(); |
rects =newArrayList<Rectangle>(); |
panel =newGamePanel(this, bird, rects); |
frame.add(panel); |
frame.setSize(WIDTH, HEIGHT); |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
frame.setVisible(true); |
frame.addKeyListener(this); |
paused =true; |
t =newTimer(1000/FPS, this); |
t.start(); |
} |
publicstaticvoidmain(String[] args) { |
newFlappyBird().go(); |
} |
@Override |
publicvoidactionPerformed(ActionEvente) { |
panel.repaint(); |
if(!paused) { |
bird.physics(); |
if(scroll %900) { |
Rectangle r =newRectangle(WIDTH, 0, GamePanel.PIPE_W, (int) ((Math.random()*HEIGHT)/5f+ (0.2f)*HEIGHT)); |
int h2 = (int) ((Math.random()*HEIGHT)/5f+ (0.2f)*HEIGHT); |
Rectangle r2 =newRectangle(WIDTH, HEIGHT- h2, GamePanel.PIPE_W, h2); |
rects.add(r); |
rects.add(r2); |
} |
ArrayList<Rectangle> toRemove =newArrayList<Rectangle>(); |
boolean game =true; |
for(Rectangle r : rects) { |
r.x-=3; |
if(r.x + r.width <=0) { |
toRemove.add(r); |
} |
if(r.contains(bird.x, bird.y)) { |
JOptionPane.showMessageDialog(frame, 'You lose!n'+'Your score was: '+time+'.'); |
game =false; |
} |
} |
rects.removeAll(toRemove); |
time++; |
scroll++; |
if(bird.y >HEIGHT|| bird.y+bird.RAD<0) { |
game =false; |
} |
if(!game) { |
rects.clear(); |
bird.reset(); |
time =0; |
scroll =0; |
paused =true; |
} |
} |
else { |
} |
} |
publicintgetScore() { |
return time; |
} |
publicvoidkeyPressed(KeyEvente) { |
if(e.getKeyCode()KeyEvent.VK_UP) { |
bird.jump(); |
} |
elseif(e.getKeyCode()KeyEvent.VK_SPACE) { |
paused =false; |
} |
} |
publicvoidkeyReleased(KeyEvente) { |
} |
publicvoidkeyTyped(KeyEvente) { |
} |
publicbooleanpaused() { |
return paused; |
} |
} |
Flappy Bird App Download
Copy lines Copy permalink