MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

SimpleGameInAlice1 Barb Ericson Georgia Institute of Technology June 2008 Creating a Simple Game in Alice.
Lecture 10 Sharing Resources. Basics of File Sharing The core component of any server is its ability to share files. In fact, the Server service in all.
Alice Learning to program: Part Four Creating Sounds, Making Billboards, Fun with 3-D Text, New Events, and Rotating Objects by Ruthie Tucker and Jenna.
Usually the next step is to run the Cognitive Tests. Click on “Run Cognitive Tests” button to start testing. All of the tests begin with you giving a brief.
IS660Z Programming Games Using Visual Basic Overview of Cannonball.
UNIT 12 LO4 BE ABLE TO CREATE WEBSITES Cambridge Technicals.
Programming with Microsoft Visual Basic th Edition
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
Variables Conditionals Loops The concept of Iteration Two types of loops: While For When do we use them? Iteration in the context of computer graphics.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
2015 Pre-Release Practice Click the button to try a random exam-style question. Click on the reveal button to check your answer.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
CS0007: Introduction to Computer Programming Introduction to Arrays.
Games and Simulations O-O Programming in Java The Walker School
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Tutorial for Arrays and Lists By Ruthie Tucker. Description This presentation will cover the basics of using Arrays and Lists in an Alice world This presentation.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Introduction to TouchDevelop
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Chapter 11 Adding Sound and Video. Chapter 11 Lessons 1.Work with sound 2.Specify synchronization options 3.Modify sounds 4.Use ActionScript with sound.
Spiral Rider PAGE 1. Set Up Scene 1.Add Stage-underwater scene 2.Add crab sprite 3.Add two fish sprites PAGE 2.
Visual Basic .NET BASICS
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Learning Unity. Getting Unity
Game Maker Terminology
Variables and Inheritance Part 1
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
CS320n –Visual Programming
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Game Maker Galactic Mail Advanced Group: Complete Galactic Mail, then start developing an independent project.
Pascal Programming Pascal Loops and Debugging. Pascal Programming Pascal Loops In our first brush with the while do loops, simple comparisons were used.
Introduction to OOP in VB.NET using Robots ACSE Conference, Nov 2004 Michael Devoy Monsignor Doyle C.S.S., Cambridge
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 2009.
Tutorial 7 Creating Animations. XP Objectives Learn about animation Create a timeline Add AP divs and graphics to a timeline Move and resize animation.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Iteration. Iteration: Review  If you wanted to display all the numbers from 1 to 1000, you wouldn’t want to do this, would you? Start display 1 display.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
© 2011 Delmar, Cengage Learning Chapter 11 Adding Sound and Video.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
Programming in Alice IT-IDT-9 Design, develop, test and implement programs using visual programming. 9.1 Utilize drag and drop software to develop programs.
COM148X1 Interactive Programming Lecture 8. Topics Today Review.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Variables and Inheritance Part 1 Alice. Review: Properties A class defines properties for its own kind of object. When an object is created (instantiated),
Computer Science Up Down Controls, Decisions and Random Numbers.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
MOM! Phineas and Ferb are … Aims:
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Coding Concepts (Basics)
Sorting "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The Sorting Hat, Harry Potter.
creating a ecosystems model in net logo
Presentation transcript:

MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal

MrsBillinghurst.net Creating an Animation - Pascal In order to create a simple animation, you will need a number of images which will swap – much like a flip book. Here we will be using 8 different images of lemmings walking to achieve the animation.

MrsBillinghurst.net Creating an Animation - Pascal To achieve the effect of a lemming walking across the screen, you will need to add a timer object and eight image objects to the screen. Each image should have one of the eight walking images in order. When you have added all the objects, move the images on top of the first setting the visible property of each one to ‘false’.

MrsBillinghurst.net Creating an Animation - Pascal The algorithm for making the lemming walk is as follows: IF lemming x is visible THEN set lemming x+1 to visible AND set all other lemmings to invisible In code, this could translate to a long IF / ELSE statement, or using procedures, a more elegant looping solution. This example will show both.

MrsBillinghurst.net Creating an Animation - Pascal For the proof of concept, we will add the animation code to the TimerTick procedure. This is an event which happens at regular intervals set in the interval property of the timer. This should be set at 200. This code will run until the lemming reaches the right hand side of the screen. As with many visual programming environments, the screen uses Top and Left co-ordinates to place the objects. This code will run until the lemming reaches the right hand side of the screen. As with many visual programming environments, the screen uses Top and Left co-ordinates to place the objects.

MrsBillinghurst.net Creating an Animation - Pascal In order to get the lemming to actually walk across the screen, we need to tell the program to change the co-ordinates of all 8 images at the same time. In this way, it appears that there is only one object on the screen. Run this code & you will have a lemming that appears to be wading through treacle across your screen. Add this code to the end of the IF statement in the TimerTick Procedure Could you enhance this by using an ImageList……

MrsBillinghurst.net Creating an Animation - Pascal The lemmings game used sections of land on which the lemmings could walk and throughout the course of the game, specific actions could be used to destroy this. The objective was to reach the escape door. Our first task is to create a visual platform for the lemming to walk to and a door for him to escape through. By adding these as images to your screen, you can make the lemming appear to be walking on a platform. Try turning the background of your screen black to make things appear less like an application. By adding these as images to your screen, you can make the lemming appear to be walking on a platform. Try turning the background of your screen black to make things appear less like an application.

