游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

如何有效地开发一款跨平台游戏

发布时间:2015-11-11 14:44:58 Tags:,,,,

作者:Benjamin Justice

作为游戏开发者同时也是linux的用户,来自BrutalHack的我们会在自己的项目中尽可能地支持更多平台。因为看到许多开发者在reddit和Twitter上鼓推这一主题,所以我们决定在此分享我们所掌握的知识。

“跨平台开发是很昂贵的”

这是游戏开发中一种常见的误解,我们也希望能够清楚地告诉你们如何在避免花费过多成本的前提下支持跨平台(台式机,手机和主机)开发。

在后半部分内容中我们会提供自己的测试建议并推荐一些较便宜的硬件。

移植很危险

大多数开发者都是面向一个系统开发游戏,并在近乎完成的时候开始“移植”游戏。这将会在游戏开发末尾引致一些全新要求。来自软件工程师和项目管理者都知道,这种事后要求有可能摧毁整个项目。

requirements-change(from gamasutra)

requirements-change(from gamasutra)

有许多游戏在公开linux发行后便掉进了这种陷阱中。像《Gauntlet》,《Divinity:Original Sin》和《Contagion》便是最近的一些典例,它们都因为各种原因而不能完成其linux版本游戏。虽然这些游戏工作室已经有好几年的Windows开发经验,但对于他们来说跨平台却是一个全新领域。

我们希望能够帮助你们避开这些陷阱并开启成功的跨平台之旅。

跨平台的心态

当你在计划开发一款跨平台游戏时,你应该使用能够交叉编译你的目标平台的游戏引擎。此外你还需要专注于一些要点:

纵横比—-你可能会遇到需要将4:3的内容变成21:9的比例

屏幕大小—-包括智能手机,平板电脑和台式机。其范围可能是从4英寸到40英寸以上不等。

通过仿效不同的屏幕大小你便能够轻松应对这两个要点。

音频和视频解码器—-不同平台支持不同的解码器。

平台特定的设计功能—-不同平台拥有不同的界面和功能。

台式机

多亏了Valves SteamPlay,面向三个常见的桌面平台发行游戏变得更普遍。毫无疑问,Windows拥有最大的市场份额,但是OSX和Linux的用户更乐意购买相关平台的游戏以支持平台开发。

三个平台的输入方法几乎都是一样的。但是你必须留意第三方插件和框架的兼容性。除此之外,你还需要测试一些重要的差异:

不同平台的文件系统是不同的。甚至连路径语法也是不同的。

Windows—-不区分大小写,主目录:C:\Users\Dude\

OS X—-不区分大小写,主目录:/Users/Dude/

Ubuntu/SteamOS—-区分大小写,主目录:/home/Dude/

显卡驱动程序—-Intel,AMD和nVidia驱动程序在不同平台是不同的。你必须尽早测试它们的功能(游戏邦注:如色器模型版本)和兼容性。

你的游戏是否有效整合到平台的管理器中了?

手机

在手机平台上你将看到其它输入方法,即你必须将其与台式机输入方法结合在一起。这类型平台拥有最多样化的显示方式。以下是手机平台间存在的一些特殊区别:

与Windows Phone相比较,Android和iOS上的文件系统是区分大小写的。

不同平台间的文件系统访问权限是不同的。

Windows Phone 8.1只支持shader model 2。

受欢迎的Unity的“Spine”工具并不支持Windows Phone。开发者知道该问题及其解决方法,并且他们好像不打算解决它。你必须为了平台兼容性而不断检查相关资产。

在Unity,如果你面向的是Windows Phone,那我们推荐使用Mono编译器而不是微软具有最大兼容性的编译器。

主机

免责声明:几乎所有关于主机开发包的东西都是基于保密协议。因此我们不能告诉你我们是否拥有任何主机开发包。我们能够提供的信息都是一些面向公众的信息。

