- Code: Select all
double cl_s;
char* returnTime(int switchTime)
{
stTime timeret=getTime();
char*t;
switch(switchTime)
{
case 0:
sprintf(t, "%d:%d:%d", timeret.hour, timeret.min, timeret.sec);
break;
case 1:
if(timeret.hour>12)
{
sprintf(t, "%d:%d:%d PM", timeret.hour-12, timeret.min, timeret.sec);
} else {
sprintf(t, "%d:%d:%d AM", timeret.hour, timeret.min, timeret.sec);
}
break;
}
return t;
}
void drawSecondHand(int X, int Y, int Scale)
{
stTime clock=getTime();
cl_s=clock.sec/9.549304;
moveto(X-cos(1.570795+(cl_s))*Scale, Y-sin(1.570795+(cl_s))*Scale);
lineto(X, Y);
}
void drawMinuteHand(int X, int Y, int Scale)
{
stTime clock=getTime();
cl_s=clock.min/9.549304;
moveto(X-cos(1.570795+(cl_s))*Scale, Y-sin(1.570795+(cl_s))*Scale);
lineto(X, Y);
}
void drawHourHand(int X, int Y, int Scale)
{
stTime clock=getTime();
cl_s=clock.hour/3.819721860586518;
moveto(X-cos(1.570795+(cl_s))*Scale, Y-sin(1.570795+(cl_s))*Scale);
lineto(X, Y);
}
Place this in global code.
Drawing hands in canvas:
- Code: Select all
erase(0, 0, 0, 1);
setpen(55, 55, 55, 0, 8);
drawHourHand(xmouse, ymouse, 155);
setpen(155, 155, 155, 0, 4);
drawMinuteHand(xmouse, ymouse, 177);
setpen(255, 255, 255, 0, 2);
drawSecondHand(xmouse, ymouse, 188);
This will draw the hands from the X and Y position of the mouse, modify the xmouse and ymouse to change position. The other numbers are the sizes of the hands.
- Code: Select all
sprintf(text, "The current time is %s", returnTime(1));
Place this in a text actor to draw the current time. (1)=AM/PM, and 0=24 hour time.