SlideShare a Scribd company logo
1 of 33
Como Criar o Game 2048
Com JavaFX e Java SE 8
Bruno Borges
Principal Product Manager
Java Evangelist
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 123
• Java Evangelist
• Orale Product Manager
• Entusiasta JavaFX e IoT
• Onde me encontrar
• @brunoborges
• plus.google.com/+BrunoBorges
Bruno Borges
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 124
Agenda
• Jogo 2048
• Da idéia à execução, da execução ao Raspberry Pi
• Java para game developers
• Java SE 8: Lambda expressions, Stream API
• JavaFX 8: Conceitos, CSS, Animações, 3D API
• Outros Exemplos
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 125
• Mova os números em uma matriz
de 4x4
• Quando números iguais se
encontram valores são somados
• Vence quando atingir 2048
• 2, 4, 8, 16, 32, 64, 128, 256, 512,
1024, 2048
O jogo
2048
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 126
Onde jogar 2048?
• iOS
• Android
• Web (Javascript)
• gabrielecirulli.github.io/2048/
• JavaFX
• PCs, Laptops, Tablets e Smartphones (que suportam Oracle Java SE 8),
Raspberry Pi e similares
Em quase todos os lugares!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 127
• Classes de estrutura
• Tile, Location, Direction
• GameManager
• Animações
• Eventos
• Estilos CSS
2048FX
Criando o jogo em JavaFX
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 128
Java Classes
Just a few
Direction, Location
Tile
GameManager
SessionManager
Game2048
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 129
Grid para o 2048
y(i)
x(j)
Criando um grid com Lambda Expressions
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1210
Direction e Location
Estruturas básicas
X Y
UP 0 -1
RIGHT 1 0
DOWN 0 1
LEFT -1 0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1211
Tile
Representa um “quadrado” no jogo, com valor atribuído
Novo tile aleatório.
90% chance para número “2”.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1212
Eventos de Teclado
Ouvindo eventos em JavaFX para movimentar os Tiles
Salva estado atual
Recupera último estado
Ignora teclas que não sejam setas “arrows”
Mapeia setas a Directions, chama GameManager
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1213
Eventos de Touchscreen
Ações mapeadas usando Lambda Expressions do Java 8
* Swipe images from quojs.tapquo.com
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1214
Animações
Movendo os Tiles de um lado para o outro
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1215
Como saber se o jogo acabou?
On Finish
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1216
Mostrar fim do jogo
gameOverProperty.set(true); ... Try again?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1217
Java para Game
Developers
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1218
Java SE 8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1219
Lambda Expressions
Listeners
Com Java SE 8
Com Java SE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1220
Lambda Expressions e Stream API
Exemplo
Com Java SE 8
Com Java SE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1221
Lambda Expression como Parâmetro
Método que recebe uma expressão Lambda
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1222
Parallel Stream
Encontrar Locations disponíveis no grid, usando multi-thread
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1223
JavaFX 8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1224
Arquitetura do JavaFX
• Prism – renderização nativa
• OpenGL (Mac, Linux, Embedded)
• Direct 3D (9 em Windows XP/Vista, 11 em Windows 7)
• Java 2D (software rendering)
• Scene Graph
• Nodes
• States
• Effects
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1225
JavaFX 3D
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1226 26
Criando Formas e Materiais Primitivos
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1227
Colocando Textura em uma Esfera
27
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1228
Colocando Textura em uma Esfera
28
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1229
Colocando Textura em uma Esfera
29
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1230
Para saber mais
 Documentação do Java 8:
 bit.ly/java8docs
 Código-fonte do jogo 2048FX
 github.com/brunoborges/fx2048
 Twitter: @brunoborges
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
ORACLE e V.OFFICE
Parceria WDP (Workforce Development Program)
A Oracle University tem o prazer de anunciar a V.OFFICE
Treinamentos como nosso mais novo parceiro WDP.
A Oracle Corporation lançou o WDP para resolver o déficit global e
contínuo de trabalhadores na área de TI e a necessidade de
treinamento acessível e de baixo custo nas habilidades
correspondentes. O WDP permite que as instituições educacionais
participantes forneçam treinamento em Oracle em tempo integral e
meio-período a alunos em suas comunidades locais.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1232
The preceding is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1233
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1234

More Related Content

Similar to Como criar o jogo 2048 em Java 8 e JavaFX

A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedBruno Borges
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverCodemotion
 
Java Embedded у вас дома
Java Embedded у вас домаJava Embedded у вас дома
Java Embedded у вас домаDiana Dymolazova
 
O Mundo Oracle e o Que Há de Novo no Java
O Mundo Oracle e o Que Há de Novo no JavaO Mundo Oracle e o Que Há de Novo no Java
O Mundo Oracle e o Que Há de Novo no JavaBruno Borges
 
