📜 ⬆️ ⬇️

How to try on a crown

This article is for those who quickly get tired of playing Angry Birds, 2048 or Lord of Rings and in whose heads they begin to see the scripts of their own games. I believe that at least 95 percent of such individuals are on a local resource. The remaining 5 percent (most likely already implemented their own ideas in the form of applications) can still walk.

You know, 100 years ago every decent person wrote poetry. Now every decent person writes his own 2D game. And the most important question is how quickly to check the playability of your idea? What is more fun and rational - poke a finger or click the mouse? Where are your users sitting? On Android or iOS? Under Windows, Linux or Mac? What tool to cut the tree of knowledge?

I checked one of the tools. It is possible that he might come to you, mate.

How to quickly write your 2D indie game? Say, crazy domino or sex pakman. I'll tell you about my own experience.
')
It all starts with an ordinary phone. In which call. Who is with you in moments of waiting or loneliness. Of course, you start to make a game for your phone. Fun, which is interesting to play for you. If you have an iPhone (they say you still have Android), then you need


All three points will take 30 minutes + 30 days + 30 weeks of your precious life. This, of course, a little, but tiring.

However, by the time you become a professional in iOS development, the dog can grow up. The blonde will replace the brunette. Life will change. You will have to learn Java again, Eclipse or Android Studio. And this is another year of life. Little of! You will want to adapt your mobile game for the desktop (like me after 7 years of iOS development) - and come on again! learn! new tool! language! and customize your eco-friendly environment!

What to do? How to be? What is the strength in, brother?

Here is my answer, reader.

The goal is to create a 2D game without costs and headaches on all platforms.


March 2018. In the world there are three popular free tools for creating universal 2D games. it


Purely philological, I chose Corona. Imagine if I took cocos2d ?!

They ask you: -What are you sitting on?
-On the coconut ...

It sounds ambiguous, even criminal ...
Defold is also something definitely old. Definitely old)

In general, I chose Corona and report on their actions.
There is another reason why I tried on the crown, but about this in the next article.

Installation environment and development environment


It took 30 minutes. He acted strictly according to the instructions. Download the SDK, then any of the recommended text editors (you can use your favorite editor) and the plugin for the editor.

I installed Atom. This is a universal free editor that I have never used in my life. By Atom, I installed a plugin for the Lua language (hints, autocompletions). Yes, everything that you will create in Corone is written in the Lua language . On the slang of Russian developers - LUNA . For me, this is a mixture of php, python and swift. Somewhat old-fashioned and very rational. For those who know more than one programming language - to learn a new one is not difficult. It is enough to read some good articles at a local resource .
By the way, the language of Lua miraculously brought me back to the memories of youth. About 8 years ago I downloaded popular games from Appstore to my Mac as * .ipa files.

You know, if * .ipa is renamed to * .zip and unpacked, then in 2 clicks you can pull out all pictures and sounds from someone else's application. So - having unpacked the then famous Angry Birds, I, besides pictures and sounds, found a bunch of files with the extension * .lua. Being a complete ignoramus, I considered them as script files describing the levels of the game and ignored. What was my surprise yesterday when I learned that Angry Birds is written in the language of Lua. And these files - the source code of the game!

Creation of the first game


Any mobile game consists of 3 actions

  1. motion * .png pictures on the screen
  2. making sounds of bunches
  3. reaction of the picture to pressing the screen with your finger (you can replace the finger with the mouse)

Meticulous nerds will say that there are games, where you need to type text on the keyboard. To create such games, 2D engines are not very suitable, from my point of view. In addition, there are games where the movement of the picture is controlled by the voice or tilt of the phone. This may be done in the Crown, but I will not say a word about it.

So, we are not distracted, but let's see how each of the 3 key actions is implemented in the programming language. I note that on my favorite Swift you need to write code 7 times more than on Lua.

Motion pictures on the screen


The source code consists of two lines.

--      ,       bird = display.newImageRect( "Assets/bird_0.png", 72, 72 ) --        25  transition.to( bird, { time=25, x=xNew, y=yNew } ) 

Making sounds


The source code consists of two lines.

 --     birdSound = audio.loadSound( "Assets/bird_shout.mp3" ) --  ,  birdChannel      birdChannel = audio.play( birdSound ) 

Finger touch screen processing


The source code does not consist of two lines, everything is somewhat old-fashioned and longer.

 --          addEventListener( "touch", onObjectTouch ) --     ,         local function onObjectTouch( event ) if ( event.phase == "began" ) then selectedItem = selectCell(event.x, event.y) print( "Touch event on: " .. selectedItem ) elseif ( event.phase == "moved" and selectedItem>0 ) then moveCell(selectedItem, event.x, event.y) elseif ( event.phase == "ended" ) then unselectCell(event.x) end return true end 

Inside the function is a code taken from my first game created with Corona. It all took 12 days (learning Lua, Corona.sdk, working with a simulator, procrastination and the fight against syntax).

So, I felt that I was ready to rivet games with no less enthusiasm than on Swift.

The idea of ​​the second game, made on Lua, is about the following - colored cubes with values ​​of multiples of two are thrown on the MxN field. 2, 4 and so on. Any two adjacent identical cubes can be collapsed into one. At the same time, the value of the new cube is doubled. Under the action of gravity, the cubes fall into the formed hole, and new random cubes fall from above. It is necessary to score the maximum number of points until the possible moves end.


Fig. 1 Screenshot emulator with a game

Conclusion


To check the playability of my next game under Corona took one day, long as caramel - in my opinion, Corona is a very, very good tool for rapid prototyping of casual toys.

I have not checked yet how quickly I can post the game in three stores (Appstore, Google Play, Mac Store) - this is the topic for the next article, I promise to tell you not only about the deployment process, but also about how to monetize games using Corona.

Perhaps the development of Corona will be my new specialty.
My previous Yugoslav contract ended March 1 and I’m not going to renew it. I'm tired of living far away from my homeland ...

Source: https://habr.com/ru/post/349432/


All Articles