IAT 167 Lecture 4 to Final

8 Pages
Unlock Document

Simon Fraser University
Interactive Arts & Tech
IAT 167
Jack Stockholm

IAT 167 Notes Week 4 Lecture 2 - Feb 3, 2011 OOP Concepts Play Pokemon tower defend game Leveling up as a way to motivate Are stories important to TDG? Oop concepts: 3 big: •Encapuslation •Inheritance •Polymorphism Encapsulation Object can b a container for data and methods Hide and restrict access to This data Do you need a mutator, or can just change? Accessor and mutator functs A: allow class consumers read internal data M: allow to change them Class consumers: user of an object is the consumer Ie, function that builds board based on info in objs Access control: Public - everything avail to everything, vis everwhere Internal - Default if not public - avail to package Multiple classes pos per package Private - only same class Reason: if someone updates var in your class, other stuff also happens - force them to use mutator method Protected - same was private, also derived classes Static - same var between ALL objects Same Obj shared between all Accessors - get and set (A and M) Get and set are keywords? Not something we need to know Inheritance Class can use data of another class (super) and it becomes sub by adding own functionality Extends another class Start w simple object, make more complex by extending Base class, don't have to redefine stuff, easier to. Reuse Polymorphism Action or method can do diff things depending. On.Obj acted on Can call the roll function of each wheel, and it can b e different. For each wheel Overloaded: same sig, diff number parameters Look at example Override: write a new function that has same name as super class, use new one instead of old one (same number parameters) Class interfaces What MUST be implemented by a class Class def w no implementation Don't think of GUI All properties avail and accessable to outside world public Interface IName { function initiative: void } Create new classes with. This interface, MUST. Have. This. Data and functions Can require multiple interfaces Want to call everything in same way ie, everything has update function, can loop and update all at once Frame work Start game Init fictions (gets calls once) Start level Level setup functs Game loop Update Render Game end Dispose Homework Make use block class for everything Get rid of empty and direct blocks Child should never tell parent what to do Don't let class Obj know about parent Every block checks if game is over - STUPID Don't add whole libraries, add what you need He also casted his varibles, and didn't scope them Week 5 - Lecture 1: Game Time and Flow Also movement, as well as time and its perception, animation flow Friday - attacker code to work on over reading break (refactor code base) Homework Review: Constructor can have return type.void, or nothing Declare, instanciate it (filling Obj var w/ a value) Static: don't need an instance, same reference always Does static require constant? Event listeners to call functions - useful for web, kind of - allows to make sure stuff loads before you do stuff This refers to the object itself Classes just a definition until you instanciate it Break fully exits switch statement After case satisfied, run code until hit break Use interface with "implements" Colour can be a uint? His code: pass in value from level array. Don't actually need switch. Shouldn't have called render internally Can also use inheritance for blocks Game Time: Two types: play time (objective), event time (time in game) Activity of player changes state (required for play) Can be 1 to 1, can not be (MM?) Don't want to feel like wasting time Relationship between ability and difficulty important to time - want flow Lose concept of play time, perfectly matched ability and difficulty Objective time becomes event time Game challenge: no obviously best choice ie, puzzle game with obvious soln (except lvl 0) Want strategy - more value in some choices than others Need to be able to make these choices Bridge: UML of TD game (code diagram) Reading wk bridge: explore win/loss mechanics, challenge How is flow achieved in 3 mechanics? Think of additional mechanics you'd like to implement Week 5 - Lecture 2 – Motion Motion Calculation - From reading Midterm: ask best option from example, write single lines of code, lots like quiz, will try to open quizes, def some terminology questions, but more code eval User events can interrupt game loop Animation Techniques: can be time or frame based Time allows to ensure smooth motion If frame advancing slow down, might get too few frames per second Updates not continuous Tiny changes in speed add up over time Both slow and fast cmpts cause issues Problematic period Other options too: Keep updating, reduce render frequency, skip render options until back on time (can't skip too often) Don't need to update faster than 25fps anyways, reduce update frequency, give more CPU to render Map Obj should know about anything other than self, should just be controlled and used by outside code. Can pass in models, however. Current map reply is still not best, but whatever All empty=0 All road = 1 Waypoints - whenever change direction, increment; results in 2 digit numbs >= current waypoint, is travel path (new Array, series of waypoints) Point Obj in AS, holds x and y, can tell distance between 2 points (distance function) Won't hit first waypoint first, have to manually put in in order Requires that you instanciate array with the correct length, otherwise will add at 0 (preindex) Passing by value versus reference (apples) Reference - actually passing actual var in, if changes inside, changes var Value - makes a copy, change occur on copy Obj vars are passed by reference (things that are passed in) Constant can be passed by val... but can't change, so irrelevant Homework: can we just compare our current position with our future position? Base the distance required to move on distance remaining? Move based on time, not number of moves. Code as written does not scale. Week 6 – Lecture 2 Exam review: Object is distinct and autonomous, knows nothing of parent, environment That out of bounds error does not give a runtime error, rather, it gives undefined Pure event driven model, want to listen for events and respond You didn't addChild, silly! Event Types: ENTER_FRAME: called every time we enter a new frame, at frame rate - use to create game loop MouseEvent: User events, interrupts. Waiting for them. Attach to object we want to do listening. TimerEvent: Fire at a specified interval - probably better practice than using ENTER_FRAME Custom Events: Not in Flash system. Click on block, need to send special info to parent. Can add other properties. Custom Events: Pass variables to listener Create a new class that extends Event Homework: create custom event Need to have certain properties like type DispatchEvent(Event) -> custom event goes inside. This is how you fire your event (raise), must use to dispatch addEventListener(CustomEvent.EVENT_TYPE, handler); Week 7 – Lecture 1: Proximity and Collision Detection Apply for the research project Right click - stuff that comes up is in right click registry, listener to detect Use as few return statements as possible - try for just one, so use a state variable or something Can do for each loops in AS 3: for each (var tempEnemy:Enemy in enemyModel) { What happens if wrong type? Allows you to avoid out of bounds errors Doesn't go a specific number of times, just runs for all items enemiesModel.indexOf(tempEnemy)
More Less

Related notes for IAT 167

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.