Hello! I'm CKlidify, and in this tutorial I will teach you how to create your first game! A guessing game!
WARNING: I WILL NOT EXPLAIN EVERY LITTLE DETAIL AND TELL YOU EXACTLY WHAT TO WRITE! I WILL JUST TELL YOU WHAT THE CODE IS GOING TO DO, THEN GIVE YOU THE CODE! I'M NOT TRYING TO BABY YOU, BECAUSE YOU SHOULD ALREADY KNOW WHAT TO WRITE WITHOUT EVEN BEING GIVEN THE CODE!
You'll need to know PRINT and INPUT
You'll need to know GOTO and IF
OPTIONAL: You'll need to know GOSUB
Look at my previous tutorials for these!
GOSUB tutorial coming soon!
Creating the GameEdit
Okay, we're going to create our first ever GAME! In petit computer! Do you think you're ready? Oh well... Let's do it anyway! In this tutorial, we use GOSUB commands, I will not explain GOSUB at all in this tutorial, but will in a future tutorial! you want to start off by creating a GOSUB for @MAIN like this:
It's kinda like GOTO, but slightly different! Now you want to write "END", afterward, create a "waypoint" named main and create a variable named NUM and make it so "NUM" is a random number between 1 and 100. Then create a variable named REPEAT and set it to 1! Do that like so:
GOSUB @MAIN END @MAIN NUM=RND(100) REPEAT=1
Now, we'll create a new "waypoint" named L1 because we can, then go sub @START and @CHECK! Then create an if statement, if repeat is equal to 1, then go to @L1. This will loop until repeat is equal to 0! Then print You got it! and wait 235 frames. Then go to main!
@L1 GOSUB @START GOSUB @CHECK IF REPEAT==1 THEN GOTO @L1 PRINT "You got it!" WAIT 235 GOTO @MAIN
Now, we're going to create a new "waypoint" named start and clear the screen, then ask for an input for the number the computer is thinking of, we'll name the variable GUESS. Then return. Return is a command only available with GOSUB, it basically returns... Self explanitory.
@START CLS INPUT "What number am I thinking of";GUESS RETURN
Now, let's create the check "waypoint" and add 3 if statements, one checking if guess is less than num, another checking if guess is greater than num and a final one checking if guess is equal to num. Then if guess IS equal to num, it will set repeat to 0. then wait 50 and return!
@CHECK IF GUESS<NUM THEN PRINT "Higher!" IF GUESS>NUM THEN PRINT "Lower!" IF GUESS==NUM THEN REPEAT=0 WAIT 50 RETURN
Now, if we run the command it will ask you what number he is thinking of. Let's just say it's 56! If I guess 23, it will say "Higher!". If I guess 72, it will say "Lower!". If I guess 56, it will say "You got it!" and reset with a brand new number after 235 frames.