Giter VIP home page Giter VIP logo

fiber2d's Introduction

Fiber2D

Join the chat at https://gitter.im/Fiber2D/Lobby

Swift Version Build State Target Platforms

This project originated as cocos2d-objc rewrite to Swift. As I stopped commiting to the repo since June, because Obj-C is dead for me.

This is still in a very alpha state, but you already can build some games with it, even though it may be unpleasant process as I change API almost every day. The project served as .dylib (.so on Linux/Android) that builds by Swift Package Manager. It requires some project config in order to use it, but you can experiment with the demo provided in the repo. Generally the project should be considered unstable and most of the API is likely to be changed.

Basement

We worked hard before starting this project and it relies on several self-made libs we made:

Thanks to them we currently have:

  • Ultra fast cross-platform math lib, that works with SIMD on Darwin platforms and has self-implemnted algorithms to run on Glibc based environment. Not speaking of zero ARC impact and modern swifty syntax features.
  • Modern agnostic renderer, which works with following list of backends out of the box:
    • Direct3D 9, 11, 12
    • Metal
    • OpenGL 2.1, 3.1+, ES 2, ES 3.1
    • WebGL 1.0, 2.0

What it looks like?

Currently this repo only contains demos for Linux, Android, iOS and macOS. macOS demo can use both MetalKit and SDL. iOS demo only supports MetalKit for now and can be easily ported to tvOS. Linux and Android demos can only be compiled with SDL, hence only GL rendering backend is available.

You can get the idea from this GIF: Fiber2D Demo Gif

Goals (updated 29 DEC 2016)

My goals for the near future are (order means nothing):

  • Port to Windows
  • Introduce basic UI components (Button, Slider, Label)
  • Introduce GPU computed Particle systems
  • Drop the concept of contentScale and use one set of assets for all screen resolutions
  • Add support for more asset format loading from .jpg to .pvr
  • Add easy post-processing mechanism

We have a trello which I will try to maintain soon.

Build

macOS

  1. Clone

    $ git clone --recursive https://github.com/s1ddok/Fiber2D.git

  2. Call helper script, that will do all the preparation stuff for you.

    cd external/SwiftBGFX/3rdparty/bgfx
    make osx-debug64 
    
  3. Generate XCode project

    cd ../../../../
    make xcodeproj-macos
    
  4. Open XCode project, compile and run. You should see the demo yourself.

iOS

  1. Clone, build bgfx for iOS
  2. make xcodeproj-ios
  3. Open demo XCode project, drag Fiber2D-iOS.xcodeproj somewhere in System/iOS group (just for reasonable structure).
  4. Go to Project Settings -> Fiber2D-demo-iOS Target settings. Add all frameworks from Fiber2D-iOS to Embedded binaries: Embedded binaries example Double check that the same binaries appear in Target dependencies section of Build Phases.
  5. Compile and run

Contributors

  • @stuartcarnie did initial setup of the bgfx renderer along with general support on how to use it
  • @gonzalolarralde helped with Android port of libDispatch/libFoundation and Fiber2D itself.

Questions

You can reach me on twitter (@s1ddok) or by e-mail in my profile.

LICENSE (BSD 2-clause)

All parts in this package (Fiber2D, SwiftMath, SwiftBGFX and bgfx itself) use the same license.

Copyright 2016 Andrey Volodin. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

fiber2d's People

Contributors

gitter-badger avatar kevinhury avatar s1ddok avatar stuartcarnie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fiber2d's Issues

[iOS Demo] Demo target appears to have issues finding its imported modules

Swift 4.0.3
XCode 9.2

I was able to get the MacOS project running via the instructions without issue. However, while following the iOS instructions I first came across build errors with the message

Missing required module 'Cbgfx'

So after some Googling I found this answer: https://stackoverflow.com/questions/31757417/swift-app-missing-required-module-when-importing-framework-that-imports-stati

Which led me to find the Cbgfx module map and point to it in the demo search paths.

$(SRCROOT)/Fiber2D-iOS.xcodeproj/GeneratedModuleMap/Cbgfx

This worked to stop the Cbgfx complaints but then I got two new problems:

Missing required modules: 'CChipmunk2D', 'Cpng'

So now I'm wondering if I've just set things up incorrectly or if something has changed since the instructions were made. From what it looks like to me the framework themselves build no problem:
screen shot 2017-12-09 at 10 36 17 am

Any advice on where I might be going wrong? Thanks

Problem following the install instructions

I followed the install instructions but on Step 3 I got the following:

error: the module at /Users/nixarn/Projects/Fiber2D/misc does not contain any source files
fix: either remove the module folder, or add a source file to the module

Same problem when I opened the OSX project and trying to run it

Falls down on rotation

