Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cookie stuff
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:2c0c33b7ee2d0c1393e140bfad873380893f7158d8dc30a32a8ea8a2eb5e9871
User & Date: zie 2018-05-18 22:21:51
Context
2018-05-18
22:54
End game check-in: 9cb3cdd267 user: sarah tags: trunk
22:21
cookie stuff check-in: 2c0c33b7ee user: zie tags: trunk
22:01
Update check-in: f62cfa3a0f user: sarah tags: trunk
Changes

Changes to finalproject/finalproject.cpp.

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

117
118
119









120


121
122
123
124
125


126







































127
128
129
130
131
132
133
134
135
136
137
138
139
...
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
};
// DO NOT ALTER OR DELETE THIS CODE (END)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

class MyPickUpGame : public PickUpGame
{
    public:
    int CookieNumber;
      void cookies()
      {
            
            CookieNumber = 1 + rand() % 10;
           
            for (int i=0; i < CookieNumber; i++)
            { int RandomxPos ;
            RandomxPos= rand()%19 ;    
            int RandomyPos;
            RandomyPos= rand()%39;     

            Screen[RandomxPos][RandomyPos]='o';
            if(Screen[RandomxPos][RandomyPos]='o')
            {
                  RandomxPos=rand()%19;
                  RandomyPos=rand()%39;
                  Screen[RandomxPos][RandomyPos]='o';
            }


            }
      }












      void endgame()
      {
            cout<< "congrats you picked up "<< CookieNumber<<". Feel free to play again.";
            exit(0);
      }










































      void BoundedMove(char UserMove)
      {

            cout << "\nbefore usernove:"
                 << "xPos=" << xPos << " yPos=" << yPos << "\n";
            Move(UserMove);
            cout << "after usernove:"
                 << "xPos=" << xPos << " yPos=" << yPos << "\n";

            // When you reset a xPos, you have to clear the character at the old location first.
            // you are not doing that here... yet :)
            if (xPos < 0)
            {
................................................................................

//You can modify and change main()
int main()
{
      system("clear"); //Clear the screen before printing anything
      srand(time(0));
      MyPickUpGame *Game = new MyPickUpGame; //Create a new game object and store it in a object pointer

      char UserMove = ' '; //This is used to store the users input
      do
      {
            cout << "Welcome to cookie pickup. You will move to the cookies by using the arrow keys." << endl;     //Program intro
            Game->Print();                                                                                         //Print the grid out
            cout << "What direction would you like to move in? \n(Move using the arrow keys or type q to quit.) "; //Instructions to the user
                                                                                                                   //UserMove = getche(); //Get one character from the user (some compilers have "getche()")







|










<
|



<

>



>
>
>
>
>
>
>
>
>
|
>
>





>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<


|







 







|







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

110
111
112
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187
188
189
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
};
// DO NOT ALTER OR DELETE THIS CODE (END)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

class MyPickUpGame : public PickUpGame
{
    public:
    int CookieNumber;
      void createCookies()
      {
            
            CookieNumber = 1 + rand() % 10;
           
            for (int i=0; i < CookieNumber; i++)
            { int RandomxPos ;
            RandomxPos= rand()%19 ;    
            int RandomyPos;
            RandomyPos= rand()%39;     


            if (Screen[RandomxPos][RandomyPos] ==  'o')
            {
                  RandomxPos=rand()%19;
                  RandomyPos=rand()%39;

            }
            Screen[RandomxPos][RandomyPos]='o';

            }
      }
      // check to see if there is a cookie laying about at the user position.
      // returns bool
      bool checkCookies(int x, int y) {
            char c;
            c = Screen[x][y];
            cout << "checkCookies: " << c << "\n";
            if (c == 'o') {
                  cout << "COOKIE HERE!!" << x << y << "\n";
                   return true;
            }
            return false;
      }
      void endgame()
      {
            cout<< "congrats you picked up "<< CookieNumber<<". Feel free to play again.";
            exit(0);
      }
      void MyMove(char Direction) {
            switch (static_cast<int>(Direction)) //Don't know the ASCII characters for the arrow keys so use the ASCII numbers
            {
            case 65: //Up arrow
                  // cout << "UP\n";
                  Screen[xPos][yPos] = ' '; //Wipe out the users current cursor
                  xPos--;                   //Move the users x position on the grid
                  if (checkCookies(xPos, yPos)) {
                        cout << "COOKIE MONSTER";
                  }
                  Screen[xPos][yPos] = '^'; //Move the users cursor
                  break;
            case 66: //Down arrow
                  // cout << "Down\n";
                  Screen[xPos][yPos] = ' ';
                  xPos++;
                  if (checkCookies(xPos, yPos)) {
                        cout << "COOKIE MONSTER";
                  }
                  Screen[xPos][yPos] = 'v';
                  break;
            case 68: //Left arrow
                     // cout << "Left\n";
                  Screen[xPos][yPos] = ' ';
                  yPos--;
                  if (checkCookies(xPos, yPos)) {
                        cout << "COOKIE MONSTER";
                  }
                  Screen[xPos][yPos] = '<';
                  break;
            case 67: //Right arrow
                  // cout << "Right\n";
                  Screen[xPos][yPos] = ' ';
                  yPos++;
                  if (checkCookies(xPos, yPos)) {
                        cout << "COOKIE MONSTER";
                  }
                  Screen[xPos][yPos] = '>';
                  break;
            }
      }

      void BoundedMove(char UserMove)
      {

            cout << "\nbefore usernove:"
                 << "xPos=" << xPos << " yPos=" << yPos << "\n";
            MyMove(UserMove);
            cout << "after usernove:"
                 << "xPos=" << xPos << " yPos=" << yPos << "\n";

            // When you reset a xPos, you have to clear the character at the old location first.
            // you are not doing that here... yet :)
            if (xPos < 0)
            {
................................................................................

//You can modify and change main()
int main()
{
      system("clear"); //Clear the screen before printing anything
      srand(time(0));
      MyPickUpGame *Game = new MyPickUpGame; //Create a new game object and store it in a object pointer
      Game->createCookies();
      char UserMove = ' '; //This is used to store the users input
      do
      {
            cout << "Welcome to cookie pickup. You will move to the cookies by using the arrow keys." << endl;     //Program intro
            Game->Print();                                                                                         //Print the grid out
            cout << "What direction would you like to move in? \n(Move using the arrow keys or type q to quit.) "; //Instructions to the user
                                                                                                                   //UserMove = getche(); //Get one character from the user (some compilers have "getche()")

Changes to finalproject/makefile.

1
2
3
4
5
6
7
8


run: finalproject
	./finalproject
finalproject: cookie.cpp
	g++ -Werror $< -o $@
clean:
	rm finalproject.out
	rm finalproject
	rm pause




|


<

|
>
>
1
2
3
4
5

6
7
8
9
run: finalproject
	./finalproject
finalproject: finalproject.cpp
	g++ -Werror $< -o $@
clean:

	rm finalproject
	rm pause
cookie: cookie.cpp
	g++ -Werror $< -o $@