Code Monkey home page Code Monkey logo

egret-framework's Introduction

Cegret-framework

Language grade: JavaScript

这是一套用于egret的游戏框架,里面包含ECS框架用于管理场景实体,一些常用2D碰撞检测及A*寻路。如果您还需要包含其他的AI系统可以查看作者其他库(行为树、简易FSM、实用AI)。

在线框架演示

非完整游戏演示

入门教程

Getting Start

打开白鹭工程 替换 Main.ts 文件内容

class Main extends es.Core {
    /** 
     * 由监听事件 egret.Event.ADDED_TO_STAGE后触发的事件
     */
    protected initialize() {
        // 初始化游戏逻辑
    }
    
    /**
    * 由监听事件 egret.Event.ENTER_FRAME后触发的事件
    */
    protected async update(){
        // 如果需要更新方法 不能删除super.update()
        // 会导致框架内所有组件及实体无法更新
        super.update();
        
        // 更新逻辑
    }
    
    /**
    * 在update方法执行完毕后执行 draw方法
    */
    public async draw(){
        // 如果需要绘制方法 不能删除super.draw()
        // 会导致框架内所有渲染组件位置无法更新
        super.draw();
        
        // 绘制逻辑
    }
}

版本计划功能

  • 简易ECS框架
    • 组件列表
      • 碰撞组件
      • 移动组件
      • 滚动精灵组件
      • 平铺精灵组件
      • 序列帧动画组件
      • 相机震动组件
      • 相机组件
      • 组件池
      • 基础碰撞组件(矩形、圆形、多边形碰撞)
      • 场景组件
    • 系统列表
      • 被动系统
      • 协调系统
      • 实体系统
      • 实体解析系统
  • 扩展库
    • object扩展
    • string扩展
    • texture扩展
    • time扩展
    • array扩展(Extension)
    • base64扩展
    • Stopwatch计数器
    • Input输入帮助
    • Keyboard键盘帮助
    • List池对象
    • Lock锁帮助
    • Emitter事件发射器
    • Random随机类帮助
    • Rectangle矩形帮助类
    • Vector2向量帮助类
    • Content资源管理器
    • 全局管理器
    • 向量集Bitset
  • 图形帮助
    • 场景过渡
    • 后处理器
    • 场景渲染器
    • 特效组
  • A*寻路(AStar)
  • 常用碰撞检测
  • 数学库
    • 矩形类(Rectangle)
    • 简易2D矩阵类(Matrix2D)
    • 简易2d 向量类(Vector2)
    • 数学扩展库(MathHelper)
    • 掩码实用类(Flags)
    • 贝塞尔曲线(Bezier)
  • 物理系统(简易)
    • Collision碰撞检测
    • ColliderTrigger帮助
    • Ray2D射线检测
    • ShapeCollision 多种形状检测
    • RealtimeCollisions 实时碰撞检测
    • SpatialHash 网格检测
  • BreadthFirst 寻路算法
  • Dijkstra 寻路算法
  • 事件处理器

关于egret用ecs框架(typescript/javascript)

ecs 是功能强大的实体组件系统。typescript与其他语言不同,因此我对ecs的设计尽可能的支持typescript特性。虽然ecs拥有标准实体组件系统,但在细节上有很大不同。创建标准ecs通常处于原始速度、缓存位置和其他性能原因。使用typescript,我们没有struct,因为没有必要匹配标准实体组件系统的设计方式,因为我们对内存布局没有那种控制。

ecs更灵活,可以更好的集中、组织、排序和过滤游戏中的对象。ecs让您拥有轻量级实体和组件,这些组件可以由系统批量处理。 例如,您在制作一个射手,您可能会有几十到几百个子弹,这些作为轻量级实体由系统批量处理。

所以ecs在设计当中拥有四种重要类型:世界(Scene),过滤器(Matcher),系统(System)和实体(Entity)

世界(Scene)

Scene是ecs包含系统和实体最外面的容器。

实体(Entity)

实体只由系统处理。

组件(Component)

组件应该只包含数据而没有逻辑代码。对数据进行逻辑是系统的工作。

系统(System)

ecs中的系统会不断的更新实体。系统使用过滤器选择某些实体,然后仅更新那些选择的实体。

作者其他库(egret)

egret-framework's People

Contributors

esengine avatar imgbotapp avatar restyled-commits avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.