• 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
adt7

Long Time Coder, First Time Going Cross-Platform

6 posts in this topic

I'm not sure if this really belongs in for beginners, since it's not really a beginner question. However I feel like I'm a beginner due to my ignorance when it comes to cross-platform development.

---

A friend and I have finally finished building a fully working prototype of our 2D game (we still need to produce some more content and assets, but all the mechanics are there).

We set out to develop the game primarily for the three major mobile platforms (iOS, Android, Windows Phone 8) and the Windows Store, with Windows (non-Store), Mac and Linux as a secondary objective. Unfortunately, we didn't really think about how we were planning to achieve this in the beginning.

Ideally I want to avoid using a "write once, build anywhere" engine as I want to avoid licensing fees and this is our first time trying to go cross-platform so I'm hoping it will be a good learning experience.

Thankfully our prototype has been written so that it should be easy to seperate the code for the game mechanics and the graphical display.

I think I've identified a set of technologies that will allow us to re-use the majority of code accross all/most platforms, but I was looking for some input/advice before we set this in stone and start re-writing our prototype.

Window Creation/Input/etc.
Some platform specific "glue" (i.e. Java for Android) to create a window, handle input etc. built for each platform.

Game Mechanics
C/C++ (Compiled separately for each platform, preferably straight C if we can get away with it)

Graphics
Windows Store/Phone 8
C++ & DirectX
iOS/Android
C/C++ & SDL

My first set of questions is that we're having difficultly determining if this approach will work for the Windows Store/Phone version, specifically:

  • Can we reference external C libraries in a Windows Phone/Store app?
  • If not, will we have to re-write everything in C++/CX or are we able to use regular C/C++ for the generic parts?

The next question I think is more a symptom of my own ignorance of C++/Objective-C more than anything else:

  • As C++/Objective-C are supersets of C, if I write straight C, can I simply compile it as C++/Objective-C on the platforms where that is required? This seems like I'm asking a really stupid question here, but I just want to make sure I'm not missing something.
Edited by adt7
0

Share this post


Link to post
Share on other sites

Which version of windows phone are we talking? Because windows phone 7 only supports C# or VB.net with XNA. Windows phone 8 does allow native code with directX.

As far as I know there are no libraries or engines with any support for windows phone 8 at this time.

0

Share this post


Link to post
Share on other sites

Sounds like you've got the right idea. In C/C++, cross-platforming is usually done with #ifdef, preferably with all the platform-specific code relegated to a few files. Although there is the issue of only being able to use the highest functionality that's common between ALL systems you're targeting, which usually means wasting a lot of potential from each individual system. So, sometimes you end up with a few more code switching spots to toss in a little extra on systems that can handle it.

 

SDL is one of the best cross-platform libraries around, because it's free and lightweight, therefore people generally make versions of it for any and everything. You may not even need anything more.

 

Otherwise, you'll need to figure out the common functionality for all the libraries on all the systems you're using. For example, how to blit a character to the screen in DirectX, versus how to do it in SDL, and how to do it in whatever Macs use. Then design your wrapper function to where it has all the options your game needs, and write the 2 or 3 versions of it that translate the options into each target library's blit function.

 

Same with loading assets. The game just says "Load Bob's walk cycle", and then the load wrapper function does whatever needs to be done on the current platform. Allocate VRAM and load the file, or maybe create a texture map in OpenGL if you were using 3D to render 2D on one platform. Then return a handle object (a class you write), which the game never looks into, but just passes around to other wrapper functions. On one platform it might contain a DirectX handle, on another it might just contain a VRAM address, or it might contain a whole image class that you wrote yourself, including an allocated memory block for the data. But from the game code perspective, it's just a handle, and all you need to remember is to delete it when you're done with it so it can do any platform-specific cleanup it needs to do.

0

Share this post


Link to post
Share on other sites
Which version of windows phone are we talking? Because windows phone 7 only supports C# or VB.net with XNA. Windows phone 8 does allow native code with directX.

As far as I know there are no libraries or engines with any support for windows phone 8 at this time.

 

We're just planning on targeting Windows Phone 8.

 

