SlideShare uma empresa Scribd logo
1 de 23
ARTDM 170, Week 12:
  User Interaction
         Gilbert Guerrero
        gguerrero@dvc.edu
gilbertguerrero.com/blog/artdm-170
Turn in Homework

• Please put your files in a folder with
  your last name and first initial
• Put the folder in my dropbox
• Example:
  
   smith-h
  
   
 design.jpg
Timeline
March                              April                        May                Last day of class
9        16      23      30       6*         13   20    27       4    11   18     25

    Create a project title and description

                                                                             Present final projects
                            Paper prototypes                                 (two days)


                                     Design background, characters,
                                     and other game elements


                                              Embed game elements in game symbol
                                              Add movement and keyboard interaction


                                                          Add Start and Game Over screens



                                                                  Add scoring and game over trigger
Paper Prototypes
Collision Detection
hitTestObject                    sprite1




sprite1.hitTestObject(sprite2)              sprite2


• When the bounding
  box of one object overlaps
  with the bounding box of
  another object, a collision is detected
• Use an if() statement to do something with
  the collision
if( sprite1.hitTestObject(sprite2) ) {
    // collision happened
}
hitTestPoint                     sprite1




sprite1.hitTestPoint(x1, y1, true)
• Check if the edge of a shape is near
  a point
• Cannot be used with two shapes,
  only a shape and a point
• Can be used with the mouse, using
  mouseX and mouseY
Collision based on distance

• Detect when two
    objects are near each
    other                    sprite1


•   Collide when the                     sprite2

    distance between their
    registration points is
    less than half their
                             sprite1
    combined sizes
                                       sprite2
Pythagorean Theorem
               C
 A
              B

• To find the distance between two
    points we need the Pythagorean
    Theorem
•   A2 + B2 = C2
Pythagorean Theorem
(x1,y1)
              dist
    dy

   (x1,y2)    dx         (x2,y2)



 • In ActionScript:
    dx = x2 - x1;
    dy = y2 - y1;
    dist = Math.sqrt(dx*dx + dy*dy);
Collision based on distance


                         sprite1

                                   sprite2
var sizeBetween =
  sprite1.width/2 + sprite2.width/2;
if(dist < sizeBetween) {
    // collision detected
}
Point.distance

• Thereʼs a function for this!
var sizeBetween =
  sprite1.width/2 + sprite2.width/2;
if( Point.distance(
  new Point(sprite1.x, sprite1.y),
  new Point(sprite2.x, sprite2.y)
  ) < sizeBetween ) {
    // collision detected
}
Hit the Brick
   example
Pop the Balloon
    example
User Interaction
 keys and spacebar
Listen for Keyboard
stage.addEventListener(
  KeyboardEvent.KEY_DOWN,
  keyDownFunction);


stage.addEventListener(
  KeyboardEvent.KEY_UP,
  keyUpFunction);
Checking which key
// key pressed down
public function
keyDownFunction(event:KeyboardEvent) {
    if(event.keyCode == 37) {
        leftArrow = true;
    } else if(event.keyCode == 39) {
        rightArrow = true;
    } else if(event.keyCode == 32) {
        jumpUp = true;
    }
}
Checking which key
// key lifted up
public function
keyUpFunction(event:KeyboardEvent) {
   if(event.keyCode == 37) {
        leftArrow = false;
    } else if(event.keyCode == 39) {
        rightArrow = false;
    }
}
Key codes

• Spacebar 32
• Left arrow 37
• Up arrow 38
• Right arrow 39
• Down arrow 40
More key codes and constants on
Adobeʼs site
Moving an object
// move to the left
if (leftArrow) {
    myBrick.x -= speed;
}



•   This would allow the user to move
    the object to the left at a certain
    speed every frame.
Time-based animation
•   Using time is more accurate than frames
•   We can capture how much time has
    passed and multiply it by the speed
var timePassed:int =
  getTimer() - lastTime;
lastTime += timePassed;

if (leftArrow) {
    myBrick.x -= speed*timePassed/1000;
}
Jumping
if( jumpUp ) {
    jumpVelocity =
      jumpVelocity - gravity*timePassed/1000;
        myBrick.y -= jumpVelocity;
    if( myBrick.y >= oldBrickY ) {
        jumpVelocity = 40;
        myBrick.y = oldBrickY;
        jumpUp = false;
    }
}
Homework, due April 20

• Embed your game elements in a
  game symbol
• Add basic movement and keyboard
  interaction
• Read p179-193, Paddle Ball in
  Chapter 5 of AS 3.0 Game
  Programming University

Mais conteúdo relacionado

Destaque

