im planning that after the quiz game the average of result is display and has a save button that can save the average and result with the character name to hall of fame .
im making a educational quiz game about computer system servicing.
and the quiz has four core competency. each core competency has a quiz and should have a highscore that save to hall of fame . so that the user can visit the hall of fame in main menu that who has the best score in every core competency.
is that make sense? or it is possible?
if its not possible, what suggestion you can say about that?
what should i do first about that?
help is really appreciate . thanks in advance
this is the quiz game with the scoreboard:
Code: Select all
# Function that will shuffle answers
init python:
def shuffle_answers(x):
renpy.random.shuffle(x)
return x
###
default q_asked=0
default right_answers=0
### scoreboard result in quiz game
screen scoreboard():
vbox:
xalign 0.5
yalign 0.5
if q_asked>0:
text "Your average score is"
text "" + str(right_answers*100/q_asked) + "%"
text "Your correct score is " + str(right_answers) + " out of " + str(q_asked)
# The game starts here.
label start:
label game:
menu:
"INSTALL & CONFIGURE COMPUTER SYSTEM":
jump COC1
"SET-UP COMPUTER NETWORK":
jump COC2
"SET-UP COMPUTER SERVICE":
jump COC3
"MAINTAIN REPAIR COMPUTER SYSTEM & NETWORK":
jump COC4
a "you can choose any Core Competencies you want to take:"
label COC1:
# list of all possible questions
# it consist of dictionaries, that describe each question:
$ q_list = [
{"question": "is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data.?", "answer": [ ["computer", "right"], ["cpu", "wrong"], ["modem", "wrong"], ["internet", "wrong"] ], "category": "multiple choice"},
{"question": "is the primary component of a computer that processes instructions. It runs the operating system and applications, constantly receiving input from the user or active software programs. It processes the data and produces output, which may stored by an application or displayed on the screen.?", "answer": [ ["cpu", "right"], ["computer", "wrong"], ["motherboard", "wrong"], ["internet", "wrong"] ], "category": "multiple choice"},
{"question": "is a primary memory. This memory is used inside the computer to hold programs and data while it is running.?", "answer": [ ["ram", "right"], ["hard drive", "wrong"], ["flashdrive", "wrong"], ["rom", "wrong"] ], "category": "multiple choice"},
{"question": "It is a part of a network. It is a special computer that users on the network can access to carry out a particular job.", "answer": [ ["server", "right"], ["lan cable", "wrong"], ["router", "wrong"], ["computer", "wrong"] ], "category": "multiple choice"},
{"question": "After adding and removing any other system components, make sure that you unplug your power supply. ", "answer": [ ["false", "right"], ["true", "wrong"] ], "category": "true or false"},
{"question": "With an effective cooling fan, the CPU can overheat and cause damage to both CPU and the motherboard. ", "answer": [ ["false", "right"], ["true", "wrong"] ], "category": "true or false"},
{"question": "Failure to do the proper jumper setting may cause damage to your CPU. ", "answer": [ ["true", "right"], ["false", "wrong"] ], "category": "true or false"},
{"question": "Test the computer, insuring that it meets the necessary system requirements before booting up.", "answer": [ ["false", "right"], ["true", "wrong"] ], "category": "true or false"}]
# game variables
$ right_answers = 0 # result of quiz game
$ quiz_length = 6 # number of questions in one game
# let's choose some questions to play with
$ q_to_ask = renpy.random.sample(q_list, quiz_length) # list of questions to ask in one game
label quize_game: # game loop
$ a = q_to_ask.pop() # pick the question (it will be removed from the list)
$ b = shuffle_answers (a["answer"]) # let's shuffle answers
$ time = 5 ### set variable time to 3
$ timer_range = 5 ### set variable timer_range to 3 (this is for purposes of showing a bar)
$ timer_jump = 'timeout_label' ### set where you want to jump once the timer runs out
show screen countdown(t=10, timeout_label="timeout_label") ### call and start the timer
# the question
$ narrator("category - {}\nQuestion - {}".format(a["category"], a["question"]), interact=False)
# the answers - result will be the second element of chosen answer ("right"/"wrong")
$ result = renpy.display_menu(b)
# evaluate the result
if result == "right":
$ right_answers += 1
"That's true."
else:
"Nope."
$ q_asked += 1
if q_to_ask: # if we still got questions to ask
jump quize_game
hide screen countdown
# when there's no questions left
"good job! you finish the test"
show screen scoreboard ### call the scorebored
"your score is = [right_answers] out of [quiz_length]"
return
label timeout_label:
"Time ended"
return
label COC2:
label COC3:
label COC4: