Share My Creation Salami!

Hello world of B4X!
Many years ago (about 30) I wrote a simple game using Visual Basic, to play together with my son and to teach him a little about programming.
The two players shared the same keyboard and mouse on a personal computer. It was just to play between us.
Last year, after retirement, I discovered B4A. I found it EXCELLENT and decided to attempt to make an App out of the old game.
Just reading some posts and the guides of Erel, and downloading some sample code, everything was easy and fun.
Now the App is (...almost) ready, not yet on Google Play Store, but I like to share with all the people of this community.
The App and its manual, in Italian or English, can be downloaded from www.programmidelcoccodrillo.it
sal2.jpg

You can play against the App or another player, on the same device or on a LAN or on Internet.
Or...you can watch the App playing against itself.
It is very simple in comparison of many other games, but I hope you'll have fun!
Giovanni_C
 

Giovanni_C

Member
Licensed User
Some more information: the registration on the download website is needed to play on internet.
It is also needed to be fully compliant with some aspects of the regulations about privacy (like the EU-GDPR).
When the game will be on Google Play Store it will be possible to download it without having to register, but playing on internet will need a registration anyway.
For everyone is curious about the game but doesn't want to register I attach here a copy of the manual, in English and Italian:
 

Attachments

  • Why_Salami.pdf
    487.7 KB · Views: 91
  • Perché_Salami.pdf
    476.1 KB · Views: 77

cklester

Well-Known Member
Licensed User
Just reading some posts and the guides of Erel, and downloading some sample code, everything was easy and fun.
Now the App is (...almost) ready, not yet on Google Play Store, but I like to share with all the people of this community.

Great job! Can you tell us a little bit about what modules you used and maybe a general step-by-step to making the game? Do you plan to make a desktop port?
 

Giovanni_C

Member
Licensed User
@Giovanni_C I'd like to implement something similar. Any chance you'd sell/share the project?
Hi 73Challenger. I am happy that you are interested in my app. Up to now I am just checking if someone likes the game. It is on Google Play Store now, but there were almost no downloads. It is still difficult to find it, if you search the name of the app you get totally different results... the only way to get the proper result is to look for "programmidelcoccodrillo" keyword. About selling the code, the app is over 4000 lines of code, with names of variables and comments in italian, probably I should translate it before to sell. Then there is all the code on the server's side, and the database. For me it was just an update to a old work made for fun, but if it will have success there could be many new functions to add, and a help could be needed.
 

73Challenger

Member
Licensed User
@Giovanni_C I'd certainly be willing to help and learn. Your app appears to fit about 80% of a use case I have. If you decide to translate it and put it into development let me know. Maybe you could post it up on github (private) and we could work on it from there, if you decide to progress. Let me know, thank you.
 

Giovanni_C

Member
Licensed User
Great job! Can you tell us a little bit about what modules you used and maybe a general step-by-step to making the game? Do you plan to make a desktop port?
Thank you! Quite late here so I will answer better tomorrow :). Now I can say that the app is on Google Play Store and is for free, I will appreciate if some people download and test it because I have no feedback up to now. There is a website, https://www.programmidelcoccodrillo.it , were players can register to be enabled to play in internet mode. About how to make the game, in another post I will try to write a simple resume of what I did, even if I am conscious that I operated in a quite "raw" mode, not using the best capabilities of the B4A platform. The core algorithms were written 30 years ago in Visual Basic, and all the code for playing in LAN and Internet modes, and to display animated gifs and menus, was taken by excellent examples found in this forum.
 

Giovanni_C

