|
还是继续这个好玩的库吧。
[pre lang="processing" line="1"]import game2dai.entities.*;
import game2dai.entityshapes.ps.*;
import game2dai.maths.*;
import game2dai.*;
import game2dai.entityshapes.*;
import game2dai.fsm.*;
import game2dai.steering.*;
import game2dai.utils.*;
import game2dai.graph.*;
// GettingStarted_01.pde
World world; //定义了一个游戏世界
StopWatch sw;//顶一个了一个时间码表
MovingEntity mover0;//定义了一个移动引擎
public void setup() {
size(480, 320);//大小
world = new World(width, height);//世界大小
sw = new StopWatch();//初始化码表
// 创建移动者
mover0 = new MovingEntity(
new Vector2D(width/2, height/2), // 初始位置
15, //碰撞半径
new Vector2D(15, 15), // 速度
40, //最大速度
new Vector2D(1, 1), // 朝向
1, //质量
0.5, // 回转率
200 // 最大力
);
// 这个移动者的外形
ArrowPic view = new ArrowPic(this);
// 显示碰撞和运动效果
view.showHints(Hints.HINT_COLLISION | Hints.HINT_HEADING | Hints.HINT_VELOCITY);
// 为我们的移动引擎添加渲染
mover0.renderer(view);
// 约束区
Domain d = new Domain(60, 60, width-60, height-60);
mover0.worldDomain(d, SBF.REBOUND);
//添加到游戏世界中
world.add(mover0);
sw.reset();
}
public void draw() {
double elapsedTime = sw.getElapsedTime();
world.update(elapsedTime);
background(200, 255, 200);
// 约束区可见
Domain d = mover0.worldDomain();
fill(255, 200, 200);
noStroke();
rect((float)d.lowX, (float)d.lowY, (float)d.width, (float)d.height);
world.draw();
}[/code]
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|