当前位置: 首页 > 软件库 > 游戏/娱乐 > >

brute

授权协议 EPL-1.0 License
开发语言 C/C++
所属分类 游戏/娱乐
软件类型 开源软件
地区 不详
投 递 者 洪琦
操作系统 未知
开源组织
适用人群 未知
 软件概览

Brute

A simple and lightweight Entity Component System library for writing games with Clojure or ClojureScript.

Clojars Version

The aim of this project was to use basic Clojure building blocks to form an Entity System architecture, and get out of theauthor's way when deciding exactly what approach would best fit their game when integrating with this library.

To that end:

  • Entities are UUIDs.
  • The Component type system can be easily extended through a multimethod get-component-type, but defaults to using the component's instance class as its type.
  • Components can therefore be defrecords or deftypes by default, but could easily be maps or just about anything else.
  • Systems are simply references to functions of the format (fn [delta]).

To learn more about Entity Component Systems, please read the Entity Systems Wiki.I personally, also found Adam Martin's Blog Post seriesvery useful at giving a step by step explanation of Entity System architecture.

News

Blog posts and news can be found on the Compound Theory Blog

Usage

See the Library API for all the functionality of this library.

Quick Start

A quick example based overview of what functionality Brute provides.

I've used fully qualified namespace, brute.entity and brute.system to be explicit about what is part of Brute in the demo code below, and what denotes custom code.

Creating the Basic Entity Component System

Brute doesn't store any data in a ref/atom, but instead provides you with the functions and capabilities for manipulating an immutable data structure that represents this ES system. This is particularly useful because:

  • How the entity data structure is persisted is up to you and the library you are using (although 9/10 times I expect it will end up stored in a single atom, and reset! on each game loop), which gives you complete control over when state mutation occurs – if it occurs at all. This makes concurrent processes much simpler to develop.
  • You get direct access to the ES data structure, in case you want to do something with it that isn’t exposed in the current API.
  • You can easily have multiple ES systems within a single game, e.g. for sub-games.
  • Saving a game becomes simple: Just serialise the ES data structure and store. Deserialise to load.
  • Basically all the good stuff having immutable data structures and pure functions should give you.

To create the initial system data structure:

(brute.entity/create-system)

This is actually a map, that lets you access Entities and their Components from a variety of ways, so you can always do it in a performant way.

{;; Nested Map of Component Types -> Entity -> Component Instance
        :entity-components      {}
     ;; Map of Entities -> Set of Component Types
        :entity-component-types {}}

Do note, that this data structure may be subject to change between releases.

Creating a Ball Entity, with corresponding Component instances.

  • A Ball component instance to know it is a Ball.
  • A Rectangle component instance to draw a rectangle in its' place
  • A Velocity component instance to know what direction it is travelling in, and how fast.
(defn create-ball
    "Creates a ball entity"
    [system]
    (let [ball (brute.entity/create-entity) ;; Returns a UUID for the Entity
          center-x (-> (graphics! :get-width) (/ 2) (m/round))
          center-y (-> (graphics! :get-height) (/ 2) (m/round))
          ball-size 20
          ball-center-x (- center-x (/ ball-size 2))
          ball-center-y (- center-y (/ ball-size 2))
          angle (create-random-angle)]
        (-> system
            (brute.entity/add-entity ball) ;; Adds the entity to the ES data structure and returns it
            (brute.entity/add-component ball (c/->Ball)) ;; Adds the Ball instance to the ES data structure and returns it
            (brute.entity/add-component ball (c/->Rectangle (rectangle ball-center-x ball-center-y ball-size ball-size) (color :white))) ;; Adds the Rectangle instance to the ES data structure and returns it
            (brute.entity/add-component ball (c/->Velocity (vector-2 0 300 :set-angle angle)))))) ;; Adds the Velocity instance to the ES data structure and returns it

Render each of the Entities that have a Rectangle Component

(defn- render-rectangles
    "Render all the rectangles"
    [system]
    (let [shape-renderer (:shape-renderer (:renderer system))]
        (.begin shape-renderer ShapeRenderer$ShapeType/Filled)
        (doseq [entity (brute.entity/get-all-entities-with-component system Rectangle)] ;; loop around all the entities that have a Rectangle Component instance
            (let [rect (brute.entity/get-component system entity Rectangle) ;; get the Rectangle Component Instance for this entity
                  geom (:rect rect)] ;; Rectangle component contains a Rectangle geometry shape.
                (doto shape-renderer ;; Draw the actual rectangle on the screen
                    (.setColor (:colour rect)) ;; Rectangle component contains the colour
                    (.rect (rectangle! geom :get-x)
                           (rectangle! geom :get-y)
                           (rectangle! geom :get-width)
                           (rectangle! geom :get-height)))))
        (.end shape-renderer)))

