Glove is a framework for making games. It is implemented in Crystal.
To use this shard, add the following lines to your shard.yml
:
dependencies:
glove:
git: git@github.com:ddfreyne/glove.git
Glove comes with shaders in its shaders/
directory, which needs to be copied to where the executable is located. For example, the following will create a target/
directory that contains the executable and the shaders directory:
rm -rf target/
mkdir -p target
crystal build -o target/mygame src/mygame.cr
cp -r lib/glove/src/shaders target/shaders
It is useful to let the executable cd
to the directory it is located in, before doing anything else, so that it can find the shaders easily:
if full_path = Process.executable_path
Dir.cd(File.dirname(full_path))
end
The target/
directory should also include any assets that the game needs to run; a more complete build script could therefore look as follows:
rm -rf target/
mkdir -p target
crystal build -o target/mygame src/mygame.cr
cp -r lib/glove/src/shaders target/shaders
cp -r assets target/assets # <- added
Here is a trivial example that renders a card (from assets/card.png
):
require "glove"
if full_path = Process.executable_path
Dir.cd(File.dirname(full_path))
end
card =
Glove::Entity.new.tap do |e|
e << Glove::Components::Texture.new("assets/card.png")
e << Glove::Components::Transform.new.tap do |t|
t.width = 140_f32
t.height = 190_f32
t.translate_x = 400_f32
t.translate_y = 300_f32
end
end
scene =
Glove::Scene.new.tap do |scene|
scene.spaces << Glove::Space.new.tap do |space|
space.entities << card
end
end
game = Glove::EntityApp.new(800, 600, "Inari")
game.clear_color = Glove::Color::WHITE
game.replace_scene(scene)
game.run
Glove::EntityApp
is a generic game superclass that provides functionality for handling entities, and everything associated with it. Here is how a typical game would build an instance and run the game:
game = Glove::EntityApp.new(800, 600, "Inari")
game.clear_color = Glove::Color::WHITE
scene = Glove::Scene.new.tap do |scene|
# … build scene here …
end
game.replace_scene(scene)
game.run
Glove::Entity
is a game object that is visible and/or reacts to user input.
Glove::Component
is a property of an entity. A common component is Glove::Components::Transform
, which adds width, height, rotation, scale, … to an entity. Another common component is Glove::Components::Camera
, which marks an entity as being a camera, and defines which part of a space (see below) will be rendered, with what rotation, etc.
Glove::Action
defines a change to an entity. It can either be instant (e.g. remove entity) or act over time (e.g. move).
Glove::Space
groups entities in a scene that logically belong together and can interact with each other. Entities in different spaces never interact. For example, one space might contain the game entities, and another space might contain UI elements.
Glove::Scene
describes a scene (such as the main menu, credits, or in-game screen). It contains one or more spaces.
Glove::System
describes logic for making changes to a space. A common system is a physics system, which would calculate velocities and update positions.
There are also a handful of simple data classes:
Glove::Color
Glove::Point
Glove::Quad
Glove::Rect
Glove::Size
Glove::Vector
This project started out by playing with crystal-gl by Gustavo Giráldez.
引言 本着“凡我不能创造的,我就不能理解”的思想,本系列文章会基于纯Python以及NumPy从零创建自己的深度学习框架,该框架类似PyTorch能实现自动求导。 ��系列文章完整目录: ��点此�� 要深入理解深度学习,从零开始创建的经验非常重要,从自己可以理解的角度出发,尽量不适用外部框架的前提下,实现我们想要的模型。本系列文章的宗旨就是通过这样的过程,让大家切实掌握深度学习底层实现,而不是仅
GloVe的全称叫Global Vectors for Word Representation,它是一个基于全局词频统计(count-based & overall statistics)的词表征工具,它可以把一个单词表达成一个由实数组成的向量,这些向量捕捉到了单词之间一些语义特性,比如相似性、类比性等。 构建共现矩阵 设共现矩阵为 X X X ,其元素为 X i , j X_{i,j} Xi,j
https://blog.csdn.net/coderTC/article/details/73864097 https://zhuanlan.zhihu.com/p/42073620
0. 前言 在《使用fastText模型构建单词向量》一节中,我们学习了如何构建 fastText 模型以生成单词向量,GloVe (Global Vectors for Word Representation) 是另一种生成单词向量的方式。在本节中,我们将介绍 GloVe 的算法原理,然后介绍如何实现 GloVe 模型生成单词向量。 1. GloVe 算法模型 1.1 模型目标 GloVe 的提
1. 整体思路 在这个算法中,为了使得效果比较有对比性,我们仍然采用前面word2vec算法实现时的数据来进行GloVe模型的实现,为此,这里的数据处理和数据准备(即剔除标点、分词、得到数据与编号的字典)过程都可以拿过来用,当然这里还多了一步,构造共现矩阵的步骤。因为GloVe模型实际上就是对word2vec模型的一种改进,只不过训练的参数多了两个偏置项,损失的函数也发生了变化而已,所以,构建模型
一、问题 最近安装glove, 搜了一下网上的资料,基本可以归纳为两步:第一:安装好gcc, 第二步:直接pip install glove_python; 可是等你执行pip install glove_python的时候,就报各种错误,比如: C:\Users\pc\Desktop\glove_python-0.1.0>python setup.py install running insta