SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Raphael Marques

Mestrando em Informática da UFPB
jose.raphael.marques@gmail.com
raphaelmarques.wordpress.com
2
var video = Media{
   source: "http://..."
};
var player = MediaPlayer{
   media: video
   autoPlay: true
};
var view = MediaView{
   mediaPlayer: player
};
                            3
4
5
6
7
8
9
10
11
12
13
14
15
16
   Site:
     http://sites.google.com/site/joseraphaelmarques/
   Link lateral: RaceFX
   Sessão: Parte 1
   Link na página: src completo
   Descompactar no pacote racefx



                                                     17
   Site:
     http://sites.google.com/site/joseraphaelmarques/
   Link lateral: RaceFX
   Sessão: Parte 2
   Link na página: src baixar
   Descompactar no pacote racefx



                                                     18
19
public class Track{
    public-init var down: Image;
    public-init var top: Image;
    public-init var layout: Image;
    var layoutView = ImageView{image: layout};
    public-read var downView = ImageView{image: down};
    public-read var topView = ImageView{image: top};
    public function isTrack(x: Number, y: Number):Boolean{
       return layoutView.contains(x,y);
    }
}

                                                             20
21
public-init var track: Track;
function updateMove(factor: Number):Void{
  var vx = Math.cos(angle) * vel * factor;
  var vy = -Math.sin(angle) * vel * factor;
    var i = x + vx;
    var j = y + vy;
    if(not track.isTrack(i, j)){
        vel = 0;
    }else{
        x = i;
        y = j;
    }
}

                                              22
23
def track = Track{
  down: Image {
     url: "{__DIR__}track1down.png"
  }
  top: Image {
     url: "{__DIR__}track1top.png"
  }
  layout: Image {
     url: "{__DIR__}track1layout.png"
  }
}

                                        24
25
var checkpoint1 = Polygon{
   points: [219,1,247,1,247,137,219,137]
};
var checkpoint2 = ...
var checkpoint3 = ...
var checkpoint4 = ...

var checkpointcar1 = checkpoint2;
var checkpointcar2 = checkpoint2;
                                           26
27
var laps1 = 0;
var laps2 = 0;

var laps1Text = Text {...}
var laps2Text = Text {...}




                             28
function checkLaps(){
  if(checkpointcar1.contains(car1.x, car1.y)){
      if(checkpointcar1 == checkpoint1){
            laps1++;
            checkpointcar1 = checkpoint2;
      }else ...
  }
  if(checkpointcar2.contains(car2.x, car2.y)){
      ...
  }
}

                                             29
public override function create():Node{
  Group{
    content: [
         track.downView,
         car1,
         car2,
         track.topView,
         laps1Text,
         laps2Text,
    ]
  }
}
                                          30
31
   Site:
     http://sites.google.com/site/joseraphaelmarques/
   Link lateral: RaceFX
   Sessão: Parte 3
   Link na página: src baixar
   Descompactar no pacote racefx

   Baixe o src completo da parte 2 se necessário.

                                                     32
33
Server              Client
         Internet




                             34
Server              Client
         Internet




                             35
Server              Client
         Internet




                             36
Server              Client
         Internet




                             37
   Client
   Server
   SenderCar
     float x;
     float y;
     float angle;
   ReceiverListener
     public void receive(SenderCar car);
   MySocket
     public void send(SenderCar car);

                                            38
39
public var socket: MySocket;


public function update(time: Long):Void{
  ...
  if(vel != 0){
      updateMove(factor);
      socket.send(new SenderCar(x,y,angle));
  }
}


                                               40
override function receive(car: SenderCar):Void{
  //evitar deadlock
  FX.deferAction(
     function ():Void{
            this.x = car.x;
            this.y = car.y;
            this.angle = car.angle;
     }
  );
}


                                                  41
42
43
44
45
Button {
  text: "PLAY LOCAL“
  …
  action: function() {
     close();
     game.play();
  }
}

                         46
function close():Void{
  var timeline = Timeline {
     keyFrames : [
          KeyFrame {
               time: 1s
               values : translateX => -640
                    tween Interpolator.LINEAR
          }
     ]
  };
  timeline.play();
}
                                           47
48
public var rede = false;
public var server = false;

function update():Void{
  ...
  if(not rede){
      car2.update(time);
  }
  ...
}

                             49
public function reset():Void{
  ...
  if(rede and not server){//client
      car1.y = 90;
      car2.y = 50;
  }else{//server ou local
      car1.y = 50;
      car2.y = 90;
  }
  …
}

                                     50
function checkKey(code:KeyCode,value:Boolean){
  if(code == KeyCode.VK_LEFT){
      ...
  } else
      ...
  } else if(not rede){
      if(code == KeyCode.VK_A){
      ...
      } else ...
  }
}




                                                 51
