SlideShare a Scribd company logo
1 of 36
Космические утки-нацисты
шпионы, и где они обитают
1
Докладчики: Любовь Ложкина, Евгений Ворожцов, Алексей Трусов
Основная идея
2
Играть без регистрации и СМС!!!
Составляющие проекта
• Клиент
• Сервер
• Телевизор
3
Клиент
Решаемые задачи:
• Гироскоп и акселерометр
• Адаптивное приложение
4
Гироскоп и акселерометр
Гироскоп — устройство, способное
реагировать на
изменение углов ориентации тела.
5
Акселерометр — это прибор, который
позволяет фиксировать даже
незначительные изменения
ускорения в зависимости от его
положения в пространстве.
Как получить данные?
window.addEventListener("deviceorientation", handleOrientation);
function handleOrientation(event) {
var alpha = event.alpha;
var beta = event.beta;
var gamma = event.gamma;
}
6
Поворот системы координат
Этот - или этот - ?
7
Поворот на угол gamma
Этот точно нам нужен!
Из углов в координаты
8
Сцена 90
160
Угол gamma или y-координаты
Траблы с данными:
• сдвинутая область
значений,
• использовать всю
область неудобно.
9
event.gamma; // In degree in the range [-90,90]
-50
0
-90
90
0
-10
Угол gamma или y-координаты
10
-50
0
-90
90
0
-10
0
45
-45
Если value принадлежит [0, 90] или [-90, -50],
то передаем 45
value – (-50, -10), то
рассчитываем по формуле
value - [-10, 0], то передаем -45
Формула расчета y-координаты
gamma = gamma + 30;
y = -height * gamma / (maxDeg.y * 2);
maxDeg.y – 20
height – 90
11
Примеры:
Пусть gamma = -50, тогда
gamma = -50 + 30= -20
y = -90 * -20 / (20 * 2) = 45
Пусть gamma = -30, тогда
gamma = -30 + 30= 0
y = -90 * 0 / (20 * 2) = 0
Пусть gamma = -10, тогда
gamma = -10 + 30= 20
y = -90 * 20 / (20 * 2) = -45
Почему я ненавижу угол alpha
Вроде бы все
также… 12
20-20
По формуле
Доводим
до 20
Доводим
до -20
alpha = event.alpha; // In degree in the range [0, 360)
НО тут
есть
“шовчик”
13
3600
14
0
350
По формуле
190
Доводим
до
350
30
Доводим
до 30
360
0
20По формуле
220
Доводим
до 20
60
Доводим
до 60
360
Доводим
до 20
Море слез
P. S. А еще оказалось, что alpha
зависит от знака угла gamma. И
появилась функция с названием
deleteAlphaDependence …
0
220По формуле
30
Доводим
до
220
240
Доводим
до 240
360
Доводим
до 240
Адаптивное приложение
15
Выбираем способ реализации
16
17
Основная библиотека
18
Майнд карта фреймворков
19
Стек технологий
20
А теперь немножко магии
21
ACTION
FETCH API
Круговорот «воды»
22
Redux-Saga
• проста и декларативна
• есть много полезных effect’ов
23
Redux-Saga
export function* someAction() {
while(true){
const action = yield take(‘GET_DATA’);
const result = yield call(api.getData, action.payload);
if (!result.error) {
yield put({ type: ‘GET_DATA_SUCCESS’, result });
} else {
yield put({ ‘GET_DATA_FAILED’, result });
}
}
}
24
Redux-Saga Effects
• take, takeEvery, takeLatest
• call
• put
• select
• race
• fork
• delay*
25
«Слушаем» сокеты
26
Socket.io + React
Мое костыльное решение*
/* some imports */
import store from ‘../configureStore’;
const socket = io(URL, {autoconnect: false});
export function initSocket(id) {
const { dispatch } = store;
socket.connect();
socket.emit(‘Start Game’, { id });
socket.on(‘Start Game’, data =>
dispatch({ type: ‘SOCKET_ON_START_GAME’, data
});
/* some code */
}
27
А что еще?
Немного об HTML 5 API
Fullscreen API (el.requestFullScreen())
Vibrate API (Navigator.vibrate)
// use vibrate
navigator.vibrate([100, 300, 500]);
28
Резюмируем
Сервер
• API для общего функционала
• Socket.io для игры
• База данных
Задача:
максимально
снизить нагрузку
на сервер.
29
Сервер. API
• Стандартизированные ответы
• Минимизация обращений к базе
{
"result":"ok",
"data":{
"nick":"цереус_62“
}
}
30
Сервер. Socket.io
• Подсчет оставшегося времени
• Передача прицела на ТВ
• Передача результата выстрела обратно
клиенту
31
Сервер. База данных
32
• Список пользователей
• Список записавшихся на интервью
• Результаты
Телевизор
33
Общий вид приложения на ТВ
Телевизор
• Обрабатывает движение
уток
• Обрабатывает
отображение прицелов
• Определяет
попадания при выстреле
• Возвращает
результат стрельбы
• Отрисовывает анимацию
34
Телевизор. Анимация
35
Спасибо за внимание!
36
Ваши вопросы!

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Angry ducks