Page 8 of 9
Re: Simple minigames (Screen Language only).
Posted: Mon Aug 30, 2021 6:56 pm
by Trafagal
Thank you Alex, I manage to find the reason why. I think maybe no need to define the diff_timer.
Just to share with others who might be looking for the "Find the Difference" Game.
You need to update a small part of this section in the original codes for the screen left and right. Be careful of the indentation.
Code: Select all
screen left_scr:
# Screen at left has all differences
fixed:
xpos 50 ypos 100
button:
background "base_image_{}.png".format(x)
action Show('left_scr', diff_timer-1)
mouse "left"
Re: Simple minigames (Screen Language only).
Posted: Fri Oct 01, 2021 1:58 am
by Bryy
Is there a way to do an effective Tower Defense in Renpy?
Re: Simple minigames (Screen Language only).
Posted: Fri Oct 01, 2021 12:52 pm
by Alex
CDD or sprite manager maybe...
Maybe someone will share the code if you'll ask in Q&A forum...
Re: Simple minigames (Screen Language only).
Posted: Fri Oct 01, 2021 5:11 pm
by Bryy
Alex wrote: ↑Fri Oct 01, 2021 12:52 pm
Maybe someone will share the code if you'll ask in Q&A forum...
Don't bring logic into this.
Re: Simple minigames (Screen Language only).
Posted: Thu Mar 24, 2022 4:14 pm
by Neyunse
Alex wrote: ↑Sat Dec 12, 2015 8:25 pm
Group battle game.
Code: Select all
define battle_narrator = Character(None, interact=False)
screen battle_screen:
vbox:
xalign 0.01 yalign 0.05
spacing 5
for each_party_member in party_list:
frame:
size_group "party"
xminimum 250 xmaximum 250
yminimum 75
vbox:
text "[each_party_member[name]]" size 22 xalign 0.5
null height 5
hbox:
bar:
xmaximum 130
value each_party_member["current_hp"]
range each_party_member["max_hp"]
left_gutter 0
right_gutter 0
thumb None
thumb_shadow None
null width 5
text "[each_party_member[current_hp]] / [each_party_member[max_hp]]" size 16
hbox:
frame:
size_group "party"
yminimum 40
text "Potions left - [potions_left]" yalign 0.5
if players_turn and potions_left > 0:
textbutton "<- Use" action Return("heal") yminimum 40
else:
textbutton "<- Use" action None yminimum 40
vbox:
xalign 0.99 yalign 0.05
spacing 5
if enemies_list != []:
for i, each_enemy_member in enumerate(enemies_list):
hbox:
if players_turn and each_enemy_member["current_hp"] > 0:
textbutton "Attack ->" action Return(i) yminimum 75
else:
textbutton "Attack ->" action None yminimum 75
frame:
size_group "enemies"
xminimum 250 xmaximum 250
yminimum 75
vbox:
text "[each_enemy_member[name]]" size 22 xalign 0.5
null height 5
hbox:
bar:
xmaximum 130
value each_enemy_member["current_hp"]
range each_enemy_member["max_hp"]
left_gutter 0
right_gutter 0
thumb None
thumb_shadow None
null width 5
text "[each_enemy_member[current_hp]] / [each_enemy_member[max_hp]]" size 16
init python:
def check_party(x):
#### This function will check
# if at least one of X party members is alive.
#
for member in x:
if member["current_hp"] > 0:
return "ok"
return "lost"
label battle_game_2:
#### Some variables that describes the game state.
#
# The "party_list" is a list of all allies each one of that
# is described by a dictionary.
#
$ party_list =[{"name":"Me", "max_hp":50, "current_hp":50, "min_damage":3, "max_damage":5}]
$ potions_left = 10
$ players_turn = False
#### Enemies list will have the description for enemies.
#
$ enemies_list = []
scene black
#### Let's show the game screen.
#
show screen battle_screen
#### We can add some allies to the party:
#
menu:
"Who do you take with you?"
"Friend 1":
$ party_list.append ( {"name":"Friend 1", "max_hp":30, "current_hp":30, "min_damage":5, "max_damage":6} )
"Friend 2":
$ party_list.append ( {"name":"Friend 2", "max_hp":60, "current_hp":60, "min_damage":1, "max_damage":4} )
"Noone... :(":
pass
#### Enemies party can be set manually or automatically like:
#
python:
for i in range ( 0, renpy.random.randint(1,4) ):
enemy_name = "Enemy %d" %i
enemy_max_hp = renpy.random.randint(10,20)
enemy_current_hp = enemy_max_hp
enemy_min_damage = renpy.random.randint(1,3)
enemy_max_damage = renpy.random.randint(4,6)
enemies_list.append ( {"name":enemy_name, "max_hp":enemy_max_hp, "current_hp":enemy_current_hp, "min_damage":enemy_min_damage, "max_damage":enemy_max_damage} )
"Let the battle begins!"
#### Main battle loop.
#
label battle_2_loop:
#### At first let's check if player's party is ok.
#
if check_party(party_list) == "lost":
jump battle_2_lose
#### All the party members will do their actions one after another.
#
$ party_index = 0
while party_index < len(party_list):
$ current_player = party_list[party_index]
#### Current player will act only if he still alive.
#
if current_player["current_hp"] > 0:
#### Let's check if enemies party is still ok.
#
if check_party(enemies_list) == "lost":
jump battle_2_win
#### Let the player make his turn.
#
$ players_turn = True
battle_narrator"[current_player[name]], it's your turn now."
#### Store the result of player's interaction.
#
$ res = ui.interact()
#### Now disallow player's interact with the game.
#
$ players_turn = False
if res == "heal":
$ current_player["current_hp"] = min( current_player["current_hp"]+5, current_player["max_hp"] )
$ potions_left -= 1
"*Drink* 5hp restored"
else:
$ player_damage = renpy.random.randint( current_player["min_damage"], current_player["max_damage"] )
$ enemies_list[res]["current_hp"] -= player_damage
"Take this! (damage dealt - [player_damage]hp)"
#### And the turn goes to the next party member.
#
$ party_index += 1
##### And now it's enemies party turn.
#
# At first let's check if enemy's party is ok.
#
if check_party(enemies_list) == "lost":
jump battle_2_win
#### All the party members will do their actions one after another.
#
$ enemy_index = 0
while enemy_index < len(enemies_list):
$ current_enemy = enemies_list[enemy_index]
#### Current enemy will act only if he is still alive.
#
if current_enemy["current_hp"] > 0:
#### Let's check if player's party is still ok.
#
if check_party(party_list) == "lost":
jump battle_2_lose
#### Enemy will attack the random player.
#
$ party_member_to_attack = party_list[renpy.random.randint( 0, (len(party_list)-1) )]
$ enemy_damage = renpy.random.randint( current_enemy["min_damage"], current_enemy["max_damage"] )
$ party_member_to_attack["current_hp"] -= enemy_damage
"Rrrrr! ([current_enemy[name]] dealt [enemy_damage]hp damage to [party_member_to_attack[name]])"
#### And the turn goes to the next party member.
#
$ enemy_index += 1
#### Next round of the battle.
#
jump battle_2_loop
#### The results of the game.
#
label battle_2_win:
"Well done!"
hide screen battle_screen
return
label battle_2_lose:
"X_X"
hide screen battle_screen
return
A question, how can I display interactive sprites (ex. imagebuttons), to choose who to attack?
Re: Simple minigames (Screen Language only).
Posted: Thu Mar 24, 2022 6:26 pm
by Alex
Neyunse wrote: ↑Thu Mar 24, 2022 4:14 pm
A question, how can I display interactive sprites (ex. imagebuttons), to choose who to attack?
Well, add an image to enemy description
Code: Select all
#### Enemies party can be set manually or automatically like:
#
python:
for i in range ( 0, renpy.random.randint(1,4) ):
enemy_name = "Enemy %d" %i
enemy_max_hp = renpy.random.randint(10,20)
enemy_current_hp = enemy_max_hp
enemy_min_damage = renpy.random.randint(1,3)
enemy_max_damage = renpy.random.randint(4,6)
enemy_image = "images/enemy.png"
enemies_list.append ( {"name":enemy_name, "image":enemy_image, "max_hp":enemy_max_hp, "current_hp":enemy_current_hp, "min_damage":enemy_min_damage, "max_damage":enemy_max_damage} )
Then change this part of "battle_screen" to show enemies as buttons using their images
Code: Select all
vbox:
xalign 0.99 yalign 0.05
spacing 5
if enemies_list != []:
for i, each_enemy_member in enumerate(enemies_list):
hbox:
if players_turn and each_enemy_member["current_hp"] > 0:
textbutton "Attack ->" action Return(i) yminimum 75
else:
textbutton "Attack ->" action None yminimum 75
frame:
size_group "enemies"
xminimum 250 xmaximum 250
yminimum 75
vbox:
text "[each_enemy_member[name]]" size 22 xalign 0.5
null height 5
hbox:
bar:
xmaximum 130
value each_enemy_member["current_hp"]
range each_enemy_member["max_hp"]
left_gutter 0
right_gutter 0
thumb None
thumb_shadow None
null width 5
text "[each_enemy_member[current_hp]] / [each_enemy_member[max_hp]]" size 16
Re: Simple minigames (Screen Language only).
Posted: Mon May 16, 2022 7:24 am
by Max987r
Hey Alex
How can I make (in memoria )that if you match certain cards it will reduce timer ?
Like eg:- AA is matched timer reduce to 50 to 40 or 45 to 35 decreases 10
Pls help
Re: Simple minigames (Screen Language only).
Posted: Mon May 16, 2022 9:31 am
by Max987r
Max987r wrote: ↑Mon May 16, 2022 7:24 am
Hey Alex
How can I make (in memoria )that if you match certain cards it will reduce timer ?
Like eg:- AA is matched timer reduce to 50 to 40 or 45 to 35 decreases 10
Pls help
Solved it BTW thanks for the game idea.
Re: Simple minigames (Screen Language only).
Posted: Mon May 16, 2022 10:54 am
by Max987r
Max987r wrote: ↑Mon May 16, 2022 9:31 am
Max987r wrote: ↑Mon May 16, 2022 7:24 am
Hey Alex
How can I make (in memoria )that if you match certain cards it will reduce timer ?
Like eg:- AA is matched timer reduce to 50 to 40 or 45 to 35 decreases 10
Pls help
Solved it BTW thanks for the game idea.
Help again how can I make it even if the trap cards are not removed from the grid the game end?
That is if player not open the traps game win but the have to match all none trap cards
Eg: AA you have to match if you dont find T(trap) game ends
Re: Simple minigames (Screen Language only).
Posted: Mon May 16, 2022 3:19 pm
by Alex
Max987r wrote: ↑Mon May 16, 2022 10:54 am
Help again how can I make it even if the trap cards are not removed from the grid the game end?
That is if player not open the traps game win but the have to match all none trap cards
Eg: AA you have to match if you dont find T(trap) game ends
If you've made your trap cards this way -
viewtopic.php?f=51&t=18047&start=45#p466948 then winning condition will be
Code: Select all
# 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 and j["c_value"] not in trap_cards: # <---
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
Re: Simple minigames (Screen Language only).
Posted: Tue May 17, 2022 1:53 am
by Max987r
Alex wrote: ↑Mon May 16, 2022 3:19 pm
Max987r wrote: ↑Mon May 16, 2022 10:54 am
Help again how can I make it even if the trap cards are not removed from the grid the game end?
That is if player not open the traps game win but the have to match all none trap cards
Eg: AA you have to match if you dont find T(trap) game ends
If you've made your trap cards this way -
viewtopic.php?f=51&t=18047&start=45#p466948 then winning condition will be
Code: Select all
# 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 and j["c_value"] not in trap_cards: # <---
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
Thanks Alex I will try it out
Re: Simple minigames (Screen Language only).
Posted: Tue May 17, 2022 4:30 am
by Max987r
Max987r wrote: ↑Tue May 17, 2022 1:53 am
Alex wrote: ↑Mon May 16, 2022 3:19 pm
Max987r wrote: ↑Mon May 16, 2022 10:54 am
Help again how can I make it even if the trap cards are not removed from the grid the game end?
That is if player not open the traps game win but the have to match all none trap cards
Eg: AA you have to match if you dont find T(trap) game ends
If you've made your trap cards this way -
viewtopic.php?f=51&t=18047&start=45#p466948 then winning condition will be
Code: Select all
# 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 and j["c_value"] not in trap_cards: # <---
renpy.jump ("memo_game_loop")
renpy.jump ("memo_game_win")
Thanks Alex I will try it out
it work but not as I intended
what i meant is player must match card that are in value_list but if you open card in trap_list time will decreaseand it will get removed and if the player matches all the cards only in value list then the game end it doest matter if trap_list cards are matched or not.
eg:-
Code: Select all
value_list = [A,B,C,D] Trap_list = [T]
grid: ABCD
TABC
DTAA
if player open (T) time decreases (X represent open matches)
End Of game grid:
XXXX
TXXX
XTXX
game ends even with trap cards on the field (just the cards in value list are matched)
Re: Simple minigames (Screen Language only).
Posted: Tue May 17, 2022 11:52 am
by Alex
Max987r wrote: ↑Tue May 17, 2022 4:30 am
...what i meant is player must match card that are in value_list but if you open card in trap_list time will decreaseand ...
Try to make time penalty like
Code: Select all
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
$ memo_timer -= 5 # <---
jump turns_done
$ turns_left -= 1
jump turns_loop
Re: Simple minigames (Screen Language only).
Posted: Tue May 17, 2022 1:58 pm
by Max987r
Alex wrote: ↑Tue May 17, 2022 11:52 am
Max987r wrote: ↑Tue May 17, 2022 4:30 am
...what i meant is player must match card that are in value_list but if you open card in trap_list time will decreaseand ...
Try to make time penalty like
Code: Select all
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
$ memo_timer -= 5 # <---
jump turns_done
$ turns_left -= 1
jump turns_loop
I have done that and that's how I was able to decrease the time.
I need your help to figure out how to make even some card ie trap cards remain on screen game ends?
Re: Simple minigames (Screen Language only).
Posted: Tue May 17, 2022 2:26 pm
by Alex
Max987r wrote: ↑Tue May 17, 2022 1:58 pm
...I need your help to figure out how to make even some card ie trap cards remain on screen game ends?
This will end the game if only trap cards are remain onscreen -
viewtopic.php?f=51&t=18047&p=552135&sid ... f9#p552110