52
var game = Game{
   rede: false
   server: false
};




                   53
54
Raphael Marques

Mestrando em Informática da UFPB
jose.raphael.marques@gmail.com
raphaelmarques.wordpress.com

Contenu connexe

Tendances

Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2MEJenchoke Tachagomain
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++Ankit Kumar
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory ManagementAlan Uthoff
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicalsManoj Chauhan
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the raceVictor_Cr
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the raceVictor_Cr
 
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...Tao Xie
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languagesJonas Follesø
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.Mike Fogus
 
Compact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinCompact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinDmitry Pranchuk
 
openFrameworks 007 - utils
openFrameworks 007 - utilsopenFrameworks 007 - utils
openFrameworks 007 - utilsroxlu
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in DepthC4Media
 

Tendances (20)

Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory Management
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the race
 
Lecture4
Lecture4Lecture4
Lecture4
 
Travel management
Travel managementTravel management
Travel management
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”
 
Legacy projects: how to win the race
Legacy projects: how to win the raceLegacy projects: how to win the race
Legacy projects: how to win the race
 
Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...
ACM Distinguished Program: Cooperative Testing and Analysis: Human-Tool, Tool...
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
GCD in Action
GCD in ActionGCD in Action
GCD in Action
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languages
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.
 
Compact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinCompact and safely: static DSL on Kotlin
Compact and safely: static DSL on Kotlin
 
openFrameworks 007 - utils
openFrameworks 007 - utilsopenFrameworks 007 - utils
openFrameworks 007 - utils
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 

En vedette

Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Raphael Marques
 
JavaFX: Desktop para desenvolvedores WEB
JavaFX: Desktop para desenvolvedores WEBJavaFX: Desktop para desenvolvedores WEB
JavaFX: Desktop para desenvolvedores WEBjesuinoPower
 
Como ingressar no mercado de Machine Learning
Como ingressar no mercado de Machine LearningComo ingressar no mercado de Machine Learning
Como ingressar no mercado de Machine LearningGabriel Cypriano Saca
 
Aprendizado de Máquinas com Azure Machine Learning e R
Aprendizado de Máquinas com Azure Machine Learning e RAprendizado de Máquinas com Azure Machine Learning e R
Aprendizado de Máquinas com Azure Machine Learning e RDiego Nogare
 
Introdução ao Machine Learning para Hackers
Introdução ao Machine Learning para HackersIntrodução ao Machine Learning para Hackers
Introdução ao Machine Learning para HackersGabriel Cypriano Saca
 
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SP
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SPBoas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SP
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SPjesuinoPower
 
Criando aplicações java fx em minutos
Criando aplicações java fx em minutosCriando aplicações java fx em minutos
Criando aplicações java fx em minutosBruno Oliveira
 
Aplicações Práticas de Machine Learning
Aplicações Práticas de Machine LearningAplicações Práticas de Machine Learning
Aplicações Práticas de Machine LearningLuiz Costa
 
JavaFX: A nova biblioteca gráfica da plataforma Java
JavaFX: A nova biblioteca gráfica da plataforma JavaJavaFX: A nova biblioteca gráfica da plataforma Java
JavaFX: A nova biblioteca gráfica da plataforma JavajesuinoPower
 

En vedette (15)

Introdução ao JavaFX
Introdução ao JavaFXIntrodução ao JavaFX
Introdução ao JavaFX
 
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
 
JavaFX 1.2
JavaFX 1.2JavaFX 1.2
JavaFX 1.2
 
JavaFX
JavaFXJavaFX
JavaFX
 
Classes Internas
Classes InternasClasses Internas
Classes Internas
 
Operadores Java
Operadores JavaOperadores Java
Operadores Java
 
JavaFX: Desktop para desenvolvedores WEB
JavaFX: Desktop para desenvolvedores WEBJavaFX: Desktop para desenvolvedores WEB
JavaFX: Desktop para desenvolvedores WEB
 
Como ingressar no mercado de Machine Learning
Como ingressar no mercado de Machine LearningComo ingressar no mercado de Machine Learning
Como ingressar no mercado de Machine Learning
 
Aprendizado de Máquinas com Azure Machine Learning e R
Aprendizado de Máquinas com Azure Machine Learning e RAprendizado de Máquinas com Azure Machine Learning e R
Aprendizado de Máquinas com Azure Machine Learning e R
 
Introdução ao Machine Learning para Hackers
Introdução ao Machine Learning para HackersIntrodução ao Machine Learning para Hackers
Introdução ao Machine Learning para Hackers
 
