Simple minigames (Screen Language only).

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
Alex
Lemma-Class Veteran
Posts: 2310
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Simple minigames (Screen Language only).

#76 Post by Alex » Thu Jun 27, 2019 3:59 pm

Well, this part sets the positions for buttons

Code: Select all

    # This will make the description for all buttons (numbers, values and positions)
    python:
        for i in range (0, len(buttons_values) ):
            numbers_buttons.append ( {"b_number":i, "b_value":buttons_values[i], "b_x_pos":(renpy.random.randint (10, 70))*10, "b_y_pos":(renpy.random.randint (15, 50))*10, "b_to_show":True} )
For now "b_x_pos" and "b_y_pos" are set randomly, but you can predefine some positions and use them to set buttons positions. Or you could put the buttons inside a grid...

How would you like to place those buttons on screen?

User avatar
bubski_sketches
Newbie
Posts: 2
Joined: Wed Jun 26, 2019 6:38 pm
Contact:

Re: Simple minigames (Screen Language only).

#77 Post by bubski_sketches » Mon Jul 08, 2019 9:42 pm

Figured it out through trial and error thanks to your clarification above,

Thanks so much again!

User avatar
Matalla
Regular
Posts: 198
Joined: Wed Mar 06, 2019 6:22 pm
Completed: The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Simple minigames (Screen Language only).

#78 Post by Matalla » Fri Aug 16, 2019 3:37 pm

Hey Alex, thanks for your work.

I am implementing your fifteen game in my project and all works well, even with the clumsy modifications I made.

There's only a little thing that bothers me: after time is up, you can keep moving pieces. This has no real consequences, as if the puzzle is failed, even solving it after the time runs out, don't change anything. And if it's solved you can't make any move (but a sound I put in the buttons keeps playing).

I have tried several things but I can't figure out how to disable the buttons after time is up.
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
Alex
Lemma-Class Veteran
Posts: 2310
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Simple minigames (Screen Language only).

#79 Post by Alex » Fri Aug 16, 2019 5:48 pm

Matalla wrote:
Fri Aug 16, 2019 3:37 pm
...I have tried several things but I can't figure out how to disable the buttons after time is up.
Hi, Matalla!
All game tiles are buttons, so you can use a variable to set their 'sensitive' property to True/False.
https://www.renpy.org/doc/html/screens.html#button

Here's an example of this - viewtopic.php?f=8&t=56083&p=514958&hili ... ve#p514958

User avatar
Matalla
Regular
Posts: 198
Joined: Wed Mar 06, 2019 6:22 pm
Completed: The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Simple minigames (Screen Language only).

#80 Post by Matalla » Fri Aug 16, 2019 6:34 pm

Alex wrote:
Fri Aug 16, 2019 5:48 pm
Matalla wrote:
Fri Aug 16, 2019 3:37 pm
...I have tried several things but I can't figure out how to disable the buttons after time is up.
Hi, Matalla!
All game tiles are buttons, so you can use a variable to set their 'sensitive' property to True/False.
https://www.renpy.org/doc/html/screens.html#button

Here's an example of this - viewtopic.php?f=8&t=56083&p=514958&hili ... ve#p514958
It works! Thanks Alex.

I usually do this kind of things with SensitiveIf inside the action, but with all the stuff that I don't fully understand going on inside your action, I didn't even try. This method seems more suited for code ignorants like me, so thanks for showing it to me too.

For anyone interested, putting this below the action block, do the trick.

Code: Select all

sensitive fifteen_timer > 0
Edit: Oh, wait... that only works with the lose option. I'll have to think something that covers the win option too. Or I could hide the screen and show the image, which is what I had in place before.

Edit2: I'm dumber than I'd like to think:

Code: Select all

sensitive timer_on
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

Re: Simple minigames (Screen Language only).

#81 Post by XemiTicTac » Thu Nov 07, 2019 8:30 am

Hi Alex! Im implementing the Memoria game to my proyect, i want make the cards to appear in a specific area of ​​the screen. Like set area screen limits x and y to put the cards. Its maybe with position attribute or with the area attribute? Thanks for sharing us these minigames ! :D

PD: I dont know if i explained my problem properly xD

User avatar
Alex
Lemma-Class Veteran
Posts: 2310
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Simple minigames (Screen Language only).

#82 Post by Alex » Thu Nov 07, 2019 4:11 pm

XemiTicTac wrote:
Thu Nov 07, 2019 8:30 am
... i want make the cards to appear in a specific area of ​​the screen. ...
Well, for now all the cards are placed in a grid, so you can set the position of the grid, like

Code: Select all

    grid 3 4:
        align (0.5, 0.5)
        for card in cards_list:
or apply the transform to it - viewtopic.php?f=8&t=55947&p=514658#p514658

The other way would be to add individual positions for each card in their description and show them not in a grid but at their positions, like

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", "A", "A", "A", "A", "B",  "B", "B", "B", "B", "B"]
    
    # Then - shuffle them
    $ values_list = cards_shuffle(values_list)
    
    # And make the cards_list that describes all the cards
    $ cards_list = []
    $ card_positions_list = [(100, 50), (150, 70), (70, 150), (120, 90)] #the number of positions must match the number of cards !!!
    python:
        for i in range (0, len(values_list) ):
            cards_list.append ( {"c_number":i, "c_value": values_list[i], "c_chosen":False, "c_pos":card_positions_list[i]} )

Code: Select all

    #grid 3 4:
    for card in cards_list:
        button:
            pos card["c_pos"]
            background None

User avatar
XemiTicTac
Newbie
Posts: 12
Joined: Mon Oct 28, 2019 12:40 pm
Contact:

Re: Simple minigames (Screen Language only).

#83 Post by XemiTicTac » Fri Nov 08, 2019 11:46 am

Tried these methods and it worked ! Thanks as always Alex, pretty appreciate your help. :D

thomas_oak
Newbie
Posts: 19
Joined: Thu Oct 24, 2019 11:28 am
Contact:

Re: Simple minigames (Screen Language only).

#84 Post by thomas_oak » Sat Nov 16, 2019 11:01 am

Is there a simple way to freeze the timer upon completion of the memoria game, so as to increase the player's prize depending on how well they have done?

User avatar
Alex
Lemma-Class Veteran
Posts: 2310
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Simple minigames (Screen Language only).

#85 Post by Alex » Sat Nov 16, 2019 1:41 pm

Try to add a variable 'timer_on' and set it to True/False to start/stop timer.
Something like

Code: Select all

##### The game screen
screen memo_scr:    
    
    ##### Timer
    if timer_on: # <---
        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

Code: Select all

    # Before start the game, let's set the timer
    $ memo_timer = 50.0

    $ timer_on = True # <---
    
    # Shows the game screen
    show screen memo_scr

Code: Select all

label memo_game_win:
    $ timer_on = False
    $ can_click = False
    if memo_timer > 20:
        "Great job!"
    hide screen memo_scr
    $ renpy.pause (0.1, hard = True)
    $ renpy.pause (0.1, hard = True)
    "You win!"
    return

thomas_oak
Newbie
Posts: 19
Joined: Thu Oct 24, 2019 11:28 am
Contact:

Re: Simple minigames (Screen Language only).

#86 Post by thomas_oak » Sat Nov 16, 2019 3:30 pm

Splendid. Thanks Alex

Post Reply

Who is online

Users browsing this forum: No registered users