f

Dependencies:   mbed 4DGL-uLCD-SE MMA8452

Files at this revision

API Documentation at this revision

Comitter:
dfrausto3
Date:
Tue Apr 12 01:39:20 2022 +0000
Parent:
5:077b66dfe296
Commit message:
f

Changed in this revision

dictionary.h Show annotated file Show diff for this revision Revisions of this file
doubly_linked_list.cpp Show annotated file Show diff for this revision Revisions of this file
doubly_linked_list.h Show annotated file Show diff for this revision Revisions of this file
hardware.cpp Show annotated file Show diff for this revision Revisions of this file
keyboard.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/dictionary.h	Mon Mar 14 23:38:03 2022 +0000
+++ b/dictionary.h	Tue Apr 12 01:39:20 2022 +0000
@@ -13,7 +13,15 @@
 } word;  
 
 
-Word dictionary[2] = {
+Word dictionary[10] = {
     {"speed", {1,1,2,1,0}, {'s','p', 'e', 'd', '!'}},
-    {"crane", {1,1,1,1,1}, {'c', 'r', 'a', 'n', 'e'}}
+    {"crane", {1,1,1,1,1}, {'c', 'r', 'a', 'n', 'e'}},
+    {"porte", {1,1,1,1,1}, {'p','o', 'r', 't', 'e'}},
+    {"adult", {1,1,1,1,1}, {'a', 'd', 'u', 'l', 't'}},
+    {"naive", {1,1,1,1,1}, {'n','a', 'i', 'v', 'e'}},
+    {"glans", {1,1,1,1,1}, {'g', 'l', 'a', 'n', 's'}},
+    {"thick", {1,1,1,1,1}, {'t','h', 'i', 'c', 'k'}},
+    {"agony", {1,1,1,1,1}, {'a', 'g', 'o', 'n', 'y'}},
+    {"spiky", {1,1,1,1,1}, {'s','p', 'i', 'k', 'y'}},
+    {"child", {1,1,1,1,1}, {'c', 'h', 'i', 'l', 'd'}}
     };
--- a/doubly_linked_list.cpp	Mon Mar 14 23:38:03 2022 +0000
+++ b/doubly_linked_list.cpp	Tue Apr 12 01:39:20 2022 +0000
@@ -1,1 +1,255 @@
-//Put your DLL from P2-1 in here
\ No newline at end of file
+//=================================================================
+// Implementation for DLL module.
+//
+// Copyright 2022 Georgia Tech.  All rights reserved.
+// The materials provided by the instructor in this course are for
+// the use of the students currently enrolled in the course.
+// Copyrighted course materials may not be further disseminated.
+// This file must not be made publicly available anywhere.
+//=================================================================
+#include <stdlib.h>
+#include <stdio.h>
+#include "doubly_linked_list.h"
+
+//===========================
+/* Creating nodes and lists */
+//===========================
+
+LLNode* create_llnode(void* data) {
+    LLNode* newNode = (LLNode*)malloc(sizeof(LLNode));
+    newNode->data = data;
+    newNode->next = NULL;
+    newNode->prev = NULL;
+    return newNode;
+}
+
+DLinkedList* create_dlinkedlist(CompareFunction compare) {
+    DLinkedList* newList = (DLinkedList*)malloc(sizeof(DLinkedList));
+    newList->head = NULL;
+    newList->tail = NULL;
+    newList->size = 0;
+    newList->compare = compare;
+    return newList;
+}
+
+//============================
+/* Accessing nodes and lists */
+//============================
+
+int getSize(DLinkedList* dLinkedList){
+    int s = dLinkedList->size;
+    return s;
+
+}
+
+LLNode* getHead(DLinkedList* dLinkedList){
+    return dLinkedList->head;
+}
+
+LLNode* getTail(DLinkedList* dLinkedList){
+    return dLinkedList->tail;
+}
+
+LLNode* getNext(LLNode* node){
+    return node->next;
+}
+
+LLNode* getPrev(LLNode* node){
+    return node->prev;
+}
+
+void* getData(LLNode* node){
+    return node->data;
+}
+
+//============================
+/* Inserting nodes into lists */
+//============================
+
+void insertAfter(DLinkedList* dLinkedList, LLNode* prev_node, void* data){
+    LLNode* newNode = create_llnode(data);  //Creates new Node
+    LLNode* nextNode = getNext(prev_node);  //gets a pointer for the next node
+    if (prev_node != NULL) {
+        if (nextNode == NULL) {  //if the node passed through is the tail then inserts the new node as the new tail
+            prev_node->next = newNode;
+            newNode->prev = prev_node;
+            dLinkedList->tail = newNode;
+            dLinkedList->size = dLinkedList->size + 1;
+        }
+        else { //if the node passed through is not the tail then inserts the new node after and updates surrounding nodes
+            newNode->next = nextNode;
+            nextNode->prev = newNode;
+            prev_node->next = newNode;
+            newNode->prev = prev_node;
+            dLinkedList->size = dLinkedList->size + 1;
+        }
+    }
+    else {
+        printf("ERROR: Node is Null\n");
+    }
+}
+
+
+void insertBefore(DLinkedList* dLinkedList, LLNode* prev_node, void* data){
+    LLNode* newNode = create_llnode(data);  //Creates new node
+    LLNode* prevNode = getPrev(prev_node);  //gets a pointer for the prev node
+    if (prev_node != NULL) {
+        if (prevNode == NULL) {     // if the node passed through is the head then inserts the node as the new head
+            prev_node->prev = newNode;
+            newNode->next = prev_node;
+            dLinkedList->head = newNode;
+            dLinkedList->size = dLinkedList->size + 1;
+        }
+        else { //if the node passed through is not the head then inserts the new node before and updates surrounding nodes
+            newNode->prev = getPrev(prev_node);
+            prevNode->next = newNode;
+            prev_node->prev = newNode;
+            newNode->next = prev_node;
+            dLinkedList->size = dLinkedList->size + 1;
+        }
+    }
+    else {
+        printf("ERROR: Node is Null\n");
+    }
+}
+
+
+void insertHead(DLinkedList* dLinkedList, void* data){ //inserts data at the head
+    LLNode* newHead = create_llnode(data);
+    if (dLinkedList == NULL) { //if dLinkedList does not exist throws an error message
+        printf("Cant' do that");
+        return;
+    }
+    else if (dLinkedList->head == NULL) {
+        dLinkedList->head = newHead;
+        dLinkedList->tail = newHead;
+        dLinkedList->size = dLinkedList->size + 1;
+    }
+    else {
+        LLNode* oldHead = dLinkedList->head;
+        dLinkedList->head = newHead;
+        newHead->next = oldHead;
+        oldHead->prev = newHead;
+        dLinkedList->size = dLinkedList->size + 1;
+    }
+}
+
+void insertTail(DLinkedList* dLinkedList, void* data) { //if dLinkedList does not exist throws an error message
+    LLNode* newTail = create_llnode(data);
+    if (dLinkedList == NULL) {
+        printf("Cant' do that");
+        return;
+    }
+    else if (dLinkedList->head == NULL) {
+        dLinkedList->head = newTail;
+        dLinkedList->tail = newTail;
+        dLinkedList->size = dLinkedList->size + 1;
+    }
+    else {
+        LLNode* oldTail = dLinkedList->tail;
+        dLinkedList->tail = newTail;
+        newTail->prev = oldTail;
+        oldTail->next = newTail;
+        dLinkedList->size = dLinkedList->size + 1;
+    }
+
+}
+
+//============================
+/* Looking up nodes in lists */
+//============================
+
+LLNode* findNode(DLinkedList* dLinkedList, void* data){
+    //LLNode* findNode = create_llnode(data);
+   
+    LLNode* compNode = dLinkedList->head;
+    if (compNode == NULL) {
+        return NULL;
+    }
+    //runs through dLinkedList looking for data
+    int i;
+    for (i = 0; i < dLinkedList->size; i++) {
+        int j = dLinkedList->compare(compNode->data, data);
+        if (j == 1) {
+            return compNode;
+        }
+        else {
+            compNode = compNode->next;
+        }
+    }
+    return NULL;
+}
+
+//===========================
+/* Deleting nodes and lists */
+//===========================
+
+void deleteNode(DLinkedList* dLinkedList, LLNode* Node){
+    if (Node != NULL){
+        LLNode* PrevNode = getPrev(Node);
+        LLNode* NextNode = getNext(Node);
+        if (PrevNode == NULL && NextNode != NULL) { //if head delets noed and updates the head of the list
+            dLinkedList->head = NextNode;
+            dLinkedList->size = dLinkedList->size - 1;
+            NextNode->prev = NULL;
+        }
+        else if (NextNode == NULL && PrevNode != NULL) { //if tail delets the node and updates the tail of the list
+            dLinkedList->tail = PrevNode;
+            dLinkedList->size = dLinkedList->size - 1;
+            PrevNode->next = NULL;
+        }
+        else if (PrevNode == NULL && NextNode == NULL) {
+            dLinkedList->tail = NULL;
+            dLinkedList->head = NULL;
+            dLinkedList->size = dLinkedList->size - 1;
+        }
+        else {
+            dLinkedList->size = dLinkedList->size - 1;
+            (Node->prev)->next = NextNode;
+            (Node->next)->prev = PrevNode;
+        }
+    }
+    //free(Node->data);
+    free(Node);
+}
+
+
+void destroyList(DLinkedList* dLinkedList){
+    LLNode* startNode = dLinkedList->head;
+    LLNode* nextNode;
+    if (startNode != NULL) {
+        nextNode = startNode->next;
+    }
+    int i;
+    for (i = 0; i < getSize(dLinkedList); i++) {
+        free(startNode->data);
+        free(startNode);
+        startNode = nextNode;
+        if (startNode != NULL) {
+            nextNode = startNode->next;
+        }
+    }
+    free(dLinkedList);
+}
+
+//==================
+/* Reversing lists */
+//==================
+void reverse(DLinkedList* dLinkedList) {
+    if (dLinkedList->size > 1) {
+        LLNode* headNode = dLinkedList->head;
+        LLNode* tailNode = dLinkedList->tail;
+        LLNode* tempNode = dLinkedList->head;
+        int i = 0;
+        dLinkedList->head = tailNode;
+        dLinkedList->tail = headNode;
+        while (i < dLinkedList->size) {
+            headNode->prev = headNode->next;
+            tempNode = headNode->prev;
+            headNode = tempNode;
+            i++;
+        }
+
+        
+    }
+}
\ No newline at end of file
--- a/doubly_linked_list.h	Mon Mar 14 23:38:03 2022 +0000
+++ b/doubly_linked_list.h	Tue Apr 12 01:39:20 2022 +0000
@@ -1,1 +1,253 @@
-//Put your DLL header file from P2-1 in here
\ No newline at end of file
+//Put your DLL header file from P2-1 in here//Put your DLL header file from P2-1 in here//=================================================================
+// Header file for DLL module.
+//
+// Copyright 2022 Georgia Tech.  All rights reserved.
+// The materials provided by the instructor in this course are for
+// the use of the students currently enrolled in the course.
+// Copyrighted course materials may not be further disseminated.
+// This file must not be made publicly available anywhere.
+//=================================================================
+
+#ifndef DOUBLELINKEDLIST_H
+#define DOUBLELINKEDLIST_H
+
+// A function pointer type
+typedef int (*CompareFunction)(void* input1, void* input2);
+
+// A linked list node structure.
+typedef struct llnode_t {
+    void* data;
+    struct llnode_t* prev;
+    struct llnode_t* next;
+}LLNode;
+
+/// The structure to store the information of a doubly linked list
+typedef struct dlinkedlist_t {
+    struct llnode_t* head;
+    struct llnode_t* tail;
+    int size;
+    CompareFunction compare;
+} DLinkedList;
+
+//===========================
+/* Creating nodes and lists */
+//===========================
+
+/**
+ * create_llnode
+ *
+ * Creates a node by allocating memory for it on the heap,
+ * and initializing its previous and next pointers to NULL and 
+ * its data pointer to the input data pointer
+ *
+ * @param data A void pointer to data the user is adding to the doubly linked list.
+ * @return A pointer to the linked list node
+ */
+LLNode* create_llnode(void* data);
+
+/**
+ * create_dlinkedlist
+ *
+ * Creates a doubly linked list by allocating memory for it on the heap. 
+ * Initialize the size to zero, as well as head and tail pointers to NULL
+ *
+ * @return A pointer to an empty dlinkedlist
+ */
+DLinkedList* create_dlinkedlist(CompareFunction compare);
+
+//============================
+/* Accessing nodes and lists */
+//============================
+
+/**
+ * getSize
+ *
+ * Return the size of the doubly linked list
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @return  the size
+ */
+int getSize(DLinkedList* dLinkedList);
+
+/**
+ * getHead
+ *
+ * Return the head of the doubly linked list
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @return A pointer to an LLNode
+ */
+LLNode* getHead(DLinkedList* dLinkedList);
+
+/**
+ * getTail
+ *
+ * Return the tail of the doubly linked list
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @return A pointer to an LLNode
+ */
+LLNode* getTail(DLinkedList* dLinkedList);
+
+/**
+ * getNext
+ *
+ * Return the next node after the input node.
+ *
+ * @param node A pointer to an LLNode
+ * @return A pointer to an LLNode
+ */
+LLNode* getNext(LLNode* node);
+
+/**
+ * getPrev
+ *
+ * Return the previous node before the input node.
+ *
+ * @param node A pointer to an LLNode
+ * @return A pointer to an LLNode
+ */
+LLNode* getPrev(LLNode* node);
+
+/**
+ * getData
+ *
+ * Return the input node's data.
+ *
+ * @param node A pointer to an LLNode
+ * @return A void pointer to the node's data.
+ */
+void* getData(LLNode* node);
+
+//============================
+/* Inserting nodes into lists */
+//============================
+
+/**
+ * insertAfter
+ *
+ * Insert data after the prev_node. Update head/tail if necessary.
+ * Assumes prev_node is not NULL and is in dLinkedList.
+ * (Check if it is NULL and if so, print an error message and return.)
+ * Update the size.
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param pre_node A pointer to a linked list node.
+ * @param data A void pointer to data.
+ */
+void insertAfter(DLinkedList* dLinkedList, LLNode* prev_node, void* data);
+
+/**
+ * insertBefore
+ *
+ * Insert data before the next_node. Update head/tail if necessary.
+ * Assumes next_node is not NULL and is in dLinkedList. 
+ * (Check if it is NULL and if so, print an error message and return.)
+ * Update the size.
+
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param pre_node A pointer to a linked list node.
+ * @param data A void pointer to data.
+ */
+void insertBefore(DLinkedList* dLinkedList, LLNode* next_node, void* data);
+
+/**
+ * insertHead
+ *
+ * Create a new LLNode with the given data and insert it at the head of the
+ * doubly linked list. Update head/tail/size if necessary.
+ * Note: The case where dLinkedList is not empty can be implemented by calling
+ * insertBefore with the head of the list as the next_node.
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param data A void pointer to data the user is adding to the doubly linked list.
+ * 
+ */
+void insertHead(DLinkedList* dLinkedList, void* data);
+
+
+/**
+ * insertTail
+ *
+ * Create a new LLNode with the given data and insert it at the tail of the 
+ * doubly linked list. Update head/tail/size if necessary.
+ * Note: The case where dLinkedList is not empty can be implemented by calling
+ * insertAfter with the tail of the list as the prev_node.
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param data A void pointer to data the user is adding to the doubly linked list.
+ * 
+ */
+void insertTail(DLinkedList* dLinkedList, void* data);
+
+
+//============================
+/* Looking up nodes in lists */
+//============================
+
+/**
+ * findNode
+ *
+ * Finds the node whose data points to the same structure pointed to by data.
+ * Uses dLinkedList's compare function to determine whether the data match.
+ * Update head/tail if necessary.
+ *
+ * Return NULL if dLinkedList is empty or data is not found in it.
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param data The data to be searched for
+ * @return A pointer to an LLNode
+ */
+
+LLNode* findNode(DLinkedList* dLinkedList, void* data);
+
+
+//===========================
+/* Deleting nodes and lists */
+//===========================
+
+/**
+ * deleteNode
+ *
+ * Delete the node pointed to by Node (splice it out).  
+ * Update head/tail if necessary.
+ * Free the Node's data as well as the Node.
+ * Assumes Node is not NULL and is in dLinkedList.
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * @param Node A pointer to a linked list node.
+ */
+void deleteNode(DLinkedList* dLinkedList, LLNode* Node);
+
+
+/**
+ * destroyList
+ *
+ * Destroy the doubly linked list. Everything in the linked list including list structure,
+ * nodes and data are all freed from the heap
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ *
+ */
+void destroyList(DLinkedList* dLinkedList);
+
+
+//==================
+/* Reversing lists */
+//==================
+
+/**
+ * reverse
+ *
+ * Reverse the order of the doubly linked list. Update head/tail if necessary.
+ * This should not create a new list (it should rewire the nodes in dLinkedList).
+ *
+ * @param dLinkedList A pointer to the doubly linked list
+ * 
+ */
+void reverse(DLinkedList* dLinkedList);
+
+
+#endif
+
--- a/hardware.cpp	Mon Mar 14 23:38:03 2022 +0000
+++ b/hardware.cpp	Tue Apr 12 01:39:20 2022 +0000
@@ -43,6 +43,10 @@
 GameInputs read_inputs() 
 {
     GameInputs in;
+    in.b1 = !button1;
+    in.b2 = !button2;
+    in.b3 = !button3;
+    acc.readXYZGravity(&in.ax, &in.ay, &in.az);
     return in;
 }
 
--- a/keyboard.cpp	Mon Mar 14 23:38:03 2022 +0000
+++ b/keyboard.cpp	Tue Apr 12 01:39:20 2022 +0000
@@ -2,8 +2,14 @@
 #include "dictionary.h"
 #include <string>
 
-
-
+DLinkedList* keyboard;
+LLNode* current;
+Word goalWord;
+char guess[5];
+char correctGuess[5];
+int guessLetter = 0;
+int j = 0; int ccount = 0;
+char* curr;
 
 int compareChar(void* input1, void* input2){
     if(*(char*)input1 == *(char*)input2){
@@ -14,37 +20,156 @@
     }
 }
 
+void lost_game() 
+{
+    uLCD.cls();
+    while(1)
+    {
+        uLCD.locate(1, 3);
+        uLCD.printf("Sorry You Lost");
+        uLCD.locate(3, 5);
+        uLCD.printf("Please Reset");   
+    }
+}
+
+void won_game()
+{
+    uLCD.cls();
+    while(1)
+    {
+        uLCD.locate(1, 3);
+        uLCD.printf("Congrats you WON!");
+        uLCD.locate(3, 5);
+        uLCD.printf("Please Reset");
+    }
+}
+
 
 void init_keyboard()
 {
-
+    int x = rand() % 11;
+    goalWord = dictionary[x];
+    keyboard = create_dlinkedlist(compareChar);
+    for (int i = 0; i < 26; i++) {
+        char* temp = (char*) malloc(sizeof(char));
+        *temp = 'a' + i;
+        insertTail(keyboard, temp);
+    }
+    current = keyboard->head;
+    char* test = (char*)(keyboard->head->data);
+    uLCD.locate(9, 13);
+    uLCD.printf("%c", *test);
+    uLCD.locate(1, 2);
+    uLCD.printf("Correct Letters");
 }
 
 
 void moveleft()
 {
-
+    if(current->prev)
+    {
+        current = current->prev;
+        uLCD.locate(9, 13);
+        uLCD.printf("%c", *((char*)current->data));
+        wait_ms(200);
+    }
+    
 }
 
 
 void moveright()
 {
-    
+    if(current->next)
+    {
+        current = current->next;
+        uLCD.locate(9, 13);
+        uLCD.printf("%c", *((char*)current->data));
+        wait_ms(200);
+    }
 }
 
 
 void select_letter()
 {   
-
+    if (guessLetter < 5) {
+        curr = (char*)(current->data);
+        guess[guessLetter] = *(curr);
+        
+        uLCD.locate(5 + guessLetter, 4 + j);
+        uLCD.printf("%c", guess[guessLetter]);
+        
+        guessLetter++;
+        if (guessLetter >= 5) {
+            guessLetter = 0;
+            j++;
+            wait_ms(200);
+            check_word();
+        }
+            
+    }
+    wait_ms(200);
 }
 
 
 void remove_letter()
 {   
-
+    if (guessLetter > 0) {
+        guessLetter--;
+        uLCD.locate(5 + guessLetter, 4 + j);
+        guess[guessLetter] = NULL;
+        uLCD.printf(" ");
+    }
+    wait_ms(200);
 }
 
 void check_word()
 {
-       
-}
+    int x; int nword; int count = 0;
+    char* a = goalWord.letters;
+    for (x = 0; x < 5; x++) {
+        if(guess[x] == *(a+x)) {
+            count++;                        
+        } else { 
+            count = 0;
+            int y;
+            for (y = 0; y < 5; y++) {
+                nword = 1;
+                if(guess[x] == *(a+y)) {
+                    pc.printf("%c\n", guess[x]);
+                    uLCD.color(WHITE);
+                    uLCD.locate(5+x, 3+j);
+                    uLCD.printf("%c", guess[x]); 
+                    uLCD.color(GREEN);
+                    nword = 0;   
+                    break;
+                }
+            }
+            if (nword) {
+                pc.printf("nword is 1!!!\n", guess[x]);
+                uLCD.locate(5+x, 3+j);
+                uLCD.printf(" ");
+                //char* test = (char*)(keyboard->head->data);
+                deleteNode(keyboard, findNode(keyboard, (char*)(guess+x)));
+                //uLCD.locate(9, 13);
+                //uLCD.printf("%c", *test);
+            } else {
+                correctGuess[x] = guess[x];
+                int g;
+                for(g = 0; g < 5; g++) {
+                    if (correctGuess[g] == guess[x]) {
+                        break;                        
+                    } else {
+                        uLCD.locate(5 + ccount++, 3);
+                        uLCD.printf("%c", guess[x]);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+    if (count == 5) {
+        won_game();
+    } else if (j==6) {
+        lost_game();
+    }    
+}
\ No newline at end of file
--- a/main.cpp	Mon Mar 14 23:38:03 2022 +0000
+++ b/main.cpp	Tue Apr 12 01:39:20 2022 +0000
@@ -26,6 +26,7 @@
 
 void set_random_seed();
 
+
 /*
 * This function handles the main logic of the game. You should
 * initialize the hardware in this function, make calls to 
@@ -33,9 +34,7 @@
 * the word. 
 */
 int main()
-{
-    
-    GameInputs inputs; 
+{ 
     // First things first: initialize hardware
     ASSERT_P(hardware_init() == ERROR_NONE, "Hardware init failed!");
     pc.printf("Program Starting\n");
@@ -53,11 +52,11 @@
      Call the function set_random_seed -- you need to complete its
      definition below.*/
     set_random_seed();
-/*
-   2) call init_keyboard() and show start screen
+   //2) call init_keyboard() and show start screen
+    init_keyboard();
    
-   3) initialize any other game state that you add.
-*/
+   //3) initialize any other game state that you add.
+
     
     
 /* Insert code into this game loop to complete its implementation:
@@ -65,8 +64,19 @@
     while(1){
         t.start(); //start a timer
         draw_lower_status(); //draw the lower status bar
+        draw_sprite();
+        GameInputs inputs;
         inputs = read_inputs(); //read the inputs of the game
         
+        if (inputs.ax > .5 && !inputs.b1 && !inputs.b2 && !inputs.b3) {
+            moveleft();
+        } else if (inputs.ax < -.5 && !inputs.b1 && !inputs.b2 && !inputs.b3) {
+            moveright();
+        } else if (inputs.b1) {
+            select_letter();
+        } else if (inputs.b2) {
+            remove_letter();        
+        }
         
         /*
         your code here, make decisions based on those inputs, update the keyboard
@@ -75,7 +85,7 @@
         
         t.stop();
         dt = t.read_ms();
-        if (dt < 100) wait_ms(100 - dt);
+        if (dt < 500) wait_ms(500 - dt);
         
         }
 }
@@ -97,13 +107,28 @@
 */
 void set_random_seed() {
     Timer t;
+    int start = 1;
+    GameInputs startButton;
     t.start(); // start the timer
-    wait_ms(200);
-    // add code here
+    
+    uLCD.locate(1, 3);
+    uLCD.printf("Welcome to MBEDL");
+    uLCD.printf("\n Press any Button");
+    uLCD.locate(4, 5);
+    uLCD.printf("To Start");
+    
+    while (start) {
+        draw_sprite();
+        startButton = read_inputs();
+        if (startButton.b1 || startButton.b2 || startButton.b3) {
+            start = 0;
+        }
+        wait_ms(200);
+    }
+    
     t.stop();  //  end the timer
     int seed = t.read_ms(); //read the number of milliseconds elapsed between the start and stop
     srand(seed); // use elapsed time as the seed
-    
-    uLCD.printf("seed: %d\n", seed); // TEMP: delete this
+    uLCD.cls();
 }
 // ===User implementations end===