Web game development with Phaser: fast, fun and entertaining

In this article

    Creating web-based games is much easier than you can imagine. We added Phaser based game as an “easter egg” to our website in order to show you how powerful it is.

    Web application development and realization of the client's desires takes all our time. Our developers are always prepared to show creativity and bring fresh ideas to each project. Sometimes we even have to restrain our creative impulse to meet the requirements.

    So, what do we do in between?

    We choose leisure activity, not only physical but also the one within the world of development.

    Despite the weight of responsibilities which becomes our companion as we grow older and more experienced in our field, we always look for the opportunity for simply doing whatever we want to do.

    Here goes a background: some of our developers have grown watching the evolution of video games industry from its origin. For some of them this magic that appeared on the computer screen has become a kind of catalyst - how exactly does it all work? What does it consist of? Can I create something similar, but ten times cooler?

    That’s why we created such an “easter egg” on our website, spending around 40 hours (1 sprint) on it without any designer involved. We took phaser.js gaming framework as a basis, which allows developing browser-based 2D games of any genre for any platform with HTML5 support.

    This framework has an impressive array of features. Although most other frameworks include the same amount and variety of tools, we chose this one due to its flexibility and straightforwardness.

    Here are some key benefits of using Phaser:

    • does not require the disclosure of source code;
    • low weight and high performance (due to the Pixi.js rendering);
    • MightyEditor visual editor (animations, tiles and sprites usage support);
    • built-in sound support;
    • built-in physics (supports collision of objects);
    • flexibility (any detail is replaceable);
    • plugin support;
    • low entry barrier (e.g. we can move the player around the map using simple functions as moveToXY (), moveUp (), etc.);
    • vast community support and a large number of examples supplied with the framework (over 500);

    Almost each Phaser feature is visible on the official website and provided with examples with the source code and detailed comments attached.

    Here is a brief instruction of what you’ll need to get started.

    First, you need to install Phaser on your local server. You can do this by downloading the framework from the official repository on GitHub or using Bower or NPM. But the easiest way is to take advantage of the cdnjs.com service.

    The next step would be creating your ‘game.js’ file (this will contain the code of the game) and connecting it to the index.html. You should initialize Phaser.js, create the frame write the beginning of your future game. Specify the window size (e.g. 800x600), the type of render (e.g. selection between WebGL and Canvas), name and the main functions.

    Then you should declare a variable for the future `sprite.preload ()` contains code for loading resources. Try loading some image: the first parameter would be the name of the image, and the second is the path to it.

    Create the sprite from the image that you have just uploaded and place it in the center of the screen, then you should launch the arcade physics in the game and make it available for the `sprite.update ()` is called 60 times per second. It is designed for updating positions and deleting game objects (in general, it serves to create the whole dynamic part of the game).

    If you want to make the picture move to the bottom of the screen just set the `velocity` parameter.

    We hope that this is enough for understanding the basics of working with Phaser. Don’t forget that Phaser.js has a very active and responsive community (sometimes even the creator himself answers questions on the forum).

    Getting back to our game, we took this example as the basis, replacing almost all the “guts” and using our own elements.

    screenshot old

    We increased the speed of the game and added several variations of landscape obstacles and tanks in order to make the gameplay more accurate and tactical.

    screenshot new

    We also implemented a power-up system, as well as ammunition and health bars; there’s a progressive system of levels - your tank will change its appearance, characteristics of speed and durability depending on the number of enemies killed.

    The indicator of enemy position at the edge of the screen tracks enemy tanks situated off the visible map so you can always be on the lookout.

    As a result, the only thing that remained from the original example was the enemy tank explosion animation.

    Maybe.War is still at the development stage and we will be adding as much new content as we can. In the nearest future, we want to implement destructible objects, new tank, and ammunition upgrades, new opponents (perhaps even bosses). Phaser gives a huge number of opportunities and helps developing other projects of greater volume (up to real-time strategies simply within the browser tab).

    We never dwell on one thing and have already had experience in developing browser games. We want you to keep in mind that some game projects have better compatibility with other solutions. Most of the rookie developers assume that the framework they have chosen will start to impose their skills and it makes them think that they are capable of great things by simply using a good tool. The world of development would be far easier to comprehend if this were true.

    Our competence allows us to improve not only within the scope of your project but also in our own development, gaining experience and even more joy. Our own elaborations help our team to constantly evolve and we are always aimed at directing all our strength to support your web application - be it a huge business platform or an educational game for children.

    TL;DR: Press CTRL+G right now and enjoy.

    Blog

    it-staff-augmentation-trends image

    The Future of IT Staff Augmentation: Emerging Trends and Predictions

    Today, we will discuss the most notable IT staff augmentation trends, as this service has gained incredible popularity among diverse companies. First, we will say a few words about outstaffing itself and those who use it, and then we will move on to the staff augmentation trends. The experts in this article are the top management of MaybeWorks, a company that has been augmenting IT specialists for many years.

    Jul 23, 2024
    ionic-developers-salary image

    Ionic Developers Salary for 2024: Guide and Insights

    It's hard to deny the importance and role of software in our smartphones, tablets, and other devices. We use apps to access our bank accounts, make purchases, make doctor's appointments, count calories and steps, learn Spanish, find jobs, and talk to friends.

    Jul 22, 2024
    angular-js-to-react-migration image

    Migrating From AngularJS To React: A Step-by-Step Guide

    Staying current with evolving technologies is paramount to ensuring scalability, maintainability, and enhanced user experiences. As AngularJS reaches its sunset phase, many developers migrate AngularJS to React, a robust and widely adopted JavaScript library. This transition not only promises modernization but also unlocks a host of benefits, from improved performance to a more intuitive development experience. This article explores how to convert AngularJS to React.

    Jul 15, 2024
    scaling-software-development-team image

    How to Scale a Development Team: Challenges and Tips

    The difficulties associated with rapid growth often limit the productivity gains hoped for by hiring additional employees. The side effects of growth can even lower the team's overall efficiency. Both fast-growing startups with 10 to 250 employees and small teams of developers growing rapidly within large organizations can experience productivity drops and communication difficulties. Typical problems for companies in the ultra-fast-growth stage include employee dissatisfaction, decreased enthusiasm, product quality issues, and customer dissatisfaction.

    Jul 08, 2024
    ionic-framework-for-hybrid-app-development image

    Hybrid App Development With Ionic Framework

    Mobile application development is one of the most dynamic and fastest-growing IT industries. As the number of smartphone users increases yearly, the demand for mobile applications grows.

    Jul 01, 2024
    future-proof-software-engineering image

    How to Make Your Software Development Future-proofing?

    The idea of future-proofing your code frequently surfaces in software discussions. It sounds ideal—who wouldn't want their code to withstand the test of time? However, the reality is far less enchanting and significantly more complex. This article will explore what people typically mean by "future-proofing" and 5 steps to create future-proofed software. You will also find an answer to the question, “Is software development future-proof?”

    Jul 01, 2024
    ionic-features image

    Features of Ionic Framework

    With the passage of time, from the birth of the first smartphones to the present, there has been an increase in supply and demand in the app market. It encompasses various areas, including entertainment, social services, wellness, etc. From a technical point of view, apps can be classified into three categories.

    Jun 24, 2024
    development-team-extension image

    IT Team Extension: Benefits, Challenges, Steps to Extend

    Dev team extension in Europe involves providing specialists for temporary remote work. The employee remains employed by the company and receives labor remuneration and tax deductions from his direct employer, not the client. This article will discuss everything you need to know about IT team extensions.

    Jun 17, 2024

    Contact Us

    We have a good offer for you

    clock icon

    15 minutes of consultation

    shield icon

    Strict non-disclosure policy

    window icon

    Involvement of High-Level Developers to your Project

    hand-shake icon

    Fruitful Cooperation & Prominent Increment

    Server error. Please, try in a few minutes again
    Call Back