|
本帖最后由 董董soul 于 2018-11-7 16:31 编辑
| 类 | 描述 | 1 | ArrowPic | 一个可以设置颜色,大小的三角形形状。 | 2 | CirclePic | | 3 | PersonPic | 一个可以设置颜色,大小的俯视图。 See the players in the Simple Soccer simulation. | 4 | BitmapPic | 使用位图构建实体,用于创建动画。 | 5 | ObstaclePic | 用于构建障碍,类似圆形图片库,但本处则用于提供避障运算。 | 6 | UmbrellaPic | 一个可以设置颜色,大小的类似伞一样的物品,其实是阻碍。. In the Marketplace Patrol sketch it is used to render Obstacles that represent market stalls. | 7 | BuildingPic | 建筑 | 8 | WallPic | 墙 |
创建一个动画。 - 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.*;
- // 动画渲染_01
- World world;//定义一个游戏世界
- StopWatch sw;//定义一个时间码表
- Vehicle tank;//定义一个车辆
- Vector2D target = new Vector2D();//一个二维向量,double类型
- BitmapPic view;//位图
- public void setup() {
- size(600, 320);//大小
- world = new World(width, height);//初始化世界
- sw = new StopWatch();//初始化时间码表
- // 创建移动者
- tank = new Vehicle(new Vector2D(width/2, height/2), // 位置
- 40, // 碰撞半径
- new Vector2D(0, 0), // 速度
- 40, //最大速度
- new Vector2D(1, 0), // 朝向
- 15, // 质量
- 1.5f, // 转角
- 1000 //最大力
- );
- // 设置移动者外形,这里是位图动画
- view = new BitmapPic(this, "tanks.png", 8, 1, 0);
- view.showHints(Hints.HINT_COLLISION | Hints.HINT_HEADING | Hints.HINT_VELOCITY);
- tank.renderer(view);
- // 添加到 游戏世界中
- world.add(tank);
- sw.reset();
- }
- public void draw() {
- double elapsedTime = sw.getElapsedTime();
- target.set(mouseX, mouseY);
- tank.AP().arriveOn(target);
- float speed = (float) tank.speed();
- float maxSpeed = (float) tank.maxSpeed();
- if (speed > 1) {
- int newInterval = (int) map(speed, 0, maxSpeed, 600, 40);
- view.interval(newInterval);
- }
- else {
- view.interval(0);
- }
- world.update(elapsedTime);
- background(218, 140, 54);
- world.draw();
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|