Wise&mystical
1.0
Project about Europe
Loading...
Searching...
No Matches
quizLogic.cpp
Go to the documentation of this file.
1
#include <
raylib.h
>
2
#include "
animations.h
"
3
#include "
cityOperations.h
"
4
#include "
quizLogic.h
"
5
#include "
timer.h
"
6
10
void
handleQuizInput
(
City
activeCity,
Option
options[4],
bool
* showQuizPtr,
bool
* optionSelectedPtr,
int
* scorePtr,
int
* startNumPtr,
int
* endNumPtr,
int
* countUpstepPtr,
bool
* countUpDonePtr,
int
* bonusPtr)
11
{
12
// Chdck if the left mouse button is pressed
13
if
(
IsMouseButtonPressed
(
MOUSE_BUTTON_LEFT
))
14
{
15
// Cycle through the option hitboxes
16
for
(
int
i = 0; i < 4; i++)
17
{
18
// Check for collision with the true answer
19
if
(
CheckCollisionPointRec
(
Vector2
(
GetMousePosition
()), options[i].hitbox) && activeCity.
trueAnswer
== i + 1)
20
{
21
if
(*showQuizPtr ==
true
)
22
{
23
// Update score and count up sequence variables
24
*startNumPtr = *scorePtr;
25
*scorePtr += 200 + *bonusPtr;
26
*endNumPtr = *scorePtr;
27
*countUpDonePtr =
false
;
28
*countUpstepPtr = (*endNumPtr - *startNumPtr) / 100;
29
}
30
31
*optionSelectedPtr =
true
;
32
*showQuizPtr =
false
;
33
34
}
35
else
if
(
CheckCollisionPointRec
(
Vector2
(
GetMousePosition
()), options[i].hitbox))
36
{
37
*optionSelectedPtr =
true
;
38
*showQuizPtr =
false
;
39
}
40
}
41
}
42
}
animations.h
cityOperations.h
handleQuizInput
void handleQuizInput(City activeCity, Option options[4], bool *showQuizPtr, bool *optionSelectedPtr, int *scorePtr, int *startNumPtr, int *endNumPtr, int *countUpstepPtr, bool *countUpDonePtr, int *bonusPtr)
Handle mouse input relative to the quiz options.
Definition:
quizLogic.cpp:10
quizLogic.h
raylib.h
CheckCollisionPointRec
RLAPI bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
Definition:
rshapes.c:1599
GetMousePosition
RLAPI Vector2 GetMousePosition(void)
Definition:
rcore.c:3761
MOUSE_BUTTON_LEFT
@ MOUSE_BUTTON_LEFT
Definition:
raylib.h:648
IsMouseButtonPressed
RLAPI bool IsMouseButtonPressed(int button)
Definition:
rcore.c:3696
City
Initialise cities.
Definition:
cityOperations.h:8
City::trueAnswer
int trueAnswer
Definition:
cityOperations.h:22
Option
Definition:
quizLogic.h:6
Vector2
Definition:
physac.h:129
timer.h
Game
_build
quizLogic.cpp
Generated by
1.9.5