473,464 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C++ Arrays: Electronic Billboard Imitation

18 New Member
Let me state first off that this is not a school assignment, its something I thought that would be nice to do and well I ended up with the idea of using arrays to perform the task (if possible).

I've done a cast-based animation with a static int, and bool, which works, however is limited to one line (prove me wrong, I'm still new to this).

This is what I have so far, in terms of the function that animates the 'billboard':

Expand|Select|Wrap|Line Numbers
  1. void animateBoard()
  2. {
  3.     //for (int x = 0; x < 20; x++)
  4.     //{
  5.  
  6.     for (int i = 0; i < 20; i++)
  7.     {
  8.         for (int j = 0; j < 20; j++)
  9.         {
  10.             for (int k = 0; k < 20; k++)
  11.             {
  12.                 myArray[k][i] = myDisplay[k][19-i];
  13.                 //myArray[19-k][j-19-i] = '_';
  14.             }
  15.             for (int l = 0; l < 20; l++)
  16.             {
  17.                 myArray[l][i-j] = myDisplay[l][19-i];
  18.             }
  19.             displayBoard();
  20.             Sleep(250);
  21.             system("cls");
  22.         }
  23.  
  24.     /*
  25.     int x, y, i, j;
  26.     y = 19;
  27.     for (i = 0; i < 20; i++)
  28.     {
  29.         x = 19;
  30.         for (j = 0; j < 20; j++)
  31.         {
  32.             myArray[j][i] = myDisplay[x][y];
  33.             x--;
  34.         }
  35.         y--;
  36.         Sleep(250);
  37.         system("cls");
  38.         displayBoard();
  39.  
  40.         //for (x = 0; x <= i; x++)
  41.         //{
  42.         //    for (y = 0; y <= j; y++)
  43.         //    {
  44.         //        myArray[y][x] = '_';
  45.         //    }
  46.             //Sleep(220);
  47.             //system("cls");
  48.             //displayBoard();
  49.         //}
  50.     }
  51.     */
  52.  
  53.     }
  54. }
I have two, two-dimensional arrays, and I am using a recursion function (several nested) to change their values.

As you can see I've tried a lot of methods that I have commented out and most just deleted (the current version does something bizzarre). The problem I am having is that its not giving me any error instead it doesn't print the desired results. I've had it do what I wanted (in a sense) diagonally, however printing in a non-chronological order.

I'm trying to imitate a common advertising electronic billboard you see everywhere that shuffles a message (or picture) across the screen or perform some sort of animation.

I'm quite confident its possible to do this in C++ while it may be tedious, I hope someone can help me out here.

Thanks.
Jun 27 '07 #1
4 2256
inihility
18 New Member
I forgot to add that in the code provided, it is based on the already mentioned two, two dimensional arrays of the size 20 (thus the i < 20, etc. conditions).
Jun 27 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
When you cast in C++, you destroy the type safety of your program. Casting in C++ is used when a) you are calling a relic C function with a void* argument or b) your C++ design is screwed up.

The code I see here is C code.

Then there's this:
I'm trying to imitate a common advertising electronic billboard you see everywhere that shuffles a message (or picture) across the screen or perform some sort of animation.
This looks like a base class ElectronicBillboard Crawler data member.
Expand|Select|Wrap|Line Numbers
  1. class ElectronicBillboard
  2. {
  3.    private:
  4.       Crawler   c;
  5. };
  6.  
The Crawler is a base class with a virtual Crawl() method. So you derive a CrawlingPicture class from Crawler and override the Crawl() method. CrawlingPicture IS-A Crawler.

The ElectronicBillboard has a Display() method and part of that method is to display the crawler.

Expand|Select|Wrap|Line Numbers
  1. void ElectronicBillboard::Display()
  2. {
  3.       //displays the main board here
  4.      while(etc...)
  5.      {
  6.       this->c->Crawl()//displays the crawler
  7.      }
  8. }
  9.  
You create CrawlingPicture object and use it as a Crawler object.

Expand|Select|Wrap|Line Numbers
  1. CrawlingPicture cp("c:\\thepicture.jpg");
  2. ElectronicBillboard b("the text of the top of the board", cp);
  3. b.Display();          //shows the text of the billboard with the picture crawling across the bottom.
  4.  
You just add derived classes from Crawl for the various crawlers.
Jun 27 '07 #3
inihility
18 New Member
Thanks for the reply weaknessforcats. Could you perhaps put together a small example of a 3(?) line message/characters running across the screen? I'm pretty new to C++ (at the really beginning of OOP) like I mentioned earlier and I'm having a little trouble trying to understand all the code snippets, what they do, and where they should be put, so it would be really helpful if you could use the Crawler (class?) in an example, that way I could probably analyse the example and have a better understanding of how things work.

