Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Making of CuBeat, Programming-wise

IGDSHARE
April 11, 2014

Making of CuBeat, Programming-wise

It basically is an overview of the libs and tools used, with explanation about some more "re-usable" parts and also about what we (probably) did awfully wrong.

IGDSHARE

April 11, 2014
Tweet

More Decks by IGDSHARE

Other Decks in Programming

Transcript

  1. 2014.04.11 @ OSDC.tw
    By Johnson Lin
    @cubeatgame || www.facebook.com/cubeatgame
    The Making of
    Programming-wise

    View full-size slide

  2. About me
    Johnson Lin
    Programmer & Indie Game
    igdshare.org & IGDA Taiwan ( igda.tw )
    archilife.org & Indie game contests scholarship
    ( 祐生研究基金會 )

    View full-size slide

  3. Overview
    Libraries Used (with some in-house ones)
    - especially: Easing Functions & Custom Dictionary
    Development Issues (that I think is interesting)
    - AI design & impl
    - Why game programming is messy
    - Cross-platform?
    All (?) the Mistakes (??)

    View full-size slide

  4. Let's demo first.

    View full-size slide

  5. Overview
    Libraries Used (with some in-house ones)
    - especially: Easing Functions & Custom Dictionary
    Development Issues (that I think is interesting)
    - AI design & impl
    - Why game programming is messy
    - Cross-platform?
    All (?) the Mistakes (??)

    View full-size slide

  6. Libs & tools
    https://github.com/godfat/cubeat/

    View full-size slide

  7. Libs & tools
    gcc 4.6
    ruby 1.8-1.9
    CMake
    code::Blocks (on Win)
    https://github.com/godfat/cubeat/

    View full-size slide

  8. Libs & tools
    Irrlicht 1.7 (custom)
    Boost 1.48
    Freetype 2.3.x
    LuaJIT2
    Ogg/Vorbis
    ALmixer
    ManyMouse
    Loki
    … (any many other things no longer used)
    gcc 4.6
    ruby 1.8-1.9
    CMake
    code::Blocks (on Win)
    https://github.com/godfat/cubeat/

    View full-size slide

  9. Easing Equations
    Lala
    (Demo)

    View full-size slide

  10. Easing Equations
    obj->tween
    (start, end, time, loop, callback, delay);

    View full-size slide

  11. Easing Equations
    obj->tween
    (start, end, time, loop, callback, delay);
    AnimatorParam anim, anim2;
    anim.start(s).end(e).time(t);
    anim2.start(s2).end(e2).time(t2);

    View full-size slide

  12. Easing Equations
    obj->tween
    (start, end, time, loop, callback, delay);
    AnimatorParam anim, anim2;
    anim.start(s).end(e).time(t);
    anim2.start(s2).end(e2).time(t2);
    obj->queue(anim).tween(anim2);

    View full-size slide

  13. Easing Equations
    obj->tween
    (start, end, time, loop, callback, delay);
    AnimatorParam anim, anim2;
    anim.start(s).end(e).time(t);
    anim2.start(s2).end(e2).time(t2);
    obj->queue(anim).tween(anim2);
    * cubeat-core/include/EasingEquations.hpp
    * cubeat-core/include/Accessors.hpp
    * cubeat-core/include/view/Object.hpp
    * cubeat-core/include/view/detail/CustomAnimator.hpp

    View full-size slide

  14. Custom "dictionary"
    'key1': {
    'somelist':
    [-1.1, [14, 15, [3]], 6, 13],
    1: '234',
    'val': 5
    }

    View full-size slide

  15. Custom "dictionary"
    'key1': {
    'somelist':
    [-1.1, [14, 15, [3]], 6, 13],
    1: '234',
    'val': 5
    }
    #comment
    #number => 1, -1, 1.0, -1.0, 0xfe, -0xfd.
    #string => 'string', ThisIsAString_Too
    #map => { ... }
    #vector => [ ... ]
    #delim => ,(comma) :(colon)

    View full-size slide

  16. Custom "dictionary"
    map.V("stafflist").M(1).S("phone");

    View full-size slide

  17. Custom "dictionary"
    map.V("stafflist").M(1).S("phone");
    implies =>
    'stafflist': [
    ... ,
    { 'phone' : 'something', ... },
    ...
    ]

    View full-size slide

  18. Custom "dictionary"
    map.V("stafflist").M(1).S("phone");
    implies =>
    'stafflist': [
    ... ,
    { 'phone' : 'something', ... },
    ...
    ]
    map = map_any::construct( from_str );
    vec = vector_any::construct( from_str );

    View full-size slide

  19. Custom "dictionary"
    Uses:
    tr1::unordered_map & std::vector + boost.any
    boost.algorithm
    boost.lexical_cast

    View full-size slide

  20. Custom "dictionary"
    Uses:
    tr1::unordered_map & std::vector + boost.any
    boost.algorithm
    boost.lexical_cast
    Have often-used std container interfaces

    View full-size slide

  21. Custom "dictionary"
    Uses:
    tr1::unordered_map & std::vector + boost.any
    boost.algorithm
    boost.lexical_cast
    Have often-used std container interfaces
    Very ugly usage of exception when serializing

    View full-size slide

  22. Custom "dictionary"
    Uses:
    tr1::unordered_map & std::vector + boost.any
    boost.algorithm
    boost.lexical_cast
    Have often-used std container interfaces
    Very ugly usage of exception when serializing
    * cubeat-core/include/utils/dictionary.hpp
    * cubeat-core/src/utils/dictionary.cpp

    View full-size slide

  23. Overview
    Libraries Used (with some in-house ones)
    - especially: Easing Functions & Custom Dictionary
    Development Issues (that I think is interesting)
    - AI design & impl
    - Why game programming is messy
    - Cross-platform?
    All (?) the Mistakes (??)

    View full-size slide

  24. AI Design & Impl Problems
    Started asking around on ptt.cc (Prob_Solve)
    in 2007.

    View full-size slide

  25. AI Design & Impl Problems
    Started asking around on ptt.cc (Prob_Solve)
    in 2007.
    Dunno how to impl AI strategy for building chains.

    View full-size slide

  26. AI Design & Impl Problems
    Started asking around on ptt.cc (Prob_Solve)
    in 2007.
    Dunno how to impl AI strategy for building chains.
    Research some kind of patterns?
    Neural network??
    Reinforcement learning???
    Genetic algorithm????

    View full-size slide

  27. AI Design & Impl Problems
    Started asking around on ptt.cc (Prob_Solve)
    in 2007.
    Dunno how to impl AI strategy for building chains.
    Research some kind of patterns?
    Neural network??
    Reinforcement learning???
    Genetic algorithm????

    View full-size slide

  28. AI Design & Impl Problems
    http://kamoland.com/wiki/wiki.cgi?RensaWiki

    View full-size slide

  29. AI Design & Impl Problems
    http://kamoland.com/wiki/wiki.cgi?RensaWiki
    Puyopuyo "Rensa" walkthrough site
    with AI programming competiton !!!
    ...

    View full-size slide

  30. AI Design & Impl Problems
    http://kamoland.com/wiki/wiki.cgi?RensaWiki
    Puyopuyo "Rensa" walkthrough site
    with AI programming competiton !!!
    ...
    And basically,
    the strongest strategy is just brute-force.

    View full-size slide

  31. AI Design & Impl Problems
    http://kamoland.com/wiki/wiki.cgi?RensaWiki

    View full-size slide

  32. AI Design & Impl Problems
    So, let players try the AI.

    View full-size slide

  33. AI Design & Impl Problems
    So, let players try the AI.

    View full-size slide

  34. AI Design & Impl Problems
    So, let players try the AI.

    View full-size slide

  35. AI Design & Impl Problems
    So, let players try the AI.
    Few people could beat EASY.

    View full-size slide

  36. AI Design & Impl Problems
    So, let players try the AI.
    Few people could beat EASY.
    * made AI even slower, too boring
    - player learns nothing

    View full-size slide

  37. AI Design & Impl Problems
    So, let players try the AI.
    Few people could beat EASY.
    * made AI even slower, too boring
    - player learns nothing
    * occasional "critical hit"
    - randomness problem
    - you don't want player get defeated randomly
    - computer simulated "hand-shaking"
    - had to make pace feel right to new player

    View full-size slide

  38. AI Design & Impl Problems

    View full-size slide

  39. AI Design & Impl Problems
    FACT 1
    Easy AI is the HARDEST one to get right.

    View full-size slide

  40. AI Design & Impl Problems
    FACT 1
    Easy AI is the HARDEST one to get right.
    FACT 2
    Good enough is good enough.

    View full-size slide

  41. Why Game Programming is Messy
    (Demo)

    View full-size slide

  42. Why Game Programming is Messy
    A. Impossible to know what will actually work

    View full-size slide

  43. Why Game Programming is Messy
    A. Impossible to know what will actually work
    B. Many things are coupled by nature/design,
    nothing to do with how you code it

    View full-size slide

  44. Why Game Programming is Messy
    A. Impossible to know what will actually work
    B. Many things are coupled by nature/design,
    nothing to do with how you code it
    A+B = layers of workarounds,
    unexpected complexity & bugs/crashes
    hard to keep code clean

    View full-size slide

  45. Cross-Platform meaning?
    C/C++ is a portable language.

    View full-size slide

  46. Cross-Platform meaning?
    C/C++ is a portable language.
    But use cross-platform libs & tools & getting
    all the code to compile is only the beginning.

    View full-size slide

  47. Cross-Platform meaning?
    C/C++ is a portable language.
    But use cross-platform libs & tools & getting
    all the code to compile is only the beginning.
    Some libraries may not be maintained well.

    View full-size slide

  48. Cross-Platform meaning?
    Deployment & UX adjustments is PITA.

    View full-size slide

  49. Cross-Platform meaning?
    Deployment & UX adjustments is PITA.
    - OSX *.app formats

    View full-size slide

  50. Cross-Platform meaning?
    Deployment & UX adjustments is PITA.
    - OSX *.app formats
    - ManyMouse (old) on Linux

    View full-size slide

  51. Cross-Platform meaning?
    Deployment & UX adjustments is PITA.
    - OSX *.app formats
    - ManyMouse (old) on Linux
    - Android apk filesystem restrictions
    - etc

    View full-size slide

  52. Cross-Platform meaning?
    Deployment & UX adjustments is PITA.
    - OSX *.app formats
    - ManyMouse (old) on Linux
    - Android apk filesystem restrictions
    - etc
    May be better to focus on 1 platform at a time,
    but keep code portability at all cost.

    View full-size slide

  53. Overview
    Libraries Used (with some in-house ones)
    - especially: Easing Functions & Custom Dictionary
    Development Issues (that I think is interesting)
    - AI design & impl
    - Why game programming is messy
    - Cross-platform?
    All (?) the Mistakes (??)

    View full-size slide

  54. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "MVP"
    Presenter
    View Model

    View full-size slide

  55. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "MVP"
    Presenter
    View Model
    Presenter bind view's method to model's function object

    View full-size slide

  56. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Well.. why not

    View full-size slide

  57. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Well.. why not
    View
    Model

    View full-size slide

  58. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Template setter & getter for view objects:
    obj->set(vec2(100, 200)).set(128);

    View full-size slide

  59. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Template setter & getter for view objects:
    obj->set(vec2(100, 200)).set(128);
    And because it looks cool:
    obj->onPress(button) = bind(function, ...);

    View full-size slide

  60. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Pre-processed C++ source/header

    View full-size slide

  61. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Pre-processed C++ source/header
    Using eruby (erb-like) to proc. embedded ruby

    View full-size slide

  62. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Pre-processed C++ source/header
    Using eruby (erb-like) to proc. embedded ruby
    Model.cpp.eruby -> preprocess -> Model.cpp

    View full-size slide

  63. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Pre-processed C++ source/header
    Using eruby (erb-like) to proc. embedded ruby
    Model.cpp.eruby -> preprocess -> Model.cpp
    Debug hooks
    Auto #ifndef #define #endif block for headers
    Generate property getter/setters.
    Expand Boost.object_pool signatures.

    View full-size slide

  64. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "Multiple-View System"

    View full-size slide

  65. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "Multiple-View System"
    There was a time when 2D/3D switches seemed
    cool to us.

    View full-size slide

  66. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "Multiple-View System"
    There was a time when 2D/3D switches seemed
    cool to us.
    And we also thought maybe we need multiple
    view presentations.

    View full-size slide

  67. All the Mistakes
    Questionable/Bogus stuff & decisions we had

    View full-size slide

  68. All the Mistakes
    Questionable/Bogus stuff & decisions we had

    View full-size slide

  69. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "Multiple-View System"
    void go_exploding(int color_id){
    BOOST_FOREACH(pViewBase& view, view_slaves_){
    if(view)
    view->go_exploding(color_id);
    }
    view_master_->go_exploding(color_id);
    }

    View full-size slide

  70. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    "Multiple-View System"
    void go_exploding(int color_id){
    BOOST_FOREACH(pViewBase& view, view_slaves_){
    if(view)
    view->go_exploding(color_id);
    }
    view_master_->go_exploding(color_id);
    }
    It hasn't been utilitzed. ....Yet.

    View full-size slide

  71. All the Mistakes
    Questionable/Bogus stuff & decisions we had

    View full-size slide

  72. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Read the book already even
    before we started,
    clearly that was not enough.

    View full-size slide

  73. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Read the book already even
    before we started,
    clearly that was not enough.
    The last 10% need 90% time,

    View full-size slide

  74. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Read the book already even
    before we started,
    clearly that was not enough.
    The last 10% need 90% time,
    and it is recursively true.

    View full-size slide

  75. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Biggest Mistake:

    View full-size slide

  76. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Biggest Mistake:
    The game isn't out yet.

    View full-size slide

  77. All the Mistakes
    Questionable/Bogus stuff & decisions we had
    Biggest Mistake:
    The game isn't out yet.
    (hopefully we can get it done before Spring is out,
    but Spring includes May... hmmm)

    View full-size slide

  78. Thank you for listening!
    Q & A
    [email protected]
    gplus.to/jslin
    johnson_lin @ plurk

    View full-size slide