当前的主机拥有与台式机相似的硬件以及与手机相似的应用生态系统。我们将讨论测试环节中的开发包。

主机平台拥有以下的区别:

主机支持不同的着色语言:

Xbox One:HLSL(Direct X 11)

PlayStation 4:PlayStation Shader Language(GNM,GNMX)

Wii U:??? (GX2)

Unity:GLSL着色器不能交叉编译

游戏通常是运行于沙盒中,这将限制你的文件系统的访问权限

不要遗漏一些特殊的外围工具,如Wii控制器

跨平台游戏测试

设备是非常昂贵的。特别是对于独立开发者来说,当你刚起步时你是不可能购买所有可行的系统。然而如果你遵循我在上述所提供的建议,你在一开始便只需要一个较小的测试环境。

如果你开发的并不是原生跨平台多人游戏,你便只需要确保你的游戏是从所有的系统起步便可。

如果你使用了Unity,Java或其它跨平台环境,你便可以假设交叉编译器/虚拟机能够确保你的游戏在所支持的所有设备上保持逻辑的一致性。

随机选择一个系统去测试一个新功能是一种好方法,因为对于游戏逻辑测试来说平台并不是很重要。

在发行任何版本的游戏前,你应该明确地在每个目标平台上测试游戏。如果你忘记任何微小的重属性,这可能会导致非常尴尬的情况。

最小的测试环境

免责声明:我们的总部在德国,所以所有价格都是基于德国的零售价(更新于2015年10月)。

让我们假设我们正在使用Unity 5开发一款游戏,即我们需要谨慎对待所有跨平台问题(游戏邦注:如不同的纹理格式)。

我们的潜在目标平台是:

台式机—-Windows,OS X,Ubuntu/SteamOS(Linux)

手机—-iOS,Android,Windows Phone 8.1

主机—-Xbox One,PlayStation 4,Wii U

我们想要减少我们需要购买的设备数量,但却仍希望能够有效地测试我们的游戏。通过使用上述建议,我们建议你在最初测试环境中的预算不要超过200欧元。

台式机

这些平台都比较相似。如果你遵循我们在上面的建议,你便能够使用你的开发机器先测试游戏了。你可以在你的Windows(或OS X)计算机上安装linux并基于区分大小写与不区分大小写的系统去测试你的游戏。你应该确保你的游戏能够有效运行于Windows(或OS X)以及Ubuntu WIndow Managers上(最小,全屏)。

这些平台提供了相似的外围装置,支持键盘/鼠标以及控制器输入内容。我们建议你最好购买一台Xbox 360控制器,因为“plug’n play”兼容性支持Windows和Linux系统。对于Mac,你还需要一个驱动程序。

推荐的“初始”桌面设置(30欧元):

你的开发计算机(如果它是基于较低分辨率的图像而运行,这也足够了)

Xbox 360控制器(30欧元,全新的)

手机

尽管手机设备拥有相同的触屏外围装置和传感器,但是它们的OS却具有很大的区别:iOS,Android和Windows Phone的文件系统访问也是不同的,所以你应该在游戏发行前去测试所有的文件操作。

我们建议你能够购买拥有高通四核CPU和1GB内存的最便宜的触屏设备。

推荐的“初始”手机设置(70至150欧元):

Windows Phone—-微软Lumia 532(我们花了70欧元买了一台全新的)

可选择的:最便宜的Android平板电脑是Amazon Fire(75欧元)

主机

当你在面向主机开发一款游戏时,你应该协调好计算机和控制器(Xbox 360控制器能够作用于Windows和Ubuntu/SteamOS)。

这里常出现的一个话题便是主机开发包的价格。索尼和任天堂对于PlayStation 4的开发包的价格还保持着沉默,而微软则表示如果他们认同你的游戏理念便能够免费提供给你Xbox One开发包。

我们建议你能够先使用免费的Xbox One开发包,然后再选择其它开发包(游戏邦注:因为开发包通常都不便宜)。