Twitter improves your journalism
Twitter improves your journalismTwitter improves your journalism
Twitter improves your journalismSteve Buttry
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysGilbert Guerrero
 
ARTDM170 Week2: GIF Animation
ARTDM170 Week2: GIF AnimationARTDM170 Week2: GIF Animation
ARTDM170 Week2: GIF AnimationGilbert Guerrero
 
American Spy Hidden Camera watch
 American Spy Hidden Camera watch American Spy Hidden Camera watch
American Spy Hidden Camera watchgeorge david
 
Planning for an Uncertain Future. Jaap van der Meer, TAUS
Planning for an Uncertain Future. Jaap van der Meer, TAUSPlanning for an Uncertain Future. Jaap van der Meer, TAUS
Planning for an Uncertain Future. Jaap van der Meer, TAUSABBYY Language Serivces
 
Manage your changing workload
Manage your changing workloadManage your changing workload
Manage your changing workloadSteve Buttry
 
Planning Digital Enterprise Stories
Planning Digital Enterprise StoriesPlanning Digital Enterprise Stories
Planning Digital Enterprise StoriesSteve Buttry
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionGilbert Guerrero
 

Destaque (9)

Twitter improves your journalism
Twitter improves your journalismTwitter improves your journalism
Twitter improves your journalism
 
Conf Aen
Conf AenConf Aen
Conf Aen
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + Arrays
 
ARTDM170 Week2: GIF Animation
ARTDM170 Week2: GIF AnimationARTDM170 Week2: GIF Animation
ARTDM170 Week2: GIF Animation
 
American Spy Hidden Camera watch
 American Spy Hidden Camera watch American Spy Hidden Camera watch
American Spy Hidden Camera watch
 
Planning for an Uncertain Future. Jaap van der Meer, TAUS
Planning for an Uncertain Future. Jaap van der Meer, TAUSPlanning for an Uncertain Future. Jaap van der Meer, TAUS
Planning for an Uncertain Future. Jaap van der Meer, TAUS
 
Manage your changing workload
Manage your changing workloadManage your changing workload
Manage your changing workload
 
Planning Digital Enterprise Stories
Planning Digital Enterprise StoriesPlanning Digital Enterprise Stories
Planning Digital Enterprise Stories
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 

Semelhante a Artdm170 week12 user_interaction

ARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionGilbert Guerrero
 
ARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting InteractivityARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting InteractivityGilbert Guerrero
 
Workflows for developing next gen 3D browser games
Workflows for developing next gen 3D browser gamesWorkflows for developing next gen 3D browser games
Workflows for developing next gen 3D browser gamesMichael Plank
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)Chhom Karath
 
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdf
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdfI have been working on this ROCK, PAPER, SCISSORS project for the pa.pdf
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdffasttracksunglass
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvasdeanhudson
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconftutorialsruby
 
Swift for tensorflow
Swift for tensorflowSwift for tensorflow
Swift for tensorflow규영 허
 
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...Flink Forward
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88Mahmoud Samir Fayed
 
Lecture 3.1 to 3.2 bt
Lecture 3.1 to 3.2 btLecture 3.1 to 3.2 bt
Lecture 3.1 to 3.2 btbtmathematics
 

Semelhante a Artdm170 week12 user_interaction (20)

ARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User InteractionARTDM 170, Week 11: User Interaction
ARTDM 170, Week 11: User Interaction
 
ARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting InteractivityARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting Interactivity
 
Workflows for developing next gen 3D browser games
Workflows for developing next gen 3D browser gamesWorkflows for developing next gen 3D browser games
Workflows for developing next gen 3D browser games
 
Real life XNA
Real life XNAReal life XNA
Real life XNA
 
libGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)
 
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdf
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdfI have been working on this ROCK, PAPER, SCISSORS project for the pa.pdf
I have been working on this ROCK, PAPER, SCISSORS project for the pa.pdf
 
Geohex at Off4g2009
Geohex at Off4g2009Geohex at Off4g2009
Geohex at Off4g2009
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvas
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
building_games_with_ruby_rubyconf
building_games_with_ruby_rubyconfbuilding_games_with_ruby_rubyconf
building_games_with_ruby_rubyconf
 
Swift for tensorflow
Swift for tensorflowSwift for tensorflow
Swift for tensorflow
 
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
 
SA09 Realtime education
SA09 Realtime educationSA09 Realtime education
SA09 Realtime education
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184
 
The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88
 
Primitives
PrimitivesPrimitives
Primitives
 
Lecture 3.1 to 3.2 bt
Lecture 3.1 to 3.2 btLecture 3.1 to 3.2 bt
Lecture 3.1 to 3.2 bt
 

