App Inventor 2
Programming mobile phones with Android
by App Inventor 2 - Juan Antonio Villalpando
- Initiation Tutorial App Inventor 2 -
Return to tutorial index
____________________________
- Here we see a game of Russian Roulette and other Minesweeper.
4.- Russian Roulette.
ip4_russian roulette.aia (This is the source code file to be consulted, modified, debug ... in App Inventor 2 )
p4_ruleta_rusa.apk (This is the definitive installation file. The copy in our mobile and installed)
(By this QR code can also install this application on a mobile. This installation is simpler)
Let's see a game - based of Russian Roulette.
In this case we have a revolver for 6 bullets.
- First Reload revolver putting a single bullet and rotating the drum. The bullet will be located randomly in one of the six sites.
- Then let 's pressing randomly the different buttons .
- If the number instead of the bullet matches the number of the button pressed, the screen turns red.
- Else, (Button.Enabled = False).
_________________
Design
I acted on the widths and heights to resize the controls.
_________________
Blocks
NOTE:
- For the blocks if ... then ... if not
Click on the blue flag and drag the sub - block if not,
|
|
When you click the button Reload, Button7.Click, a random number from 1 to 6 is created, they are enabled ( Enable = True ) all buttons and the bottom of the screen goes blank it gets.
When you press any button:
- If the value x randomly generated in the reset matches the number of the button, the screen turns red.
- Else, it disables the button down.
__________________________________
Russian Roulette to play between two phones. Of course these applications would be much better to install two different mobile phones and play against another.This could be done by FirebaseDB data base to be discussed later.To prove it, installed by QR, this application in two mobile and play against each other.
Russian roulette between two phones. |
_________________________________________________
_________________________________________________
4B.- Minesweeper.
p4B_busca_minas.aia (This is the source code file to be consulted, modified, refined ... in App Inventor 2)
p4b looking minas.apk (This is the definitive installation file. The copy in our mobile and installed)
(By this QR code can also install this application on a mobile. This installation is simpler)
- Based on the previous application of "Russian Roulette", we will build a simple "Minesweeper".
- Let's modify a bit the Design and blocks, but keep the style.
- Press the button "Start", 6 random numbers (which only have two values: 0 or 1) will be created. Each random number is assigned to a button:b1, b2, b2, b4, b6 and b5.
- If the random number is 1, it means that there is a mine. If it is a 0 no mine.
- The user pressed the buttons. If the pressed button has a corresponding variable to 1, you will have a mine and the screen is colored red.
_________________
Design
- It is similar to "Russian Roulette".
- Add Label1.
_________________
Blocks
NOTE:- To put different summands, click on blue icon block sum and we add "number".
------------------------------------------------------------------------------------
Beginning of the blocks:
_________________________________________________
Minesweeper
Buscaminas.aia
- This application was made Aulafor of Valencia, was the winner of our first contest App inventor.- It is a simple minesweeper. We start six places where they can be mines. Pressing the start button mines are created in some random places. The player must hit where the mines are.
- The code contains blocks that have not yet seen: Lists, Any button ... but it is advisable to take a look and compare it with the previous application of Russian roulette.
- Le randomly assigned to each button a 0 or a 1, this will mark having or not mine. So that several buttons may have zero or one, may be several mine.
|
|
________________________________________________________
|