This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsec_hand.cpp
82 lines (76 loc) · 2.18 KB
/
sec_hand.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
Contains all the functions/classes/whatever it takes to make the second hand move.
Copyright 2010 James Russell
*/
//INCLUDES//
#include "sec_hand.h"
//External functions and classes.//
extern AC_C_DigiClock AC_DigiClock;
extern SDL_Surface *AC_SecondHandSurfRotate;
extern SDL_Surface *AC_SecondHandSurf;
extern SDL_Surface *AC_SecondHandCover;
////////////////CLASS////////////////
//Class constructor.
AC_C_SecondHand::AC_C_SecondHand(void)
{
//Set the base positions.
x=95;
y=125;
//Set the degrees to 0.
Degrees=360;
//Say that the second hand is paused.
Is_Paused=true;
}
//This initalizes anything that couldn't before.
void AC_C_SecondHand::Init(void)
{
//Rotate the surf so that the show func has something to show.
AC_SecondHandSurfRotate=rotozoomSurface(AC_SecondHandSurf,Degrees,1,0);
}
//Pause or unpause function.
void AC_C_SecondHand::Pause(void)
{
//If the timer is already paused...
if(Is_Paused==true)
{
//Unpause the timer.
Is_Paused=false;
//Set the degrees to the current second.
Degrees=-(AC_DigiClock.Return_Seconds()*6);
}
//Otherwise, the timer must of been unpaused.
else if(Is_Paused==false)
{
//So pause it.
Is_Paused=true;
}
}
//Rotate the surface function.
void AC_C_SecondHand::Rotate(void)
{
//If the second hand is not paused...
if(Is_Paused==false)
{
//Calculate the degrees that it should be pointing at.
Degrees=-(AC_DigiClock.Return_Seconds()*6);
//Free the surface before rotating it again.
SDL_FreeSurface(AC_SecondHandSurfRotate);
//Then rotate the surface.
AC_SecondHandSurfRotate=rotozoomSurface(AC_SecondHandSurf,Degrees,1,0);
}
}
//Show the second hand function.
void AC_C_SecondHand::ShowSecondHand(void)
{
//Just show the surf.
AC_ShowSurface(AC_SecondHandSurfRotate,x-AC_SecondHandSurfRotate->w/2,y-AC_SecondHandSurfRotate->h/2);
//Then show the cover over that.
AC_ShowSurface(AC_SecondHandCover,53,78);
}
//Reset the second hand position to 0.
void AC_C_SecondHand::Reset(void)
{
//Just reset the degrees to 0.
Degrees=0;
}
////////////////EOF////////////////////