Mais de Gilbert Guerrero

Designing for Skepticism and Bright Sunlight
Designing for Skepticism and Bright SunlightDesigning for Skepticism and Bright Sunlight
Designing for Skepticism and Bright SunlightGilbert Guerrero
 
ARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QAARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QAGilbert Guerrero
 
Artdm 170 week15 publishing
Artdm 170 week15 publishingArtdm 170 week15 publishing
Artdm 170 week15 publishingGilbert Guerrero
 
ARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to ProcessingARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to ProcessingGilbert Guerrero
 
ARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation SchemesARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation SchemesGilbert Guerrero
 
Artdm 171 Week12 Templates
Artdm 171 Week12 TemplatesArtdm 171 Week12 Templates
Artdm 171 Week12 TemplatesGilbert Guerrero
 
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page CompsARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page CompsGilbert Guerrero
 
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper PrototypesARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper PrototypesGilbert Guerrero
 
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User ExperienceARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User ExperienceGilbert Guerrero
 
ARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping CyberspaceARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping CyberspaceGilbert Guerrero
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motionGilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionGilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionGilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionGilbert Guerrero
 
Artdm170 Week5 Intro To Flash
Artdm170 Week5 Intro To FlashArtdm170 Week5 Intro To Flash
Artdm170 Week5 Intro To FlashGilbert Guerrero
 

Mais de Gilbert Guerrero (20)

Designing for Skepticism and Bright Sunlight
Designing for Skepticism and Bright SunlightDesigning for Skepticism and Bright Sunlight
Designing for Skepticism and Bright Sunlight
 
ARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QAARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QA
 
Artdm 171 week15 seo
Artdm 171 week15 seoArtdm 171 week15 seo
Artdm 171 week15 seo
 
Artdm 170 week15 publishing
Artdm 170 week15 publishingArtdm 170 week15 publishing
Artdm 170 week15 publishing
 
ARTDM 171, Week 14: Forms
ARTDM 171, Week 14: FormsARTDM 171, Week 14: Forms
ARTDM 171, Week 14: Forms
 
ARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to ProcessingARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to Processing
 
ARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation SchemesARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation Schemes
 
Artdm 171 Week12 Templates
Artdm 171 Week12 TemplatesArtdm 171 Week12 Templates
Artdm 171 Week12 Templates
 
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page CompsARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page Comps
 
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper PrototypesARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
 
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User ExperienceARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User Experience
 
ARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping CyberspaceARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping Cyberspace
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motion
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm171 Week6 Images
Artdm171 Week6 ImagesArtdm171 Week6 Images
Artdm171 Week6 Images
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 Week5 Intro To Flash
Artdm170 Week5 Intro To FlashArtdm170 Week5 Intro To Flash
Artdm170 Week5 Intro To Flash
 
Artdm171 Week5 Css
Artdm171 Week5 CssArtdm171 Week5 Css
Artdm171 Week5 Css
 
Artdm171 Week4 Tags
Artdm171 Week4 TagsArtdm171 Week4 Tags
Artdm171 Week4 Tags
 

Último

AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster1508 A/S
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyChristopher Totten
 
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道yrolcks
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine CharlottePulte
 
Karim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppKarim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppNadaMohammed714321
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxNitish292041
 
guest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssguest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssNadaMohammed714321
 
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisFW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisPeclers Paris
 
NBA power point presentation final copy y
NBA power point presentation final copy yNBA power point presentation final copy y
NBA power point presentation final copy ysrajece
 
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDin
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDinGeneral Simple Guide About AI in Design By: A.L. Samar Hossam ElDin
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDinSamar Hossam ElDin Ahmed
 
guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssNadaMohammed714321
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks CharlottePulte
 
Sharif's 9-BOX Monitoring Model for Adaptive Programme Management
Sharif's 9-BOX Monitoring Model for Adaptive Programme ManagementSharif's 9-BOX Monitoring Model for Adaptive Programme Management
Sharif's 9-BOX Monitoring Model for Adaptive Programme ManagementMd. Shariful Hoque
 
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfsimpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfLucyBonelli
 
Niintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxNiintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxKevinYaelJimnezSanti
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptJIT KUMAR GUPTA
 
world health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbworld health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbpreetirao780
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designersPixeldarts
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024digital learning point
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 

Último (20)

AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenology
 
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine
 
Karim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppKarim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 ppppppppppppppp
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
 
guest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssguest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssss
 
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisFW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
 