主机制造商都会要求你签订一份带有保密协议的合同。你应该仔细阅读这两份文件。文件可能会包含你可以使用开发包多长时间以及有关你的游戏发行等重要信息!

完成测试环境

在面向所有平台发行你的游戏前,我们必须在真正的硬件上测试它。以下设置将花费大概2350欧元,包括苹果的OS X和iOS。当然了你可以暂时使用朋友的系统去节约成本。

比较起来,只有Windows版本的我们完整的桌面设置只省下关于Mac Mini的500欧元。

推荐的“完整的”桌面硬件(1630欧元左右):

带有具有集成GPU和双重引导的AMD A10 CPU:Windows 10和Ubuntu 14.04(400欧元左右,全新的)

带有Intel CPU+集成GPU+具有双重引导的专用的nVidia GPU:Windows 10和Ubuntu 14.04(500欧元左右,全新的)

如果你很有钱的话,你可以买一台带有nVidia GPU的MAC(在ebay上是1500欧元左右)以及带有AMD GPU的Mac(2000欧元全新的)

“Hackintoshes”是非法的。所以我们不需要在这里讨论它。

Xbox 360控制器(大概30欧元左右,全新的)

PC的两个Windows 10授权(200欧元左右)

Windows 7和Windows 8.1将继续拥有不错的市场份额,所以你应该确保你的游戏能够开始并运行于这些较早的OS上。

推荐的“完整的”手机硬件(695欧元左右):

Windows Phone:微软Lumia 532(我们花了70欧元买了一台全新的)

Android:Motorola Moto G第一代(150欧元全新的)

Windows:你可以购买一台拥有更好的驱动程序的Nexus 5(320欧元左右)

最便宜的Android平板电脑是Amazon Fire(75欧元)

iOS:iPad mini 4(400欧元左右)

通过购买Lumia 532,Moto G,Kindle Fire和iPad mini 4,你便能够测试最重要的纵横比以及屏幕大小,同时还能涵盖所有主要的手机OS。你必须记住大多数工作流程都需要一台Mac去配置iOS。

结论

当我最初开始开发跨平台软件和游戏时,我们非常惊讶于代码库所呈现出的诸多好处,因为跨平台代码不需要对根本操作系统做出过多假设。基于像Unity 5等现代引擎,跨平台开发变得更加简单了。

本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转发,如需转载请联系:游戏邦

How to Develop for Cross-Platform

by Benjamin Justice

Hello,

as game developers and linux users, we from BrutalHack support as many platforms as possible in our projects (applications and games). Seeing that many developers struggle with this topic on reddit and twitter, we decided to share our knowledge on this topic.

“Cross-platform development is expensive”

This is a common misconception in game development and we want to give you insights on how to support multiple platforms (desktop, mobile and console) without large costs and why people believe elsewise.

In the second half we offer testing advice and recommend cheap hardware.

Ports are Dangerous

Most developer develop their game for a single system and begin “porting” it when it is nearly finished. This introduces new requirements at the end of development. A (not so) secret knowledge of software engineers and project managers is that late requirements can destroy any project.

Many games have fell into this pithole after announcing a linux release. Gauntlet, Divinity: Original Sin and Contagion are recent examples of games which had problems completing their linux versions due to various reasons. After all, these studios have years of windows experience but cross-platform is completely new terrain for them.

We want to help you avoid these traps and help you begin your successful cross-platform journey :)

The Cross-Platform Mindset

When you plan to develop a cross-platform game, you should use a game engine which can cross-compile to your target platforms. Furthermore, you must pay attention to a some points.:

Aspect Ratio – You will encounter anything from 4:3 to 21:9

Screen Size – Smartphones, tablets and desktops. 4 inches to 40+ inches.

These two points can easily be covered by emulating different screen sizes.

Audio & Video Codecs – The supported codecs differ by platform.

