极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 17854|回复: 1

Processing之旅-----【好玩的库之AI_for_2D_Games—3】

[复制链接]
发表于 2013-10-14 09:25:55 | 显示全部楼层 |阅读模式
本帖最后由 董董soul 于 2018-11-7 16:31 编辑

描述
1
ArrowPic
一个可以设置颜色,大小的三角形形状。
2
CirclePic
一个可以设置颜色,大小的圆形形状。. An example is the football inSimple Soccer.
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

创建一个动画。
  1. import game2dai.entities.*;
  2. import game2dai.entityshapes.ps.*;
  3. import game2dai.maths.*;
  4. import game2dai.*;
  5. import game2dai.entityshapes.*;
  6. import game2dai.fsm.*;
  7. import game2dai.steering.*;
  8. import game2dai.utils.*;
  9. import game2dai.graph.*;
  10. // 动画渲染_01
  11. World world;//定义一个游戏世界
  12. StopWatch sw;//定义一个时间码表
  13. Vehicle tank;//定义一个车辆
  14. Vector2D target = new Vector2D();//一个二维向量,double类型
  15. BitmapPic view;//位图

  16. public void setup() {
  17.   size(600, 320);//大小
  18.   world = new World(width, height);//初始化世界
  19.   sw = new StopWatch();//初始化时间码表
  20.   // 创建移动者
  21.   tank = new Vehicle(new Vector2D(width/2, height/2), // 位置
  22.     40,                 // 碰撞半径
  23.     new Vector2D(0, 0), // 速度
  24.     40,                 //最大速度
  25.     new Vector2D(1, 0), // 朝向
  26.     15,                 // 质量
  27.     1.5f,               // 转角
  28.     1000                //最大力
  29.   );
  30.   // 设置移动者外形,这里是位图动画
  31.   view = new BitmapPic(this, "tanks.png", 8, 1, 0);   
  32.   view.showHints(Hints.HINT_COLLISION | Hints.HINT_HEADING | Hints.HINT_VELOCITY);
  33.   tank.renderer(view);
  34.   // 添加到 游戏世界中
  35.   world.add(tank);
  36.   sw.reset();
  37. }

  38. public void draw() {
  39.   double elapsedTime = sw.getElapsedTime();
  40.   target.set(mouseX, mouseY);
  41.   tank.AP().arriveOn(target);
  42.   float speed = (float) tank.speed();
  43.   float maxSpeed = (float) tank.maxSpeed();
  44.   if (speed > 1) {
  45.     int newInterval = (int) map(speed, 0, maxSpeed, 600, 40);
  46.     view.interval(newInterval);
  47.   }
  48.   else {
  49.     view.interval(0);
  50.   }
  51.   world.update(elapsedTime);
  52.   background(218, 140, 54);
  53.   world.draw();
  54. }
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2016-4-8 19:33:46 | 显示全部楼层
你好,请问我在进行测试的时候,出现
d.pde:31:0:31:0: The constructor BitmapPic(d, String, int, int, int) is undefined报错,请问要如何解决(图片资源已添加。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-19 19:44 , Processed in 0.043741 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表