• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Liza Shulyayeva

Advice for managing two different codebases for one game using Git (browser and iOS versions)

6 posts in this topic

I'm making a JavaScript and HTML5 game. I mostly work in the browser on my Mac, but the final ideal goal is to deploy on iOS as well as browser. Therefore at least a couple of times a week I compile the entire thing using a different framework to deploy to and test on my iPhone. Most of the code ports over nicely, but as you can probably expect some parts require modifications and tweaking (not to mention the fact that the browser version does not need the framework files). This results in my having to change up various piece of code in both files on the day that I test the port. I try to consolidate the code as much as possible and sometimes end up making edits to the iOS code that are ported back to the browser code, or vice versa. Juggling two codebases for the same game can get quite confusing and a hassle in general.

The editing timeline basically looks like this: [list=1]
[*]Work on browser version, add new features, test, etc. Doing this in the browser allows me to work [i]much[/i] more efficiently than compiling and testing in Xcode each time.
[*]End of week port entire thing to iOS framework, deploy to iPhone
[*]That day fix any problems in iOS port, try to consolidate code between the two as much as possible. This results in tweaks being done in both codebases and copies/pasted between each other that day
[*]Continue working on browser version until next port
[/list]
Right now I use Git for version control, hosting my code on Github for the browser version of the game. I have a dev and master branch. I do not currently use version control for the iOS version at all because I do not know the best way to set this thing up. Should I maintain the entire iOS codebase including the framework in another branch of my main game repo? Should the iOS version be in its own repo? Ideally I'd be able to set it up so that I can just pull relevant files from the browser branch to the iOS branch when I'm testing the port (but sometimes parts of the code would need to be left out, as there are some differences required), then push necessary changes back to both the browser and iOS versions of my hosted code.

I'm not a Git expert and am just not sure what the best way is to go about this. Right now I mostly use it for keeping a main working version of the game in one branch and merging the development branch into it when experimental stuff gets finalised. Fiddling with two sets of code on these porting days is getting confusing and I'm finding myself making mistakes, plus wasting tons of time. Can anyone advise how one might manage this kind of thing better? Edited by Drakonka
0

Share this post


Link to post
Share on other sites
First, you should use source control for [i]all[/i] your source, all the time. This is a lesson you do not want to learn the hard way.

Second, I would set up everything in one remote git archive on separate branches, and have (at least) two local git clones, one for your browser work and one for your iOS work. You can pull and push from each to the remote archive, and cherry-pick back and forth as much as you please. Just remember to always work on a branch until you;re happy, then merge to your main branch -- that way you can cherry-pick entire branches from one project to the other in one go.

If you can factor your code base into appropriate modules (libraries, frameworks) so the the common code is separate from the non-common code, that would also make merges easier.
2

Share this post


Link to post
Share on other sites
Thanks for your suggestions. Ashaman, I'm afraid the solution you suggest is a bit over my head at the moment. I'll have to read up on pre-processors and learn more before I can feel confident in using something like this, but thank you for pointing me in the right direction!

Bregma, I think this is the way to go for me at the moment. I'll try setting this up when I get home tonight in the way you suggest.

Thanks again, I appreciate the advice.
0

Share this post


Link to post
Share on other sites
Sounds like you're on the right path. As far as pre-processor, think a python script that looks for:
#StartIPhone
....
#StopIPhone

#StartBrowser
...
#EndBrowser

Then spits out a file only including the code between the proper #defines.
You would keep a source folder, and the preprocessor would spit copies of the file out into your build directories
So, you would probably want to set up a folder hierarchy like:
Project
+- Source
+- BrowserVersion
+- iPhoneVersion
+-+- Support files
+-+- Js Files
So, lets say you have game.js, in there you would have

function DoSomeStuff() {
CallingMoreFunctions();
#StartIPhone
iPhoneSpecificNumber += 1;
#EndIPhone
#StartBrowser
IncreaseBrowserNumber();
#EndBrowser
DumbExampleIKnow();
}

then you could run your python script
python preprocessor.py somefile.js
which would copy somefile.js to both your html and ios build directories. The iPhone version does not contain the Start/End Browser block, and the browser version does not contain the Start/End IPhone block.

Run, test, edit, rinse repeat.

I only say python because it's what we use at work, any language would work. Edited by uglybdavis
1

Share this post


Link to post
Share on other sites
Yes, this is a good example for preprocessors. What preprocessors do basically format your code before passing it on to the compiler. So essentially, you can add/remove certain parts of the source code depending on the flags of the preprocessors you have setup.

For example: you have this code:

[CODE]
doSomething();
#if IPHONE
doiPhoneStuff();
#elif WEB
doWebStuff();
#endif
doSomethingElse();
[/CODE]

Before compiling for iPhone, you set IPHONE variable to true, and WEB to false, and thus the code after being preprocessed will look like this:

[CODE]
doSomething();
doiPhoneStuff();
doSomethingElse();
[/CODE]
1

Share this post


Link to post
Share on other sites
Ah ok, I see what you mean. I'll look into this. I still want to start off by setting up version control for the iOS version properly and seeing how much I can get done with branches to begin with (as I've been meaning to learn to use Git more efficiently as it is anyway), but I think this is something that can definitely come in useful for me in the future, so I'll be sure to learn more.

Thanks for the awesome examples!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0