Sounds like you've got the right idea. In C/C++, cross-platforming is usually done with #ifdef, preferably with all the platform-specific code relegated to a few files. Although there is the issue of only being able to use the highest functionality that's common between ALL systems you're targeting, which usually means wasting a lot of potential from each individual system. So, sometimes you end up with a few more code switching spots to toss in a little extra on systems that can handle it.

 

Rather than this the only stuff I'm planning on taking a "write once" approach are the game mechanics, i.e. the model. Each of the platform projects will be completely standalone and will reference this and the appropriate graphics code. Therefore if I need a slightly different approach between SDL and DirectX this shouldn't be a problem, since the only place these interface differences will appear is in platform specific code.

 

SDL is one of the best cross-platform libraries around, because it's free and lightweight, therefore people generally make versions of it for any and everything. You may not even need anything more.

 

I know I'll at least need more for Windows Phone/Store, but I'm hoping SDL will do the job fr everything else, from everything I've read it looks like it.

0

Share this post


Link to post
Share on other sites
Window Creation/Input/etc.
Some platform specific "glue" (i.e. Java for Android) to create a window, handle input etc. built for each platform.
Among the platforms you listed the only glue would be on iOS using Objective-C or Objective-C++ in a maximum of 3 files.
For Android, use NativeActivity (or better yet, conserve your sanity and don’t target Android). Seriously if you are just starting out in cross-platform development you shouldn’t compound your troubles by doing native development for Android. I watched my coworker’s heart turn black starting since his task was to port our engine to Android, and I am still trying to change his heart back to its original green.

My first set of questions is that we're having difficultly determining if this approach will work for the Windows Store/Phone version, specifically:
  • Can we reference external C libraries in a Windows Phone/Store app?


Yes.

The next question I think is more a symptom of my own ignorance of C++/Objective-C more than anything else:
  • As C++/Objective-C are supersets of C, if I write straight C, can I simply compile it as C++/Objective-C


Yes.


L. Spiro
0

Share this post


Link to post
Share on other sites
<p><p>





Window Creation/Input/etc.
Some platform specific "glue" (i.e. Java for Android) to create a window, handle input etc. built for each platform.

Among the platforms you listed the only glue would be on iOS using Objective-C or Objective-C++ in a maximum of 3 files.
For Android, use NativeActivity (or better yet, conserve your sanity and don’t target Android). Seriously if you are just starting out in cross-platform development you shouldn’t compound your troubles by doing native development for Android. I watched my coworker’s heart turn black starting since his task was to port our engine to Android, and I am still trying to change his heart back to its original green.

<p><p>My first set of questions is that we're having difficultly determining if this approach will work for the Windows Store/Phone version, specifically:

  • Can we reference external C libraries in a Windows Phone/Store app?
Yes.

The next question I think is more a symptom of my own ignorance of C++/Objective-C more than anything else:
  • As C++/Objective-C are supersets of C, if I write straight C, can I simply compile it as C++/Objective-C
Yes.


L. Spiro
Hmm, my long post disappeared....

Ah well, Just wanted to add, i started making my own Android/iOS game/"engine" (And i've made crossplatform games/"engines" for Win+Linux before) and quite quickly switched to Unity when i noticed just how much time i would have to spend fixing device or version specific issues. (just look at the changelog for Unity3D, Android gets more than twice the number of fixes iOS does, a fairly large number of the Android fixes are for a specific device, a specific architecture, a specific Android version (or group of versions), a specific GPU/GPU vendor, etc. it is quite nice to have someone else take care of that mess for you. (Allthough Unity obviously havn't fixed all device specific issues since they keep adding new device specific fixes in each minor release) Edited by SimonForsman
0

Share this post


Link to post
Share on other sites

Using OpenGL, developing for android and iOS is very similar. The difficulty is Windows Phone 8. I am not sure that they will even let you upload native code to the device without an expensive developers license.

 

That aside, I would suggest creating a very basic 2D engine in OpenGL and DirectX with the same interface so your game will compile on both seemlessly when it comes to making builds for each of the platforms. This is the approach I am taking with my software, but luckily I don't have to worry about DirectX or Windows Phone platforms.

 

Another option could be SDL, but again I don't think the Windows 8 Platform will allow it to work.

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