Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Case Study: Finalhit Incorporates C++ and Cocos2d-x in Windows* Desktop Game Development

$
0
0

By Karen Marcus

Case Study: Finalhit Incorporates C++ and Cocos2d-x in Windows* Desktop Game Development [PDF 980KB]

In 2012, 30 developers participated in the Europe, Middle East, and Africa–based Ultrabook™ Experience Software Challenge. Intel held the challenge to foster developer creativity in enhancing the user experience with Ultrabook devices. Participants had six weeks to develop original applications that integrated touch, gesture, and voice functionality. Finalhit Ltd. was a participant and won third place for its application, Live Ball, which the team developed specifically for the challenge. The game enables players to use the keyboard and mouse, touch, or device tilting to keep a beach ball from touching the ground (see Figure 1). Ivan Petrovic, managing director, characterizes the game as “easy but addictive.”

Finalhit previously developed Ultra Screen Saver Maker, a leading screen saver creation tool. Live Ball is the first game the company has developed. The two applications have some common elements, including C++ as a programming language, use of the Windows* platform, entertainment value, and a keen awareness of customers’ use of mobile devices and the new breed of hybrid laptop–tablets.


Figure 1. Live Ball main menu and play screen

Initial Development Steps

For the challenge, the first task for the team was to find a 2-D game engine platform. Their requirements were based on the short deadline for the challenge, challenge guidelines, and the opportunity to develop for iOS* and Android*. The 2-D game engine had to:

  • Be simple to use and easy to learn
  • Include a physics engine
  • Be extendable to add support for touch and sensors
  • Support cross-platform functionality, including mobile phones

After extensive research, the team chose Cocos2d-x, which supports all desktop and mobile platforms, is an open source project, and is easily extendable. Petrovic notes, “Five hundred-plus million downloads of Cocos2d-x–based games worldwide sounded trustworthy, too.”

The Cocos2d-x game engine’s features satisfied several important requirements:

  • It compiles to native code for all platforms.
  • It is based on C++.
  • Games can be developed and fully debugged in Microsoft* Visual Studio* and Windows.
  • 95% of the code is portable.
  • It is open source and therefore fully extensible.
  • It supports Windows 8 Desktop and soon will support a Windows RT implementation.

Petrovic says, “We are going to release a Windows 8 Store app when Cocos2d-x fully supports it. All game platforms face this obstacle, because Microsoft doesn’t support OpenGL* on Windows RT, just Microsoft DirectX*. As of March 27, 2013, Microsoft China ported Cocos2d-x to Windows Phone 8; this is a major step toward implementing Windows RT support.” The team encourages other developers to adopt Cocos2d-x, because it supports platforms with a large market share.

The team also needed to choose the right programming language. Petrovic explains, “HTML5 is known to have performance issues on the current generation of mobile phones, so we wanted to explore other options. Lua-based engines are popular, but to extend them, we needed to develop things in C++. So, we figured C++ was the natural choice for a task like this.”

Development Process for Windows 8

Live Ball was designed as a Windows Desktop application. The team selected this option based on their familiarity with programming Desktop applications as well as the limited timeframe, as more time would have been needed for Windows Store app development.

Even with Desktop development taking less time, the biggest challenge for the team was the short deadline. Petrovic notes, “We had six weeks to develop a game from scratch, with touch and sensor support, with no previous experience programming games or touch and sensors.”

Though the application was designed for Windows Desktop, the team wanted to make it work on both Windows-based Ultrabook devices and mobile devices. Petrovic comments, “Existing game engines have just begun a Windows Store implementation, and they are far from stable.”

In the development process, the team did not use any Windows 8–specific features. Petrovic says, “We are happy to say that Live Ball works on Windows 8, Windows 7, Windows Vista*, and Windows XP; Apple iPhone*, iPad*, and iPod touch*; and Android.” He adds, “When designing games, you don’t have to follow any specific operating system user interface (UI) guidelines. Games usually run in full screen or in windowed mode, without much need for standard UI controls. In contrast, we realized that if we developed a Windows RT app only, we would need to sacrifice support for earlier Windows versions and mobile platforms. So we also developed the Windows Desktop app.”

Development Process for Ultrabook Platforms

With Live Ball, users can touch or tilt Ultrabook devices to run left or right to hit the ball. Petrovic observes, “Touch and sensors bring the mobile experience to Windows running on Ultrabook devices. We believe every game should offer as many ways to interact with it as possible. So, besides the mouse and keyboard, we’ve added touch and accelerometer support.”

Touch

Live Ball implements single tap to browse through menus and touch events as well as long touch and drag to move the character during the game. Petrovic explains how these touch actions were selected: “Single tap is a natural choice for browsing menus, because it is similar to mouse clicks (see Figure 2). Long touch is something most users are used to from playing games on mobile devices. Moving the character using long touch is more convenient than using the mouse in the game.”


Figure 2. When users tap or click a menu item, it grows larger, as with Start Game and High scores above.

Petrovic notes that it was important to properly identify the touch capabilities the operating system and device supported. He says, “We’ve extended the Cocos2d-x platform to support touch, so it properly registers and handles Windows WM_TOUCH messages. We’ve implemented full WM_TOUCH message logic and applied it to the Cocos2d-x concept. Cocos2d-x officially includes our code now.”

In addition, says Petrovic, “We’ve carefully implemented the Windows Touch application programming interface (API), including a check if the computer supports touch at all, while maintaining backward compatibility with previous Windows versions. Maintaining backward compatibility with previous Windows versions consists of checking whether each Windows Touch API function exists in user32.dll.”

