失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 《游戏学习》java代码实现《愤怒的小鸟》实战源码

《游戏学习》java代码实现《愤怒的小鸟》实战源码

时间:2018-06-22 07:00:13

相关推荐

《游戏学习》java代码实现《愤怒的小鸟》实战源码

项目代码结构目录

部分代码展示

import javax.swing.ImageIcon;import org.jbox2d.collision.shapes.CircleShape;import mon.Vec2;import org.jbox2d.dynamics.Body;import org.jbox2d.dynamics.World;/**** @author tarzan*/public class AngryBirdsModel extends AngryBirdsCharacter{public ImageIcon birds1=new ImageIcon("src/AngryBirdsImagePack/birds.png");public ImageIcon birds2=new ImageIcon();public ImageIcon birds3=new ImageIcon();public AngryBirdsModel() {super();}public Body createBirds(World mom,int birdtype,Vec2 pos) {this.getCharacterdef().position.set(pos);this.getCharacterdef().linearDamping=0.01f;this.getCharacterfixdef().filter.groupIndex=-1;this.charactershape=new CircleShape();Body bird=mom.createBody(characterdef);switch(birdtype) {case 1:this.charactershape.m_radius=0.5f;this.getCharacterfixdef().shape= this.charactershape;this.getCharacterinfo().setName("Lil Bird");this.getCharacterinfo().setHafheight(0.5f);this.getCharacterinfo().setHafwidth(0.5f);this.getCharacterinfo().setAppearance(birds1.getImage());bird.m_userData=this.getCharacterinfo();bird.createFixture(characterfixdef);break;case 2:this.charactershape.m_radius=0.7f;this.getCharacterfixdef().shape= this.charactershape;this.getCharacterinfo().setName("Strong Bird");this.getCharacterinfo().setHafheight(0.7f);this.getCharacterinfo().setHafwidth(0.7f);this.getCharacterinfo().setAppearance(birds2.getImage());bird.m_userData=this.getCharacterinfo();bird.createFixture(characterfixdef);break; case 3:this.charactershape.m_radius=1f;this.getCharacterfixdef().shape= this.charactershape;this.getCharacterinfo().setName("Angry Bird");this.getCharacterinfo().setHafheight(1f);this.getCharacterinfo().setHafwidth(1f);this.getCharacterinfo().setAppearance(birds3.getImage());bird.m_userData=this.getCharacterinfo();bird.createFixture(characterfixdef);break;}return bird;}}

启动类AngryBirdsMain

import AngryBirdsLevel.BirdsLevel;/**** @author tarzan*/public class AngryBirdsMain {/*** Entrance of This Game.*/public static void main(String[] args){BirdsLevel ts=new BirdsLevel();AngryBirdsMenu menu=new AngryBirdsMenu();AngryBirdsPanel game=new AngryBirdsPanel();AngryBirdsViewFrame mainframe=new AngryBirdsViewFrame(menu,game);//MusicController music=new MusicController();AngryBirdsController tc=new AngryBirdsController(ts,game);AngryBirdsMenuController mc=new AngryBirdsMenuController(menu);AngryBirdsPanelController pc=new AngryBirdsPanelController(mainframe.getLayoutpanel(),mc,tc); ts.getWorld().setContactListener(tc);//music.start();Thread switcher=new Thread(pc);switcher.start();mainframe.setVisible(true);}}

游戏截图

项目源码下载地址

愤怒的小鸟java版小游戏源码_java愤怒的小鸟源码-网络游戏文档类资源-CSDN下载

如果觉得《《游戏学习》java代码实现《愤怒的小鸟》实战源码》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。