Machine Learning - Introdução e Aplicações
Machine Learning - Introdução e AplicaçõesMachine Learning - Introdução e Aplicações
Machine Learning - Introdução e Aplicações
 
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SP
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SPBoas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SP
Boas práticas na criação de aplicações sérias com JavaFX - TDC 2014 SP
 
Criando aplicações java fx em minutos
Criando aplicações java fx em minutosCriando aplicações java fx em minutos
Criando aplicações java fx em minutos
 
Aplicações Práticas de Machine Learning
Aplicações Práticas de Machine LearningAplicações Práticas de Machine Learning
Aplicações Práticas de Machine Learning
 
JavaFX: A nova biblioteca gráfica da plataforma Java
JavaFX: A nova biblioteca gráfica da plataforma JavaJavaFX: A nova biblioteca gráfica da plataforma Java
JavaFX: A nova biblioteca gráfica da plataforma Java
 

Similaire à Mini-curso JavaFX Aula3 UFPB

YQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to userYQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to userTom Croucher
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataAutodesk
 
Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。Mr. Vengineer
 
The State of JavaScript (2015)
The State of JavaScript (2015)The State of JavaScript (2015)
The State of JavaScript (2015)Domenic Denicola
 
Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019Champ Yen
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseAlex Derkach
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webpjcozzi
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35Bilal Ahmed
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentialsPramod Kadam
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScriptChengHui Weng
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...GeeksLab Odessa
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.jsNoritada Shimizu
 
OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010Robert Anderson
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 

Similaire à Mini-curso JavaFX Aula3 UFPB (20)

Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
 
YQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to userYQL and YUI - Javascript from server to user
YQL and YUI - Javascript from server to user
 
20151224-games
20151224-games20151224-games
20151224-games
 
YQL Tutorial
YQL TutorialYQL Tutorial
YQL Tutorial
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design Data
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。Tiramisu をちょっと、味見してみました。
Tiramisu をちょっと、味見してみました。
 
The State of JavaScript (2015)
The State of JavaScript (2015)The State of JavaScript (2015)
The State of JavaScript (2015)
 
Three.js basics
Three.js basicsThree.js basics
Three.js basics
 
Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
 
OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010OL4JSF - Latinoware 2010
OL4JSF - Latinoware 2010
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 

Plus de Raphael Marques

Introdução a Informática - Arquitetura
Introdução a Informática - ArquiteturaIntrodução a Informática - Arquitetura
Introdução a Informática - ArquiteturaRaphael Marques
 
O que você produz além de código?
O que você produz além de código?O que você produz além de código?
O que você produz além de código?Raphael Marques
 
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Raphael Marques
 
Slides de PDI 2009 - Raphael Update 5
Slides de PDI 2009 - Raphael Update 5Slides de PDI 2009 - Raphael Update 5
Slides de PDI 2009 - Raphael Update 5Raphael Marques
 
slides PDI 2007 leonardo
slides PDI 2007 leonardoslides PDI 2007 leonardo
slides PDI 2007 leonardoRaphael Marques
 
Slides PDI 2009 Raphael versao4
Slides PDI 2009 Raphael versao4Slides PDI 2009 Raphael versao4
Slides PDI 2009 Raphael versao4Raphael Marques
 

Plus de Raphael Marques (11)

Sistemas numéricos
Sistemas numéricosSistemas numéricos
Sistemas numéricos
 
Windows explorer
Windows explorerWindows explorer
Windows explorer
 
Interface do windows
Interface do windowsInterface do windows
Interface do windows
 
Internet
InternetInternet
Internet
 
Introdução a Informática - Arquitetura
Introdução a Informática - ArquiteturaIntrodução a Informática - Arquitetura
Introdução a Informática - Arquitetura
 
O que você produz além de código?
O que você produz além de código?O que você produz além de código?
O que você produz além de código?
 
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
Aplicações desktop (GUI) e aplicações ricas para internet (RIA)
 
Slides de PDI 2009 - Raphael Update 5
Slides de PDI 2009 - Raphael Update 5Slides de PDI 2009 - Raphael Update 5
Slides de PDI 2009 - Raphael Update 5
 
slides PDI 2007 leonardo
slides PDI 2007 leonardoslides PDI 2007 leonardo
slides PDI 2007 leonardo
 
Slides PDI 2009 Raphael versao4
Slides PDI 2009 Raphael versao4Slides PDI 2009 Raphael versao4
Slides PDI 2009 Raphael versao4
 
Minicurso Java && Cl
Minicurso Java && ClMinicurso Java && Cl
Minicurso Java && Cl
 