Member
Licensed User
Great job! Can you tell us a little bit about what modules you used and maybe a general step-by-step to making the game? Do you plan to make a desktop port?
FIRST PART
To cklester and to everyone can be interested I put here a simple description of the steps that I followed to port the old code into B4A and to build a working app.
Before I have to say that the tutorials and the examples provided by Erel and many other members of this forum were precious in every step.
Please don't care if I list also steps that can be obvious.
1) Read tutorials about B4A, in particular those about the lifecycle of activities (i.e. this one: https://www.b4x.com/etp.html?vimeography_gallery=1&vimeography_video=255402345)
2) Download some examples, and try to modify them, just to become familiar with the development environment and with the debugger. The B4A Bridge is a fantastic tool to get an app to run immediately on a device in release or in debug mode.
3) Put down the flow of the app, in natural language or with flow diagrams (...they are old stuff but always work and can be a great help).
4) Once the flow is clear in your mind you can start. Maybe the flow will change during the work, maybe it will be optimized or you'll have to find workarounds because you'll get stuck somewhere, but a clear initial plan is always a good start.
5) Design the user interface. I found the B4A Designer tool a excellent help. Give meaningful names to the panels, buttons, labels and other component: it will make easier to work with them in the code. IMPORTANT: it is always better to design and test a single or very few components of the UI at one time. So it is needed to set priorities, and slowly add the other components.
6) Declare variables and data structures that you think you'll need in your code. Here too, one starts with a minimum set, then the number of variables will grow during the development.
7) Fill the Sub Activity_Create with al the initialization code, like Activity.LoadLayout, Activity.Title, Activity.AddMenuItem, initialize the canvas where you'll want to draw, initialize your variables. Enable and make visible what you want to show at the start. For Salami I wrote a set of init subroutines called in the Activity_Create and in other parts of the code. These subroutines are small modules, each one performs a single task, one draws the initial grid, one sets the initial values for the matrix that will contain the status of the grid's cells, one sets the initial language, one checks the expire date of the app, and so on.
8) Test the results of the activity creation, that is: see if when you launch the app you get what you expect. It is a first important step, even if the app is still empty and, for instance, the menu items will not work, you'll add the other components one at a time.
----------------------------
Before this text becomes a book I stop here, just to know if I am writing what I was asked for.
To write a app being only one person is a difficult task. In all the software projects it should be good that the programs are tested by someon different from who wrote the code, but when you have to do all on your own I believe that it is needed a lot of order and organization, and a method that will reduce errors in design and coding. For this reason I have started in the way that you see, but if you want to know something else just ask.
I'll continue with a second and maybe a third part in another day. Have a good weekend to everyone!
 

73Challenger

Member
Licensed User
@Giovanni_C What intrigues me about your project is the algorithm to find horizontal and diagonal "salamis'" and drawing lines, the user controls and the possibility of playing against other players online. These are 3 features that, in my opinion, sets this project far above others. Looking forward to seeing more. Thank you for the previous post!
 

Giovanni_C

Member
Licensed User
@Giovanni_C What intrigues me about your project is the algorithm to find horizontal and diagonal "salamis'" and drawing lines, the user controls and the possibility of playing against other players online. These are 3 features that, in my opinion, sets this project far above others. Looking forward to seeing more. Thank you for the previous post!
Thank you, to have someone who likes the game is pleasant. About the algorithm, don't know, in comparison to programs that are able to play chess my algorithm is very simple. There are data structures (bi-dimentional matrixes) where every move of the players are memorized. So, the matrixes contain information about the contents of the single cells of the grid: is the cell empty? does it contain a symbol of one player or of the other? is it part of a salami? and, if yes, what is the orientation of the salami? (horizontal, vertical, diagonal_1, diagonal_2). For each move the algorithm scans a small sorrounding (a ray of 4 cells is enough) of the cell where a new symbol was added, and finds if one or more new salamis were made. In positive case the bonus is increased and the player can continue, otherwise it will be the turn of the other player.
About playing against other players online, there are two different ways:
- on a wifi local network the app establishes a peer-to-peer communication with another device, and there is an exchange of messages between the two apps. I had to set up a very simple "protocol" of communication: a very small array of bytes is sent from one app to the other; the first byte says what happens (sending display width and height, move without salami, move with salami, abandoning the game, and so on). For the connection between the two apps I just used a very good example from Erel, already existing in the forum, can't remember the name, something like wifidirect.
- to play on internet I choose to use a server as a bridge between the two players; it is my choice, maybe there are easier ways, but I didn't find a simple way to establish a peer-to-peer connection on the internet. The server has a MySQL database containing information like who is online and which device is using (just width and height of the display). The interface between the app and the database is in PHP language on the server's side. For each new game a new table is created. It will contain all the moves of the two players. A move causes the app to update the table. The other app, whose player is waiting for his/her turn, is not notified in push mode, so has to do a periodical check to see if there is a new event from the other player, a kind of "polling" with a quite low frequency (it can vary according with the status of the game between 300 and 3000msec). Setting up this part required some time.
In another post I will continue to list in a SECOND PART some general suggestions of steps to build the app.
 
Top