MrsBillinghurst.net Creating an Animation - Pascal Your screen should now look like this: Run your program to see the difference that adding images makes. In order for your lemmings to look like they are walking on the grass, use Shift + PgDown to send things to the back of the screen. The Z Order will be important to ensure your lemming is at the front of the screen. In order for your lemmings to look like they are walking on the grass, use Shift + PgDown to send things to the back of the screen. The Z Order will be important to ensure your lemming is at the front of the screen.

MrsBillinghurst.net Creating an Animation - Pascal In the original design, the objective is to exit via a door. Run your program to ensure that your door is placed at the same point that your lemming stops. When your lemming stops, add code so that the lemming disappears. You have already made use of the.Visible property. To make the lemming disappear entirely, set all images to invisible. You have already made use of the.Visible property. To make the lemming disappear entirely, set all images to invisible.

MrsBillinghurst.net Creating an Animation - Pascal Lemmings in the 80s was all about the music. The 8 bit looped songs just about drove everyone who played to distraction, so let’s add our own! Save your WAV music file into a local folder and create a new procedure called PlaySong. For Windows, you will also need to add the Uses MMSystem library file. This will be called from the CreateForm procedure. In order to play the song at the same time as your animation, you must ensure that you use ASYNC to run the procedure asynchronously to the timer procedure.

MrsBillinghurst.net Classes & Objects - Pascal Whilst it’s great to have a single animation, the purpose of a game like this is to have controls which will populate the screen with multiple instances of a class. Imagine that your code takes on two parts: The first part of the code describes to the program what a lemming is and what it can do: this is a class with attributes and methods The second part of the code creates an ‘instance’ of the class in the form of an object. Each object has the same attributes and methods as the class, but this time, it has actual values.

MrsBillinghurst.net Classes & Objects - Pascal To create a lemming class, we need to know what the lemming will do. Above the Tform class declaration, but still inside the type heading, create a new class called TLemming of type Tobject. In here, you will have Private variables (these are local to just the objects created from the class) and Public methods (such as create) Our Lemming class will have a single image and booleans to let us know what state the lemming is in.

MrsBillinghurst.net Classes & Objects - Pascal The program variables will also need to be adjusted. LemmingList is an array of the Tlemmings that we created above. This allows you to create more than just one instance of the class which will act in the same way as each other. The integers allow you to count which image is displayed, how many lemmings you want to create and how many lemmings have been created so far.

MrsBillinghurst.net Classes & Objects - Pascal The next stage is to write the constructor method for the TLemming class Self is used here to indicate that each attribute is being applied to the newly created object. Before the object can appear on screen, you will need to state its parent (in this case Form1). Self is used here to indicate that each attribute is being applied to the newly created object. Before the object can appear on screen, you will need to state its parent (in this case Form1).

MrsBillinghurst.net Classes & Objects - Pascal At this point, you can set up the initial values for the variables (although we’re not quite there yet!) LemmingImage will commence the animation at the first image. NumLemmings could be adjusted to be a user input based on how many lemmings they wanted to use. SetLength() is a function which changes the length of the array to the number of lemmings required. LemmingImage will commence the animation at the first image. NumLemmings could be adjusted to be a user input based on how many lemmings they wanted to use. SetLength() is a function which changes the length of the array to the number of lemmings required.

MrsBillinghurst.net Classes & Objects - Pascal The next step is to add the Timers and a door image to the form. Set the TimerWalk & TimerDrop enabled properties to false. You will start these inside the code. The Timers will each control a section of the lemmings movements. Name these: TimerCreateLem (interval: 1500) TimerWalk (interval: 100) TimerDrop (interval: 100) The Timers will each control a section of the lemmings movements. Name these: TimerCreateLem (interval: 1500) TimerWalk (interval: 100) TimerDrop (interval: 100)

MrsBillinghurst.net Classes & Objects - Pascal Double click on your TimerCreateLem Timer object to access its tick procedure. In here, set up the code that will create a new instance of a lemming and set its initial boolean values (landed and safe) to false. For each ‘tick’ of the timer, a new lemming will be created and added to the array until the maximum is reached.

MrsBillinghurst.net Classes & Objects - Pascal Double click on your TimerDrop Timer object to access its tick procedure. In here, set up the code that will allow any lemming that has been created, but hasn’t yet landed on the ground to fall down. Once, the lemming has landed, set the attribute to true. Then start the TimerWalk. Once, the lemming has landed, set the attribute to true. Then start the TimerWalk.

MrsBillinghurst.net Classes & Objects - Pascal Double click on your TimerWalk Timer object to access its tick procedure. In here, you will be creating a number of sections of code. Firstly, if your lemming has landed, move them forward:

MrsBillinghurst.net Classes & Objects - Pascal Next, if the lemming has landed, iterate through the image files to simulate movement (this CASE statement should go up to image 8 where it sets the image back to image 1):

MrsBillinghurst.net Classes & Objects - Pascal After the CASE statement, an IF, ELSE statement is used to update the Lemming Image number, which will loop back around to 1 if image 8 has been reached.

MrsBillinghurst.net Classes & Objects - Pascal Finally, if the lemming has reached the door & it has not already been recorded as going through the door, play the ‘YIPPEE’ wav file and make the Lemming dissapear. By setting the safe attribute to true, this statement will only run once for each lemming.

MrsBillinghurst.net Classes & Objects - Pascal Extend your code by creating a random song to be played for the level.

MrsBillinghurst.net Classes & Objects - Pascal Test your code by adjusting the number of lemmings created via the NumLemmings variable. Extend this by allowing the user to increase or decrease the number of lemmings to be used.