Platform-Specific Social Features – The interfaces and functionality differ by platform.

Desktop

Thanks to Valves SteamPlay, it has become more common to release for the three common desktop platforms. While it’s out of question, that Windows has the largest market share, OSX und Linux users prefer to buy games for their platform to support the development.

The input methods are nearly identical among the three platforms. However you must pay close attention to the compatibility of third party plugins and frameworks. Apart from that, the important differences to test are:

Filesystems differ by platform. Even the path syntax is unique for windows.

Windows – case-insensitive, home directory: C:\Users\Dude\

OS X – case-insensitive, home directory: /Users/Dude/

Ubuntu/SteamOS – case-sensitive, home directory: /home/Dude/

GPU Drivers – Intel, AMD and nVidia drivers differ by platform. You must test the functionality (e.g. shader model version) and compatibility early (we’ll cover testing later). Testing compatibility & performance too late can result in a case like the Linux version of “Middle-earth: Shadows of Mordor”, which only supports nVidia GPUs.

Does your game integrate into the platforms’ window managers correctly? (minimize, fullscreen)

Mobile

On mobile you will face other input methods, which you must bring together with the desktop input. This category has the most versatile display types you will see. Here are the special differences between mobile platforms:

The filesystems on Android and iOS are case-sensitive in comparison to Windows Phone.

The filesystem access rights differ greatly by platform.

Windows Phone 8.1 only supports shader model 2

The popular Unity asset “Spine” does not support Windows Phone. The problem and solution are known by the developer and it seems he doesn’t intend to fix it. Always check assets for platform compatibilities!

In Unity we recommend using the Mono compiler for Windows Phone, instead of the Microsoft compiler for maximum compatibility.

Consoles

Disclaimer: Everything regarding the console devkits is under NDA. Thus we cannot tell you if we ever had any console devkits. All information we are giving you here is publicly available. We will decline any questions about devkits. Sorry :)

The current console generation has hardware similar to desktop computers, but an app-ecosystem similar to mobile devices. We will talk about devkits in the testing section below.

The console platforms have the following differences:

The consoles support different shader languages:

Xbox One: HLSL (Direct X 11)

PlayStation 4: PlayStation Shader Language (GNM, GNMX)

Wii U: ??? (GX2)

Unity only: GLSL shaders cannot be cross-compiled

Games usually run in a sandbox, which limits your filesystem access rights

Don’t forget unique periphery, such as Wii controllers

Cross-Platform Playtesting

Devices are expensive. Especially as an indie developer, buying all possible systems is just not possible when you start. However, if you follow the tips we gave you above, you only need a minimal testing environment at first.

If you are not developing native cross-platform multiplayer (floating point synchronisation), you only have to make sure that your game starts properly on all systems at first.

If you use Unity, Java or other cross-platform environments, you can assume that the cross-compilation / virtual machine will keep your game logic consistent across the supported platforms (unless you are doing something very exotic).

It’s good practice to randomly choose which system you test a new feature on, because the platform should not matter for testing game logic.

Before releasing any version of your game, you should definitely test it on each target platform. It’s quite embarassing to forget a small dependency which makes your game crash.

Minimal Testing Environment

Disclaimer: We are located in germany, so all prices are based on german retail prices (updated october 2015).

Let’s assume that we are developing a game with Unity 5, which takes care of many cross-platform issues (e.g. different texture formats).

Our potential target platforms are:

Desktop – Windows, OS X, Ubuntu/SteamOS (Linux)

Mobile – iOS, Android, Windows Phone 8.1

Consoles – Xbox One, Playstation 4, Wii U

We want to reduce the amount of devices which we have to buy, but still be able to playtest our game properly. By using the tips from above we will recommend you an initial testing environment for less than 200€ (Hardware listed in the next sections).

Desktop

