random movement of character

I was hoping if someone can help me with cmatrix::fill
Last edited on
probably I am not getting it right, but it looks strange for an int (counter) to be strictly minor than an uninitialised bool (matrix).
the matrix is supposed to be 2d, however im not sure how to declare it. u can basically ignore the code i have written in CMatrix::Fill. because i have absolutely no idea what to do
it depends on how CMatrix is declared, but still I do not understand what Fill is supposed to do.
Let me assume the character map is a c-style array, the loop should look like
1
2
3
for(int i = 0; i<m_numCols;++i){
for(int j = 0; j<m_numRows;++j){
storage[j][i] = dispChar;


now you need a way to update the storage on the screen.
If this helps

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// File: cmatrix.h
// ============================================================================
// This header file contains the declaration for the CMatrix class. The class
// is used by the CScreen class to help fill the screen display with characters
// at random localtions.
// ============================================================================

#ifndef CMATRIX_H
#define CMATRIX_H

#include    <iostream>
#include    <fstream>
using namespace std;

// class declaration
class   CMatrix
{
public:
    // constructor
    CMatrix(int numRows, int numCols);

    // member functions
    void    Fill(char dispChar, int msecs);

private:
    int     m_numRows;
    int     m_numCols;
};

#endif  // CMATRIX_H 

and how can I declare a 2d with an unknown number of elements? The fill function is basically supposed to fill the screen with asterisks at random locations. and i have no idea how will they fill randomly
cmatrix.h -- This header file contains the declaration for the CMatrix class. The purpose of this class is to fill the screen with a character at random locations. If you look at the class declaration, you'll see that it only has two data members: one to store the total number of rows, and another to store the total number of columns. These data members are initialized by the class constructor, which receives those values in the parameter list.

Once the CMatrix object has been initialized, it's ready to have its CMatrix::Fill member function called. This function takes as input a character to draw, and a sleep interval to control the speed with which they're drawn. A loop is entered to draw the character to random locations on the screen, until all available locations have been used and the screen is completely filled. (Hmm... how will it keep track of available screen locations? How will it know when the screen has been completely filled?)

matrix is the CMatrix object^
Last edited on
Topic archived. No new replies allowed.