NBA power point presentation final copy y
NBA power point presentation final copy yNBA power point presentation final copy y
NBA power point presentation final copy y
 
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDin
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDinGeneral Simple Guide About AI in Design By: A.L. Samar Hossam ElDin
General Simple Guide About AI in Design By: A.L. Samar Hossam ElDin
 
guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssss
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks
 
Sharif's 9-BOX Monitoring Model for Adaptive Programme Management
Sharif's 9-BOX Monitoring Model for Adaptive Programme ManagementSharif's 9-BOX Monitoring Model for Adaptive Programme Management
Sharif's 9-BOX Monitoring Model for Adaptive Programme Management
 
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfsimpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
 
Niintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxNiintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptx
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
 
world health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbworld health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbb
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 

Artdm170 week12 user_interaction

  • 1. ARTDM 170, Week 12: User Interaction Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170
  • 2. Turn in Homework • Please put your files in a folder with your last name and first initial • Put the folder in my dropbox • Example: smith-h design.jpg
  • 3. Timeline March April May Last day of class 9 16 23 30 6* 13 20 27 4 11 18 25 Create a project title and description Present final projects Paper prototypes (two days) Design background, characters, and other game elements Embed game elements in game symbol Add movement and keyboard interaction Add Start and Game Over screens Add scoring and game over trigger
  • 6. hitTestObject sprite1 sprite1.hitTestObject(sprite2) sprite2 • When the bounding box of one object overlaps with the bounding box of another object, a collision is detected • Use an if() statement to do something with the collision if( sprite1.hitTestObject(sprite2) ) { // collision happened }
  • 7. hitTestPoint sprite1 sprite1.hitTestPoint(x1, y1, true) • Check if the edge of a shape is near a point • Cannot be used with two shapes, only a shape and a point • Can be used with the mouse, using mouseX and mouseY
  • 8. Collision based on distance • Detect when two objects are near each other sprite1 • Collide when the sprite2 distance between their registration points is less than half their sprite1 combined sizes sprite2
  • 9. Pythagorean Theorem C A B • To find the distance between two points we need the Pythagorean Theorem • A2 + B2 = C2
  • 10. Pythagorean Theorem (x1,y1) dist dy (x1,y2) dx (x2,y2) • In ActionScript: dx = x2 - x1; dy = y2 - y1; dist = Math.sqrt(dx*dx + dy*dy);
  • 11. Collision based on distance sprite1 sprite2 var sizeBetween = sprite1.width/2 + sprite2.width/2; if(dist < sizeBetween) { // collision detected }
  • 12. Point.distance • Thereʼs a function for this! var sizeBetween = sprite1.width/2 + sprite2.width/2; if( Point.distance( new Point(sprite1.x, sprite1.y), new Point(sprite2.x, sprite2.y) ) < sizeBetween ) { // collision detected }
  • 13. Hit the Brick example
  • 14. Pop the Balloon example
  • 15. User Interaction keys and spacebar
  • 16. Listen for Keyboard stage.addEventListener( KeyboardEvent.KEY_DOWN, keyDownFunction); stage.addEventListener( KeyboardEvent.KEY_UP, keyUpFunction);
  • 17. Checking which key // key pressed down public function keyDownFunction(event:KeyboardEvent) { if(event.keyCode == 37) { leftArrow = true; } else if(event.keyCode == 39) { rightArrow = true; } else if(event.keyCode == 32) { jumpUp = true; } }
  • 18. Checking which key // key lifted up public function keyUpFunction(event:KeyboardEvent) { if(event.keyCode == 37) { leftArrow = false; } else if(event.keyCode == 39) { rightArrow = false; } }
  • 19. Key codes • Spacebar 32 • Left arrow 37 • Up arrow 38 • Right arrow 39 • Down arrow 40 More key codes and constants on Adobeʼs site
  • 20. Moving an object // move to the left if (leftArrow) { myBrick.x -= speed; } • This would allow the user to move the object to the left at a certain speed every frame.
  • 21. Time-based animation • Using time is more accurate than frames • We can capture how much time has passed and multiply it by the speed var timePassed:int = getTimer() - lastTime; lastTime += timePassed; if (leftArrow) { myBrick.x -= speed*timePassed/1000; }
  • 22. Jumping if( jumpUp ) { jumpVelocity = jumpVelocity - gravity*timePassed/1000; myBrick.y -= jumpVelocity; if( myBrick.y >= oldBrickY ) { jumpVelocity = 40; myBrick.y = oldBrickY; jumpUp = false; } }
  • 23. Homework, due April 20 • Embed your game elements in a game symbol • Add basic movement and keyboard interaction • Read p179-193, Paddle Ball in Chapter 5 of AS 3.0 Game Programming University

Notas do Editor