• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

akoaysigod/GameEngine: a simple 2D game engine in Metal

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

akoaysigod/GameEngine

开源软件地址:

https://github.com/akoaysigod/GameEngine

开源编程语言:

Swift 93.7%

开源软件介绍:

GameEngine

A rather creatively named 2D game engine written in Swift using the Metal API. I pretty much only make tile based games and this engine is very geared towards doing that efficiently.

It currently only works on iOS and partially on macOS, still need to test tvOS to see what needs to be done. I had plans to port it to Linux/Vulkan but swift linux is not fun and my video card is too old at the moment to even run Vulkan so I'll be putting that on hold indefinitely.

Currently, the example projects are built into the main project because for whatever reason you can't debug metal externally if it's bundled into a framework. Maybe I just didn't do it correctly.

current state

This is probably not close to being ready to go. It could technically be used now though.

Documentation can be here a good portion of the public API has been documented.

A ton of things left to do including:

  • fix project layout I don't think I need two frameworks
  • create separate example projects for testing
  • texture animation
  • fix the data structures for font rendering
  • fix up the text rendering shaders to have more options
  • fix up text rendering in general, can probably move it over to the sprite pipeline.
  • lighting system, probably will do next, needs to be redone again as macOS does not support buffer access like iOS does

I'm pretty sure this is as fast as it'll ever be. It seems rather slow or maybe it's because I'm kind of new to this. I can render 100 textured quads at ~15% CPU or 1.1ms CPU/GPU frame time. At 10000 I start to lose FPS. That is way more than I'll ever need for the game I'm making.

Should you use it?

Probably not. I was having some performance issues using SpriteKit and I think (hope) this will address those issues but I don't know what I'm doing really. This will also never be as robust as SpriteKit as I have fairly specific needs.

With that being said, feel free to use it.

howto

If you know SpriteKit you can probably skip this. One thing worth keeping in mind is the TextNode will take a really long time to create with no compiler optimization. The algorithm is pretty intense and the array bound checking kills it. It's worth running once with optimizations to force the font textures to be saved to disk.

To just test stuff out you can just build the GameEngineTest target which is not actually a unit test target. The TestGameViewController is already setup to display some stuff.

Otherwise, subclass GameViewController and in viewDidLoad():

if let view = self.view as? GameView {
  scene = Scene(size: view.bounds.size)
  view.presentScene(scene)
}

//this should probably be done in a subclass of `Scene` where it's easier to override the update method
let sprite = Sprite(named: "AnImageYouAdded")
scene.addNode(sprite)

And you should see the sprite at the bottom left corner of the screen.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap