Giter Site home page Giter Site logo

chestnutmachine's Introduction

🥊 딱밤 머신 ( chestnutMachine ) Multi version

아두이노, 웹앱, 파이어베이스를 이용한 딱밤머신 만들기
(Arduiono Wemos D1 R1 + React + Firebase realtimeDatabase)

solo version(solo브랜치)을 먼저 작업했고 추가로 멀티플레이 기능을 넣었습니다.

📃 요구사항 명세 (Multi version)

  • 게임의 최대 인원수는 4명이다.
  • 첫번째로 방을 만드는 사람이 방장이 되며 게임 시작하기를 누를 수 있다.
  • 홈 화면에서 방 생성여부를 알 수 있다.
  • 게임을 시작하면 방에들어온 유저 순서대로 딱밤머신을 쳐서 점수를 측정한다.

🎨디자인 작업 (Multi version 추가)

https://www.figma.com/file/HbsvGWSwO512AxkmoUUTxk/%EB%94%B1%EB%B0%A4%EB%A8%B8%EC%8B%A0?node-id=0%3A1

스크린샷

게임 페이지 유저가 들어왔을 경우 게임시작 게임 끝
image image image image image

👑 결과물 웹 URL: https://daehwan2.github.io/chestnutMachine/ ( Multi version )

데이터베이스 구조

유저 3명이 대기중일 때

