I put a shortcut onto your desktop, the screen that you look at after you log in.

Similar documents
Programming Fundamentals

Interactive Tourist Map

The first time you open Word

DeskTop Publishing on Linux

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

HTML4 TUTORIAL PART 2

How To Upload Your Newsletter

Boise State University. Getting To Know FrontPage 2000: A Tutorial

[ the academy_of_code] Senior Beginners

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

Assignment 0. Nothing here to hand in

My First Cocoa Program

My First iphone App. 1. Tutorial Overview

Introduction to MS Word XP 2002: An Overview

The Mathcad Workspace 7

How to make a Work Profile for Windows 10

Part 1: Understanding Windows XP Basics

Make a Halloween Card with CorelDRAW

Lab: Supplying Inputs to Programs

October 15. Tips for. Google Drive. Tips to expand your sharing and collaboration capabilities. Training

Introduction to Microsoft Office 2016: Word

The Fundamentals. Document Basics

Lecture (01) Getting started. Dr. Ahmed ElShafee

Burning CDs in Windows XP

A Document Created By Lisa Diner Table of Contents Western Quebec School Board October, 2007

COMP : Practical 6 Buttons and First Script Instructions

Mailman Max. The postcode is a great way to work out the next sorting office a letter should go to, so you ll use that.

A new clients guide to: Activating a new Studio 3.0 Account Creating a Photo Album Starting a Project Submitting a Project Publishing Tips

Have the students look at the editor on their computers. Refer to overhead projector as necessary.

Using Microsoft Word. Text Editing

Playlist Builder 1.5 Manual

Karlen Communications

GP NHSmail Migration. -How To Guide-

Add Photo Mounts To A Photo With Photoshop Part 1

Cell Phone. Adobe Illustrator Lesson 16 Working with Gradients Transparency Menu 1. START>PROGRAMS>ADOBE ILLUSTRATOR CS3

Basics. Mouse The mouse normally looks like a little arrow, but it can change depending on what you are doing

TSS Rental Software Solutions. What to? A Tape drive, USB Key, CD/DVD, External Hard Drive, Off Site backup, or any other reliable media.

MadCap Software. Index Guide. Flare 2017 r2

Introduction to Microsoft Excel 2007

Class #1. introduction, functions, variables, conditionals

animation, and what interface elements the Flash editor contains to help you create and control your animation.

Lesson 1. Importing and Organizing Footage using Premiere Pro CS3- CS5

Word: Print Address Labels Using Mail Merge

Making ecards Can Be Fun!

Files and Folders What are Files and Folders Files: This is the Data, Images, and things the user makes

Strategic Series-7001 Introduction to Custom Screens Version 9.0

Creative Sewing Machines Workbook based on BERNINA Embroidery Software V8

Easy Windows Working with Disks, Folders, - and Files

seminar learning system Seminar Author and Learning System are products of Information Transfer LLP.

This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step.

CTC Accounts Active Directory Synchronizer User Guide

Intro. Scheme Basics. scm> 5 5. scm>

ORGANIZING YOUR ARTWORK WITH LAYERS

Interface. 2. Interface Photoshop CS/ImageReady CS for the Web H O T

Clean & Speed Up Windows with AWO

Keep Track of Your Passwords Easily

Lutheran High North Technology The Finder

Using Microsoft Excel

I-Carver CNC Project Computer Directions. Rob MacIlreith Last Update Oct 2017

HAPPY HOLIDAYS PHOTO BORDER

My First iphone App (for Xcode version 6.4)

How to set up an Amazon Work Profile for Windows 8

Installing and getting started with Visual Studio for C programming in Windows.

Setting up Your Brand New ipad for Individual Use

Barchard Introduction to SPSS Marks

FRONTPAGE STEP BY STEP GUIDE

PowerPoint Basics: Create a Photo Slide Show

InDesign Basics. Adobe

How do I use BatchProcess

Chapter 2 The SAS Environment

EXCEL + POWERPOINT. Analyzing, Visualizing, and Presenting Data-Rich Insights to Any Audience KNACK TRAINING

Exercise 6 - Addressing a Message

Learning Worksheet Fundamentals

Tutorial. Creating activities in Expert mode

Using Microsoft Word. Getting Started With Word. Starting the Program

Applied ICT Skills MS Windows

As you probably know, Microsoft Excel is an

The Very Basics of the R Interpreter

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar

Lab 2. CSE 3, Summer 2010 In this lab you will learn about file structures and advanced features of Microsoft Word.

3. Let s say that we are unsure about what kind of

My First Command-Line Program

The original image. Let s get started! The final result.

ENGL 323: Writing for New Media Repurposing Content for the Web Part Two

CS Problem Solving and Object-Oriented Programming

EXPORTING ASSETS. Lesson overview

avenue.quark TUTORIAL

SharePoint: Fundamentals

Creating a Brochure in Publisher

Without further ado, let s go over and have a look at what I ve come up with.

Creating An Account With Outlook

Accessing Your Payroll Stubs via

XP: Backup Your Important Files for Safety

Epilog Laser Cutter Instructions (Only the Essentials)

COMPUTER SKILLS LECTURE 07

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

Introduction, Notepad++, File Structure, 9 Tags, Hyperlinks 1

Basic Texturing Tutorial by Gary Wu

CSS Crash Course for Fearless Bloggers by Gill Andrews

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms

Transcription:

