Home
Start a new game
Explore games
Help
Log in or sign up
Log in
Username
Password (
Forgot it?
)
×
New to Playfic?
Full Name
Email
Username
Password
Password (confirm)
Are you sure about this?
Beginner to Advanced Programming Tutorial
by
Cool Dude
Played 610 times
View game source
(spoilers!)
Download the
.z8 file
Source Code
"Tutorial Game" When play begins, say "This is a tutorial on how to [bold type]program[roman type] games, not play them. I've noticed a lot of well-made games, but the majority is badly made games that don't really work and are not fun. To use this tutorial, look in the code for how to make things you are wondering about. Enjoy!". ["Say" is a command used to print text. Comands can't be used on their own line, they have to be triggered by an event. The above line is pretty straightforward: When play begins, say "...". Don't forget to have proper punctation: put periods in between sentences, put quotes around text, etc., because if you don't, errors will pop up.] The story headline is "An Interactive Tutorial". White Space is a room. [This creates a room. There is nothing in the room, so you can't really do anything yet.] The description of white space is "A white tiled plain, extending infinitely in all directions except down.". Dirt Room is a room. [This will be used later.] The description of the dirt room is "The walls are gross dirt, dripping moisture. The clean white tiled space is much preferable to this." [The player is in this room by default, so to add another object:] The table is in the white space. "A table stands in the space, seamlessly attached to the white tiles." [What's the quoted text for? The text is printed instead of the default "You can see a table here"] [Ok, so now there's a table, but we can take it and we can't put anything on it. It's a pretty useless table. In order to put things on the table, we make it a supporter.] The table is a supporter. [And we can't take it, so:] The table is fixed in place. [And then we add a description:] The description of the table is "The table is made of white particle board." [Notice that we have no period at the end of the sentence. This is because it is already there, just behind the quote.] [Now for something on the table] The vase is on the table. The description of the vase is "It's thin white ceramic, with a pattern of flowers along the rim." [Now we have to make some flowers in the vase] Some flowers are in the vase. The description of the flowers is "The flowers are made of paper." [This automatically makes the vase an open unopenable container.] [Now, we will see "In the vase are some flowers" printed. We don't want that, so how do we make these flowers not show that description?] The flowers are scenery. [This makes them part of the background, so it doesn't have any description text, but we can still interact with them. Now, if the flowers are scenery, when we try to take them, we are faced with the message "That's hardly portable." We shouldn't be able to take the flowers, but they are quite portable, so here, we need to use an event.] [Events are triggered by actions or times. This one will be triggered by an action.] Instead of taking the flowers, say "You don't want to ruin this setup." Instead of taking the vase, try taking the flowers. [Try is a command. It basically forces the player to do the action.] [Now, we add in the tiles, which are also part of the background:] Some tiles are in the white space. The description is "White, shiny, and seamless." The tiles are scenery. [Now, we make an escape scene:] Instead pulling the tiles for the first time: say "You pry open a few tiles. Underneath is a dark musty room."; now holefound is true. [Notice that we have a colon and semicolon, instead of a comma. This is because there are multiple commands in one rule. The sentence still ends with a period.] Instead of pulling the tiles [not for the first time]: say "You have already found a hole, you don't need another." [Now, the player should be able to go down the hole, so we put a directional statement:] The dirt room is down from the white space. [Variable time! There are different kinds of variables, truth states, numbers, texts, and objects. Variables have a value that can change.] Holefound is a truth state that varies. Holefound is false. [You shouldn't be able to go down when you haven't found the hole, so we add this event:] Instead of going down from the white space while holefound is false, say "You can't go that way." [Now, with another directional statement, we can make the exit from the dirt room to the outdoors. To do this, we will use a door. Doors are in between rooms. You can see how I use them. It isn't complicated. ] The dirty door is a door."A grimy door [if the player is in the dirt room]leads west[otherwise]leads east[end if] from here." It is west of the dirt room. When play begins, now the dirty door is scenery. Flat Field is west of the dirty door. The description is "A flat field which extends for miles in each direction. A village is on the horizon, straight north." The cave of grime is in the flat field. "A grimy cave made seemingly out of dirt stands here, ruining the scene." Instead of taking the cave, say "You can't." Instead of entering the cave, try going east. [Now, we want people to notice the door by examining the walls in the dirt room, and this takes two steps:] Some walls are scenery in the dirt room. "[one of]You look at the walls. The faint outline of a door leading west catches your attention...[or]They are gross.[stopping]".[With scenery, the quoted text is just the description.] Carry out examining the walls for the first time, now the dirty door is not scenery. [What if, back in the white space, someone tries to pry open the tiles instead of pulling. We have to make a command: pry. Here's how:] Prying is an action applying to one thing.[Creates an action: "prying"] Understand "pry [something]", "pry open [something]" or "pry [something] open" as prying. Report prying something: say "You can't." Instead of prying the tiles, try pulling the tiles. [The end of the game] [Now, it's time to make an end scene:] Instead of going north while in the flat field: say "You set off towards the village. Soon, you are back at civilization."; end the story. The Village is north of the flat field. [Finishing touches] [Ok, I didn't use all the events I could. I will list a few more: Every turn: At (time e.g. 10:00): After printing banner text: etc.] Every turn while in the flat field, if a random chance of 1 in 3 succeeds, say "A gust of wind blows in your face." [Oh, and, there are ifs: if (condition), …; if (condition) begin; …; …; end if; ifs are commands, so don't try to put them on their own. I'll go more into complex Inform 7 in my next tutorial, but for now, this is the end. I hope this will be affective.]