Mini-curso JavaFX Aula3 UFPB

  • 1. Raphael Marques Mestrando em Informática da UFPB jose.raphael.marques@gmail.com raphaelmarques.wordpress.com
  • 2. 2
  • 3. var video = Media{ source: "http://..." }; var player = MediaPlayer{ media: video autoPlay: true }; var view = MediaView{ mediaPlayer: player }; 3
  • 4. 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17. Site:  http://sites.google.com/site/joseraphaelmarques/  Link lateral: RaceFX  Sessão: Parte 1  Link na página: src completo  Descompactar no pacote racefx 17
  • 18. Site:  http://sites.google.com/site/joseraphaelmarques/  Link lateral: RaceFX  Sessão: Parte 2  Link na página: src baixar  Descompactar no pacote racefx 18
  • 19. 19
  • 20. public class Track{ public-init var down: Image; public-init var top: Image; public-init var layout: Image; var layoutView = ImageView{image: layout}; public-read var downView = ImageView{image: down}; public-read var topView = ImageView{image: top}; public function isTrack(x: Number, y: Number):Boolean{ return layoutView.contains(x,y); } } 20
  • 21. 21
  • 22. public-init var track: Track; function updateMove(factor: Number):Void{ var vx = Math.cos(angle) * vel * factor; var vy = -Math.sin(angle) * vel * factor; var i = x + vx; var j = y + vy; if(not track.isTrack(i, j)){ vel = 0; }else{ x = i; y = j; } } 22
  • 23. 23
  • 24. def track = Track{ down: Image { url: "{__DIR__}track1down.png" } top: Image { url: "{__DIR__}track1top.png" } layout: Image { url: "{__DIR__}track1layout.png" } } 24
  • 25. 25
  • 26. var checkpoint1 = Polygon{ points: [219,1,247,1,247,137,219,137] }; var checkpoint2 = ... var checkpoint3 = ... var checkpoint4 = ... var checkpointcar1 = checkpoint2; var checkpointcar2 = checkpoint2; 26
  • 27. 27
  • 28. var laps1 = 0; var laps2 = 0; var laps1Text = Text {...} var laps2Text = Text {...} 28
  • 29. function checkLaps(){ if(checkpointcar1.contains(car1.x, car1.y)){ if(checkpointcar1 == checkpoint1){ laps1++; checkpointcar1 = checkpoint2; }else ... } if(checkpointcar2.contains(car2.x, car2.y)){ ... } } 29
  • 30. public override function create():Node{ Group{ content: [ track.downView, car1, car2, track.topView, laps1Text, laps2Text, ] } } 30
  • 31. 31
  • 32. Site:  http://sites.google.com/site/joseraphaelmarques/  Link lateral: RaceFX  Sessão: Parte 3  Link na página: src baixar  Descompactar no pacote racefx  Baixe o src completo da parte 2 se necessário. 32
  • 33. 33
  • 34. Server Client Internet 34
  • 35. Server Client Internet 35
  • 36. Server Client Internet 36
  • 37. Server Client Internet 37
  • 38. Client  Server  SenderCar  float x;  float y;  float angle;  ReceiverListener  public void receive(SenderCar car);  MySocket  public void send(SenderCar car); 38
  • 39. 39
  • 40. public var socket: MySocket; public function update(time: Long):Void{ ... if(vel != 0){ updateMove(factor); socket.send(new SenderCar(x,y,angle)); } } 40
  • 41. override function receive(car: SenderCar):Void{ //evitar deadlock FX.deferAction( function ():Void{ this.x = car.x; this.y = car.y; this.angle = car.angle; } ); } 41
  • 42. 42
  • 43. 43
  • 44. 44
  • 45. 45
  • 46. Button { text: "PLAY LOCAL“ … action: function() { close(); game.play(); } } 46
  • 47. function close():Void{ var timeline = Timeline { keyFrames : [ KeyFrame { time: 1s values : translateX => -640 tween Interpolator.LINEAR } ] }; timeline.play(); } 47
  • 48. 48
  • 49. public var rede = false; public var server = false; function update():Void{ ... if(not rede){ car2.update(time); } ... } 49
  • 50. public function reset():Void{ ... if(rede and not server){//client car1.y = 90; car2.y = 50; }else{//server ou local car1.y = 50; car2.y = 90; } … } 50
  • 51. function checkKey(code:KeyCode,value:Boolean){ if(code == KeyCode.VK_LEFT){ ... } else ... } else if(not rede){ if(code == KeyCode.VK_A){ ... } else ... } } 51
  • 52. 52
  • 53. var game = Game{ rede: false server: false }; 53
  • 54. 54
  • 55. Raphael Marques Mestrando em Informática da UFPB jose.raphael.marques@gmail.com raphaelmarques.wordpress.com