项目代码结构目录
部分代码展示
import javax.swing.ImageIcon;
import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2dmon.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代码实现《愤怒的小鸟》实战源码
发布评论