Lecture 6: Thread Safe Event services and Coordinate System CSS290: APPS ON MOBILE DEVICES.

Slides:



Advertisements
Similar presentations
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, toString reading: self-checks: #13-18,
Advertisements

Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Lecture 7: Real Time Applications. Tasks, and Storage CSS290: APPS ON MOBILE DEVICES.
Spatial Information Systems (SIS) COMP Spatial access methods: Indexing.
Lecture 2: Events + Service Routines + Instance vs local Variable CSS290: APPS ON MOBILE DEVICES.
C# vs. C++ What's Different & What's New. An example C# public sometype myfn { get; set; } C++ public: sometype myfn { sometype get (); void set (sometype.
AI & 2D Development COSC 315 Fall 2014 Bridget M. Blodgett.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 10 And, Finally... The Stack. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Stacks A LIFO.
Chapter 10 The Stack Stack: An Abstract Data Type An important abstraction that you will encounter in many applications. We will describe two uses:
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Constructors and Encapsulation reading: self-checks: #10-17.
Functions Art &Technology, 3rd Semester Aalborg University Programming David Meredith
CS179: GPU Programming Lecture 11: Lab 5 Recitation.
Click & Fix 11/04/10 James Cui Janam Jhaveri Paul Mongold.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
Introduction to Microprocessors
CS305j Introduction to Computing Classes 1 Topic 23 Classes – Part I "A 'class' is where we teach an 'object' to behave." -Rich Pattis Based on slides.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Salman Marvasti Sharif University of Technology Winter 2015.
Intersections of Lines in 2 Space Three Cases: 1) 2) 3)
Lecture 3: Application State + Event Driven Programming CSS290: APPS ON MOBILE DEVICES.
FEN 2014UCN Teknologi/act2learn1 Higher order functions Observer Pattern Delegates Events Visitor Pattern Lambdas and closures Lambdas in libraries.
Chapter 4 Generic Vector Class. Agenda A systemic problem with Vector of Object – Several approaches at a solution – Generic structures Converting classes.
From C++ to C# Part 5. Enums Similar to C++ Similar to C++ Read up section 1.10 of Spec. Read up section 1.10 of Spec.
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
Chapter 4: Systems of Equations and Inequalities Section 4.7: Solving Linear Systems of Inequalities.
14.3 Day 2 change of variables
Definite Integration and Areas 01 It can be used to find an area bounded, in part, by a curve e.g. gives the area shaded on the graph The limits of integration...
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Chapter 8 Sensors and Camera. Figure 08.01: The Accelerometer can gauge the orientation of a stationary device.
Lecture 5 Basic geometric objects
Introduction to Operating Systems
Building Java Programs
Introduction to Programming
Chapter 8: Main Memory.
Chapter 10-1: Structure.
FUNCTIONS In C++.
Multiple Classes and Inheritance
Concurrency.
Review: Two Programming Paradigms
Chapter 10 And, Finally... The Stack
Chapter 10 The Stack.
Building Java Programs
Introduction to Operating Systems
GEOMATIKA UNIVERSITY COLLEGE CHAPTER 2 OPERATING SYSTEM PRINCIPLES
CSCI 3328 Object Oriented Programming in C# Review: Exam I
Coding Concepts (Sub- Programs)
Thread Implementations; MUTEX
Dr. Bhargavi Dept of CS CHRIST
Chapter 8 Lecture 8-1: Classes and Objects
Chapter 10 And, Finally... The Stack
VENN DIAGRAMS AND PROBABILITY
Today’s science starter Day 3: Forces and Motion
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Object Oriented Programming Review
Thread Implementations; MUTEX
CSE 153 Design of Operating Systems Winter 19
Chapter 9: Pointers and String
Chapter 10 Algorithms.
Space groups Start w/ 2s and 21s 222.
Rehearsal: Lazy Evaluation Infinite Streams in our lazy evaluator
IPC144 Introduction to Programming Using C Week 5 – Lesson 1
Events, Delegates, and Lambdas
CSCI 3328 Object Oriented Programming in C# Review: Exam I
CSS290: Apps on Mobile Devices
Presentation transcript:

Lecture 6: Thread Safe Event services and Coordinate System CSS290: APPS ON MOBILE DEVICES

TODAY: CONCEPTS Reading: Chapter 5 Sensors and Services Thread invoking functions Delegates Logical Coordinate Control by Orientation vs. Hardware Coordinate from Accelerometer

DELEGATE KEYWORD: A FUNCTION POINTER Define a data type that accepts a function! delegate returnType TypeName(parameter list) E.g. delegate void MyFuncType(double a, double b) New datatype is: MyFuncType! Convenient for passing function pointers around!

ADDING A NEW REFERENCE INTO IDE The Reference Tab in the Solution Explorer Finding the right reference Using the reference in your code To work with Accelerometer we need Microsoft.Devices.Sensors

1. ACCTEST: ACCELEROMETER Event service is called form an external thread SHOULD NOT change our variable from that service routine Called from external thread, danger of external thread and our own thread trying to change the same variable! Instead: BeginInvoke()  called sometime later when it is safe. Accelerometer X/Y/Z Resting state for Z is -1 (gravitational pull) Notice: -Y is downwards. X/Y is associated with the hardware If you change the phone orientation, X/Y direciton DOES NOT change

2. ACC CONTROLS OBJ: Accelerometer with Orientation Phone orientation changes the logical X/Y directions Accelerometer returns the same X/Y/Z readings regardless of phone orientation! We must translate the change! Switch on Orientation changing support Translate coordinate space depending on phone orientation

3. BOUND CHECK Switch off orientation (annoying) mBall class Passed in ContentPanel for bound checking Random position inside the bound Bound intersection checking Test for X overlaps Test for Y overlaps Must satisfy all conditions for potential collision

EXERCISE 6: Integrate Bound checking with Exercise 5 Check for ball touch net in Timer service (nice central place) Integrate Music/Sound effect Integrate Accelerometer for moving the net No need for orientation support BECAREFUL!! mTheNet must be a Shape! (Rectangle)!! UIImage does _NOT_ work!!