This will help you a lot:
https://www.youtube.com/watch?v=5KRazhSI-SA&list=PLlLxfPB9MrBtN8vFOZIUhotV9cs3VCV5Z
I found Rick's tutorials really good for learning not just how to use AppGameKit, but how to become a better programmer. Click on the link to see the entire Tutorial playlist on Youtube.
I think it is good to create an editbox that will allow you to input data and test your logic for a simple ROCK/PAPER/SCISSORS game.
// Project: EditBox
// Created: 2020-08-27
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "EditBox" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
CreateEditBox(1)
SetEditBoxSize(1, 400, 40)
SetEditBoxTextSize(1,40)
SetEditBoxPosition(1,GetVirtualWidth()/2,GetVirtualHeight()/2)
startcheck = 0
SetEditBoxFocus(1,1)
// Stat of Main Loop
do
If startcheck = 0
Print("PLEASE INPUT ROCK, PAPER OR SCISSORS")
endif
if GetEditBoxChanged(1)
Computer = random(0,2)
// This is a rem statement that will not be read by the compiler. The Computer integer variable (whole number variable) receives a generated random number between 0 and 2, so 0, 1 or 2.
// Let's assume 0 is ROCK, 1 is PAPER, 2 is SCISSORS. This can be converted to a string variable with if statements.
if Computer = 0
Computer$ = "ROCK"
elseif Computer = 1
Computer$ = "PAPER"
elseif Computer = 2
Computer$ = "SCISSORS"
endif
PlayerInput$ = GetEditBoxText(1)
// Converts the input string from whatever case to upper case only, so if you input "rock" or "rOcK" it will convert each version to "ROCK"
Player$ = upper(PlayerInput$)
startcheck = 1
// Sets the edit box cursor active again, so one can input again without having to click on the box to make the cursor go into focus.
SetEditBoxFocus(1,1)
endif
// The Player$ variable is a string variable that stores text, this variable will store the data input from the editbox that you can input. Let's say you input "ROCK".
// The next lines will process the player input and compare it with computer generated input
if startcheck = 1
if Player$ = Computer$
print("Computer chose "+Computer$)
Print("")
print("Player chose "+Player$)
Print("")
Print("THE GAME IS A DRAW")
elseif Player$ = "ROCK" AND Computer$ = "PAPER" OR Player$ = "PAPER" AND Computer$ = "SCISSORS" OR Player$ = "SCISSORS" AND Computer$ = "ROCK"
print("Computer chose "+Computer$)
Print("")
print("Player chose "+Player$)
Print("")
Print("YOU LOSE!")
Print("")
Print("COMPUTER WINS!")
elseif Player$ = "PAPER" AND Computer$ = "ROCK" OR Player$ = "SCISSORS" AND Computer$ = "PAPER" OR Player$ = "ROCK" AND Computer$ = "SCISSORS"
print("Computer chose "+Computer$)
Print("")
print("Player chose "+Player$)
Print("")
Print("YOU WIN!")
Print("")
Print("COMPUTER LOSES!")
endif
endif
If startcheck = 1
Print("")
Print("PLEASE INPUT NEXT CHOICE TO PLAY AGAIN")
endif
Sync()
loop
I created this little demo for you to explore. I learnt this some time ago from a DarkBASIC Pro programming book and it taught me a lot. I put rem or // statements to explain some parts, but I left some parts without explanation, so it is up to you to figure it out yourself what is what. You can built upon that to create a scoring system for the player and computer using separate integer variables to add scores for the player and computer. To use the code, just create a new project and copy paste the code into the AppGameKit and run it.
From Rik's tutorials I reason it is beneficial to master the database and types. Later it will be beneficial to learn about the functions, but don't focus on them at present, take it step by step, make something that works and you will grow on that and when you have a problem do not give up, once you solve it, you will appreciate it a lot and learn from it a lot.
Enjoy your journey of discovery. Keep going and never give up!