whats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptxwhats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptxGabrielSoche
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiBruno Borges
 
Novidades do Java SE 8
Novidades do Java SE 8Novidades do Java SE 8
Novidades do Java SE 8Bruno Borges
 
Владимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущееВладимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущееOlga Lavrentieva
 
NetBeans Day 2016 - Getting the best of NetBeans IDE
NetBeans Day 2016 - Getting the best of NetBeans IDENetBeans Day 2016 - Getting the best of NetBeans IDE
NetBeans Day 2016 - Getting the best of NetBeans IDELeonardo Zanivan
 
Return of Rich Client Java - Brazil
Return of Rich Client Java - BrazilReturn of Rich Client Java - Brazil
Return of Rich Client Java - BrazilStephen Chin
 
Coding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EECoding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EEGeertjan Wielenga
 
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Marco Antonio Maciel
 
Александр Белокрылов, Александр Мироненко. Java Embedded у вас дома
Александр Белокрылов, Александр Мироненко. Java Embedded у вас домаАлександр Белокрылов, Александр Мироненко. Java Embedded у вас дома
Александр Белокрылов, Александр Мироненко. Java Embedded у вас домаVolha Banadyseva
 
WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5Bruno Borges
 
Java è il linguaggio dell’IoT - Weaver
Java è il linguaggio dell’IoT - WeaverJava è il linguaggio dell’IoT - Weaver
Java è il linguaggio dell’IoT - WeaverCodemotion
 
Oak Table Collaborate Snapclone Talk
Oak Table Collaborate Snapclone TalkOak Table Collaborate Snapclone Talk
Oak Table Collaborate Snapclone TalkKellyn Pot'Vin-Gorman
 
PL/SQL All the Things in Oracle SQL Developer
PL/SQL All the Things in Oracle SQL DeveloperPL/SQL All the Things in Oracle SQL Developer
PL/SQL All the Things in Oracle SQL DeveloperJeff Smith
 
IOUG Collaborate 2014 DBaaS in a DBAs World
IOUG Collaborate 2014 DBaaS in a DBAs WorldIOUG Collaborate 2014 DBaaS in a DBAs World
IOUG Collaborate 2014 DBaaS in a DBAs WorldKellyn Pot'Vin-Gorman
 

Similar to Como criar o jogo 2048 em Java 8 e JavaFX (20)

A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado Embedded
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - Weaver
 
Java Embedded у вас дома
Java Embedded у вас домаJava Embedded у вас дома
Java Embedded у вас дома
 
O Mundo Oracle e o Que Há de Novo no Java
O Mundo Oracle e o Que Há de Novo no JavaO Mundo Oracle e o Que Há de Novo no Java
O Mundo Oracle e o Que Há de Novo no Java
 
whats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptxwhats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptx
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
 
Novidades do Java SE 8
Novidades do Java SE 8Novidades do Java SE 8
Novidades do Java SE 8
 
Владимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущееВладимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущее
 
NetBeans Day 2016 - Getting the best of NetBeans IDE
NetBeans Day 2016 - Getting the best of NetBeans IDENetBeans Day 2016 - Getting the best of NetBeans IDE
NetBeans Day 2016 - Getting the best of NetBeans IDE
 
Return of Rich Client Java - Brazil
Return of Rich Client Java - BrazilReturn of Rich Client Java - Brazil
Return of Rich Client Java - Brazil
 
Marcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL WorkbenchMarcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL Workbench
 
Session 203 iouc summit database
Session 203 iouc summit databaseSession 203 iouc summit database
Session 203 iouc summit database
 
Coding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EECoding for Desktop & Mobile with HTML5 & Java EE
Coding for Desktop & Mobile with HTML5 & Java EE
 
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
 
Александр Белокрылов, Александр Мироненко. Java Embedded у вас дома
Александр Белокрылов, Александр Мироненко. Java Embedded у вас домаАлександр Белокрылов, Александр Мироненко. Java Embedded у вас дома
Александр Белокрылов, Александр Мироненко. Java Embedded у вас дома
 
WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5
 
Java è il linguaggio dell’IoT - Weaver
Java è il linguaggio dell’IoT - WeaverJava è il linguaggio dell’IoT - Weaver
Java è il linguaggio dell’IoT - Weaver
 
Oak Table Collaborate Snapclone Talk
Oak Table Collaborate Snapclone TalkOak Table Collaborate Snapclone Talk
Oak Table Collaborate Snapclone Talk
 
PL/SQL All the Things in Oracle SQL Developer
PL/SQL All the Things in Oracle SQL DeveloperPL/SQL All the Things in Oracle SQL Developer
PL/SQL All the Things in Oracle SQL Developer
 
