And once you have the minute and hour, you can either:
- create 24 hour hand sprites and 24 minute hand sprites, and raw draw the appropriate one onto the clock face every time the time changes
- use the raw drawing functions and the floating point maths plugin to raw draw triangles representing the hands when the time changes
eg in the room script
int currHour = 0;
int currMinute = 0;
function drawClockHand(int x, int y, int length, int width, int angle)
{
int fx = int_to_float(x);
int fy = int_to_float(y);
int fl = int_to_float(length);
int fw = int_to_float(width);
int fa = angle_from_degrees(int_to_float(angle));
int sina = sin(fa);
int cosa = cos(fa);
// the point
int p1x = fadd(fx, fmul(fl, sina));
int p1y = fsub(fy, fmul(fl, cosa));
// the base
int dx = fadd(fx, fmul(fw, sina));
int dy = fsub(fy, fmul(fw, cosa));
int p2x = fadd(fsub(fx, dx), fmul(fw, cosa));
int p2y = fadd(fsub(fy, dy), fmul(fw, sina));
int p3x = fsub(fsub(fx, dx), fmul(fw, cosa));
int p3y = fsub(fsub(fy, dy), fmul(fw, sina));
RawDrawTriangle(p1x, p1y, p2x, p2y, p3x, p3y);
}
in the room's repeatedly_execute_always:
int nextHour = GetTime(1);
int nextMinute = GetTime(2);
if (nextMinute != currMinute || nextHour != currHour)
{
currMinute = nextMinute;
currHour = nextHour;
RawDrawImage(140, 10, SPRITE_CLOCKWITHNOHANDS);
int minuteAngle = 6*nextMinute; // 360/60 = 6
int hourAngle = 15*nextHour; // 360/24 = 15
// draw an offset shadow
RawSetColour(0); // black
drawClockHand(161, 31, 20, 1, minuteAngle);
drawClockHand(161, 31, 14, 2, hourAngle);
// draw the hands
RawSetColour(25620); // gunmetal
drawClockHand(160, 30, 20, 1, minuteAngle);
drawClockHand(160, 30, 14, 2, hourAngle);
}
Totally untested but you get the idea.
Cheers,
Steve
- create 24 hour hand sprites and 24 minute hand sprites, and raw draw the appropriate one onto the clock face every time the time changes
- use the raw drawing functions and the floating point maths plugin to raw draw triangles representing the hands when the time changes
eg in the room script
int currHour = 0;
int currMinute = 0;
function drawClockHand(int x, int y, int length, int width, int angle)
{
int fx = int_to_float(x);
int fy = int_to_float(y);
int fl = int_to_float(length);
int fw = int_to_float(width);
int fa = angle_from_degrees(int_to_float(angle));
int sina = sin(fa);
int cosa = cos(fa);
// the point
int p1x = fadd(fx, fmul(fl, sina));
int p1y = fsub(fy, fmul(fl, cosa));
// the base
int dx = fadd(fx, fmul(fw, sina));
int dy = fsub(fy, fmul(fw, cosa));
int p2x = fadd(fsub(fx, dx), fmul(fw, cosa));
int p2y = fadd(fsub(fy, dy), fmul(fw, sina));
int p3x = fsub(fsub(fx, dx), fmul(fw, cosa));
int p3y = fsub(fsub(fy, dy), fmul(fw, sina));
RawDrawTriangle(p1x, p1y, p2x, p2y, p3x, p3y);
}
in the room's repeatedly_execute_always:
int nextHour = GetTime(1);
int nextMinute = GetTime(2);
if (nextMinute != currMinute || nextHour != currHour)
{
currMinute = nextMinute;
currHour = nextHour;
RawDrawImage(140, 10, SPRITE_CLOCKWITHNOHANDS);
int minuteAngle = 6*nextMinute; // 360/60 = 6
int hourAngle = 15*nextHour; // 360/24 = 15
// draw an offset shadow
RawSetColour(0); // black
drawClockHand(161, 31, 20, 1, minuteAngle);
drawClockHand(161, 31, 14, 2, hourAngle);
// draw the hands
RawSetColour(25620); // gunmetal
drawClockHand(160, 30, 20, 1, minuteAngle);
drawClockHand(160, 30, 14, 2, hourAngle);
}
Totally untested but you get the idea.
Cheers,
Steve