Qt Framework with Tools Designed to Streamline the Creation of Applications for Smartphones As Well As for Desktop OS
Total Page:16
File Type:pdf, Size:1020Kb
Getting Started With Mobile Programming For Beginners (Season 2) Prepared & Presented By : Engr. Sajid Ali Anjum (Nokia Developer Champion) Website : http://sajisoft.com Contact : [email protected] Review Of First Season Held in June, 2011 • Day 1 : Basics Concepts for Getting Started With Mobile Phone Development; Introduction to Qt. • Day 2 : JavaME • Day 3 : Flash Lite • Day 4 : Google Maps, Motion Sensor, Augmented Reality and latest technologies ; How to generate revenue from your apps/games Review Of 72 Hours Of Innovation • Project Stood First : Location Based Tracking System • Technology : Qt & Java • Members (09CS) : Muhammad Zeeshan Nawaz, Gulraiz Javaid, Naveed Afzal and Muhammad Shahid • Project Stood Second : Matrix Solver • Technology : JavaME • Members (10ES ) : Ihsan ullah, Ehsan Ul Haq, Saad Cheema, Furqan Hassan, Aamir Shahzad and Shamweel Qamar Review Of 72 Hours Of Innovation • Project : Open-Source Framework For Interfacing PC and Mobile via Bluetooth • Technology : Python & M-Shell • Members(08CS) : Awais Rafique and Jafri Gardezi • Project : 2D Car Racing Game • Technology : Adobe Flash • Members (10ES) : Muhammad Majid Khan, Ahmad Suleman, Ahsan Javed, Ubaid-ur-Rehman, Amara Javed and Anum Mazhar Review Of 72 Hours Of Innovation • Project : Battery Alarm • Technology : Qt • Developed By : 1st year of Computer Science (BSCS) • Members : Abdul Salam Ai, Abdul Salam, Sadam Ali and Abdul Latif Ali • Article @ Official Nokia Blog : • http://goo.gl/Bohgc Contents • Day # 1 : Motivation, Basics Of 2D Game Development, Qt Quick Basics, Developing hello world of 2D Gaming, Physics Engines & Hardware Acceleration. • Day# 2 : Basics Of Cross-Platform Development, Understanding MoSync and Porting our game to MoSync, TouchDevelop by Microsoft Research , understanding LBS & Sharing Ideas. Who is presenting ? • Sajid Ali Anjum, 07-11 batch, B.Sc. Computer Systems Engineering, UCET, The Islamia University Of Bahawalpur • Major Contributions : 1) Solved 1000+ software problems at Nokia Developer Discussion Board 2) Wrote number of articles at Nokia Developer wiki & at my blog. 3) Develop 15+ software projects for mobile phones using C++, Java, Qt, Adobe Flash, Python, M-Shell, MoSync, Haxe, HTML5, PHP and MySQL. Who is presenting ? • Major Achievements : 1) Nokia Developer Champion for three times in a row (Feb 2010-12). 2) Qt Ambassador, in Jan 2012. 3) Nokia Developer Poster Of The Month in Feb 2010. 4) Dzone Developer MVB (Most Valuable Blogger) in Sep 2010. 5) Nokia Developer Launchpad in Oct 2010. 6) Winner of TOP 250 Paid Games in Calling All Innovators 2011. 7) Finalist of PTA-Ericsson Mobile Excellence Award on Oct 2011 8) Publisher at Nokia Store under name “SajiSoft”, April 2010. 9) Offered pre-release testing by different top companies. 10) Worked with different companies on different projects. The Falcons Of Iqbal Dr. Allama Muhammad Iqbal Video Games • Video game is an electronic game that involves human interaction with a user interface to generate visual feedback on a video device. Gaming Facts • PEW Research , 97% of teens play video games. • Flurry Report : U.S. Mobile Game Revenue Passed Portable Games In 2011 • ABI Research, mobile gaming revenue is expected to reach from almost $4 billion in 2011 to $16 Billion in 2016. Few Success Stories • Angry Birds • Fruit Ninja • Doodle Jump • Sniper Action ……. Angry Birds by Rovio Mobile • Angry Birds Game, was released in December 2009 at Apple Store, Earns Over a Million a Month. • Up to Dec 2010, it got 50 million downloads and upto March 2012, it got 700 million downloads. Fruit Ninja by Halfbrick Studios • Fruit Ninja, was released in April 2010, Sold 200,000 copies over a month. • By March 2011, total downloads across all platforms exceeded 20 million. Doodle Jump by Lima Sky • Doodle Jump, was released in April 2009, Sold 200,000 copies over a month. • Doodle Jump, sold 15 million copies in 3 years. Games as an educational & training tool • Video games let people step into other shoes, make decisions, explore consequences, said Alan Gershenfeld of E-Line Media – all skills we need for the 21st century. • In games, the player has agency, which is very, very powerful. Games are participatory. You’re interacting, which is very, very powerful. Games are adaptive. They’re personalized. You can go at your own pace, advance at your own pace. • Article : goo.gl/vMOEG Development Cycle Create Deploy Design Test Code Build Create • Decide what sort of problem you want to solve ? • Idea ? • You can always get inspiration by looking around in your community and/or in different online communities ( like ideasproject.com , for gaming; flash games sites etc ) Design • We have to create the mock-ups, graphics and other design- related activities in this stage. • We have to use any image manipulation/processing software like GIMP, Adobe Photoshop, Adobe Illustrator, Inkscape etc. that serves our purpose to create required graphics. http://www.developer.nokia.com/Design/ Code • Write down the code to make the game digitally alive. Build • In this step, we have to compile the code and build executable , that are further executed, to test our code. • This step is mostly provided by the development tool and developer’s usually need a single click to move from this stage to the next one i.e. “Test”. Qt Build Toolbar Test • In this step, we test our executable in an emulator or simulator as provided by the SDK & also in the real device. Qt Simulator Control Deploy • Once your coding and testing is complete, you are ready to deploy your application and distribute it to millions of the users by registering and publishing at respective mobo stores; to start earning revenue. What is Qt? • The Qt SDK combines the Qt framework with tools designed to streamline the creation of applications for smartphones as well as for desktop OS. • Qt framework - intuitive APIs for C++ and CSS/JavaScript-like programming with Qt Quick for rapid UI creation. • Qt Creator IDE - powerful cross-platform integrated development environment, including UI designer tools and on-device debugging • Tools and toolchains - All you need: simulator, local and remote compilers, internationalization support, device toolchains and more. Qt SDK Qt SDK QML • QML (Qt Meta Language or Qt Modeling Language) is a JavaScript-based, declarative language for designing user interface–centric applications. It is part of Qt Quick, the UI creation kit developed by Nokia within the Qt framework. • QML is mainly used for mobile applications where touch input, fluid animations (60 FPS) and user experience are crucial. • QML elements shipped with Qt are a sophisticated set of building blocks, graphical (e.g., rectangle, image) and behavioral (e.g., state, transition, animation). Imperative vs. Non-Imperative • Imperative languages focus on how the program should follow it's tasks, while non-imperative languages, functional or logical, tell the program what it needs to do, as opposed on how to do it. • Procedural programming is imperative programming in which the program is built from one or more procedures. • Declarative programming is a non-imperative style programming, which expresses what the program should accomplish without prescribing how to do it in terms of sequences of actions to be taken. QML Basics • Lets learns basics of QML : • Basic syntax • The id property • Property bindings • States • Animation Hello World Of 2D Gaming • Lets practically develop our first game and learn basics of 2D Gaming. • A classic game of Pong , implemented in QML. Download source code from here : http://sajisoft.com/workshops/mobopong.zip Simple Rectangle-Rectangle Collision • Simple Rectangle to Rectangle collision is as follow : x,y x+width,y Sprite x, y+height x+width, y+height X,Y (0,0) X increasing Y Increasing Simple Rectangle-Rectangle Collision • Simple Rectangle to Rectangle collision is as follow : • bool sprite_collided(int x1,int y1, int w1,int h1, int x2,int y2,int w2,int h2) { int left1, left2; int right1, right2; int top1, top2; int bottom1, bottom2; left1 = x1; left2 = x2; right1 = x1 + w1; right2 = x2 + w2; top1 = y1; top2 = y2; bottom1 = y1 + h1; bottom2 = y2 + h2; if (bottom1 < top2) return false; if (top1 > bottom2) return false; if (right1 < left2) return false; if (left1 > right2) return false; return true; } Circle-Circle Collision • Simple Rectangle to Rectangle collision is as follow : Sprite X,Y (0,0) X increasing One can detect this collision by : (x2-x1)^2 + (y1-y2)^2 <= (r1+r2)^2 i.e. the distance between the center points is less Sprite A than the sum of the radii. Sprite B Y Increasing Other Collisions • There are many other type of collisions like rectangle-circle collision, rotated rectangle-rectangle collision etc. • This workshop target beginners, thus , I am leaving these topics for the students to explore. Physics Engines • A physics engine is computer software and/or libraries that provides an approximate simulation of certain physical systems, such as rigid body dynamics(including collision detection), soft body dynamics, and fluid dynamics, of use in the domains of computer graphics, video games and films. Box2D • Box2D is a free open source 2D physics simulator engine written in C++. • It is ported to QML, JS, C#, AS3 and many other languages. • It is one of a very famous engine for 2D games and also used in many of the commercial games including one of a big success ‘Angry Birds’ Getting Started With Box2D (QML) • Go to https://gitorious.org/qml-box2d and download the source code. • Extract the downloaded zip file and read the “README” file inside it to understand that how to compile the code and install the libraries. • Once you compile the code, you are ready to create your first game using Box2D. • Let’s do a hello world using Box2D practically. Graphics Hardware Acceleration • Modern Smartphones use Graphics Processing Unit (GPU) for efficient manipulation of computer graphics. • To take advantage of GPU , we have to use the APIs that provide support of hardware acceleration like OpenGL ES, OpenVG etc • If Hardware Acceleration is not used in heavy graphics game then there is a decrease in performance of the game.