-[MTLDebugRenderCommandEncoder setScissorRect:]:2029: failed assertion `(rect.y(0) + rect.height(1024))(1024) must be <= 768'

make macos - failing.

cd external/SwiftBGFX
sh prepare_bgfx_macos.sh
Building configurations...
Running action 'ninja'...
Generating ../.build/projects/ninja-osx/Makefile...
Generating ../.build/projects/ninja-osx/debug32/build.ninja...
Generating ../.build/projects/ninja-osx/release32/build.ninja...
Generating ../.build/projects/ninja-osx/debug64/build.ninja...
Generating ../.build/projects/ninja-osx/release64/build.ninja...
Generating ../.build/projects/ninja-osx/debug/build.ninja...
Generating ../.build/projects/ninja-osx/release/build.ninja...
Generating ../.build/projects/ninja-osx/debug32/bgfx.ninja...
Generating ../.build/projects/ninja-osx/release32/bgfx.ninja...
Generating ../.build/projects/ninja-osx/debug64/bgfx.ninja...
Generating ../.build/projects/ninja-osx/release64/bgfx.ninja...
Generating ../.build/projects/ninja-osx/debug/bgfx.ninja...
Generating ../.build/projects/ninja-osx/release/bgfx.ninja...
Generating ../.build/projects/ninja-osx/debug32/bx.ninja...
Generating ../.build/projects/ninja-osx/release32/bx.ninja...
Generating ../.build/projects/ninja-osx/debug64/bx.ninja...
Generating ../.build/projects/ninja-osx/release64/bx.ninja...
Generating ../.build/projects/ninja-osx/debug/bx.ninja...
Generating ../.build/projects/ninja-osx/release/bx.ninja...
Generating ../.build/projects/ninja-osx/debug32/bimg.ninja...
Generating ../.build/projects/ninja-osx/release32/bimg.ninja...
Generating ../.build/projects/ninja-osx/debug64/bimg.ninja...
Generating ../.build/projects/ninja-osx/release64/bimg.ninja...
Generating ../.build/projects/ninja-osx/debug/bimg.ninja...
Generating ../.build/projects/ninja-osx/release/bimg.ninja...
Generating ../.build/projects/ninja-osx/debug32/bimg_decode.ninja...
Generating ../.build/projects/ninja-osx/release32/bimg_decode.ninja...
Generating ../.build/projects/ninja-osx/debug64/bimg_decode.ninja...
Generating ../.build/projects/ninja-osx/release64/bimg_decode.ninja...
Generating ../.build/projects/ninja-osx/debug/bimg_decode.ninja...
Generating ../.build/projects/ninja-osx/release/bimg_decode.ninja...
Done. Generated 31/31 projects.
make: ninja: No such file or directory
make: *** [clean] Error 1
make: ninja: No such file or directory
make: *** [clean] Error 1
==== Building bgfx (debug64) ====
make: ninja: No such file or directory
make: *** [bgfx] Error 1
==== Building bgfx (release64) ====
make: ninja: No such file or directory
make: *** [bgfx] Error 1

make macos
swift build -Xswiftc -Iexternal/SwiftBGFX/3rdparty/bgfx/3rdparty/khronos -Xswiftc -Iexternal/SwiftBGFX/3rdparty/bx/include -Xswiftc -Iexternal/SwiftBGFX/3rdparty/bgfx/3rdparty -Xlinker -lc++ -Xlinker -lbgfxDebug -Xlinker -lbxDebug -Xlinker -lbimgDebug -Xlinker -lz -Xcc -DCP_USE_CGTYPES=0 -Xlinker -framework -Xlinker AppKit -Xlinker -framework -Xlinker Quartz -Xlinker -Lexternal/SwiftBGFX/3rdparty/bgfx/.build/osx64_clang/bin -Xcc -Iexternal/SwiftBGFX/3rdparty/bx/include/compat/osx -Xcc -DBGFX_CONFIG_RENDERER_METAL=1 -Xlinker -framework -Xlinker Metal -Xlinker -framework -Xlinker MetalKit -Xlinker -framework -Xlinker Foundation
Compile Swift Module 'Fiber2D' (106 sources)
/Users/jpope/Desktop/Fiber2D/Fiber2D/Node+Scene.swift:32:22: error: missing argument for parameter #1 in call
onEnter.fire()
^
<#Void#>
/Users/jpope/Desktop/Fiber2D/Fiber2D/events/Event.swift:79:17: note: 'fire' declared here
public func fire(_ data: T) {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/Node+Scene.swift:37:41: error: missing argument for parameter #1 in call
onEnterTransitionDidFinish.fire()
^
<#Void#>
/Users/jpope/Desktop/Fiber2D/Fiber2D/events/Event.swift:79:17: note: 'fire' declared here
public func fire(_ data: T) {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/Node+Scene.swift:42:39: error: missing argument for parameter #1 in call
onExitTransitionDidStart.fire()
^
<#Void#>
/Users/jpope/Desktop/Fiber2D/Fiber2D/events/Event.swift:79:17: note: 'fire' declared here
public func fire(_ data: T) {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/Node+Scene.swift:56:21: error: missing argument for parameter #1 in call
onExit.fire()
^
<#Void#>
/Users/jpope/Desktop/Fiber2D/Fiber2D/events/Event.swift:79:17: note: 'fire' declared here
public func fire(_ data: T) {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionEase.swift:32:16: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
action.update(state: easeBlock(state))
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionEase.swift:32:30: note: conflicting access is here
action.update(state: easeBlock(state))
^~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:87:32: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
innerContainer.update(state: dt - (nextDt - 1.0 / Float(repeatCount)))
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:87:52: note: conflicting access is here
innerContainer.update(state: dt - (nextDt - 1.0 / Float(repeatCount)))
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:87:32: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
innerContainer.update(state: dt - (nextDt - 1.0 / Float(repeatCount)))
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:87:73: note: conflicting access is here
innerContainer.update(state: dt - (nextDt - 1.0 / Float(repeatCount)))
^~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:71:32: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
innerContainer.start(with: target)
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:71:44: note: conflicting access is here
innerContainer.start(with: target)
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:109:28: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
innerContainer.start(with: target)
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:109:40: note: conflicting access is here
innerContainer.start(with: target)
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:40:28: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
innerContainer.start(with: target)
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionRepeat.swift:40:40: note: conflicting access is here
innerContainer.start(with: target)
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionSequence.swift:37:28: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
actions[0].start(with: target)
~~~~^~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionSequence.swift:37:40: note: conflicting access is here
actions[0].start(with: target)
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionSequence.swift:61:28: error: simultaneous accesses to parameter 'self', but modification requires exclusive access; consider copying to a local variable
actions[found].start(with: target)
~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/ActionSequence.swift:61:40: note: conflicting access is here
actions[found].start(with: target)
^~~~~~
/Users/jpope/Desktop/Fiber2D/Fiber2D/System.swift:47:12: warning: redundant conformance constraint 'T': 'Component'
where T: Component {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/System.swift:46:48: note: conformance constraint 'T': 'Component' inferred from type here
public func subtree(of type: T.Type) -> ComponentNode
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/System.swift:47:12: warning: redundant conformance constraint 'T': 'Component'
where T: Component {
^
/Users/jpope/Desktop/Fiber2D/Fiber2D/System.swift:46:48: note: conformance constraint 'T': 'Component' inferred from type here
public func subtree(of type: T.Type) -> ComponentNode
^
error: terminated(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/jpope/Desktop/Fiber2D/.build/debug.yaml
make: *** [macos] Error 1

Welcome to Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8). Type :help for assistance.

screen shot 2017-06-26 at 10 44 42 am

Alternative engines?

As I understand you killed objc-cocos2d, fiber2d is too raw to use in serious projects (it even becomes a hell to run demo project).
Could you suggest an alternative with objc/swift programming?

Swift and Kotlin

I just want to talk about Swift and it's future.

First rumors was like Google want to make it first class lang: https://thenextweb.com/dd/2016/04/07/google-facebook-uber-swift/

Currently for cross-platform game development I'm using cocos2d-x and C++, which is supported by platform IDE's: Xcode and android studio. This gives me a top level of controll and I can easy use any new features in these IDE's. Overall like I can say - ability to work natively. This is really cool. But what is not cool, it's C++. It's fast, powerful but it's not easy to learn it and overall it's too complicated..

So, I waited for Swift to be official on android maybe.. But what do we have now: Kotlin is now an official android language.
https://developer.android.com/kotlin/index.html
https://android-developers.googleblog.com/2017/05/android-announces-support-for-kotlin.html

Swift is like Kotlin. Or better to say vice versa? Kotlin first appeared at 2011, but Swift at 2014. Well, whatever..
And fun to compare some syntax of both languages:
http://nilhcem.com/swift-is-like-kotlin/

Anyway, this means no way for Swift for android. I don't believe that Google has any plans for it.

Finally, looks like C++ is only the one right way.. and we have cocos2d-x, but they currently moving into wrong direction - to JS. Also, they developing closed-source editor, same crappy as was android studio. For me it's like "china low quality product".

Any ideas, thought about all this?

p.s. pls don't close this issue to early. cocos2d forum died, so no place to talk about this I think.

Project status / Taking contributions?

Hi, I'm pretty interested in this project and was wondering what the status is on development/whether the project is at a point where you want contributions and have an idea where help is most useful

It's great to see this effort out there. I really am not sure where to turn to get a cross-platform engine written in swift that has an API like cocos2d

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.