Matlab Class 6 Xiaotao Su, Ph. D

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Create a Simple Game in Scratch
Matlab Class 5 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)
Introduction to Programming
Constructor and New Fields // Don't synch draw() with vertical retrace of monitor graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = true;
Using Draw Tools C 2012jkc. Click File on the menu bar and select Page Setup on the drop- down menu to get the Page Setup dialog box. Under the Margins.
Areas How do you work out the area of this shape ? HINT.
Color Correct and Remove Keystoning A minimalist approach to photographing your art By Paul Marley.
With Barcode Reader :33. with Barcode Reader :33 Selection of barcode reader 1a. Select the button „Configuration“.
Create an Image Map Web Publishing & Design. Hot Spots  hot spot: An area on an object containing a hyperlink. An entire object can be a single hot spot,
Matlab Class 7 Hristiyan Kourtev & Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS)
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
Introduction to Java Simple Graphics. Objects and Methods Recall that a method is an action which can be performed by an object. –The action takes place.
Computer Science Term 1, 2006 Tutorial 1. Tutorial Leader ● Jeremy Long – B. Sc. in Computer Science (2005) – M. Sc. in Computer Science (2007,
Introduction to Image processing using processing.
Design Studies 20 ‘Show Off’ Project How to make a computer monitor In Google Sketchup By: Liam Jack.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
EGR 115 Introduction to Computing for Engineers 3D animation in MATLAB Monday 17 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Introduction To Matlab Class 9 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Matlab Class 4 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
GAME:IT Paddle Ball Objectives: Review skills from Introduction Create a background Add simple object control (up and down) Add how to create a simple.
Matlab Class 6 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Matlab Class 8 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader Rutgers Center for Cognitive Science (RuCCS) and Chris Kourtev.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introduction to Processing David Meredith Aalborg University Art &Technology, 3rd Semester Programming.
Get Microsoft Mouse Mischief
Get Microsoft Mouse Mischief
Click the mouse button or press the Space Bar to display the answers.
Windows Tutorial 3 Personalizing Your Windows Environment
Sound and more Animations
Create a Halloween Computer Game in Scratch
MOM! Phineas and Ferb are … Aims:
Introduction to Illustrator
Pixels, Colors and Shapes
Scratch for Interactivity
Introduction To Matlab Class 3
The Psychophysics Toolbox
The Psychophysics Toolbox
Inserting and Working with Images
Workshop 3.1 Sketching DesignModeler.
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
SketchUp Calculator Level of Difficulty Time
Matlab Class 2 Xiaotao Su, Ph. D
Using the INSERT TAB in MS Word 2007
Microsoft® Small Basic
Introduction To Matlab Class 2
Basic Graphics Drawing Shapes 1.
Introduction To Matlab Class 7
TAB ONE TAB TWO TAB THREE TAB FOUR TAB FIVE
Mouse Inputs in Processing
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Chapter 5, Conditionals Brief Notes
موضوع بحث: تعریف علم اصول جلسه 43.
اشاره به نتایج قیاس های فقهی گاهی، حکم شرعی است
علم اصول، «نفس قواعد» است نه «علم به قواعد»
Lecture 7: Introduction to Processing
A few tricks to take you beyond the basics of Microsoft Office
Surface Area of Rectangular Prisms and Cubes
PowerPoint Now, I will explain about power point.
Buttons & Boards CSE 120 Winter 2019
Creating a Simple Game in Scratch
قاعده لا ضرر، تنها در شبهات حکمیه جاری است
جلسه 34.
JavaScript – Let’s Draw!
Tables BIS 101 Spring 2018.
1 ج : اشاره بعضی از اصولیون به تعریف ترکیبی آخوند با «یک لفظ»
Presentation transcript:

Matlab Class 6 Xiaotao Su, Ph. D Matlab Class 6 Xiaotao Su, Ph.D. Visual Psychophysicist & IT Group Leader & Hristiyan Kourtev Rutgers Center for Cognitive Science (RuCCS)

Displaying images on screen w/ PTB img = imread(‘winter.jpg’, ‘jpg’); You draw an image just like you would a rectangle: Screen(window, ‘PutImage’, img, [0, 0, 200, 200]);

Image info and structures img_info = imfinfo(‘winter.jpg’) img_info.Width will be the width of the image screen(window, ‘PutImage’, img, [0, 0, img_info.Width, img_info.Height]);

Making/Playing sounds w/ PTB A sound is a 2 x N matrix where N is the number of bits that make up the sound file and the two channels are for left and right [sound, samplerate, samplesize] = wavread(‘feedback.wav’); sound = sound’; Snd(‘Play’, sound, samplerate, samplesize); Tip: To make your own wav files I recommend using an application called audacity http://audacity.sourceforge.net/

Getting Input from the Mouse [mouse_x, mouse_y, buttons] = GetMouse(window_ptr); Hide and show the windows cursor during a simulation: HideCursor, ShowCursor If sum(buttons)>0, a button has been clicked

Task 1 – Mousing Around Draw a green circle of radius 30 pixels, whose location on the screen is controlled by the mouse Change the color of the circle to red when a button is clicked and back to green when released Hints: You will need to use the following functions Draw a circle: Screen(window, 'FillOval', dot_color, circle_rect); The position of the cursor marks the center of the circle and the rectangle it is inscribed in.

dot_r = 20; %radius of cursor HideCursor; green = [0, 255, 0]; % mousingAround.m clear all; try which_screen=0; bg_color = [0, 0, 0]; [window_ptr, screen_dimensions]= … Screen(which_screen, … 'OpenWindow', bg_color); dot_r = 20; %radius of cursor HideCursor; green = [0, 255, 0]; red = [255,0, 0]; tic; while(toc<5) [mouse_x, mouse_y, buttons] = GetMouse; if(sum(buttons)>0) dot_color = red; else dot_color = green; end cursor = [ mouse_x-dot_r, mouse_y-dot_r, ... mouse_x+dot_r, mouse_y+dot_r]; Screen(window_ptr, 'FillOval', dot_color, cursor); Screen('Flip', window_ptr); clear Screen; ShowCursor; catch

Direction/Velocity Vectors A vector has both magnitude and direction Direction = [x,y] Magnitude = v = √(x2+y2) = sqrt(x^2 + y^2) % Pythagorean x v y x

Detecting Collisions With Borders rect1 = [10, 10, 50, 50]; % [x1, y1, x2, y2] screen_dimensions = [0, 0, 1280, 1024]; Collision w/ top border if: rect1(2) <= screen_dimensions(2) Collision w/ left border if: rect1(1) <= screen_dimensions(1) Collision w/ bottom border if: rect1(4) >= screen_dimensions(4) Collision w/ right border if: rect1(3) >= screen_dimensions(2)

Task 2 – Bouncing off the walls Modify your existing program to add 2 blue squares that start off in a random direction at speed 5 and 7 pixels respectively and bounce off the walls Hints: Will need to use the Pythagorean theorem to calculate the direction vectors making sure the magnitude is as specified If a square bumps into the left or right walls, invert (multiply by -1) the x component of its velocity vector If a square bumps into the top or bottom walls, invert (multiply by -1) the y component of its velocity vector

Task 3 – Click, Click Modify your program to: Add a circular cursor controlled by the mouse Make the squares clickable. They should change color to purple when clicked. Hint: Purple = [255,0,255]; Hint: The cursor is inside the square if: if((mouse_x>shape_rect(1))&... (mouse_x<shape_rect(3))&... (mouse_y>shape_rect(2))&... (mouse_y<shape_rect(4))) shape_color = purple; end