In this lesson, you ll learn to create your first program. I put a shortcut onto your desktop, the screen that you look at after you log in. When you double-click on this shortcut, a folder will open. This folder is located in your Documents folder and is called something like LovePrograms. This is the folder where you will create your programs. Each new Love program will have its own folder. The LovePrograms folder already has a few program folders in it. We ll ignore these for now. Step 1: Create a folder for your first program by right-clicking over an empty area of the LovePrograms folder and selecting New and then Folder from the popup menu. This will create a new folder that you can rename to Project01 (or anything else that you would like). Double-click the Project01 folder to open it. Step 2: Love programs always have a file called main.lua. This is the place that Love looks for its first instructions. Create the main.lua file by right-clicking over an empty area of the Project01 folder and selecting New and then Text Document. This will create a file that you can rename to main.lua. When you change the extension from.txt to.lua Windows will warn you, but that s OK. Step 3: To write the instructions that Love will execute we will use an editor called NotePad++. An editor is like a simple word processor but geared towards writing simple text documents. NotePad++ is a nice programming editor because it understands a bit about how Lua programs should look. This is helpful to us. Double-click the main.lua file to open it in NotePad++. These are the three steps you ll follow each time that you want to create a new Love program. If you want to modify an existing program, you ll skip to step 3 and open the existing main.lua file.

A Love Program Now that we have main.lua open in NotePad++, let s type in a bare bones Love program. Type the text on lines 1 through 8. When you are done, select File, Save from the menu or type Ctrl+S (hold down the Ctrl key and type S). Here are a few things you should notice. First, each line is numbered. If we make a mistake in our Lua instructions, Love will tell us the line where the error occurred. Second, NotePad++ has colored the words function, end and the brackets ( ) blue. This is because NotePad++ understands Lua key words. Key words have specific meanings in a language. This would be like girl, run or house in English. Next, NotePad++ has connected each occurrence of function to the nearest following end keyword with a gray line to the left of the code. In Lua the keywords function and end enclose a group of instructions that can be executed as a group. This group is naturally called a function. We use functions in real life. Function fred.washclothes() gather clothes put clothes in washing machine put detergent in washing machine start washing machine wait for washing machine to finish remove clothes from washing machine end When someone says fred.washclothes() they expect that Fred will execute the instructions inside the function. This is more efficient that telling Fred the individual steps each time. In Lua, as well as most languages, functions are used to create groups of instructions that perform common tasks.

Understanding the Bare Bones Love Program We ve learned that functions exist to perform common tasks. The bare bones Love program contains three functions. When you run Love and point it at your program s folder, Love opens the main.lua file and calls the function love.load() once and only once. The purpose of the function love.load() is to do those tasks that only need to be done once. These might include setting the size of the Love program window. Or you might load a fancy font and set this as the default for your entire program. When the function love.load() finishes, it returns control to the Love program. Next, Love calls the function love.draw(). As you might imagine, the purpose of this function is to draw everything that you want onto the Love program window. This might be text like Fred is naughty or pictures, or shapes. There are lots of things that you can do. When the function love.draw() finishes, it returns control to the Love program. Finally, Love calls the function love.update(). When this function finishes it also returns control to the Love program. We ll learn more about this function later so don t worry about it for the moment. The main thing is that after Love calls love.update() it then loops back and calls love.draw() again. It keeps calling these two functions one after the other until you end the program. Expanding Your First Program Let s just run the bare bones program to see what happens. You can do this in NotePad++ by choosing Run and then Launch in Love 2D from the menu, or holding down Shift and Ctrl, and the typing L You should see a black window with the caption Untitled ; not very impressive. Let s add an instruction to love.load() line 2. Remember to save your addition using Ctrl+S.

Note that Love and Lua are case sensitive. That means that UPPERCASE and lowercase letters are different. The following are all different and only the last one correct. I ve marked the letters that are wrong. Love.graphics.setBackgroundColor(200,255,200) love.graphics.setbackgroundcolor(200,255,200) love.graphics.setbackgroundcolor(200,255,200) Wrong Wrong Correct The function love.graphics.setbackgroundcolor() changes the color of the Love window. Try running the program using Shift+Ctrl+L. The background should be a pale green. The numbers inside the brackets are called arguments and affect the function s behavior. We could modify the function fred.washclothes() to fred.washclothes(who). Then someone could call fred.washclothes( Jack ) or fred.washclothes( Jill ). This way one function can do many similar but different things. In the love.graphics.setbackgroundcolor function the three arguments specify the desired color. Colors in many programs are specified in something called RGB or Red, Green, Blue. In Lua, 0 means none of a color and 255 means the most of a color. 0,0,0 means no Red, Green or Blue which is black. 255,255,255 means the most of Red, Green, and Blue which is white. 255,0,0 means the most of Red, and no Green or Blue which is pure red. Let s finish off the first lesson by printing something into the Love window. Add the instructions on lines 6, 7 and 8 to the love.draw() function. The first instruction calls love.graphics.setcolor() and specifies the color of the next thing that you will print or draw. Remember that 0, 0, 0 means black.

The next instruction calls love.graphics.print(). The three arguments are what to print, the horizontal location, and the vertical location. Text is enclosed in quotes in most languages. For the horizontal position zero is at the left. For the vertical position zero is at the top. You can play with the arguments and see what happens. You can change the numbers to print in different locations. You can change the text inside the quotes to print a different message.