I hope not...
47 Replies - 13290 Views - Last Post: 10 April 2013 - 07:47 PM
#16
Re: Traffic Lights - Complete the code.
Posted 01 March 2012 - 11:57 PM
I hope not...
#17
Re: Traffic Lights - Complete the code.
Posted 02 March 2012 - 03:35 PM
The only problem is, I am having a little trouble with setting them up so I can change an individual light color on a set of lights. So at the moment I am brain storming some ideas
#18
Re: Traffic Lights - Complete the code.
Posted 02 March 2012 - 04:21 PM
#19
Re: Traffic Lights - Complete the code.
Posted 02 March 2012 - 04:55 PM
#20
Re: Traffic Lights - Complete the code.
Posted 02 March 2012 - 04:59 PM
#21
Re: Traffic Lights - Complete the code.
Posted 02 March 2012 - 05:02 PM
aaron1178, on 02 March 2012 - 11:55 PM, said:
In this instance it means that it only has file scope.
Shane Hudson, on 02 March 2012 - 11:59 PM, said:
Why not! At least do as much as you can before the deadline.
This post has been edited by ButchDean: 02 March 2012 - 05:01 PM
#22
Re: Traffic Lights - Complete the code.
Posted 03 March 2012 - 12:29 AM
Hey, at least I got the traffic light signal to render like yours. I could even set the color of the signal (*), but unfortunately all three of them to the same color.
#23
Re: Traffic Lights - Complete the code.
Posted 03 March 2012 - 03:22 PM
#24
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 12:40 AM
http://augustcouncil...torial/ptr.html
I might have another crack at it, even though there is little time left.
EDIT:
Okay, I've got to work tomorrow so I will post what I have done so far.
I've modified Core.cpp to the following because the while loop was an infinite loop and I couldn't get the timer working so here is Core.cpp
int main()
{
int lightsSet = 0;
LIGHTSDISPLAY->UpdateDisplay(lightsSet);
cin.get();
return 0;
}
and here is ConsoleOutput.cpp. I've got it working so you can set the default signal. But the only thing is that the traffic light was a bit to many characters.
static void ConfigureLightsAndDisplay(char* lights, int lightSet)
{
ClearScreen();
int BackC = 1;//Blue
int ForgC = 0;//Black
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);//
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor); //
for( int e = 0; e < 3; e++ )
{
for( int i = 0; i < sizeof(trafficLightFrame); i++ )
{
if(lights[i] == '*')
{
if(e == lightSet)
{
if( lightSet == 0 ){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), RED); }
else if( lightSet == 1 ){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), AMBER); }
else{ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), GREEN); }
}
else
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0);
}
cout << lights[i];
}
else
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
cout << lights[i];
}
}
}
ClearScreen();
}
And that produces a result of
Aaron1178-TrafficLightsChallengeResult.zip (10.77K)
Number of downloads: 53
This post has been edited by aaron1178: 04 March 2012 - 02:03 AM
#25
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 03:57 PM
1. You need the timer function to get the lights to work anyway, in order to time the game loop.
2. I really don't like cin.get(); being in there, but I realize you put it in there to stop the program quitting. If the original while were left in you would only have to hit Escape to quit the app.
3. This code:
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
just isn't necessary.
4. ConfigureLightsAndDisplay() won't work as you have it because you are not querying the state of the system with the methods contained in LightStatus.cpp.
5. The traffic light you have drawn are not the same as in the example exe.
You certainly did have an idea of what was going on under the hood. Good attempt, and Kudos for being the only one who appears to have attempted it!
#26
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 04:48 PM
#27
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 05:06 PM
#28
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 05:11 PM
#29
Re: Traffic Lights - Complete the code.
Posted 04 March 2012 - 05:22 PM
#30
Re: Traffic Lights - Complete the code.
Posted 05 March 2012 - 02:50 PM
The complete solution to the challenge can be found here.
I'd like to give special kudos to aaron1178 for having a good go at this.
Please fire any questions you have. The next challenge that I will be putting up soon is based on this, so for those interested it is advised you study this carefully.
|
|

New Topic/Question
Reply




MultiQuote



|