📜 ⬆️ ⬇️

Wooden toys or How I wrote mobile games from my phone

Once, when the trees were large, and mobile phones were still quite wild, and there were no uniform standards for Windy phones, I was the happy owner of the Siemens C72, one of the few phones that allows you to fully work with the file system (on other phones while access to the file system was either very limited or completely absent).

It just so happened that by that time I didn’t have a PC, but I already wanted to plunge into the fascinating world of programming. So I put and the idea was born - to start coding on a mobile phone. Tin, you say? Orenburg programmers are so harsh that we write mobile applications on the mobile themselves. Yes, that's right, and I decided to write my first article on Habr, based on my experience, because In Runet, such topics have not yet been raised.

So how did it all begin?
')
Of course, from the popular mobile platform - java. (Before java, there was another mobile platform - Mophun, but since it was designed mainly for games - it completely coped with this task - the games on Mophun differed in spectacular 3D graphics, speed even on the weakest devices; often such games supported the network the game via Bluetooth / Internet - but as far as applications are concerned - the Mophun platform did not even provide elementary access to the file system, what kind of programming can there be?

So - java. I will code on a mobile keyboard, with a 130x130 screen and 1.5 - 2 Mb operative. I launch the mini-opera, spend more than one hour searching for any programming method, and finally I find - mobile basic.

imageimage

The application did not allow compiling the program code into an executable file, it was essentially an interpreter - write, run, save the program text, but no more. There was no choice - I had to learn the language. Since the BASIC was originally a very easy language, then two weeks later I was perplexed to write already quite good applications.

But I wanted to progress - working with graphics, creating the simplest games. Fortunately, by that time, on our forum, we still found a way to create separate Java applications using mobile BASIC. It consisted in the following: write the program code directly, save it to a text file, then use the memory area where the mobile phones store the files created by the applications (for example, saves in games are stored there). It was necessary to pull out this file using a special program, zip it with the source file, with all the resources and directly with the mobile basic itself. So I finally got a ready-made java application.

And I started writing a game. The toy was simple - you control a fish, you eat smaller associates, and you run away from larger ones - you survive, in short :) We needed graphics, but there were no problems with that - by that time there was a graphic editor PaintCAD, which leaves the Windows paint (not the one that is written in .NET, of course :-) far behind.

image

Sketched a couple of simple models, packed them into an archive with a basic (so that the resources were available when writing the game) and began to write the code itself. A couple of days the game was ready. She certainly worked not without bugs, but eventually corrected everything.

imageimageimage

Here is the code section of this game:

520 GELLOAD "f4","f4.bmp":SPRITEGEL "f4","f4"
521 GELLOAD "f5","f5.bmp":SPRITEGEL "f5","f5"
522 X5%=-50:Y5%=110
530 X%=65:Y%=65
531 GELLOAD "f7","f7.bmp":SPRITEGEL "f7","f7"
532 X7%=-20:Y7%=0
537 XF1%=XF1%+1:YF1%=60+MOD(RND(0),60):SPRITEMOVE "f1",XF1%,YF1%
538 SETCOLOR 0,250,0
539 XF1%=XF1%+1:YF1%=60+MOD(RND(0),60):SPRITEMOVE "f1",XF1%,YF1%
540 IF LEFT(0) THEN X%=X%-1
541 XF%=XF%-1:SPRITEMOVE "f",XF%,YF%
542 IF XF%<=0 THEN XF%=580+MOD(RND(0),50):YF%=60+MOD(RND(0),60):SPRITEMOVE "f",XF%,YF%
545 IF UP(0) THEN Y%=Y%-1
546 IF SPRITEHIT("f4","f") THEN CLS:O%=O%+1:GOTO 1000
547 DRAWSTRING CHR$(1086)+CHR$(1095)+CHR$(1082)+CHR$(1086)+CHR$(1074)+":"+STR$(O%),30,2
548 SETCOLOR 0,250,0
549 XF1%=XF1%+2:SPRITEMOVE "f1",XF1%,YF1%
550 IF RIGHT(0) THEN X%=X%+1
552 IF XF1%>=130 THEN XF1%=-300+MOD(RND(0),50):YF1%=60+MOD(RND(0),60)
553 SPRITEMOVE "f1",XF1%,YF1%
554 IF SPRITEHIT("f4","f1") THEN GOTO 2000
555 IF DOWN(0) THEN Y%=Y%+1


By the way, precisely because of the openness of Siemens devices, only Siemens drivers were programming on the BASIC at that time. Later, numerous applications for this appeared, such as mobile pascal, jasmin, and then full-fledged Java compilers.

But by that time I already had a device on windows mobile, which replaced the old man Siemens (the buttons already fell off the coding :-).

Here the choice, of course, is much steeper. The GCC port (C ++ compiler), Pocket C # (with its IDE), Basic4PPC, Python, Perl, Tcl / tk, MortScript, Turbo Pascal (on the DOS Emulator) are just some of them.

Basic4PPC:

imageimage

CEdit:

image

Turbo Pascal:

image

Here is the process of creating applications on Pocket GCC: we write code, for example, CEdit (editor with syntax highlighting), save the finished * .cpp file, then click on the batch file (it contains the paths to the compiler, and to the * .cpp file), and after a couple of minutes pick up the freshly baked .exe program file.
This process does not require a powerful device at all: there is enough processor with a frequency of 200 MHz and a free RAM of 15-20 mb - and even the most low-end devices for WM have such characteristics.

Think, it’s so good to have a full-fledged programmer in your pocket, and at your leisure, away from the PC, you can always write a small program and enjoy its work directly on the PDA :)

***
PS Moped is not mine, I just posted a miner provided a rostrum and acted as editor. Author - Artemzr , please love and favor.
PS2 On the advice of ilya_compman transferred to " Abnormal programming ."

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


All Articles