IOUG Collaborate 2014 DBaaS in a DBAs World
IOUG Collaborate 2014 DBaaS in a DBAs WorldIOUG Collaborate 2014 DBaaS in a DBAs World
IOUG Collaborate 2014 DBaaS in a DBAs World
 

More from Bruno Borges

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesBruno Borges
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on KubernetesBruno Borges
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsBruno Borges
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless ComputingBruno Borges
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersBruno Borges
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudBruno Borges
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...Bruno Borges
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemBruno Borges
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemBruno Borges
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudBruno Borges
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXBruno Borges
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Bruno Borges
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Bruno Borges
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Bruno Borges
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Bruno Borges
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Bruno Borges
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Bruno Borges
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudBruno Borges
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXBruno Borges
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsBruno Borges
 

More from Bruno Borges (20)

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless Computing
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring Developers
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSockets
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 

Como criar o jogo 2048 em Java 8 e JavaFX

  • 1. Como Criar o Game 2048 Com JavaFX e Java SE 8 Bruno Borges Principal Product Manager Java Evangelist
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 123 • Java Evangelist • Orale Product Manager • Entusiasta JavaFX e IoT • Onde me encontrar • @brunoborges • plus.google.com/+BrunoBorges Bruno Borges
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 124 Agenda • Jogo 2048 • Da idéia à execução, da execução ao Raspberry Pi • Java para game developers • Java SE 8: Lambda expressions, Stream API • JavaFX 8: Conceitos, CSS, Animações, 3D API • Outros Exemplos
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 125 • Mova os números em uma matriz de 4x4 • Quando números iguais se encontram valores são somados • Vence quando atingir 2048 • 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 O jogo 2048
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 126 Onde jogar 2048? • iOS • Android • Web (Javascript) • gabrielecirulli.github.io/2048/ • JavaFX • PCs, Laptops, Tablets e Smartphones (que suportam Oracle Java SE 8), Raspberry Pi e similares Em quase todos os lugares!
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 127 • Classes de estrutura • Tile, Location, Direction • GameManager • Animações • Eventos • Estilos CSS 2048FX Criando o jogo em JavaFX
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 128 Java Classes Just a few Direction, Location Tile GameManager SessionManager Game2048
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 129 Grid para o 2048 y(i) x(j) Criando um grid com Lambda Expressions
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1210 Direction e Location Estruturas básicas X Y UP 0 -1 RIGHT 1 0 DOWN 0 1 LEFT -1 0
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1211 Tile Representa um “quadrado” no jogo, com valor atribuído Novo tile aleatório. 90% chance para número “2”.
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1212 Eventos de Teclado Ouvindo eventos em JavaFX para movimentar os Tiles Salva estado atual Recupera último estado Ignora teclas que não sejam setas “arrows” Mapeia setas a Directions, chama GameManager
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1213 Eventos de Touchscreen Ações mapeadas usando Lambda Expressions do Java 8 * Swipe images from quojs.tapquo.com
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1214 Animações Movendo os Tiles de um lado para o outro
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1215 Como saber se o jogo acabou? On Finish
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1216 Mostrar fim do jogo gameOverProperty.set(true); ... Try again?
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1217 Java para Game Developers
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1218 Java SE 8
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1219 Lambda Expressions Listeners Com Java SE 8 Com Java SE 7
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1220 Lambda Expressions e Stream API Exemplo Com Java SE 8 Com Java SE 7
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1221 Lambda Expression como Parâmetro Método que recebe uma expressão Lambda
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1222 Parallel Stream Encontrar Locations disponíveis no grid, usando multi-thread
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1223 JavaFX 8
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1224 Arquitetura do JavaFX • Prism – renderização nativa • OpenGL (Mac, Linux, Embedded) • Direct 3D (9 em Windows XP/Vista, 11 em Windows 7) • Java 2D (software rendering) • Scene Graph • Nodes • States • Effects
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1225 JavaFX 3D
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1226 26 Criando Formas e Materiais Primitivos
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1227 Colocando Textura em uma Esfera 27
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1228 Colocando Textura em uma Esfera 28
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1229 Colocando Textura em uma Esfera 29
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1230 Para saber mais  Documentação do Java 8:  bit.ly/java8docs  Código-fonte do jogo 2048FX  github.com/brunoborges/fx2048  Twitter: @brunoborges
  • 30. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | ORACLE e V.OFFICE Parceria WDP (Workforce Development Program) A Oracle University tem o prazer de anunciar a V.OFFICE Treinamentos como nosso mais novo parceiro WDP. A Oracle Corporation lançou o WDP para resolver o déficit global e contínuo de trabalhadores na área de TI e a necessidade de treinamento acessível e de baixo custo nas habilidades correspondentes. O WDP permite que as instituições educacionais participantes forneçam treinamento em Oracle em tempo integral e meio-período a alunos em suas comunidades locais.
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1232 The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1233
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1234