“When touch was present,” adds Petrovic, “we stopped processing false mouse move/button messages and properly handled the WM_TOUCH message so Cocos2d-x would understand it. When a user taps the screen, Windows generates mouse messages for legacy app support. To avoid duplicate notifications, it was necessary to see whether it was the real mouse click or touch event by checking (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH.”

Sensors

At the start of the challenge, the team considered the available Ultrabook sensors to determine which were the most suitable for the game; they found that the accelerometer was a logical choice. Live Ball uses the accelerometer to move the character during the game.

Sensor development was challenging, because, says Petrovic, “There is a lack of real-world examples for sensor implementation in C++.” He continues, “Although native support for sensors exists in Windows 7 and later, it seems that prior to Windows 8, sensors were mostly neglected in Windows. This was a time-consuming task, so we decided not to submit such code for inclusion in Cocos2d-x but to stay close to source. We’ve implemented the SENSOR_TYPE_ACCELEROMETER_3D sensor, so users can tilt the device to move the character left or right to hit the balls.” He adds, “It is interesting to see users perform this on a laptop, as the action was exclusive to mobile devices before Ultrabook devices came along.”

The Ultrabook Experience Software Challenge

Finalhit had several key opportunities in this challenge:

  • Creating a game for the first time
  • Finding the right 2-D game engine platform
  • Finding the right programming language
  • Completing the application within the allotted time
  • Incorporating sensor implementation using C++ with few real-world examples

In developing for Ultrabook devices, the team was impressed with their fast boot time and their ability to resume operation from hibernation mode in just seconds. Petrovic says, “Ultrabook works like a charm; no additional performance optimization was necessary. It has great multimedia platform capabilities, and everything is built in for both fun and business. The integrated GPU is fast enough to process all our game needs without removing any sprite or background details. It is definitely the best laptop we’ve ever used.” He adds, “It still looks pretty unreal on a Windows platform. The great features that previously existed only in the mobile world—touch and accelerometer—provide a completely different experience for users playing our game.”

Finalhit views Live Ball as a proof of concept from which they can dive farther into game development. Petrovic notes that the company launched Live Ball based on its experience with the challenge, using all the features the team had already coded. Petrovic states, “We are in the process of finalizing an Intel® Perceptual Computing software development kit implementation, so in addition to keyboard, mouse, touch, and accelerometer, players will be able to play the game by using gestures and voice commands with Creative Interactive Gesture Camera. With this version, we will participate in the Intel® Perceptual Computing Challenge Phase 2.”

Summary

Finalhit Ltd. participated and won third place in the Intel® 2012 Ultrabook Experience Software Challenge. The company created the Live Ball game specifically for this challenge. Initial development steps included finding the right 2-D game engine platform and programming language. For the 2-D game engine platform, the team settled on Cocos2d-x, because it has the ability to support all desktop and mobile platforms, is an open source platform, and is easily extendible. The team selected C++ as the programming language. The game was developed as a Windows Desktop application based on the team’s familiarity with programming Desktop applications and the limited timeframe. The team incorporated touch, accelerometer, and speaker use into the game’s functionality. Users can tilt the Ultrabook device to move the game character and touch the screen to perform certain actions. The team had to extend the Cocos2d-x platform to support touch to properly register Windows WM_TOUCH messages and maintain backward compatibility with previous Windows versions. Sensor development proved challenging because of a lack of real-world examples for sensor implementation using C++. Through the development process, the team was impressed with several aspects of Ultrabook devices, including the fast boot time; recovery from hibernation mode; great multimedia platform capabilities; and fast, integrated CPU.

Company

Finalhit is an independent software development company founded in 2001 in London, United Kingdom. It strives to create extremely easy-to-use software without compromising innovation and cutting-edge technology.

The company has been programming in C++ for Windows for more than 10 years. Its flagship product, Ultra Screen Saver Maker, which creates screen savers, has had more than 500,000 downloads worldwide and has been used by thousands of companies, including Accenture, Adidas, Alcatel, BMW, DHL, IBM, Ingenico, Mercedes-Benz, Motorola, Nestlé, NextGen, Novartis, and Oracle.

About the Author

Karen Marcus, M.A., is an award-winning technology marketing writer with 16 years of experience. She has developed case studies, brochures, white papers, data sheets, solution briefs, articles, website copy, video scripts, and other documents for such companies as Intel, IBM, Samsung, HP, Amazon Web Services, Microsoft, and EMC. Karen is familiar with a variety of current technologies, including cloud computing, IT outsourcing, enterprise computing, operating systems, application development, digital signage, and personal computing.

Intel, the Intel logo, and Ultrabook are trademarks of Intel Corporation in the US and/or other countries.

Copyright © 2013 Intel Corporation. All rights reserved.

*Other names and brands may be claimed as the property of others.

  • ultrabook
  • Windows* 8
  • Windows store
  • Apps
  • Windows desktop
  • APIs
  • Ultrabook™ devices
  • touch
  • touch-enable
  • game development
  • sensor
  • Microsoft Windows* 8
  • Game Development
  • Microsoft Windows* 8 Desktop
  • Microsoft Windows* 8 Style UI
  • Sensors
  • Touch Interfaces
  • User Experience and Design
  • URL

  • Viewing all articles
    Browse latest Browse all 3384

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>