Operácie

Among Us Človeče

Z SensorWiki

Záverečný projekt predmetu DTV / LS2023 - Péter Heller, Gabriel Bukriš


Ako sa hrá človeče?

► Cieľom hry je dostať všetky štyri figúrky zo štartového poľa na cieľové polia.

► Po hodení šestky môže figúrka odštartovať.

► Pritom musia figúrky raz obísť všetky polia, bez toho, aby ju súper nevyhodil.

► Počet prejdených polí sa určí hodom očíslovanej kocky.

Používané technológie

Figúrky │ 3D tlač

Najprv sme museli navrhnúť herné figúrky. Na to sme použili OPENSCAD.

Potom sme chceli, aby každá herná figúrka bola jedinečná pre 4 hráčov, preto sme navrhli 4 rôzne typy klobúkov, ktoré sme umiestnili na základný model.

Potom sme išli do fablabu a vytlačili sme ich v rôznych farbách.


Amongus3DAll.jpg













Herná plocha │ Laser

► Plocha je z dreva

► Hernú plochu sme vyrezali s laserom

► Hracie polia sú gravírované


Doska v Inkscape
Dokončená doska



Kocka │ Elektronika

Rozhodli sa vytvoriť digitálnu kocku so zvukovými efektmi.

Použité komponenty:

► Arduino UNO

► 6 segment display

► Gombík

► Buzzer

► Resistor 330Ω

ArduinoIRL.jpg
ArduinoSim.png



// Constants for the 7-segment display pins
const int segmentPins[] = {2, 3, 4, 5, 6, 7, 8};

// Button pin
const int buttonPin = 9;

// Variables
int randomNumber = 0;
bool buttonPressed = false;

void setup() {
  // Set the 7-segment display pins as outputs
  for (int i = 0; i < 7; i++) {
    pinMode(segmentPins[i], OUTPUT);
  }
  Serial.begin(9600);

  // Set the button pin as input
  pinMode(buttonPin, INPUT_PULLUP);
  
  pinMode(12, OUTPUT);

  // Initialize the random seed
  randomSeed(analogRead(0));

  // Set the initial display to 0
  displayNumber(0);
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(buttonPin) == LOW && !buttonPressed) {
    buttonPressed = true;
    Serial.print("megy");

    for (int i = 0; i < 10; i++){
          playSlotMachineSound();
      randomNumber = random(1, 7);
    // Display the generated number
    	displayNumber(randomNumber);
      delay (20);
    }
    
    // Generate a random number between 1 and 6
    randomNumber = random(1, 7);
    // Display the generated number
    displayNumber(randomNumber);
  }

  // Reset the button pressed flag if the button is released
  if (digitalRead(buttonPin) == HIGH && buttonPressed) {
    buttonPressed = false;
  }
}

void playSlotMachineSound() {
  // Define the frequencies for the sound
  int frequencies[] = {262, 196, 440, 392, 349, 293};

  // Play the sound for a short duration
  for (int i = 0; i < 6; i++) {
    tone(12, frequencies[i], 100);
    delay(20);
    noTone(12);
    //delay(50);
  }
}

// Display a number on the 7-segment display
void displayNumber(int number) {
  // Define the 7-segment display patterns for each digit
  const int digitPatterns[][7] = {
    {1, 0, 0, 1, 1, 1, 1},  // 1
    {0, 0, 1, 0, 0, 1, 0},  // 2
    {0, 0, 0, 0, 1, 1, 0},  // 3
    {1, 0, 0, 1, 1, 0, 0},  // 4
    {0, 1, 0, 0, 1, 0, 0},  // 5
    {0, 1, 0, 0, 0, 0, 0},  // 6
};

  // Display the segments for the given number
  if (number >= 1 && number <= 6) {
    // Display the segments for the given number
    for (int i = 0; i < 7; i++) {
      digitalWrite(segmentPins[i], digitPatterns[number - 1][i]);
    }
  }
}


Zdrojový kód: Digital dice




Kľúčové slová 'Category', ktoré sú na konci stránky nemeňte.