Programming in LOLGraphics 3.4/Making a simple game in LOLGraphics
Introduction
editIn 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.
Drawing the field
editYou 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 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 IM 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.
Drawing the player
editThe player will be an orange square that can move around the screen.
HAI 3.4 0 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DRAW_FIELD PLZ RUN SUBPROGRAM DEFALT_VARIABLES IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 IM OUTTA UR SUBPROGRAM
Notice how the drawing happens in the same subprogram where the default variables are set. This will change.
Player movement
editAs it is, we don’t have much of a game. Let’s implement player movement:
HAI 3.4 0 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DEFALT_VARIABLES PLZ RUN SUBPROGRAM DRAW_FIELD PLZ RUN SUBPROGRAM DEFALT_VARIABLES FOREVER RUN MOVE IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y I HAS A TWO BYTE DAT IZ CALLED BUTTON PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ SET TWO BYTE BUTTON -1 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED MOVE PLZ READ CHAR BUTTON SWITCH [[BUTTON]] CASE 56,87,119 UP CASE 52,65,97 LEFT CASE 50,83,115 DOWN CASE 54,68,100 RIGHT IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED UP PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DOWN PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED LEFT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED RIGHT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM 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.
Detecting Lava
editNow 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 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DEFALT_VARIABLES PLZ RUN SUBPROGRAM DRAW_FIELD FOREVER RUN MOVE IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y I HAS A TWO BYTE DAT IZ CALLED BUTTON PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ SET TWO BYTE BUTTON -1 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED MOVE PLZ READ CHAR BUTTON SWITCH [[BUTTON]] CASE 56,87,119 UP CASE 52,65,97 LEFT CASE 50,83,115 DOWN CASE 54,68,100 RIGHT PLZ RUN SUBPROGRAM CKECK_LAVA_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED UP PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DOWN PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED LEFT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED RIGHT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVA PLZ PRINT TEXT YOU FELL IN LAVA IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_X SWITCH [[X]] CASE 80,90,100,110,120,130,140 CKECK_LAVA_Y IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_Y SWITCH [[Y]] CASE 80,90,100,110,120,130,140 FELL_IN_LAVA IM 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.
Detecting Carpet
editNow we can detect when the player enters lava, let’s also detect when the player steps on the carpet.
HAI 3.4 0 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DEFALT_VARIABLES PLZ RUN SUBPROGRAM DRAW_FIELD FOREVER RUN MOVE IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y I HAS A TWO BYTE DAT IZ CALLED BUTTON PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ SET TWO BYTE BUTTON -1 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED MOVE PLZ READ CHAR BUTTON SWITCH [[BUTTON]] CASE 56,87,119 UP CASE 52,65,97 LEFT CASE 50,83,115 DOWN CASE 54,68,100 RIGHT PLZ RUN SUBPROGRAM CKECK_LAVA_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED UP PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DOWN PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED LEFT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED RIGHT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVA PLZ PRINT TEXT YOU FELL IN LAVA IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_X SWITCH [[X]] CASE 80,90,100,110,120,130,140 CKECK_LAVA_Y PLZ RUN SUBPROGRAM CKECK_CARPET_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_Y SWITCH [[Y]] CASE 80,90,100,110,120,130,140 FELL_IN_LAVA IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPET PLZ PRINT TEXT YOU WIN IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_X SWITCH [[X]] CASE 280,290,300,310,320,330,340 CKECK_CARPET_Y IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_Y SWITCH [[Y]] CASE 180,190,200,210,220,230,240 ON_CARPET IM OUTTA UR SUBPROGRAM
Trivia question
editNow 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 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DEFALT_VARIABLES PLZ RUN SUBPROGRAM DRAW_FIELD FOREVER RUN MOVE IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y I HAS A TWO BYTE DAT IZ CALLED BUTTON PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ SET TWO BYTE BUTTON -1 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED MOVE PLZ READ CHAR BUTTON SWITCH [[BUTTON]] CASE 56,87,119 UP CASE 52,65,97 LEFT CASE 50,83,115 DOWN CASE 54,68,100 RIGHT PLZ RUN SUBPROGRAM CKECK_LAVA_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED UP PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DOWN PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED LEFT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED RIGHT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVA PLZ PRINT TEXT YOU FELL IN LAVA PLZ PRINT TEXT PLZ PRINT TEXT YOU LOSE IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_X SWITCH [[X]] CASE 80,90,100,110,120,130,140 CKECK_LAVA_Y PLZ RUN SUBPROGRAM CKECK_CARPET_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_Y SWITCH [[Y]] CASE 80,90,100,110,120,130,140 FELL_IN_LAVA IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPET PLZ PRINT TEXT WHO WAS THE FIRST PLZ PRINT TEXT WHO PRESIDENT OF THE PLZ PRINT TEXT UNITED STATES? PLZ PRINT TEXT PLZ PRINT TEXT 1) RICHARD NIXON PLZ PRINT TEXT 2) GEORGE WASHINGTON PLZ PRINT TEXT 3) DONALD TRUMP PLZ PRINT TEXT 4) JOHN ADAMS I HAS A ONE BYTE DAT IZ CALLED ANSWER PLZ ASK TEH USR 2 GIMME A ONE BYTE ANSWER PLZ CLEAR TEH CONSOLE SWITCH [ANSWER] LABELCASE 2 WIN PLZ PRINT TEXT YOU LOSE! PLZ GOTO LABEL END DIS IZ MY LABEL! IT IZ KALLED WIN PLZ PRINT TEXT YOU WIN! DIS IZ MY LABEL! IT IZ KALLED END IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_X SWITCH [[X]] CASE 280,290,300,310,320,330,340 CKECK_CARPET_Y IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_Y SWITCH [[Y]] CASE 180,190,200,210,220,230,240 ON_CARPET IM 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.
Slight improvement
editYou 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:
- One way, is to set the x and y values of the player to something out of bounds and then redraw the screen. This will cause the player to be “drawn” but because it will be out of the screen you won’t see him. Feel free to use this way, but this is not what we are going to use in this book.
- The second way is it to create a one-byte variable called IN_LAVA, set it to 0, and when the player falls in lava, set it to 1. The drawing routine will check the value of this variable and set if it’s equal to 1, the player won’t be drawn. Feel free to use it in your code, but this isn’t what we will be doing in this book.
- The third way would be to set the value of x or y to a number like -1 and then in the drawing routine to check if x==-1, and if yes then the player won’t be drawn. You can use any number that can’t be evenly divided by 10 and it won’t have any effect on how the code runs because the player moves at a speed of 10 pixel/iteration and starts with x,y coordinates that can be evenly divided by 10. This is what we will do.
So here’s the improved code:
HAI 3.4 0 1 IM IN UR CODE EXECUTIN UR KOMANDZ PLZ RUN SUBPROGRAM DEFALT_VARIABLES PLZ RUN SUBPROGRAM DRAW_FIELD FOREVER RUN MOVE IM OUTTA UR CODE IM IN UR SUBPROGRAM DAT IZ KALLED DEFALT_VARIABLES I HAS A TWO BYTE DAT IZ CALLED X I HAS A TWO BYTE DAT IZ CALLED Y I HAS A TWO BYTE DAT IZ CALLED BUTTON PLZ SET TWO BYTE X 200 PLZ SET TWO BYTE Y 150 PLZ SET TWO BYTE BUTTON -1 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DRAW_FIELD PLZ CHANGE PAINT BRUSH 0 154 23 PLZ FILL RECT 0 0 630 430 PLZ CHANGE PAINT BRUSH RED PLZ FILL RECT 100 100 50 50 PLZ CHANGE PAINT BRUSH MAGENTA PLZ FILL RECT 300 200 50 50 SWITCH [[X]] LABELCASE -1 END PLZ CHANGE PAINT BRUSH ORANGE PLZ FILL RECT X Y 25 25 IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED MOVE PLZ READ CHAR BUTTON SWITCH [[BUTTON]] CASE 56,87,119 UP CASE 52,65,97 LEFT CASE 50,83,115 DOWN CASE 54,68,100 RIGHT PLZ RUN SUBPROGRAM CKECK_LAVA_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED UP PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED DOWN PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE Y Y+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED LEFT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X-10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED RIGHT PLZ SET TWO BYTE BUTTON -1 PLZ SET TWO BYTE X X+10 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED FELL_IN_LAVA PLZ PRINT TEXT YOU FELL IN LAVA PLZ PRINT TEXT PLZ PRINT TEXT YOU LOSE PLZ SET TWO BYTE X -1 PLZ RUN SUBPROGRAM DRAW_FIELD IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_X SWITCH [[X]] CASE 80,90,100,110,120,130,140 CKECK_LAVA_Y PLZ RUN SUBPROGRAM CKECK_CARPET_X IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_LAVA_Y SWITCH [[Y]] CASE 80,90,100,110,120,130,140 FELL_IN_LAVA IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED ON_CARPET PLZ PRINT TEXT WHO WAS THE FIRST PLZ PRINT TEXT WHO PRESIDENT OF THE PLZ PRINT TEXT UNITED STATES? PLZ PRINT TEXT PLZ PRINT TEXT 1) RICHARD NIXON PLZ PRINT TEXT 2) GEORGE WASHINGTON PLZ PRINT TEXT 3) DONALD TRUMP PLZ PRINT TEXT 4) JOHN ADAMS I HAS A ONE BYTE DAT IZ CALLED ANSWER PLZ ASK TEH USR 2 GIMME A ONE BYTE ANSWER PLZ CLEAR TEH CONSOLE SWITCH [ANSWER] LABELCASE 2 WIN PLZ PRINT TEXT YOU LOSE! PLZ GOTO LABEL END DIS IZ MY LABEL! IT IZ KALLED WIN PLZ PRINT TEXT YOU WIN! DIS IZ MY LABEL! IT IZ KALLED END IM OUTTA UR CODE IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_X SWITCH [[X]] CASE 280,290,300,310,320,330,340 CKECK_CARPET_Y IM OUTTA UR SUBPROGRAM IM IN UR SUBPROGRAM DAT IZ KALLED CKECK_CARPET_Y SWITCH [[Y]] CASE 180,190,200,210,220,230,240 ON_CARPET IM OUTTA UR SUBPROGRAM
Notice that the label “END” is the same one in the carpet subprogram. This doesn’t matter since after it there’s IM OUTTA UR CODE
which ends the program.