1+ #include <stdint.h>
2+ #include <math.h>
3+ #include "math_question.h"
4+ #include "doomstat.h"
5+ #include "m_controls.h"
6+ #include "sounds.h"
7+
8+ //note to self
9+ //images are structed. or maybe the whole game is streched
10+ //from 59 to 141.??
11+ //just muiltply the height by 5/6 (.833333333)
12+ //max width is 320
13+ //max height is 168
14+ //max line length is 43
15+
16+ char questionString [256 ];
17+ uint8_t questionNum ;
18+
19+ typedef struct {
20+ const char * question ;
21+ const char * answers [4 ];
22+ const char answer ;
23+ const char image [8 ];
24+ } MultipleChoiceQuestion ;
25+
26+ const MultipleChoiceQuestion questions [] = {
27+ { "What are supplementary angles?" ,
28+ { "an angle whose sum is greater than 180\ndegrees" ,
29+ "either of two angles whose sum is 180\ndegrees" ,
30+ "Angles that add up to 180 degrees" ,
31+ "two angles that add up to be 360 degrees" },
32+ KEY_ANSWERC , "AMMNUM0" },
33+
34+ { "What are the corresponding angles in this\npicture?" ,
35+ { "1&2, 3&4, 5&6, 7&8" , "1&4, 2&3, 5&8, 6&7" , "1&3, 2&4, 5&7, 6&8" , "1&5, 3&7, 2&6, 4&8" },
36+ KEY_ANSWERD , "MATH_Q3" },
37+
38+ { "What are the alternate interior angles in\nthis picture?" ,
39+ { "3&4, 5&6" , "3&6, 4&5" , "4&6, 3&5" , "7&2, 8&1" },
40+ KEY_ANSWERB , "MATH_Q3" },
41+
42+ { "What other angles measure 110?" ,
43+ { "<1, <4, <8" , "<7, <8, <6" , "<3, <4, <6" , "<7, <3, <1" },
44+ KEY_ANSWERA , "MATH_Q3" },
45+
46+ { "find x and y" ,
47+ { "x= 75 y= 55" , "x= 55 y= 70" , "x= 70 y= 55" , "x= 55 y= 75" },
48+ KEY_ANSWERA , "MATH_Q5" },
49+
50+ { "find x and y" ,
51+ { "x= 80, y= 80" , "x= 100, y= 80" , "x= 80, y= 100" , "x= 100, y= 100" },
52+ KEY_ANSWERA , "MATH_Q6" },
53+
54+ { "Which of these are corresponding angles\n\n\n\n" ,
55+ { "<1 and <7, <2 and <3" , "<8 and <3, <1 and <7\n\n\n\n\n" , "<5 and <6, <4 and <3" , "<5 and <9, <4 and <7\n\n\n" },
56+ KEY_ANSWERB , "MATH_Q7" },
57+
58+ { "Which of these are alternate interior angles\n\n\n\n" ,
59+ { "<1 and <4, <2 and <6" , "<9 and <8, <4 and <7\n\n\n\n\n" , "<4 and <7, <5 and <8" , "<8 and <9, <4 and <1\n\n\n" },
60+ KEY_ANSWERC , "MATH_Q7" },
61+
62+ { "Which of these are Same-side interior angles\n\n\n\n" ,
63+ { "<6 and <8" , "<4 and <7\n\n\n\n\n" , "<5 and <9" , "<8 and <9\n\n\n" },
64+ KEY_ANSWERA , "MATH_Q7" },
65+
66+ { "what is the slope of line b?" ,
67+ { "4/5" , "-4/-5" , "-4/5" , "5/-4" },
68+ KEY_ANSWERC , "MATH_Q10" },
69+
70+ { "Determine the value of x for which a II b" ,
71+ { "35" , "56" , "112" , "53" },
72+ KEY_ANSWERD , "MATH_Q11" },
73+
74+ { "Find each missing angle measure." ,
75+ { "3y= -120, (y-15)= -25" , "3y = 120, (y-15) = 25" , "3y= 120, (y-15)= -25" , "3y= -120, (y-15)= 25" },
76+ KEY_ANSWERB , "MATH_Q12" },
77+
78+ { "determine whether statement is\nalways, sometimes, or never.\nPerpendicular lines meet at the right angle." ,
79+ { "sometimes" , "never" , "always" , "I don't know" },
80+ KEY_ANSWERC , "AMMNUM0" },
81+
82+ { "Which theorem or postulate is this?\nIf a transversal intersects two parallel\nlines, then the same-side interior angles are\nsupplementary." ,
83+ { "alternate interior angles theorem" ,
84+ "corresponding angle theorem" ,
85+ "same-side interior angles postulate" ,
86+ "alternate exterior angles theorem" },
87+ KEY_ANSWERC , "AMMNUM0" },
88+
89+ { "Which theorem or postulate is this?\nif a transversal intersects two parallel\nlines, then corresponding angles are\ncongruent." ,
90+ { "alternate interior angles theorem" ,
91+ "corresponding angle theorem" ,
92+ "same-side interior angles postulate" ,
93+ "alternate exterior angles theorem" },
94+ KEY_ANSWERB , "AMMNUM0" },
95+
96+ { "Which theorem or postulate is this?\nif a transversal intersects two parallel\nlines, then alternate interior angle are\ncongruent" ,
97+ { "alternate interior angles theorem" ,
98+ "corresponding angle theorem" ,
99+ "same-side interior angles postulate" ,
100+ "alternate exterior angles theorem" },
101+ KEY_ANSWERA , "AMMNUM0" },
102+ };
103+
104+ const unsigned int numOfQuestion = sizeof (questions ) / sizeof (MultipleChoiceQuestion );
105+
106+ mobj_t * storedTarget ;
107+ mobj_t * storedInflictor ;
108+ mobj_t * storedSource ;
109+ int storedDamage ;
110+
111+ void
112+ AnswerQuestion
113+ (int key ) {
114+ static int numOfRightAnswers = 0 ;
115+ int * keybind ;
116+ switch (key ) {
117+ case KEY_ANSWERA : keybind = & key_math_answerA ; break ;
118+ case KEY_ANSWERB : keybind = & key_math_answerB ; break ;
119+ case KEY_ANSWERC : keybind = & key_math_answerC ; break ;
120+ case KEY_ANSWERD : keybind = & key_math_answerD ; break ;
121+ default : return ;
122+ }
123+ if (questions [questionNum ].answer == * keybind ) {
124+ //reset controls
125+ key_math_answerA = KEY_ANSWERA ;
126+ key_math_answerB = KEY_ANSWERB ;
127+ key_math_answerC = KEY_ANSWERC ;
128+ key_math_answerD = KEY_ANSWERD ;
129+ players [0 ].message = "good" ;
130+ if (numOfQuestion <= ++ questionNum ) {
131+ players [0 ].message = "You've answered all questions. good job" ;
132+ S_StartSound (players [0 ].mo , sfx_perf );
133+ }
134+ players [0 ].didAnswerQuestion = true;
135+ P_GiveBody (players , storedDamage );
136+ numOfRightAnswers = numOfRightAnswers < 0 ? 1 : numOfRightAnswers + 1 ;
137+ if (numOfRightAnswers == 5 ) S_StartSound (players [0 ].mo , sfx_hanzo );
138+ } else {
139+ * keybind = -1 ;
140+ players [0 ].message = "wrong" ;
141+
142+ players [0 ].didAnswerQuestion = true;
143+ numOfRightAnswers = 0 < numOfRightAnswers ? -1 : numOfRightAnswers - 1 ;
144+ P_DamageMobj (storedTarget , storedInflictor , storedSource , (int )(storedDamage * pow (2.8 , (numOfRightAnswers * -1 ) - 1 )));
145+ }
146+ players [0 ].didAnswerQuestion = false;
147+ }
148+
149+ void
150+ askQuestion
151+ ( mobj_t * target ,
152+ mobj_t * inflictor ,
153+ mobj_t * source ,
154+ int damage )
155+ {
156+ storedTarget = target ;
157+ storedInflictor = inflictor ;
158+ storedSource = source ;
159+ storedDamage = damage ;
160+ if (numOfQuestion <= questionNum ) return ;
161+ DEH_snprintf (questionString , sizeof (questionString ), "%s\n\nQ. %s\nW. %s\nR. %s\nT. %s" ,
162+ questions [questionNum ].question , questions [questionNum ].answers [0 ],
163+ questions [questionNum ].answers [1 ], questions [questionNum ].answers [2 ],
164+ questions [questionNum ].answers [3 ]);
165+ M_StartMessage (questionString , AnswerQuestion , true);
166+ }
167+
168+ const char * getQuestionImage
169+ ( const uint8_t quesitonNumber )
170+ {
171+ return questionNum < numOfQuestion ? questions [questionNum ].image : "AMMNUM0" ;
172+ }
173+
174+ const uint8_t
175+ getQuestionNum ()
176+ {
177+ return questionNum ;
178+ }
0 commit comments