{
  "isCompleted": false,
  "isPlaying": false,
  "playingUsers": {
    "-N0dPOBFva3ysyC-OK6N": {
      "email": "[email protected]",
      "name": "김대환",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxbEhdq_D6aZbEbMoXP74LGmoNWmdqz1fjPf1RY=s96-c",
      "score": 0,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    "-N0dPPFvQyH_kc-TCEoO": {
      "email": "[email protected]",
      "name": "성미진",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJycJM9YFAz2JWKAUtUFFT55aNGdB5S2lLyMVsM=s96-c",
      "score": 0,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
    "-N0dPoTtrXfst8EwJEFk": {
      "email": "[email protected]",
      "name": "소연",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxQirk8LWPzOZ2Z0qmvSp30PiX1WPtbFhsJnTcB=s96-c",
      "score": 0,
      "uid": "k0SjuXH2Q6OX7xCK5AG5w1n2lPA3"
    }
  },
  "score": 0,
  "turn": 0
}

게임시작 눌렀을 경우 ( turn = 1 인 경우 첫번째 유저의 점수 )

{
  "isCompleted": false,
  "isPlaying": true,
  "playingUsers": {
    "-N0dPOBFva3ysyC-OK6N": {
      "email": "[email protected]",
      "name": "김대환",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxbEhdq_D6aZbEbMoXP74LGmoNWmdqz1fjPf1RY=s96-c",
      "score": 0,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    "-N0dPPFvQyH_kc-TCEoO": {
      "email": "[email protected]",
      "name": "성미진",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJycJM9YFAz2JWKAUtUFFT55aNGdB5S2lLyMVsM=s96-c",
      "score": 0,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
    "-N0dPoTtrXfst8EwJEFk": {
      "email": "[email protected]",
      "name": "소연",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxQirk8LWPzOZ2Z0qmvSp30PiX1WPtbFhsJnTcB=s96-c",
      "score": 0,
      "uid": "k0SjuXH2Q6OX7xCK5AG5w1n2lPA3"
    }
  },
  "score": 0,
  "turn": 1
}

turn = 3 인경우 세번째 유저의 점수 측정을 기다리는 상태

{
  "isCompleted": false,
  "isPlaying": true,
  "playingUsers": [
    {
      "email": "[email protected]",
      "name": "김대환",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxbEhdq_D6aZbEbMoXP74LGmoNWmdqz1fjPf1RY=s96-c",
      "score": 999,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    {
      "email": "[email protected]",
      "name": "성미진",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJycJM9YFAz2JWKAUtUFFT55aNGdB5S2lLyMVsM=s96-c",
      "score": 444,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
    {
      "email": "[email protected]",
      "name": "소연",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxQirk8LWPzOZ2Z0qmvSp30PiX1WPtbFhsJnTcB=s96-c",
      "score": 0,
      "uid": "k0SjuXH2Q6OX7xCK5AG5w1n2lPA3"
    }
  ],
  "score": 0,
  "scores": {
    "-N0dPxavUu6XHRcOctmU": {
      "createdAt": 1651036119131,
      "email": "[email protected]",
      "name": "김대환",
      "score": 999,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    "-N0dQ-MweV4CYEWmqm3I": {
      "createdAt": 1651036130460,
      "email": "[email protected]",
      "name": "성미진",
      "score": 444,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
  "turn": 3
}

게임을 완료한 경우(전부 딱밤머신을 친 경우)

{
  "isCompleted": true,
  "isPlaying": true,
  "playingUsers": [
    {
      "email": "[email protected]",
      "name": "김대환",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxbEhdq_D6aZbEbMoXP74LGmoNWmdqz1fjPf1RY=s96-c",
      "score": 999,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    {
      "email": "[email protected]",
      "name": "성미진",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJycJM9YFAz2JWKAUtUFFT55aNGdB5S2lLyMVsM=s96-c",
      "score": 444,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
    {
      "email": "[email protected]",
      "name": "소연",
      "photoURL": "https://lh3.googleusercontent.com/a/AATXAJxQirk8LWPzOZ2Z0qmvSp30PiX1WPtbFhsJnTcB=s96-c",
      "score": 688,
      "uid": "k0SjuXH2Q6OX7xCK5AG5w1n2lPA3"
    }
  ],
  "score": 0,
  "scores": {
    "-N0dPxavUu6XHRcOctmU": {
      "createdAt": 1651036119131,
      "email": "[email protected]",
      "name": "김대환",
      "score": 999,
      "uid": "Kvh7M2sodHRLYTzLeMQdY1W9PFu1"
    },
    "-N0dQ-MweV4CYEWmqm3I": {
      "createdAt": 1651036130460,
      "email": "[email protected]",
      "name": "성미진",
      "score": 444,
      "uid": "HiK1Wz3qrcYejPj1moaTDGDM4w12"
    },
    "-N0dQ2Gm5B-m2dFx2KcL": {
      "createdAt": 1651036142354,
      "email": "[email protected]",
      "name": "소연",
      "score": 688,
      "uid": "k0SjuXH2Q6OX7xCK5AG5w1n2lPA3"
    }
  },
  "turn": 0
}

chestnutmachine's People

Contributors

daehwan2 avatar

Watchers

 avatar

chestnutmachine's Issues

arduino error addons/TokenHelper.h No such file or directory

addons/TokenHelper.h No such file or directory


아두이노에서 잘되다가 에러가 났다



#if defined(ESP32)
#include <WiFi.h>
#include <FirebaseESP32.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#endif

#include <addons/TokenHelper.h>

#include <addons/RTDBHelper.h>
#include <TM1637Display.h>
#define CLK D2
#define DIO D3

#define WIFI_SSID ""

#define WIFI_PASSWORD ""


#define API_KEY ""

#define DATABASE_URL "" //<databaseName>.firebaseio.com or <databaseName>.<region>.firebasedatabase.app

#define USER_EMAIL ""
#define USER_PASSWORD ""

FirebaseData fbdo;

FirebaseAuth auth;
FirebaseConfig config;
TM1637Display display(CLK, DIO);

unsigned long sendDataPrevMillis = 0;

unsigned long count = 0;
int FSRsensor = A0;                           // 센서값을 아나로그 A0핀 설정

int value = 0;                                       // loop에서 사용할 변수 설정


void setup()
{

  Serial.begin(115200);

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();



  Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);

  config.api_key = API_KEY;

  auth.user.email = USER_EMAIL;
  auth.user.password = USER_PASSWORD;

  config.database_url = DATABASE_URL;

  config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h

  Firebase.begin(&config, &auth);

  Firebase.reconnectWiFi(true);

  Firebase.setDoubleDigits(5);

  display.setBrightness(2);
  display.showNumberDec(0,false,4);
  
}

void displaySegment(int value){
  int digit1, digit2, digit3, digit4;
  digit4 = value % 10;   // 일의 자리
  value /= 10;
  digit3 = value % 10;   // 십의 자리
  value /= 10;
  digit2 = value % 10; // 백의 자리
  value /= 10;
  digit1 = value % 10; // 천의 자리

  // display.showNumberDec(표시할 숫자, 자릿수 0을 채울 것인지, 몇자리표시할건지, 표시할 위치)
  display.showNumberDec(digit1,false,1,0);
  display.showNumberDec(digit2,false,1,1);   
  display.showNumberDec(digit3,false,1,2);
  display.showNumberDec(digit4,false,1,3);
}

void loop()
{
  if(Firebase.ready()){
    
    value = analogRead(FSRsensor);     // 센서값을 아나로그로 읽어 value 변수에 저장
    if(value >10){
      
    bool bIsPlaying;
    bool bIsCompleted;
    Firebase.getBool(fbdo,"isPlaying",&bIsPlaying);
    Firebase.getBool(fbdo,"isCompleted",&bIsCompleted);
    if(bIsPlaying && !bIsCompleted){
      Serial.print("a");
      displaySegment(value); //세그먼트에 출력
      Serial.println(value);                           // 센서값을 시리얼 모니터에 출력
      Firebase.setInt(fbdo,"score",value);
    }
  }
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.