Also when I mentioned cast-based animation, I mean't that I did it before to clear things up, and not in this example as I was only able to animate one line at a time at most (I'm trying to simultaneously animate several lines).

Many thanks.
Jun 28 '07 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
Here you go:
Expand|Select|Wrap|Line Numbers
  1. #include <windows.h>
  2. #include <iostream>
  3. using namespace std;
  4. #include <string>
  5.  
  6. class Crawler
  7. {
  8.    public:
  9.      virtual ostream& Crawl(ostream& os) = 0;
  10. };
  11.  
  12. class TextCrawler : public Crawler
  13. {
  14.    private:
  15.     string text;
  16.   public:
  17.     TextCrawler(string str);
  18.     ostream& Crawl(ostream& os);
  19.  
  20.  
  21. };
  22. TextCrawler::TextCrawler(string str)
  23. : text(str)
  24. {
  25.  
  26. }
  27. ostream& TextCrawler::Crawl(ostream& os)
  28. {
  29.    string spaces;
  30.    for (int i = 0; i < 3; ++i)
  31.    {
  32.      for (int i = 0; 60 > spaces.size(); ++i)
  33.      {
  34.         os << '\r' << spaces << text;
  35.         spaces += "      ";
  36.         Sleep(500);
  37.      }
  38.      spaces += "                 ";
  39.      os << '\r' << spaces;
  40.      spaces.erase();
  41.      }
  42.      return os;
  43. }
  44. class ElectronicBillBoard
  45. {
  46.     private:
  47.       Crawler* c;
  48.       string str;     //the billboard text
  49.     public:
  50.       ElectronicBillBoard(string text, Crawler* thecrawler);
  51.       //Display the billboard:
  52.       friend ostream& operator<<(ostream& os, const ElectronicBillBoard& bb);
  53. };
  54. ElectronicBillBoard::ElectronicBillBoard(string text, Crawler* thecrawler)
  55. : str(text), c(thecrawler)
  56. {
  57. }
  58. ostream& operator<<(ostream& os, const ElectronicBillBoard& bb)
  59. {
  60.         string str("                               ");
  61.         os << str << bb.str << endl << endl << endl;
  62.         bb.c->Crawl(os);
  63.         return os;
  64. }
  65.  
  66. int main()
  67. {       Crawler* crawler = new TextCrawler("Buy today");
  68.         ElectronicBillBoard   billboard("Used cars cheap", crawler);
  69.  
  70.         cout << billboard << endl;        
  71. }
  72.  
Jun 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: post400 | last post by:
Hi, apparently there is a very famous book that every developer should read: Code complete by Steve McConnell ! Is there an electronic version freely downloadable ? After all, the book was...
1
by: harsha mogaligundla | last post by:
Dear All , I am trying to develop a web based electronic Timesheet system for the payroll department using ASP and SQL server, the front end has fields like ssn,time -in , tim-out,regular...
2
by: Hank Reed | last post by:
I found only five small threads discussing Access and EDI and none of them were very recent. Is anyone interfacing with EDI using Access? Can anyone recommend a book that would explain the basics...
0
by: Mark Rae | last post by:
Hi, I've been asked to do some analysis on a workflow system, specifically with electronic authorisation / signature. E.g. User A logs in and initiates a timesheet, fills it in and "submits"...
1
by: DotNetNewbie | last post by:
Does anyone know of any electronic security device hardware for doors that can be accessed using vb.net? Like for instance a room that needs to be secured via an electronic device, that can open...
1
by: nobrainer | last post by:
Hi, I'm a linguist and have a large self-built bilingual dictionary. I want to turn it into a electronic dictionary, can anyone tell me how to start with it? I've some knowledge in Java...
0
by: gautamlixir | last post by:
HI EDS(ELECTRONIC DATA SYSTEMS)-A SOFTWARE GIANT(FORTUNE 100) LOCATED IN PUNE AND CHENNAI IS RAMPING UP ITS STRENGTH. THERE IS AN URGENT OPENING FOR 300 DOTNET PROFESSIONALS IN THESE 2 LOCATIONS....
9
by: Bob Alston | last post by:
I am looking for electronic forms software that would integrate well with MS Access. I have a client for whom I built a client database to replace and update one they had that was obsolete and...
0
by: news.microsoft.com | last post by:
Hey All, Sorry to post to several groups but wasn't sure which development group would be best for the question. I was wondering if there are any developers out there that have significant...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.