Systems Management

System management is an optional feature for you to use with Brute.

The following adds each system function to a list contains on the Entity System data structure, maintaining the order in which they were added.

(defn- create-systems
    "register all the system functions"
    [system]
    (-> system
    	(brute.system/add-system-fn input/process-one-game-tick)
    	(brute.system/add-system-fn scoring/process-one-game-tick)
    	(brute.system/add-system-fn ai/process-one-game-tick)
    	(brute.system/add-system-fn physics/process-one-game-tick)
    	(brute.system/add-system-fn rendering/process-one-game-tick)))

Finally call each function in the order added, simply write:

(brute.system/process-one-game-tick system (graphics! :get-delta-time))

Game Examples

Contributing

Pull requests are always welcome!

Active development happens on the develop branch. The master branch is the source for the current release.

Reader Conditionals

This project uses Reader Conditionals to support both Clojure and ClojureScript. It should be a seamless experience.

Testing

To test under Clojure: lein test

To test under ClojureScript: lein cljstest

To run all tests: lein alltest

Run all tests in the a Docker Container

You should be able to run all the tests without having to install anything, except to pull the Docker container.

make test will run all the tests in the development Docker container, which should make development easier.

License

Copyright © 2016 Mark Mandel, Google Inc.

Distributed under the Eclipse Public License either version 1.0 or (atyour option) any later version.

  •   设有主串s和子串t,子串t的定位就是要在主串s中找到一个与子串t相等的子串。通常把主串s称为目标串,把子串t称为模式串,因此定位也称作模式匹配。模式匹配成功是指在目标串s中找到一个模式串t;不成功则指目标串s中不存在模式串t。 以下算法假设串采用顺序存储结构,即: #define MAXSIZE 50 typedef struct {         char data[MAXSIZE];  

  • 1 Introduction A common threat that webdevelopers face is a password-guessing attack known as a brute force attack. Abrute-force attack is an attempt to discover a password by systematicallytrying eve

  • I - Killing the Brute-force @TOC I - Killing the Brute-force 在每个测试样例中,先输入一个m,之后一行输入m个数,a1,a2,am,ai为n=i的时候运行时间。 下一行m个数,b1,b2,bm,bi为n=i的时候暴力算法的运行时间。 题意为在bi<=3ai的限制下,求出n的最小值。 用一个结构体,里面有第i组的运行时间a,暴力运行时间b,

  •  http://code.google.com/p/chrisjohnriley-metasploit-modules/updates/list http://www.metasploit.com/modules/auxiliary/scanner/sap/sap_mgmt_con_brute_login

 相关资料
  • 两个问题是: 给定nums=[2,7,11,15],目标=9,因为nums[0]+nums[1]=2+7=9,返回[0,1]。 我知道我需要一个return语句,但我不确定应该返回什么,也不确定是否需要我的main方法。

  • 你能一步一步解释一下逻辑吗,我没有得到他们迭代1到8的部分 这里是实际问题集的链接 http://ocw.mit.edu/courses/electrice-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/assignments/mit6_006F11_ps5.pdf

  • 问题 序列 s 有 n 个成员 [s_1,s_2, cdots ,s_n] ,每个成员可以选取 [1,2, cdots ,m] 这 m 种值。 例如当 n = 5 , m = 3 时,序列 s 有如下排列组合: [1,1,1,1,1], [1,1,1,1,2], [1,1,1,1,3], [1,1,1,2,1] cdots 遍历序列 s 的可能排列组合的所有情况。 原理 加法原理:完成一件事情有

  • 讲师:gh0stkey 整理:飞龙 协议:CC BY-NC-SA 4.0 介绍 BruteXSS 是一个非常强大和快速的跨站点脚本检测工具,可用于暴力注入参数。BruteXSS 从指定的词库加载多种有效载荷进行注入,并且使用指定的载荷和扫描检查这些存在 XSS 漏洞的参数。得益于非常强大的扫描功能,在执行任务时,BruteXSS 非常准确而且极少误报。 BruteXSS 支持 POST 和 GET

  • Subsets 描述 Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For exampl

  • Subsets II 描述 Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contai

  • Permutations 描述 Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 代码 递归 /

  • Permutations II 描述 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1],

相关阅读

相关文章

相关问答

相关文档