These platforms are somewhat similar. If you follow our advice from above, you can use your development machine for testing at first. You can install linux on your Windows (or OS X) computer to test your game on a case-sensitive and a case-insensitive system. You should also make sure that your game runs on Windows (or OS X) and Ubuntu Window Managers correctly (minimizing, fullscreen).

These platforms offer similar periphery, supporting keyboard/mouse as well as controller input. We recommend buying an Xbox 360 controller due to the “plug’n play” support on Windows & Linux systems. For a Mac, you will need a driver.

Recommended “initial” desktop setup (30€):

Your development computer (If it runs on low graphics, its enough)

Xbox 360 Controller (~30€ new)

Mobile

While mobile devices all share the same touch-based periphery and sensors, their OS differ greatly: File system access differs between iOS, Android and Windows Phone, so you want to test all of your file operations before publishing.

In order to get started, we recommend buying the cheapest touch device available with a qualcomm quad-core cpu and 1GB of RAM.

Recommended “initial” mobile setup (70 – 150€):

Windows Phone – Microsoft Lumia 532 (We bought one new for 70€)

Optional: The cheapest Android tablet is the Amazon Fire (75€)

Consoles

When you are developing a game for consoles, you should be fine with a computer and a controller (Xbox 360 controllers work on Windows and Ubuntu/SteamOS out of the box).

A common topic is the price of console devkits. While Sony and Nintendo keep quiet on prices for PlayStation 4 Devkits, the Xbox One Devkit is available free of charge if Microsoft approves your game idea.

We recommend first applying for a free XBox One Devkit and then grab the other Devkits later (Devkits are usually pricey).

Console manufacturers will expect you to sign a contract along with an NDA. Read these two documents very carefully. The contract might include information on how long you may have a Devkit and other important information about your game’s release and publishing!

Complete Test Environment

Before you release your game on all platforms, we have to test it on real hardware. The following setup will cost around 2350€ including Apple OS X and iOS. Of course you can save money by abusing your friends’ systems for occasional testing, especially Apple hardware! :)

For comparison, the Windows-only version of our complete desktop setup only saves the 500€ for the Mac Mini.

Recommended “complete” desktop hardware (~ 1630€):

PC with an AMD A10 CPU with integrated GPU with Dual Boot: Windows 10 & Ubuntu 14.04 (~ 400€ new)

PC with an Intel CPU + integrated GPU + dedicated nVidia GPU with Dual Boot: Windows 10 & Ubuntu 14.04 (~ 500€ new)

Mac Mini (MGEM2D/A) (~ 500€ new)

If you are really rich, get one Mac with an nVidia GPU (1500€+ on ebay) and one with an AMD GPU (~ 2000€ new)

“Hackintoshs” are illegal. No discussion needed.

Xbox 360 Controller (~ 30€ new)

Two Windows 10 licenses for the PCs (~ 200€)

Windows 7 and Windows 8.1 will continue to have a great marketshare, so you should make sure that your game starts and runs on these older OS too.

Recommended “complete” mobile hardware (~ 695 €):

Windows Phone: Microsoft Lumia 532 (We bought one new for 70€)

Android: Motorola Moto G first generation (~ 150€ new)

Windows only: You can purchase a Nexus 5 for better driver support (~ 320€)

The cheapest Android tablet is the Amazon Fire (75€)

iOS: iPad mini 4 (~ 400€)

By purchasing the Lumia 532, Moto G, the Kindle Fire and the iPad mini 4, you can test on the most important aspect ratios and screen sizes, while also covering all major mobile OS. Keep in mind that most workflows require a Mac to deploy for iOS.

Conclusion

When we first began developing cross-platform software and games, we were surprised by the benefits for our codebase, because cross-platform code contains less assumptions about the underlying operating system. With modern engines like Unity 5 cross-platform development is more accessible than ever before.

Feel free to ask us questions about cross-platform development or linux development in thecomments section below or in social media :)source:Gamasutra

 


上一篇:

下一篇: