In this tutorial we will make a simple WASD controlled game where you control a square. If you fall in the lava pool, you lose, and if you get to the purple carpet, you will be asked a multiple-choice trivia question (who was the first president of the United States). If you answer it correctly, you win. If you answer it wrong, you lose. Simple enough.
Since the code will be written in parts, this chapter will follow the following conventions: new lines that didn’t exist in the previous version will be colored by green, lines that should be removed will be colored by red, and lines that should stay as they are will be colored by blue.

You will start of with an empty program. Let’s start by drawing the field. Yeh background will be green like grass, there will be one red square representing a pool of lava, and one magenta square.
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50IM OUTTA UR SUBPROGRAM
Notice that the delay was set to 1. This is the lowest possible and was done on purpose so that the game will run as smoothly as possible.
The player will be an orange square that can move around the screen.
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DRAW_FIELDPLZ RUN SUBPROGRAM DEFALT_VARIABLESIM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50IM OUTTA UR SUBPROGRAM
Notice how the drawing happens in the same subprogram where the default variables are set. This will change.
As it is, we don’t have much of a game. Let’s implement player movement:
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DEFALT_VARIABLESPLZ RUN SUBPROGRAM DRAW_FIELDPLZ RUN SUBPROGRAM DEFALT_VARIABLESFOREVER RUN MOVEIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YI HAS A TWO BYTE DAT IZ CALLED BUTTONPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ SET TWO BYTE BUTTON -1PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED MOVEPLZ READ CHAR BUTTONSWITCH [[BUTTON]]CASE 56,87,119 UPCASE 52,65,97 LEFTCASE 50,83,115 DOWNCASE 54,68,100 RIGHTIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED UPPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DOWNPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED LEFTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED RIGHTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAM
Notice that the player drawing routine was moved to the field, and that the program now sets default values before it starts drawing. Also in the switch/case statement, it compares the variables to the ASCII values of WASD and 8462 keys.
Now we have completed the movement, but you can walk wherever you want including on top of lava. Let’s fix that. Let’s add code that detects when you fell in lava and end the game.
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DEFALT_VARIABLESPLZ RUN SUBPROGRAM DRAW_FIELDFOREVER RUN MOVEIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YI HAS A TWO BYTE DAT IZ CALLED BUTTONPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ SET TWO BYTE BUTTON -1IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED MOVEPLZ READ CHAR BUTTONSWITCH [[BUTTON]]CASE 56,87,119 UPCASE 52,65,97 LEFTCASE 50,83,115 DOWNCASE 54,68,100 RIGHTPLZ RUN SUBPROGRAM CKECK_LAVA_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED UPPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DOWNPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED LEFTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED RIGHTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVAPLZ PRINT TEXT YOU FELL IN LAVAIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_XSWITCH [[X]]CASE 80,90,100,110,120,130,140 CKECK_LAVA_YIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_YSWITCH [[Y]]CASE 80,90,100,110,120,130,140 FELL_IN_LAVAIM OUTTA UR SUBPROGRAM
Now if you fall in the lava, you get a message informing you about this, and the game ends. Notice that because the player starts at coordinates (200,150) and moves at a speed of 10 pixels/iteration, both the x and y values will always be numbers that can evenly be divided by 10.
Now we can detect when the player enters lava, let’s also detect when the player steps on the carpet.
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DEFALT_VARIABLESPLZ RUN SUBPROGRAM DRAW_FIELDFOREVER RUN MOVEIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YI HAS A TWO BYTE DAT IZ CALLED BUTTONPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ SET TWO BYTE BUTTON -1IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED MOVEPLZ READ CHAR BUTTONSWITCH [[BUTTON]]CASE 56,87,119 UPCASE 52,65,97 LEFTCASE 50,83,115 DOWNCASE 54,68,100 RIGHTPLZ RUN SUBPROGRAM CKECK_LAVA_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED UPPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DOWNPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED LEFTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED RIGHTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVAPLZ PRINT TEXT YOU FELL IN LAVAIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_XSWITCH [[X]]CASE 80,90,100,110,120,130,140 CKECK_LAVA_YPLZ RUN SUBPROGRAM CKECK_CARPET_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_YSWITCH [[Y]]CASE 80,90,100,110,120,130,140 FELL_IN_LAVAIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPETPLZ PRINT TEXT YOU WINIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_XSWITCH [[X]]CASE 280,290,300,310,320,330,340 CKECK_CARPET_YIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_YSWITCH [[Y]]CASE 180,190,200,210,220,230,240 ON_CARPETIM OUTTA UR SUBPROGRAM
Now when you step on the carpet, you win instantly. Let’s make it so that you will get a trivia question and only win if you answered correctly.
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DEFALT_VARIABLESPLZ RUN SUBPROGRAM DRAW_FIELDFOREVER RUN MOVEIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YI HAS A TWO BYTE DAT IZ CALLED BUTTONPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ SET TWO BYTE BUTTON -1IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50PLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED MOVEPLZ READ CHAR BUTTONSWITCH [[BUTTON]]CASE 56,87,119 UPCASE 52,65,97 LEFTCASE 50,83,115 DOWNCASE 54,68,100 RIGHTPLZ RUN SUBPROGRAM CKECK_LAVA_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED UPPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DOWNPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED LEFTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED RIGHTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVAPLZ PRINT TEXT YOU FELL IN LAVAPLZ PRINT TEXTPLZ PRINT TEXT YOU LOSEIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_XSWITCH [[X]]CASE 80,90,100,110,120,130,140 CKECK_LAVA_YPLZ RUN SUBPROGRAM CKECK_CARPET_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_YSWITCH [[Y]]CASE 80,90,100,110,120,130,140 FELL_IN_LAVAIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPETPLZ PRINT TEXT WHO WAS THE FIRST PLZ PRINT TEXT WHO PRESIDENT OF THE PLZ PRINT TEXT UNITED STATES?PLZ PRINT TEXTPLZ PRINT TEXT 1) RICHARD NIXONPLZ PRINT TEXT 2) GEORGE WASHINGTONPLZ PRINT TEXT 3) DONALD TRUMPPLZ PRINT TEXT 4) JOHN ADAMSI HAS A ONE BYTE DAT IZ CALLED ANSWERPLZ ASK TEH USR 2 GIMME A ONE BYTE ANSWERPLZ CLEAR TEH CONSOLESWITCH [ANSWER]LABELCASE 2 WINPLZ PRINT TEXT YOU LOSE!PLZ GOTO LABEL ENDDIS IZ MY LABEL! IT IZ KALLED WINPLZ PRINT TEXT YOU WIN!DIS IZ MY LABEL! IT IZ KALLED ENDIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_XSWITCH [[X]]CASE 280,290,300,310,320,330,340 CKECK_CARPET_YIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_YSWITCH [[Y]]CASE 180,190,200,210,220,230,240 ON_CARPETIM OUTTA UR SUBPROGRAM
Now when you step on the carpet, you will get asked who was the first president of the United States. Also, when you fall im lava, the text “You lose” is displayed in addition to “You fell in lava”. This “game” can be considered complete, however there’s one more thing we are going to add.
You would expect that after the player falls in lava, he would not be drawn on the screen. However this is not what happens in the game as of now. Let’s fix this. There are multiple ways to do so:
So here’s the improved code:
HAI 3.4 0 1IM IN UR CODE EXECUTIN UR KOMANDZPLZ RUN SUBPROGRAM DEFALT_VARIABLESPLZ RUN SUBPROGRAM DRAW_FIELDFOREVER RUN MOVEIM OUTTA UR CODEIM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLESI HAS A TWO BYTE DAT IZ CALLED XI HAS A TWO BYTE DAT IZ CALLED YI HAS A TWO BYTE DAT IZ CALLED BUTTONPLZ SET TWO BYTE X 200PLZ SET TWO BYTE Y 150PLZ SET TWO BYTE BUTTON -1IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELDPLZ CHANGE PAINT BRUSH 0 154 23PLZ FILL RECT 0 0 630 430PLZ CHANGE PAINT BRUSH REDPLZ FILL RECT 100 100 50 50PLZ CHANGE PAINT BRUSH MAGENTAPLZ FILL RECT 300 200 50 50SWITCH [[X]]LABELCASE -1 ENDPLZ CHANGE PAINT BRUSH ORANGEPLZ FILL RECT X Y 25 25IM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED MOVEPLZ READ CHAR BUTTONSWITCH [[BUTTON]]CASE 56,87,119 UPCASE 52,65,97 LEFTCASE 50,83,115 DOWNCASE 54,68,100 RIGHTPLZ RUN SUBPROGRAM CKECK_LAVA_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED UPPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED DOWNPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE Y Y+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED LEFTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X-10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED RIGHTPLZ SET TWO BYTE BUTTON -1PLZ SET TWO BYTE X X+10PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVAPLZ PRINT TEXT YOU FELL IN LAVAPLZ PRINT TEXTPLZ PRINT TEXT YOU LOSEPLZ SET TWO BYTE X -1PLZ RUN SUBPROGRAM DRAW_FIELDIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_XSWITCH [[X]]CASE 80,90,100,110,120,130,140 CKECK_LAVA_YPLZ RUN SUBPROGRAM CKECK_CARPET_XIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_YSWITCH [[Y]]CASE 80,90,100,110,120,130,140 FELL_IN_LAVAIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPETPLZ PRINT TEXT WHO WAS THE FIRST PLZ PRINT TEXT WHO PRESIDENT OF THE PLZ PRINT TEXT UNITED STATES?PLZ PRINT TEXTPLZ PRINT TEXT 1) RICHARD NIXONPLZ PRINT TEXT 2) GEORGE WASHINGTONPLZ PRINT TEXT 3) DONALD TRUMPPLZ PRINT TEXT 4) JOHN ADAMSI HAS A ONE BYTE DAT IZ CALLED ANSWERPLZ ASK TEH USR 2 GIMME A ONE BYTE ANSWERPLZ CLEAR TEH CONSOLESWITCH [ANSWER]LABELCASE 2 WINPLZ PRINT TEXT YOU LOSE!PLZ GOTO LABEL ENDDIS IZ MY LABEL! IT IZ KALLED WINPLZ PRINT TEXT YOU WIN!DIS IZ MY LABEL! IT IZ KALLED ENDIM OUTTA UR CODEIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_XSWITCH [[X]]CASE 280,290,300,310,320,330,340 CKECK_CARPET_YIM OUTTA UR SUBPROGRAMIM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_YSWITCH [[Y]]CASE 180,190,200,210,220,230,240 ON_CARPETIM OUTTA UR SUBPROGRAM
Notice that the label “END” is the same one in the carpet subprogram. This doesn’t matter since after it there’sIM OUTTA UR CODE which ends the program.