Thank you so much!
(Although, OpenGL didn't worked for me. Must have been a problem in OpenGL.)
Code: Select all
##### The game screen
init:
python:
def cards_shuffle(x):
renpy.random.shuffle(x)
return x
##### Images
image A = im.Scale("fool.jpg", 127, 203) # different card images
image B = im.Scale("devil.jpg", 127, 203)
image C = im.Scale("back.jpg", 127, 203) # back of the card
screen memo_scr:
##### Timer
timer 1.0 action If (memo_timer > 1, SetVariable("memo_timer", memo_timer - 1), Jump("memo_game_lose") ) repeat True
text str(memo_timer) xalign 0.5 yalign 0.05
##### Cards
#
# To use images, just comment out lines that show text and uncomment lines that show images
grid 3 3:
area (0.35,0.15, 600, 720)
for card in cards_list:
button:
if card["c_chosen"]: # shows the face of the card
#text card["c_value"] # will show text
add card["c_value"] # will show image
else: # shows the back of the card
#text "X" # will show text
add "C" # will show image
action If ( (card["c_chosen"] or not can_click), None, [SetDict(cards_list[card["c_number"]], "c_chosen", True), Return(card["c_number"]) ] )
label memoria_game:
#####
#
# At first, let's set the cards to play (the amount should match the grid size - in this example 12)
$ values_list = ["A", "A", "A", "A", "A", "A", "B", "B", "B"]
# Then - shuffle them
$ values_list = cards_shuffle(values_list)
# And make the cards_list that describes all the cards
$ cards_list = []
python:
for i in range (0, len(values_list) ):
cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False} )
# Before start the game, let's set the timer
$ memo_timer = 50.0
# Shows the game screen
show screen memo_scr
# The game loop
label memo_game_loop:
$ can_click = True
$ turned_cards_numbers = []
$ turned_cards_values = []
# Let's set the amount of cards that should be opened each turn (all of them should match to win)
$ turns_left = 3
label turns_loop:
if turns_left > 0:
$ result = ui.interact()
$ memo_timer = memo_timer
$ turned_cards_numbers.append (cards_list[result]["c_number"])
$ turned_cards_values.append (cards_list[result]["c_value"])
$ turns_left -= 1
jump turns_loop
# To prevent further clicking befor chosen cards will be processed
$ can_click = False
# If not all the opened cards are matched, will turn them face down after pause
if turned_cards_values.count(turned_cards_values[0]) != len(turned_cards_values):
$ renpy.pause (1.0, hard = True)
python:
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_chosen"] = False
# If cards are matched, will check if player has opened all the cards
else:
$ renpy.pause (1.0, hard = True)
python:
# Let's remove opened cards from game field
# But if you prefere to let them stay - just comment out next 2 lines
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_value"] = Null()
for j in cards_list:
if j["c_chosen"] == False:
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
jump memo_game_loop
Code: Select all
label memoria_game:
#####
#
# At first, let's set the cards to play (the amount should match the grid size - in this example 12)
$ values_list = ["A", "A", "C", "C", "E", "F", "B", "B", "D"]
$ trap_cards = ["D", "E", "F"]
# Then - shuffle them
$ values_list = cards_shuffle(values_list)
# And make the cards_list that describes all the cards
$ cards_list = []
python:
for i in range (0, len(values_list) ):
cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False} )
# Before start the game, let's set the timer
$ memo_timer = 50.0
# Shows the game screen
show screen memo_scr
# The game loop
label memo_game_loop:
$ can_click = True
$ turned_cards_numbers = []
$ turned_cards_values = []
# Let's set the amount of cards that should be opened each turn (all of them should match to win)
$ turns_left = 2
label turns_loop:
if turns_left > 0:
$ result = ui.interact()
$ memo_timer = memo_timer
$ turned_cards_numbers.append (cards_list[result]["c_number"])
$ turned_cards_values.append (cards_list[result]["c_value"])
if cards_list[result]["c_value"] in trap_cards: #<----- check for trap-cards
jump turns_done
$ turns_left -= 1
jump turns_loop
label turns_done:
# To prevent further clicking befor chosen cards will be processed
$ can_click = False
# If not all the opened cards are matched or only one trap-card opened, will turn them face down after pause
if turned_cards_values.count(turned_cards_values[0]) != len(turned_cards_values) or len(turned_cards_values) == 1:
$ renpy.pause (1.0, hard = True)
python:
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_chosen"] = False
# If cards are matched, will check if player has opened all the cards
else:
$ renpy.pause (1.0, hard = True)
python:
# Let's remove opened cards from game field
# But if you prefere to let them stay - just comment out next 2 lines
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_value"] = Null()
for j in cards_list:
if j["c_chosen"] == False:
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
jump memo_game_loopCode: Select all
if result == "talk":
call talk_monsters
Code: Select all
##### The game screen
screen memo_combat_scr_UI:
##########################################################################################################################
## Add here combat UI buttons, attack, run and so on for effect, but with other workings.
##########################################################################################################################
##### Standard comands
#
# Different actions you can take other then selecting a card
imagebutton:
xpos .26 ypos .32
idle "gui/talk_button_idle.png" # Unchecked idle
hover "gui/talk_button_hover.png" # Unchecked hover
action [ Return("talk"), SensitiveIf(brickClicked==False) ]
focus_mask True
imagebutton:
xpos .36 ypos .42
idle "gui/attack_button_idle.png" # Unchecked idle
hover "gui/attack_button_hover.png" # Unchecked hover
action [ Return("fight"), SensitiveIf(brickClicked==False) ]
focus_mask True
imagebutton:
xpos .26 ypos .52
idle "gui/item_button_idle.png" # Unchecked idle
hover "gui/item_button_hover.png" # Unchecked hover
action [ Return("items"), SensitiveIf(brickClicked==False) ]
focus_mask True
imagebutton:
xpos .36 ypos .62
idle "gui/flee_button_idle.png" # Unchecked idle
hover "gui/flee_button_hover.png" # Unchecked hover
action [ Return("flee"), SensitiveIf(brickClicked==False) ]
focus_mask True
##### Cards
#
# To use images, just comment out lines that show text and uncomment lines that show images
grid 6 6: #Decides Size of gridd and how may cards will be in game, want more??? Add more number
xpos 150
ypos 140
# Add here information for gridd here??? like where it's to be rendered and such???
for card in cards_list: #Creates a button for each slot in gridd based on card in cards_list
button: #Creates button
background None #Decide no background will be there Can be that wish to have background for locked briks and the like, Or simply have other buttons instead... lets see.
if card["c_chosen"]: # shows the face of the card
add card["c_value"] # will show image
else: # shows the back of the card
add "brik_Back" # will show image of back
action If ( (card["c_chosen"] or not can_click), None, [SetDict(cards_list[card["c_number"]], "c_chosen", True), Return(card["c_number"]) ] )
#### The defining of the cards and deck ####################################################################################################################################################################################################
init:
python:
def cards_shuffle(x): #Define card shuffle
renpy.random.shuffle(x) #Shuffle card nr X
return x #Then return it??
##### Images
image brik_Sword = "gui/sword.png" # different card images
image brik_Combo = "gui/combo.png" # etc..
image brik_Hart = "gui/hart.png"
image brik_Magic = "gui/magic.png"
image brik_Talk = "gui/talk.png"
image brik_Shield = "gui/shield.png"
image brik_Back = "gui/used.png" # back of the card
########################################################################################################################################################################################################
label memoria_battle_engine:
#### START OF BATTLE #########################
#### SETTING UP ##############################
play music "sound/battle_enemy.mp3" #Battle music Have some check thing in case of location/enemy type
$ brickClicked = False
$ battle_continue = True #Set battle true that battle is ongoing.
#This renders all characters and menus
show y angry at battle_sprite, flip
show monster normal
show screen player_gui
show screen enemy_gui
#with dissolve
#Decide turn order for combat
call attackSequence_locator
#Animated thing to hide doors, initiating combat.
hide screen battle_transform_l_door
hide screen battle_transform_r_door
"You have encountered a %(target_enemie)s" #Stating who you are fighting
#This is turn order, shows who acts and when. This will work differently depending on combat type
show screen turnOrder
call memoria_create_newdeck
$ turned_cards_numbers = []
$ turned_cards_values = []
# Let's set the amount of cards that should be opened each turn (all of them should match to win)
$ turns_left = 3
while battle_continue==True:
###### Player turn ######################################################
while player_turn=="player":
$ can_click = True
call screen memo_combat_scr_UI
$ result = _return
if result == "talk":
call talk_monsters
elif result == "fight":
call player_attacks
if attack == "return":
pass
else:
call attackSequence_change
elif result == "items":
call player_item
elif result == "flee":
"You try to flee" #if you flee, have it check for dexterity, if fast enough you escape
if dexterity+renpy.random.randint(1, 20)>= 10:
$ player_turn = "Run"
$ battle_continue = False
else:
"The monster blocks your way!"
call attackSequence_change
else:
$ brickClicked = True
if turns_left > 0:
$ result = ui.interact()
$ turned_cards_numbers.append (cards_list[result]["c_number"])
$ turned_cards_values.append (cards_list[result]["c_value"])
$ turns_left -= 1
if turns_left == 0:
$ brickClicked = False
$ can_click = False
# If not all the opened cards are matched, will turn them face down after pause
if turned_cards_values.count(turned_cards_values[0]) != len(turned_cards_values):
$ renpy.pause (1.0, hard = True) #Have changed to transition or animation perhaps?
python:
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_chosen"] = False
$ turned_cards_numbers = []
$ turned_cards_values = []
# Let's set the amount of cards that should be opened each turn (all of them should match to win)
$ turns_left = 3
else:
$ renpy.pause (1.0, hard = True)
python:
# Let's remove opened cards from game field
# But if you prefere to let them stay - just comment out next 2 lines
for i in range (0, len(turned_cards_numbers) ):
cards_list[turned_cards_numbers[i]]["c_value"] = Null()
for j in cards_list:
if j["c_chosen"] == False:
pass
else:
renpy.call ("memoria_create_newdeck")
#Checks if your actions have killed the monster, if not, then it will either continue your turn or then go to monsters turn if still alive. Also check if you have died during your turn.
if HP<=0:
stop music fadeout 2
hide screen enemy_gui
$ random_mon_talk = renpy.random.randint(5, 25)
if myBackpack.gold < random_mon_talk:
$ myBackpack.gold = 0
else:
$ myBackpack.gold -= random_mon_talk
jump game_over
if monster_HP<=0:
$ player_turn="victory"
$ battle_continue = False
while player_turn=="monster":
call attackSequence_change
if HP<=0:
stop music fadeout 2
hide screen enemy_gui
$ random_mon_talk = renpy.random.randint(5, 25)
if myBackpack.gold < random_mon_talk:
$ myBackpack.gold = 0
else:
$ myBackpack.gold -= random_mon_talk
jump game_over
if monster_HP<=0:
$ player_turn="victory"
$ battle_continue = False
### Monster does attack, randomize his next attack in que and add it to
################################################################################################################################################################################################
# If battle is over, thees things will be checked for type of victory and what is given, checks combat, verbal, sneek, event or other tings like this.
"Battle is now over!"
if player_turn == "victory":
stop music fadeout 2
play music "sound/victory_tune.mp3"
"You have vanquished the %(target_enemie)s!"
"You gain %(monster_experience)d EXP!"
$ experience += monster_experience
call level_upp
# if level up: $ HP = max_HP,,, add to level_upp label
call loot_table_forest ## Or loot table based on location and enemie
elif player_turn == "diplomatic_victory":
stop music fadeout 2
play music "sound/victory_tune.mp3"
"The %(target_enemie)s retreets!"
$ diplomatic_xp = monster_experience/2
$ experience += diplomatic_xp
"You gain %(diplomatic_xp)d EXP!"
call level_upp
# if level up: $ HP = max_HP,,, add to level_upp label
# call loot_table_forest ## Or loot table based on location and enemie
else:
stop music fadeout 2
"You have flead the battle flee the battle!"
# hide bg forest #Change to dynamic background that can be used in all locations
hide screen enemy_gui
scene bg black
with dissolve
return
##### To create new deck when needed ##############################################################################################################################################################################################
label memoria_create_newdeck:
##### SETUP
#
# At first, let's set the cards to play, can create if menu for different decks if needed (the amount should match the grid size)
$ values_list = ["brik_Sword", "brik_Sword", "brik_Sword", "brik_Combo", "brik_Combo", "brik_Combo", "brik_Hart", "brik_Hart", "brik_Hart", "brik_Magic", "brik_Magic", "brik_Magic", "brik_Talk", "brik_Talk", "brik_Talk", "brik_Shield", "brik_Shield", "brik_Shield", "brik_Sword", "brik_Sword", "brik_Sword", "brik_Combo", "brik_Combo", "brik_Combo", "brik_Hart", "brik_Hart", "brik_Hart", "brik_Magic", "brik_Magic", "brik_Magic", "brik_Talk", "brik_Talk", "brik_Talk", "brik_Shield", "brik_Shield", "brik_Shield"]
# Then - shuffle them
$ values_list = cards_shuffle(values_list)
# And make the cards_list that describes all the cards
$ cards_list = []
python:
for i in range (0, len(values_list) ):
cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False} )
return
Code: Select all
if result == "talk":
call talk_monsters

Code: Select all
while player_turn=="player":
$ can_click = True
call screen memo_combat_scr_UI
$ result = _return
if result == "talk":
call talk_monstersUsers browsing this forum: No registered users