PACMAN OO Style.

Slides:



Advertisements
Similar presentations
GAME:IT Junior Learning Game Maker: The Control Tab.
Advertisements

September, 2004Patient Care Inquiry PCI - Customizing Your Patient ID Menu.
Select Team Offense: Special Plays (22 Purple and 13 Purple)
Prepared by: Ms. Pellegrino
Creating a Basic Pacman game
Games and Simulations O-O Programming in Java The Walker School
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Week 5 while loops; logic; random numbers; tuples Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except.
The Control Unit: Sequencing the Processor Control Unit: –provides control signals that activate the various microoperations in the datapath the select.
Introduction to Programming with Java, for Beginners Control Structures.
Intro to Java while loops pseudocode. 1 A “Loop” A simple but powerful mechanism for “making lots of things happen!” Performs a statement (or block) over.
Shortest path algorithm. Introduction 4 The graphs we have seen so far have edges that are unweighted. 4 Many graph situations involve weighted edges.
A-Mazers Team Members Isaiah Grigos Chris Hart Erick Rua Eddie Miner.
Chapter 4 Section 1 Copyright © 2011 Pearson Education, Inc.
Game Design Creating a game called PING Phase 3: Steps for building basic game.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
GAME:IT Junior Learning Game Maker: The Move Tab.
Learning Game Maker Studio:
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
30/10/ Iteration Loops Do While (condition is true) … Loop.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Lecture 4. Greenfoot 1 Pablo Romero, Department of Informatics Greenfoot Programming simulations and games in Java.
Game Maker Terminology
CS – 1P Using Electronic Voting System (EVS) questioning in the Instructional Design for CS-1P.
Game Maker Galactic Mail Advanced Group: Complete Galactic Mail, then start developing an independent project.
Religious Rights Edition True or False Edition To play, click “Slide Show” at the top and then click “From Beginning”. Hit the “go” button to the right.
Dr Nick Mitchell (Room CM 224)
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Expression or Equation? 3x + 7 4y – 10 = 54 5z + 32 = 47 6x + 2y (8x – 1) 2 + y 2x = 16.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Tank Game Part 2 of 6. Firing Shells Coming up… Players Scores Large Explosions Small Explosions Damage Health Bars Parent Shell Destructible Walls Reappear.
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
Here is a small example of the puzzle you will be completing today. You will start in the top left corner, and end at the bottom right using 3 different.
Lesson Seven: Using Flags. What Are Flags? Flags are Variables or Switches Used to Help With Logic Control of your character. Normally, Flags are used.
Objective of the lesson Use Blockly to make a dice for Snakes and Ladders All of you will: – Make an image which displays when you press a button Most.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
C++ LANGUAGE MULTIPLE CHOICE QUESTION
Keyboard Input.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Claiming Your Google Listing
Chapter 3: Decisions and Loops
Lecture 11.
Lecture 10.
Making a simple platformer with physics
THIS IS JEOPARDY. THIS IS JEOPARDY With Your Host... Paul Berman.
Stack Data Structure, Reverse Polish Notation, Homework 7
Chapter 12: Implementing Actor Behavior (“AI”)
Stacks.
Chap 3. The simplex method
Variables ICS2O.
Axiomatic semantics Points to discuss: The assignment statement
Introduction to TouchDevelop
More Loops.
Do While (condition is true) … Loop
Variables Title slide variables.
Tank Game Part 2 of 6.
Stacks.
Pacman.
Chapter 3: Selection Structures: Making Decisions
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Creating a Simple Game in Scratch
DATA TYPES AND OPERATIONS
ECE 352 Digital System Fundamentals
CSC 221: Introduction to Programming Fall 2018
Backtracking, Search, Heuristics
A practical guide for AYSO referees and coaches
A practical guide for AYSO referees and coaches
A practical guide for AYSO referees and coaches
Presentation transcript:

PACMAN OO Style

Pacman: an object oriented view What aspects of the Pacman game could be made into classes, and why would you choose those? What inheritance would there be, and why?

The player’s character moves continuously and autonomously in the last direction the player moves, except at the start of the game where the payer’s character automatically moves to the left Two integer fields are used, called X and Y to represent the character’s position. The coordinate (0,0) is the top left of the screen. On each game cycle, the player’s character moves 2 units in the current direction, unless that would result in hitting a wall, in which case it does not move A variable called dir is used to store the current direction of movement, and holds either the value “U”, “D”, “L” or “R” Game logic

Using the rules on the previous slide, write pseudocode for the Move() function of the player’s character. You can assume that there is a function called WillHitWall() that returns true if the player will hit the wall, and false otherwise Pseudocode

When the maze has gaps in its vertical edges, the player can move out of the maze to the left, and re-enter on the right, immediately opposite. This also works in reverse, where leaving the right-hand edge results in reappearing on the left. Assume the X coordinate of ‘outside maze’ is 0 on the left, and 968 on the right. The character should move from 0 to 968 or 968 to 0 as appropriate. Game logic

Add logic to allow for the aforementioned gaps in the maze walls Pseudocode 2

Compare and contrast How does the player move around the maze? How does a ghost move around the maze? What is the same, and what is different? How could we show this using OO styles?

OO Design Base +Common Logic Inherit Create a BASE class, called GameCharacter +Common Logic Program in the logic designed so far in a function called Move() Inherit Create a Player class, inheriting from GameCharacter Create a Ghost class, inheriting from GameCharacter

Draw the class diagram, showing the inheritance Hierarchy

Ghost behavior In normal situations, the ghost is not scared of pacman. How does the ghost move? Consider especially what happens when a ghost can no longer move in its current direction Hint: knowing how many different directions you can choose from when deciding the new direction is useful, because your strategy should differ accordingly

Write a method called ChooseDirection() that picks the ghost’s new direction after coming up to a wall Assume there are routines called CanMoveUp(), CanMoveDown(), CanMoveLeft() and CanMoveRight() available, all of which return true if that direction is clear, and false if it isn’t The player is a global variable called player, and it has an X and a Y attribute (player.X and player.Y) Pseudocode 3

Ghost behavior 2 When Pacman pops a power pill, two things happen: The ghosts immediately reverse their direction of travel Logic is different at junctions with two possible choices of direction – how?

Add a function called PillEaten() that sets the value of a class variable scared to true and reverses the direction of travel of the ghost. (variable is called dir from earlier) Amend your ChooseDirection() function to take account of this new behaviour Pseudocode 4

Ghost behavior 3 Once a ghost becomes scared, they remain in this state for a set period of time. Assume the ghost should remain scared for 500 cycles of the game loop.

When they become scared, a value of 500 is set in the variable scareTimer This reduces by 1 in every game cycle. When it reaches zero, the value of scared is set to false Amend PillEaten() to account for this Amend Move() as appropriate Pseudocode 5