9 mini games

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.
Post Reply
Message
Author
User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

9 mini games

#1 Post by Andredron » Thu Jan 25, 2018 6:14 pm

Last edited by Andredron on Sat Jun 02, 2018 8:28 am, edited 19 times in total.
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

1) Card mini-games

#2 Post by Andredron » Tue Feb 27, 2018 6:28 pm

Image

Game "Search for items" in one line
http://renpyfordummies.blogspot.ru/2015 ... -post.html - Download the finished project

Code: Select all

###by 7dots Ruslan Nebykov
###license: cc by-sa
###free use, when specifying the author
# This is a mini-game to find items
# save this code to the game.rpy file in the root of the game

# Called like this:
# $ InitGame("bg_room", 5.0, True, (735, 300), "figure1", (640, 226), "figure2", (288, 38), "figure3", (115, 260), "figure4")
# $ StartGame()
# where bg_room is the name of the background file without an extension .jpg
# 5.0 - the number of seconds to execute the search (if <= 0, the timer is disabled)
# (735, 300), "figure1" - coordinates and file name of the object
# without extension .png
# items can be as many as you like
# all backgrounds and pictures of objects should be in the images folder
# at the exit - true or false (met within the allotted time or not)
# number of items found in the variable oLen
# total number of items in the variable maxLen

# $ GameAsBG () # shows the screen with pictures as a background, not clickable

# in the sounds folder should be the sound of "click.mp3"
# or, if it does not, then comment out the line:
# renpy.play ("sounds / click.mp3", channel = "sound")
init python:
    # window in the center of the screen
    import os
    os.environ ['SDL_VIDEO_CENTERED'] = '1'
    # automatic sprites
    config.automatic_images_minimum_components = 1
    config.automatic_images = ['', '_', '/']
    config.automatic_images_strip = ["images"]
    oXY = []
    oN = []
    oLen = 0
    maxLen = 0
    oBg = ""
    oLast = -1
    oTime = 0.0
    oMaxTime = 5.0
    needTimer = False
    oActive = False

    # Initialize the game, placing items on the screen
    def InitGame (bg, time, * args):
        global oBg, oXY, oN, oLen, maxLen, oLast, oTime, oMaxTime, oActive, needTimer
        oXY = []
        oN = []
        oLen = 0
        oBg = bg
        oLast = -1
        oTime = time
        oMaxTime = time
        maxLen = 0
        oActive = True
        if oTime> 0.0:
            needTimer = True
        for xy, obj_name in zip (args [0 :: 2], args [1 :: 2]):
            oXY.append (xy)
            oN.append (obj_name)
            maxLen + = 1

    # Running the game
    def StartGame ():
        global oActive
        oActive = True
        while (oLen <maxLen) and ((oTime> 0.0) or not needTimer):
            renpy.call_screen ("game", _layer = "master")
        if oTime> 0.0 or not needTimer:
            return True
        else:
            return False

    # Show the game screen as an inactive background
    # Items already found will not be displayed
    def GameAsBG ():
        global oActive
        oActive = False
        renpy.show_screen ("game", _layer = "master")

    # The click handler for the item
    def oClick ():
        global oLen
        if oLast> = 0:
            if oN [oLast]:
                oN [oLast] = ""
                oLen + = 1
                renpy.play ("sounds / click.mp3", channel = "sound")

# Actually the game screen, run from the function StartGame ()
screen game:
    if oActive and needTimer:
        timer 0.01 repeat True action [SetVariable ("oTime", oTime - .01), If (oTime <= .0, true = [Hide ("game"), Return (-1)])]
    add oBg
    for i in range (0, len (oN)):
        if oN [i]:
            imagebutton:
                focus_mask True
                pos (oXY [i])
                idle oN [i]
                hover oN [i]
                # You can duplicate pictures of objects,
                # naming them "images / name of the subject_hover.png"
                # and highlight them in the image editor
                # and replace the line above with a line below
                # then when you hover the cursor, they will be highlighted
                # hover oN [i] + "hover"
                if oActive:
                    action [SetVariable ("oLast", i), oClick (), Hide ("game"), Return (i)]
                else:
                    action []
    if oActive and needTimer:
        # if oTime> .1:
            # text "[oTime]" align (.1, .1) size 48
        # else:
            # text "0.0" align (.1, .1) size 48
        bar value StaticValue (oTime, oMaxTime):
            align (.5, .001)
            xmaximum 400
            ymaximum 20
            left_bar Frame ("slider_left.png", 10, 10)
            right_bar Frame ("slider_right.png", 10, 10)
            thumb None
            thumb_shadow None
Last edited by Andredron on Wed May 23, 2018 3:55 am, edited 2 times in total.
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

2) Primitive clicker

#3 Post by Andredron » Tue Feb 27, 2018 6:50 pm

Image

http://renpyfordummies.blogspot.ru/2016 ... st_10.html - Download the finished project

Code: Select all

###by 7dots Ruslan Nebykov
###license: cc by-sa
###free use, when specifying the author
init python:
    # game window in the center of the screen
    import os
    os.environ ['SDL_VIDEO_CENTERED'] = '1'
    # auto image ads
    config.automatic_images_minimum_components = 1
    config.automatic_images = ['', '_', '/']
    config.automatic_images_strip = ['images']
    # flash
    flash = Fade (.25, 0, .5, color = "# fff")
    flash2 = Fade (.25, 0, .5, color = "# 222")

# game settings:
    # maximum scale value
    max_points = 100
    # the name of the picture (without numbering frames)
    img_name = "n"
    # first and last animation frames
    minN = 1
    maxN = 14
    # value, to which the scale is added when clicking
    # (ie, the complexity of the game, 2.0 is very difficult, 3.0 is easy)
    points_plus = 2.5

# default variables
    # If desired, you can change this value, too,
    # to better find the balance of the game
    points_minus = 1.0
    # allowable time between clicks or
    # Animation speed (time between frames)
    ani_time = .1
    # current frame
    number = 0
    # Frame increment (+ 1 / -1)
    plus = 1
    # Scale to fill
    points = 0
    # recently was a click
    clicked = True
    # Changing animation frames if clicking was recently
    # and redraw the screen to see the changes
    def NextFrameF ():
        global points, number, plus, clicked
        # If the click was recently, then we continue the animation,
        # else the next frame will not be. pause
        if clicked:
            # next / previous frame
            number + = plus
            # If beyond the number of frames, then the animation in the opposite direction
            if number> maxN:
                number = maxN - 1
                plus = -plus
            if number <minN:
                number = minN + 1
                plus = -plus
        # Scaling down if there is no longer a click
        points - = points_minus
        if points <0:
            points = 0
        clicked = False
        # redraw the screen
        renpy.restart_interaction ()
    #function → action
    NextFrame = renpy.curry (NextFrameF)

# screen game
screen clicker:
    # this is so that the game does not go on clicking the mouse
    modal True
    # reset the game settings when the screen appears
    on "show" action [SetVariable ("number", 0), SetVariable ("plus", 1), SetVariable ("clicked", True)]
    # change the frame if the click was recently,
    # and check for a loss
    timer ani_time repeat True action [NextFrame (), If (points <= 0, true = Return (False), false = NullAction ())]
    # picture with animation
    add img_name + str (number)
    # display invisible button for clicks
    # click on add a scale and set the click flag
    button:
        text _ ("")
        xfill True
        yfill True
        background "# 00000001"
        # If the scale is full, then the end of the game, victory
        action [SetVariable ("points", points + points_plus), SetVariable ("clicked", True), If (points> = max_points, true = Return (True), false = NullAction ())]
    # Alternative keypress
    key "K_SPACE" action [SetVariable ("points", points + points_plus), SetVariable ("clicked", True), If (points> = max_points, true = Return (True), false = NullAction ())]
    # indicator
    vbar value StaticValue (points, max_points):
        align (0, 0) # position on the screen
        maximum (150, 150) # dimensions
        left_bar "heartempty" # empty heart
        right_bar "heart" # full heart
        thumb None # you can put a separator here
        thumb_shadow None # and shadow

label start:
    # any unnecessary pieces for registration
    scene expression (img_name + "0")
    pause .5
    show expression Text ("Prepared!") at truecenter as txt
    with dissolve
    pause
    hide txt
    # Start with 10 points to not lose immediately
    $ points = 10

    # ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
    call screen clicker # ← game
    # ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑

    # Further all unnecessary things went again:
    # show the results of the game
    if _return:
        # rewind the animation to the last frame
        while number <maxN:
            $ number + = 1
            scene expression (img_name + str (number))
            $ renpy.pause (ani_time, hard = True)
        scene expression (img_name + str (maxN))
        with flash
        show expression Text ("Victory!") at truecenter as txt
    else:
        # rewind the animation to the first frame
        while number> 1:
            $ number - = 1
            scene expression (img_name + str (number))
            $ renpy.pause (ani_time, hard = True)
        scene expression (img_name + "0")
        with flash2
        show expression Text ("Loss.") at truecenter as txt
    # A hard pause in case the player is still tapping on the button
    $ renpy.pause (1.0, hard = True)
    hide txt
    with dissolve
    return
    
Last edited by Andredron on Wed May 23, 2018 3:57 am, edited 1 time in total.
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

3) 3 in 1 row

#4 Post by Andredron » Mon May 07, 2018 5:57 pm

The license is free, but I'll be glad if ty specify the author - = a = Firestorm (https://vk.com/a_firestorm)

Image
https://m.vk.com/doc28338738_464355483? ... be744ba950 download project

kry.rpy

Code: Select all

#cl1, cl2, cl3, cl4, cl5, cl6, cl7 are the horizontal rows
#krix- selected stone
#krix0- 2 stone you want to change

#kricol - it seems that something superfluous
#pointka - number of points
#ktmr - timer
#clp1, clp2, clp3, clp4, clp5, clp6, clp7- this is for animation
#mcnn - Style

# image any one can write down, simply changing the value here
# imagebutton idle ("k" + str (globals () ["cl" + str (z)] [i]) + ". w")
# on
# imagebutton idle ("k" + str (globals () ["cl" + str (z)] [i]) + ". png")


image kg="kg.w"   #background image
init python:
    import time
    style.mcnn=Style(style.default)
    style.mcnn.set_parent(style.button)
    style.mcnn.color="#beddff"
    style.mcnn.size=70
    style.mcnn.outlines=[(2,"#6e6e6e",0,0)]
    def krib():
        global cl1,cl2,cl3,cl4,cl5,cl6,cl7,kricol,krix,krix0,pointka,ktmr,clp1,clp2,clp3,clp4,clp5,clp6,clp7
        for i in range(0,9):
            if cl1[i]>0:
                clzz=1
                if i<7:
                    if cl1[i]==cl1[i+1]==cl1[i+2]:
                        pointka+=(cl1[i]+cl1[i+1]+cl1[i+2])*2
                        if i<6 and cl1[i]==cl1[i+3]:
                            if i<5 and cl1[i]==cl1[i+4]:
                                pointka+=cl1[i+4]*4
                                ktmr+=4
                                cl1[i+4]=0
                            pointka+=cl1[i+3]*3
                            ktmr+=2
                            cl1[i+3]=0
                        clzz,cl1[i+1],cl1[i+2]=0,0,0
                if cl1[i]==cl2[i]==cl3[i]:
                    pointka+=(cl1[i]+cl2[i]+cl3[i])*2
                    if cl1[i]==cl4[i]:
                        if cl1[i]==cl5[i]:
                            pointka+=cl5[i]*4
                            ktmr+=4
                            cl5[i]=0
                        pointka+=cl4[i]*3
                        ktmr+=2
                        cl4[i]=0
                    clzz,cl2[i],cl3[i]=0,0,0
                if clzz==0:
                    cl1[i]=0
        renpy.pause(0.05)
        for i in range(0,9):
            if cl2[i]>0:
                clzz=1
                if i<7:
                    if cl2[i]==cl2[i+1]==cl2[i+2]:
                        pointka+=(cl2[i]+cl2[i+1]+cl2[i+2])*2
                        if i<6 and cl2[i]==cl2[i+3]:
                            if i<5 and cl2[i]==cl2[i+4]:
                                pointka+=cl2[i+4]*4
                                ktmr+=4
                                cl2[i+4]=0
                            pointka+=cl2[i+3]*3
                            ktmr+=2
                            cl2[i+3]=0
                        clzz,cl2[i+1],cl2[i+2]=0,0,0
                if cl2[i]==cl3[i]==cl4[i]:
                    pointka+=(cl2[i]+cl3[i]+cl4[i])*2
                    if cl2[i]==cl5[i]:
                        if cl2[i]==cl6[i]:
                            pointka+=cl6[i]*4
                            ktmr+=4
                            cl6[i]=0
                        pointka+=cl5[i]*3
                        ktmr+=2
                        cl5[i]=0
                    clzz,cl3[i],cl4[i]=0,0,0
                if clzz==0:
                    cl2[i]=0
        renpy.pause(0.05)
        for i in range(0,9):
            if cl3[i]>0:
                clzz=1
                if i<7:
                    if cl3[i]==cl3[i+1]==cl3[i+2]:
                        pointka=(cl3[i]+cl3[i+1]+cl3[i+2])*2
                        if i<6 and cl3[i]==cl3[i+3]:
                            if i<5 and cl3[i]==cl3[i+4]:
                                pointka+=cl3[i+4]*4
                                ktmr+=4
                                cl3[i+4]=0
                            pointka+=cl3[i+3]*3
                            ktmr+=2
                            cl3[i+3]=0
                        clzz,cl3[i+1],cl3[i+2]=0,0,0
                if cl3[i]==cl4[i]==cl5[i]:
                    pointka+=(cl3[i]+cl4[i]+cl5[i])*2
                    if cl3[i]==cl6[i]:
                        pointka+=cl6[i]*3
                        ktmr+=2
                        cl6[i]=0
                    clzz,cl4[i],cl5[i]=0,0,0
                if clzz==0:
                    cl3[i]=0
        renpy.pause(0.05)
        for i in range(0,9):
            if cl4[i]>0:
                clzz=1
                if i<7:
                    if cl4[i]==cl4[i+1]==cl4[i+2]:
                        pointka+=(cl4[i]+cl4[i+1]+cl4[i+2])*2
                        if i<6 and cl4[i]==cl4[i+3]:
                            if i<5 and cl4[i]==cl4[i+4]:
                                pointka+=cl4[i+4]*4
                                ktmr+=4
                                cl4[i+4]=0
                            pointka+=cl4[i+3]*3
                            ktmr+=2
                            cl4[i+3]=0
                        clzz,cl4[i+1],cl4[i+2]=0,0,0
                if cl4[i]==cl5[i]==cl6[i]:
                    pointka+=(cl4[i]+cl5[i]+cl6[i])*2
                    clzz,cl5[i],cl6[i]=0,0,0
                if clzz==0:
                    cl4[i]=0
        renpy.pause(0.05)
        for i in range(0,7):
            if cl5[i]>0:
                if cl5[i]==cl5[i+1]==cl5[i+2]:
                    pointka+=(cl5[i]+cl5[i+1]+cl5[i+2])*2
                    if i<6 and cl5[i]==cl5[i+3]:
                        if i<5 and cl5[i]==cl5[i+4]:
                            pointka+=cl5[i+4]*4
                            ktmr+=4
                            cl5[i+4]=0
                        pointka+=cl5[i+3]*3
                        ktmr+=2
                        cl5[i+3]=0
                    cl5[i],cl5[i+1],cl5[i+2]=0,0,0
        renpy.pause(0.05)
        for i in range(0,7):
            if cl6[i]>0:
                if cl6[i]==cl6[i+1]==cl6[i+2]:
                    pointka+=(cl6[i]+cl6[i+1]+cl6[i+2])*2
                    if i<6 and cl6[i]==cl6[i+3]:
                        if i<5 and cl6[i]==cl6[i+4]:
                            pointka+=cl6[i+4]*4
                            ktmr+=4
                            cl6[i+4]=0
                        pointka+=cl6[i+3]*3
                        ktmr+=2
                        cl6[i+3]=0
                    cl6[i],cl6[i+1],cl6[i+2]=0,0,0
        for i in range(0,9):
            if cl6[i]==0:
                clp5[i]-=32
                if cl5[i]>0:
                    cl6[i]=cl5[i]
                    cl5[i]=0
                elif cl4[i]>0:
                    cl6[i]=cl4[i]
                    cl4[i]=0
                elif cl3[i]>0:
                    cl6[i]=cl3[i]
                    cl3[i]=0
                elif cl2[i]>0:
                    cl6[i]=cl2[i]
                    cl2[i]=0
                elif cl1[i]>0:
                    cl6[i]=cl1[i]
                    cl1[i]=0
                else:
                    cl6[i]=renpy.random.randint(1,6)
                for q in range(4):
                    clp5[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        for i in range(0,9):
            if cl5[i]==0:
                clp5[i]-=32
                if cl4[i]>0:
                    cl5[i]=cl4[i]
                    cl4[i]=0
                elif cl3[i]>0:
                    cl5[i]=cl3[i]
                    cl3[i]=0
                elif cl2[i]>0:
                    cl5[i]=cl2[i]
                    cl2[i]=0
                elif cl1[i]>0:
                    cl5[i]=cl1[i]
                    cl1[i]=0
                else:
                    cl5[i]=renpy.random.randint(1,6)
                for q in range(4):
                    clp5[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        for i in range(0,9):
            if cl4[i]==0:
                clp4[i]-=32
                if cl3[i]>0:
                    cl4[i]=cl3[i]
                    cl3[i]=0
                elif cl2[i]>0:
                    cl4[i]=cl2[i]
                    cl2[i]=0
                elif cl1[i]>0:
                    cl4[i]=cl1[i]
                    cl1[i]=0
                else:
                    cl4[i]=renpy.random.randint(1,6)
                for q in range(4):
                    clp4[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        for i in range(0,9):
            if cl3[i]==0:
                clp3[i]-=32
                if cl2[i]>0:
                    cl3[i]=cl2[i]
                    cl2[i]=0
                elif cl1[i]>0:
                    cl3[i]=cl1[i]
                    cl1[i]=0
                else:
                    cl3[i]=renpy.random.randint(1,6)
                for q in range(4):
                    clp3[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        for i in range(0,9):
            if cl2[i]==0:
                clp2[i]-=32
                if cl1[i]>0:
                    cl2[i]=cl1[i]
                    cl1[i]=0
                else:
                    cl2[i]=renpy.random.randint(1,6)
                for q in range(4):
                    clp2[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        for i in range(0,9):
            if cl1[i]==0:
                clp1[i]-=32
                cl1[i]=renpy.random.randint(1,6)
                for w in range(4):
                    clp1[i]+=8
                    renpy.pause(.0000001)
                ktmr+=0.1
        return
screen krix:
    text"[pointk]"style"mcnn"
    text str(int(ktmr))style"mcnn"xalign.99
    timer 1 repeat True action If(ktmr>0,true=SetVariable('ktmr',ktmr-1),false=Return())
    for z in range(1,7):
        for i in range(0,9):
            imagebutton idle("k"+str(globals()["cl"+str(z)][i])+".w")xpos(i*80+260)ypos(z*80+20)action[SetVariable('krix',i),SetVariable('kriy',z),ui.callsinnewcontext("krich")]
screen krixx:
    text"[pointk]"style"mcnn"
    text str(int(ktmr)) style"mcnn"xalign.99
    timer 1 repeat True action If(ktmr>0,true=SetVariable('ktmr',ktmr-1),false=Return())
    for z in range(1,7):
        for i in range(0,9):
            image("k"+str(globals()["cl"+str(z)][i])+".w")xpos(i*80+260)ypos(z*80+20+globals()["clp"+str(z)][i])
label krich:
    show screen krixx
    if krix>=0:
        if krix in(krix0+1,krix0-1)and kriy==kriy0:
            pass
        elif kriy in(kriy0+1,kriy0-1)and krix==krix0:
            pass
        else:
            jump krich3
        if krix0>=0:
            $krixxx=globals()["cl"+str(kriy)][krix]
            $globals()["cl"+str(kriy)][krix]=globals()["cl"+str(kriy0)][krix0]
            $globals()["cl"+str(kriy0)][krix0]=krixxx
            label krich2:
                $krib()
                if pointka>0:
                    $pointloop+=1
                    $pointk+=pointka
                    $pointka=0
                    jump krich2
                if pointloop==0:
                    $krixxx=globals()["cl"+str(kriy0)][krix0]
                    $globals()["cl"+str(kriy0)][krix0]=globals()["cl"+str(kriy)][krix]
                    $globals()["cl"+str(kriy)][krix]=krixxx
                $pointloop=0
                $krix=-1
                $krix0=-1
        else:
            label krich3:
                $krix0=krix
                $kriy0=kriy
    return
label krix:
    scene kg
    python:
        cl0,cl1,cl2,cl3,cl4,cl5,cl6,cl7,krix,kriy,kris,krin,kriw,krie,kricol,krix,krix0,kriy,kriy0,pointk,pointloop,ktmr,pointka=[],[],[],[],[],[],[],[],0,0,0,0,0,0,0,-1,-1,-1,-1,0,0,120,0
        for z in range(1,7):
            for i in range(0,9):
                globals()["cl"+str(z)].append(renpy.random.randint(1,6))
        clp0,clp1,clp2,clp3,clp4,clp5,clp6,clp7=[],[],[],[],[],[],[],[]
        for z in range(1,7):
            for i in range(0,9):
                globals()["clp"+str(z)].append(0)
    call screen krix
    return
Last edited by Andredron on Wed May 23, 2018 4:04 am, edited 3 times in total.
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Imperf3kt
Eileen-Class Veteran
Posts: 1546
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: 6 mini-games

#5 Post by Imperf3kt » Mon May 07, 2018 7:30 pm

Thanks for creating these!
Image

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

4,5,6) 3 simple card mini games.

#6 Post by Andredron » Wed May 23, 2018 3:54 am

Image Image
The license is free, but I'll be glad if specify the author - = a = Firestorm (https://vk.com/ a_firestorm)
In file script.rpy

Code: Select all

define e = Character('Eileen', color="#c8ffc8")
###When you start the game in windowed mode, the window itself is sometimes on the edges,
### or somewhere in the corner, we'll, definitely not in the center. To fix this, just add these lines
init python hide:
    import os 
    os.environ['SDL_VIDEO_CENTERED'] = '1'

init python:
    import os
screen map:
    add "map.webp"
    imagebutton idle ("tb.webp") xalign .5 yalign .5 action [Return(),Jump("dom")]
screen tet:
    $ line=renpy.get_filename_line()
    text "[line]"
label start:
label kgames:
    menu:
        e "What will we play?"
        "At 21 points":
            $ renpy.call_in_new_context("card78")
        "Fool":
            $ renpy.call_in_new_context("card79")
        "Drunkard":
            $ renpy.call_in_new_context("card77")
    jump kgames
    return

1) 21 points or blackjack, in file card78.rpy
https://pp.userapi.com/c841623/v8416236 ... fY5t0g.jpg

Code: Select all

image tb = "tb.webp"
screen c78a:
    if btnn<5:
        textbutton "Another card" xalign .5 yalign .5 action [SetVariable("karta"+str(btnn),renpy.random.randint(2,11)),SetVariable("kartam"+str(btnn),renpy.random.choice([100,200,300,400])),SetVariable("kart"+str(btnn),renpy.random.randint(2,11)),SetVariable("kartm"+str(btnn),renpy.random.choice([100,200,300,400])),SetVariable("btnn",btnn+1),Jump("cpui")]
    textbutton "Enough" xalign .5 yalign .54 action Jump("cstand")
screen c78:
    hbox xalign .1:
        add str(kart1+kartm1)+".png"
        add str(kart2+kartm2)+".png"
        add str(kart3+kartm3)+".png"
        add str(kart4+kartm4)+".png"
    hbox xalign .1 yalign .94:
        add str(karta1+kartam1)+".png"
        add str(karta2+kartam2)+".png"
        add str(karta3+kartam3)+".png"
        add str(karta4+kartam4)+".png"
label card78:
    scene tb
    $ btnn=2
    $ kart1=renpy.random.randint(2,11)
    $ kartm1=renpy.random.choice([100,200,300,400])
    $ karta1=renpy.random.randint(2,11)
    $ kartam1=renpy.random.choice([100,200,300,400])
    $ kart2=0
    $ kart3=0
    $ kart4=0
    $ kartm2=0
    $ kartm3=0
    $ kartm4=0
    $ karta2=0
    $ karta3=0
    $ karta4=0
    $ kartam2=0
    $ kartam3=0
    $ kartam4=0
    $ cpupoint=kart1
    $ ipoint=karta1
label bgme:
    show screen c78
    show screen c78a
    e "Opponent - [cpupoint]\n Your cards - [ipoint]"
    jump bgme
label cpui:
    if cpupoint>16:
        if btnn==4:
            $ kart3=0
            $ kartm3=0
        if btnn==5:
            $ kart4=0
            $ kartm4=0
    $ cpupoint=kart1+kart2+kart3+kart4
    $ ipoint=karta1+karta2+karta3+karta4
    if cpupoint>21:
        if kart1==11:
            $ kart1=1
        elif kart2==11:
            $ kart2=1
        elif kart3==11:
            $ kart3=1
        elif kart4==11:
            $ kart4=1
        $ cpupoint=kart1+kart2+kart3+kart4
    if ipoint>21:
        if karta1==11:
            $ karta1=1
        elif karta2==11:
            $ karta2=1
        elif karta3==11:
            $ karta3=1
        elif karta4==11:
            $ karta4=1
        $ ipoint=karta1+karta2+karta3+karta4
    jump bgme
label cstand:
    hide screen c78a
    $ cpupoint=kart1+kart2+kart3+kart4
    $ ipoint=karta1+karta2+karta3+karta4
    if ipoint>21:
        if cpupoint>21:
            e "Draw"
        else:
            e "Losing bust"
    elif cpupoint>21:
        e "Victory"
    elif ipoint==cpupoint:
        e "Draw"
    elif ipoint>cpupoint:
        if cpupoint<17:
            if kart2==0:
                $ kart2=renpy.random.randint(2,11)
                $ kartm2=renpy.random.choice([100,200,300,400])
                jump cstand
            elif kart3==0:
                $ kart3=renpy.random.randint(2,11)
                $ kartm3=renpy.random.choice([100,200,300,400])
                jump cstand
            elif kart4==0:
                $ kart4=renpy.random.randint(2,11)
                $ kartm4=renpy.random.choice([100,200,300,400])
                jump cstand
        e "Victory"
    else:
        e "Loss"
    return

2) Fool card, 1 on 1 card79.rpy
https://pp.userapi.com/c841623/v8416236 ... w23P_E.jpg

Code: Select all

### Card, background, main buttons
screen c79:
    if cpua==1:
        textbutton "Pick up" xalign .5 yalign .7 action [SetVariable("kstep",0),SetVariable("tblnmb",set([0])),Jump("khodv")]
    else:
        if len(tblkardal)>1:
            textbutton "Finish the move" xalign .5 yalign .7 action [SetVariable("dhod",0),SetVariable("cpua",1),Jump("khodotb")]
    hbox xalign .1:
        if kart1!=0:
            add "krb.webp"
        if kart2!=0:
            add "krb.webp"
        if kart3!=0:
            add "krb.webp"
        if kart4!=0:
            add "krb.webp"
        if kart5!=0:
            add "krb.webp"
        if kart6!=0:
            add "krb.webp"
        if kart7!=0:
            add "krb.webp"
        if kart8!=0:
            add "krb.webp"
        if kart9!=0:
            add "krb.webp"
        if kart10!=0:
            add "krb.webp"
        if kart11!=0:
            add "krb.webp"
        if kart12!=0:
            add "krb.webp"
    hbox xpos .14 yalign .5:
        if len(tblkardal)>1:
            add str(tblkardal[1])+".png"
            if len(tblkarda)>2:
                add str(tblkardal[2])+".png"
                if len(tblkarda)>3:
                    add str(tblkardal[3])+".png"
                    if len(tblkarda)>4:
                        add str(tblkardal[4])+".png"
                        if len(tblkarda)>5:
                            add str(tblkardal[5])+".png"
                            if len(tblkarda)>6:
                                add str(tblkardal[6])+".png"
                                if len(tblkarda)>7:
                                    add str(tblkardal[7])+".png"
                                    if len(tblkarda)>8:
                                        add str(tblkardal[8])+".png"
                                        if len(tblkarda)>9:
                                            add str(tblkardal[9])+".png"
                                            if len(tblkarda)>10:
                                                add str(tblkardal[10])+".png"
                                                if len(tblkarda)>11:
                                                    add str(tblkardal[11])+".png"
                                                    if len(tblkarda)>12:
                                                        add str(tblkardal[12])+".png"
    hbox xpos .15 yalign .55:
        if len(tblkardzl)>1:
            add str(tblkardzl[1])+".png"
            if len(tblkardz)>2:
                add str(tblkardzl[2])+".png"
                if len(tblkardz)>3:
                    add str(tblkardzl[3])+".png"
                    if len(tblkardz)>4:
                        add str(tblkardzl[4])+".png"
                        if len(tblkardz)>5:
                            add str(tblkardzl[5])+".png"
                            if len(tblkardz)>6:
                                add str(tblkardzl[6])+".png"
                                if len(tblkardz)>7:
                                    add str(tblkardzl[7])+".png"
                                    if len(tblkardz)>8:
                                        add str(tblkardzl[8])+".png"
                                        if len(tblkardz)>9:
                                            add str(tblkardzl[9])+".png"
                                            if len(tblkardz)>10:
                                                add str(tblkardzl[10])+".png"
                                                if len(tblkardz)>11:
                                                    add str(tblkardzl[11])+".png"
                                                    if len(tblkardz)>12:
                                                        add str(tblkardzl[12])+".png"
    hbox yalign .5:
        add str(kozir)+".png" rotate -90
    if len(koloda)>0:
        hbox yalign .5:
            add "krb.webp"
    hbox xalign .1 yalign .94:
        if karta1!=0:
            imagebutton idle str(karta1)+".png" action [SetVariable("kartah",karta1),SetVariable("knmb",1),Jump("khod0")]
        if karta2!=0:
            imagebutton idle str(karta2)+".png" action [SetVariable("kartah",karta2),SetVariable("knmb",2),Jump("khod0")]
        if karta3!=0:
            imagebutton idle str(karta3)+".png" action [SetVariable("kartah",karta3),SetVariable("knmb",3),Jump("khod0")]
        if karta4!=0:
            imagebutton idle str(karta4)+".png" action [SetVariable("kartah",karta4),SetVariable("knmb",4),Jump("khod0")]
        if karta5!=0:
            imagebutton idle str(karta5)+".png" action [SetVariable("kartah",karta5),SetVariable("knmb",5),Jump("khod0")]
        if karta6!=0:
            imagebutton idle str(karta6)+".png" action [SetVariable("kartah",karta6),SetVariable("knmb",6),Jump("khod0")]
        if karta7!=0:
            imagebutton idle str(karta7)+".png" action [SetVariable("kartah",karta7),SetVariable("knmb",7),Jump("khod0")]
        if karta8!=0:
            imagebutton idle str(karta8)+".png" action [SetVariable("kartah",karta8),SetVariable("knmb",8),Jump("khod0")]
        if karta9!=0:
            imagebutton idle str(karta9)+".png" action [SetVariable("kartah",karta9),SetVariable("knmb",9),Jump("khod0")]
        if karta10!=0:
            imagebutton idle str(karta10)+".png" action [SetVariable("kartah",karta10),SetVariable("knmb",10),Jump("khod0")]
        if karta11!=0:
            imagebutton idle str(karta11)+".png" action [SetVariable("kartah",karta11),SetVariable("knmb",11),Jump("khod0")]
        if karta12!=0:
            imagebutton idle str(karta12)+".png" action [SetVariable("kartah",karta12),SetVariable("knmb",12),Jump("khod0")]
            
            
            
            
####Here begins the game
label card79:
    scene tb
    $ cpukarn=set([])
    $ knmb=0
    
    ####Cards register numbers
    $ koloda=set([102,103,104,105,106,107,108,109,110,111,202,203,204,205,206,207,208,209,210,211,302,303,304,305,306,307,308,309,310,311,402,403,404,405,406,407,408,409,410,411])
    
    ###Prescribe the cards that will first drop to the player
    $ kart1=renpy.random.choice(list(koloda))
    $ koloda.remove(kart1)
    $ kart2=renpy.random.choice(list(koloda))
    $ koloda.remove(kart2)
    $ kart3=renpy.random.choice(list(koloda))
    $ koloda.remove(kart3)
    $ kart4=renpy.random.choice(list(koloda))
    $ koloda.remove(kart4)
    $ kart5=renpy.random.choice(list(koloda))
    $ koloda.remove(kart5)
    $ kart6=renpy.random.choice(list(koloda))
    $ koloda.remove(kart6)
    $ kart7=0
    $ kart8=0
    $ kart9=0
    $ kart10=0
    $ kart11=0
    $ kart12=0
    
    ###I prescribe the cards that first drop the computer
    $ karta1=renpy.random.choice(list(koloda))
    $ koloda.remove(karta1)
    $ karta2=renpy.random.choice(list(koloda))
    $ koloda.remove(karta2)
    $ karta3=renpy.random.choice(list(koloda))
    $ koloda.remove(karta3)
    $ karta4=renpy.random.choice(list(koloda))
    $ koloda.remove(karta4)
    $ karta5=renpy.random.choice(list(koloda))
    $ koloda.remove(karta5)
    $ karta6=renpy.random.choice(list(koloda))
    $ koloda.remove(karta6)
    $ karta7=0
    $ karta8=0
    $ karta9=0
    $ karta10=0
    $ karta11=0
    $ karta12=0
    
    ###Trumps
    $ kozir=renpy.random.choice(list(koloda))
    $ koloda.remove(kozir)
    if kozir>400:    ###If the card starts with 4
        $ cozir=4
    elif kozir>300:    ###If the card starts with 3
        $ cozir=3
    elif kozir>200:    ###If the card starts with 2
        $ cozir=2
    else:                           ###If the card starts with 1
        $ cozir=1
    $ koziri=set([0])
    if karta1/100==cozir:
        $ koziri.add(karta1)
    if karta2/100==cozir:
        $ koziri.add(karta2)
    if karta3/100==cozir:
        $ koziri.add(karta3)
    if karta4/100==cozir:
        $ koziri.add(karta4)
    if karta5/100==cozir:
        $ koziri.add(karta5)
    if karta6/100==cozir:
        $ koziri.add(karta6)
    $ igkozir=max(koziri)
    $ koziri=set([0])
    if kart1/100==cozir:
        $ koziri.add(kart1)
    if kart2/100==cozir:
        $ koziri.add(kart2)
    if kart3/100==cozir:
        $ koziri.add(kart3)
    if kart4/100==cozir:
        $ koziri.add(kart4)
    if kart5/100==cozir:
        $ koziri.add(kart5)
    if kart6/100==cozir:
        $ koziri.add(kart6)
    $ cpukozir=max(koziri) ###computer all trumps
    if igkozir==0: ###player
        $ dhod=0
        $ cpua=1
    elif igkozir<cpukozir: ###player <computer
        $ dhod=1
        $ cpua=0
    else:
        $ dhod=0
        $ cpua=1
    $ tblkardz=set([0])
    $ tblkarda=set([0])
    $ tblkardzl=list("0")
    $ tblkardal=list("0")
    $ tblkarde=set([0])
    $ kartah=0
    $ kstep=0
    $ tblnmb=set([0])
    jump khod
    
    
    
label dgme:
    show screen c79

    e " "
    jump dgme
    
    
    
label khod0:
    if cpua==1:
        $ tblkardale=len(tblkardal)
        $ tblkardale=tblkardal[tblkardale-1]
        if (kartah/100)==cozir:
            if (tblkardale/100)==cozir:
                if kartah>tblkardale:
                    jump khod0a
            else:
                jump khod0a
        if tblkardale<200:
            if kartah<200:
                if kartah>tblkardale:
                    pass
                else:
                    jump dgme
            else:
                jump dgme
        elif tblkardale<300:
            if 200<kartah<300:
                if kartah>tblkardale:
                    pass
                else:
                    jump dgme
            else:
                jump dgme
        elif tblkardale<400:
            if 300<kartah<400:
                if kartah>tblkardale:
                    pass
                else:
                    jump dgme
            else:
                jump dgme
        else:
            if kartah>400:
                if kartah>tblkardale:
                    pass
                else:
                    jump dgme
            else:
                jump dgme
        label khod0a:
            $ tblkardz.add(kartah)
            $ tblkardzl.append(kartah)
    else:
        if len(tblkarda)>1:
            $ tblnmb.discard(0)
            $ tblnmb.add(tblkardal[kstep]%100)
            $ tblnmb.add(tblkardzl[kstep]%100)
            if kartah%100 not in(tblnmb):
                jump dgme
        $ kstep+=1
        $ tblkarda.add(kartah)
        $ tblkardal.append(kartah)
    $ globals()[("karta%s"%(knmb))]=0
    $ dhod=0
    
    
    ####Card when distributed here we get
label khod:
    if dhod==0:
        if cpua==1:
            jump khod2
        jump khod2i

    jump dgme
    
    
    
    
label khod1a:
    $ cpukarn=set([kart1,kart2,kart3,kart4,kart5,kart6,kart7,kart8,kart9,kart10,kart11,kart12])
    $ cpukarn.discard(0)
    $ igkarn=set([karta1,karta2,karta3,karta4,karta5,karta6,karta7,karta8,karta9,karta10,karta11,karta12])
    $ igkarn.discard(0)
    if len(cpukarn)<6:
        if len(koloda)<1:
            if len(igkarn)<1:
                jump dgwin
            if kozir==0:
                if len(cpukarn)<1:
                    jump dglose
                if cpua==0:
                    jump dgme
                jump khod2
            else:
                $ kartavz=kozir
                $ kozir=0
                jump kartavz1
        $ kartavz=renpy.random.choice(list(koloda))
        $ koloda.remove(kartavz)
        label kartavz1:
            if kart1==0:
                $ kart1=kartavz
            elif kart2==0:
                $ kart2=kartavz
            elif kart3==0:
                $ kart3=kartavz
            elif kart4==0:
                $ kart4=kartavz
            elif kart5==0:
                $ kart5=kartavz
            else:
                $ kart6=kartavz
        if len(igkarn)<6:
            if len(koloda)<1:
                if kozir==0:
                    if len(igkarn)<1:
                        jump dgwin
                    if cpua==0:
                        jump dgme
                    jump khod2
                else:
                    $ kartavz=kozir
                    $ kozir=0
                    jump kartavz2
            $ kartavz=renpy.random.choice(list(koloda))
            $ koloda.remove(kartavz)
            label kartavz2:
                if karta1==0:
                    $ karta1=kartavz
                elif karta2==0:
                    $ karta2=kartavz
                elif karta3==0:
                    $ karta3=kartavz
                elif karta4==0:
                    $ karta4=kartavz
                elif karta5==0:
                    $ karta5=kartavz
                else:
                    $ karta6=kartavz
    elif len(igkarn)<6:
        if len(koloda)<1:
            if kozir==0:
                if len(igkarn)<1:
                    jump dgwin
                if cpua==0:
                    jump dgme
                jump khod2
            else:
                $ kartavz=kozir
                $ kozir=0
                jump kartavz3
        $ kartavz=renpy.random.choice(list(koloda))
        $ koloda.remove(kartavz)
        label kartavz3:
            if karta1==0:
                $ karta1=kartavz
            elif karta2==0:
                $ karta2=kartavz
            elif karta3==0:
                $ karta3=kartavz
            elif karta4==0:
                $ karta4=kartavz
            elif karta5==0:
                $ karta5=kartavz
            else:
                $ karta6=kartavz
    else:
        if cpua==0:
            jump dgme
        jump khod2
    jump khod1a
    
    
    
label khod2:
    $ igkarn=set([karta1,karta2,karta3,karta4,karta5,karta6,karta7,karta8,karta9,karta10,karta11,karta12])
    $ igkarn.discard(0)
    if len(igkarn)<1:
        $ dhod=1
        $ cpua=0
        jump khodotb
    if len(tblkarda)>1+kstep:
        $ tblnmb.discard(0)
        $ cpukarn=set([])
        $ tblnmb.add(tblkardal[kstep+1]%100)
        $ tblnmb.add(tblkardzl[kstep+1]%100)
        $ kstep+=1
        if kart1%100 in tblnmb:
            $ cpukarn.add(kart1)
        if kart2%100 in tblnmb:
            $ cpukarn.add(kart2)
        if kart3%100 in tblnmb:
            $ cpukarn.add(kart3)
        if kart4%100 in tblnmb:
            $ cpukarn.add(kart4)
        if kart5%100 in tblnmb:
            $ cpukarn.add(kart5)
        if kart6%100 in tblnmb:
            $ cpukarn.add(kart6)
        if kart7%100 in tblnmb:
            $ cpukarn.add(kart7)
        if kart8%100 in tblnmb:
            $ cpukarn.add(kart8)
        if kart9%100 in tblnmb:
            $ cpukarn.add(kart9)
        if kart10%100 in tblnmb:
            $ cpukarn.add(kart10)
        if kart11%100 in tblnmb:
            $ cpukarn.add(kart11)
        if kart12%100 in tblnmb:
            $ cpukarn.add(kart12)
        if len(cpukarn)<1:
            $ dhod=1
            $ cpua=0
            jump khodotb
        jump khod2a
        
        
label khod2i:
    $ cpukarn=set([kart1,kart2,kart3,kart4,kart5,kart6,kart7,kart8,kart9,kart10,kart11,kart12])
    $ cpukarnc=set([])
    $ cpukarn.discard(0)
    if len(cpukarn)<1:
        jump dglose
    if kart1/100==cozir:
        $ cpukarnc.add(kart1)
    if kart2/100==cozir:
        $ cpukarnc.add(kart2)
    if kart3/100==cozir:
        $ cpukarnc.add(kart3)
    if kart4/100==cozir:
        $ cpukarnc.add(kart4)
    if kart5/100==cozir:
        $ cpukarnc.add(kart5)
    if kart6/100==cozir:
        $ cpukarnc.add(kart6)
    if kart7/100==cozir:
        $ cpukarnc.add(kart7)
    if kart8/100==cozir:
        $ cpukarnc.add(kart8)
    if kart9/100==cozir:
        $ cpukarnc.add(kart9)
    if kart10/100==cozir:
        $ cpukarnc.add(kart10)
    if kart11/100==cozir:
        $ cpukarnc.add(kart11)
    if kart12/100==cozir:
        $ cpukarnc.add(kart12)
    if cpua==0:
        $ cpukarn=set([])
        $ kartaa=len(tblkardal)-1
        $ kartaa=tblkardal[kartaa]
        if kartaa%100<kart1%100:
            if kartaa/100==kart1/100:
                $ cpukarn.add(kart1)
        if kartaa%100<kart2%100:
            if kartaa/100==kart2/100:
                $ cpukarn.add(kart2)
        if kartaa%100<kart3%100:
            if kartaa/100==kart3/100:
                $ cpukarn.add(kart3)
        if kartaa%100<kart4%100:
            if kartaa/100==kart4/100:
                $ cpukarn.add(kart4)
        if kartaa%100<kart5%100:
            if kartaa/100==kart5/100:
                $ cpukarn.add(kart5)
        if kartaa%100<kart6%100:
            if kartaa/100==kart6/100:
                $ cpukarn.add(kart6)
        if kartaa%100<kart7%100:
            if kartaa/100==kart7/100:
                $ cpukarn.add(kart7)
        if kartaa%100<kart8%100:
            if kartaa/100==kart8/100:
                $ cpukarn.add(kart8)
        if kartaa%100<kart9%100:
            if kartaa/100==kart9/100:
                $ cpukarn.add(kart9)
        if kartaa%100<kart10%100:
            if kartaa/100==kart10/100:
                $ cpukarn.add(kart10)
        if kartaa%100<kart11%100:
            if kartaa/100==kart11/100:
                $ cpukarn.add(kart11)
        if kartaa%100<kart12%100:
            if kartaa/100==kart12/100:
                $ cpukarn.add(kart12)
        jump khod2a
    $ cpukarn-=cpukarnc
    
    
    
    
label khod2a:
    if len(cpukarn)==0:
        if kartaa/100==cozir:
            if cpua==0:
                jump khodvc
        if len(cpukarnc)>0:
            $ cpukar=min(cpukarnc)
            jump khod2u
        else:
            jump khodvc
        $ cpukarn=set([kart1,kart2,kart3,kart4,kart5,kart6,kart7,kart8,kart9,kart10,kart11,kart12])
        $ cpukarn.discard(0)
    $ cpukar=min(cpukarn)
    
    
    
    
label khod2u:
    if cpukar==kart1:
        $ kart1=0
    elif cpukar==kart2:
        $ kart2=0
    elif cpukar==kart3:
        $ kart3=0
    elif cpukar==kart4:
        $ kart4=0
    elif cpukar==kart5:
        $ kart5=0
    elif cpukar==kart6:
        $ kart6=0
    elif cpukar==kart7:
        $ kart7=0
    elif cpukar==kart8:
        $ kart8=0
    elif cpukar==kart9:
        $ kart9=0
    elif cpukar==kart10:
        $ kart10=0
    elif cpukar==kart11:
        $ kart11=0
    else:
        $ kart12=0
    if cpua==1:
        $ tblkarda.add(cpukar)
        $ tblkardal.append(cpukar)
    else:
        $ tblkardz.add(cpukar)
        $ tblkardzl.append(cpukar)
        $ cpukarn=set([kart1,kart2,kart3,kart4,kart5,kart6,kart7,kart8,kart9,kart10,kart11,kart12])
        $ cpukarn.discard(0)
        if len(cpukarn)<1:
            $ dhod=0
            $ cpua=1
            jump khodotb
    $ dhod=1
    jump khod
    
    
    
    
label khodv:
    if len(tblkardal)>1:
        $ kartavz=tblkardal[1]
        $ tblkarda.remove(kartavz)
        $ tblkardal.remove(kartavz)
        jump khodv1
    if len(tblkardzl)>1:
        $ kartavz=list(tblkardz)
        $ kartavz=kartavz[1]
        $ tblkardz.remove(kartavz)
        $ tblkardzl.remove(kartavz)
        jump khodv1
    jump khod1a
    
    
    
    
label khodv1:
    if karta1==0:
        $ karta1=kartavz
    elif karta2==0:
        $ karta2=kartavz
    elif karta3==0:
        $ karta3=kartavz
    elif karta4==0:
        $ karta4=kartavz
    elif karta5==0:
        $ karta5=kartavz
    elif karta6==0:
        $ karta6=kartavz
    elif karta7==0:
        $ karta7=kartavz
    elif karta8==0:
        $ karta8=kartavz
    elif karta9==0:
        $ karta9=kartavz
    elif karta10==0:
        $ karta10=kartavz
    elif karta11==0:
        $ karta11=kartavz
    elif karta12==0:
        $ karta12=kartavz
    else:
        jump dglose
    jump khodv
    
    
    
label khodvc:
    if len(tblkardal)>1:
        $ kartavz=tblkardal[1]
        $ tblkarda.remove(kartavz)
        $ tblkardal.remove(kartavz)
        jump khodv1c
    if len(tblkardzl)>1:
        $ kartavz=list(tblkardz)
        $ kartavz=kartavz[1]
        $ tblkardz.remove(kartavz)
        $ tblkardzl.remove(kartavz)
        jump khodv1c
    $ tblnmb=set([0])
    $ kstep=0
    $ tblkarda=set([0])
    $ tblkardal=list(["0"])
    $ tblkardz=set([0])
    $ tblkardzl=list(["0"])
    jump khod1a
    
    
    
label khodv1c:
    if kart1==0:
        $ kart1=kartavz
    elif kart2==0:
        $ kart2=kartavz
    elif kart3==0:
        $ kart3=kartavz
    elif kart4==0:
        $ kart4=kartavz
    elif kart5==0:
        $ kart5=kartavz
    elif kart6==0:
        $ kart6=kartavz
    elif kart7==0:
        $ kart7=kartavz
    elif kart8==0:
        $ kart8=kartavz
    elif kart9==0:
        $ kart9=kartavz
    elif kart10==0:
        $ kart10=kartavz
    elif kart11==0:
        $ kart11=kartavz
    elif kart12==0:
        $ kart12=kartavz
    else:
        jump dgwin
    jump khodvc
    
    
    
    
label khodotb:
    $ tblnmb=set([0])
    $ kstep=0
    $ tblkarda=set([0])
    $ tblkardal=list(["0"])
    $ tblkardz=set([0])
    $ tblkardzl=list(["0"])
    jump khod1a
    
    
    
label dglose:
    hide screen c79
    e "Loss"
    return
    
label dgwin:
    hide screen c79
    e "Victory"
    return
    
label dgnich:
    hide screen c79
    e "Draw"
    return
3) Drunkard, 1 on 1 card77.rpy

Code: Select all

screen c77:
    if len(koloda)<1:
        textbutton "Pass" xalign .5 yalign .7 action [SetVariable("dhod",0),SetVariable("igpass",1),Jump("khodp")]
    else:
        textbutton "Take a card" xalign .5 yalign .7 action Jump("khodvр")
    hbox xalign .1:
        if kart1!=0:
            add "krb.webp"
        if kart2!=0:
            add "krb.webp"
        if kart3!=0:
            add "krb.webp"
        if kart4!=0:
            add "krb.webp"
        if kart5!=0:
            add "krb.webp"
        if kart6!=0:
            add "krb.webp"
        if kart7!=0:
            add "krb.webp"
        if kart8!=0:
            add "krb.webp"
        if kart9!=0:
            add "krb.webp"
        if kart10!=0:
            add "krb.webp"
        if kart11!=0:
            add "krb.webp"
        if kart12!=0:
            add "krb.png"
    hbox yalign .5 xalign .44:
        add str(kozir)+".png"
    if len(koloda)>0:
        hbox yalign .5 xalign .56:
            add "krb.webp"
    hbox xalign .1 yalign .94:
        if karta1!=0:
            imagebutton idle str(karta1)+".png" action [SetVariable("kartah",karta1),SetVariable("knmb",1),Jump("khodp")]
        if karta2!=0:
            imagebutton idle str(karta2)+".png" action [SetVariable("kartah",karta2),SetVariable("knmb",2),Jump("khodp")]
        if karta3!=0:
            imagebutton idle str(karta3)+".png" action [SetVariable("kartah",karta3),SetVariable("knmb",3),Jump("khodp")]
        if karta4!=0:
            imagebutton idle str(karta4)+".png" action [SetVariable("kartah",karta4),SetVariable("knmb",4),Jump("khodp")]
        if karta5!=0:
            imagebutton idle str(karta5)+".png" action [SetVariable("kartah",karta5),SetVariable("knmb",5),Jump("khodp")]
        if karta6!=0:
            imagebutton idle str(karta6)+".png" action [SetVariable("kartah",karta6),SetVariable("knmb",6),Jump("khodp")]
        if karta7!=0:
            imagebutton idle str(karta7)+".png" action [SetVariable("kartah",karta7),SetVariable("knmb",7),Jump("khodp")]
        if karta8!=0:
            imagebutton idle str(karta8)+".png" action [SetVariable("kartah",karta8),SetVariable("knmb",8),Jump("khodp")]
        if karta9!=0:
            imagebutton idle str(karta9)+".png" action [SetVariable("kartah",karta9),SetVariable("knmb",9),Jump("khodp")]
        if karta10!=0:
            imagebutton idle str(karta10)+".png" action [SetVariable("kartah",karta10),SetVariable("knmb",10),Jump("khodp")]
        if karta11!=0:
            imagebutton idle str(karta11)+".png" action [SetVariable("kartah",karta11),SetVariable("knmb",11),Jump("khodp")]
        if karta12!=0:
            imagebutton idle str(karta12)+".png" action [SetVariable("kartah",karta12),SetVariable("knmb",12),Jump("khodp")]
label card77:
    scene tb
    $ cpukarn=set([])
    $ knmb=0
    $ igpass=0
    $ koloda=set([102,103,104,105,106,107,108,109,110,111,202,203,204,205,206,207,208,209,210,211,302,303,304,305,306,307,308,309,310,311,402,403,404,405,406,407,408,409,410,411])
    $ kart1=renpy.random.choice(list(koloda))
    $ koloda.remove(kart1)
    $ kart2=renpy.random.choice(list(koloda))
    $ koloda.remove(kart2)
    $ kart3=renpy.random.choice(list(koloda))
    $ koloda.remove(kart3)
    $ kart4=renpy.random.choice(list(koloda))
    $ koloda.remove(kart4)
    $ kart5=renpy.random.choice(list(koloda))
    $ koloda.remove(kart5)
    $ kart6=renpy.random.choice(list(koloda))
    $ koloda.remove(kart6)
    $ kart7=renpy.random.choice(list(koloda))
    $ koloda.remove(kart7)
    $ kart8=0
    $ kart9=0
    $ kart10=0
    $ kart11=0
    $ kart12=0
    $ karta1=renpy.random.choice(list(koloda))
    $ koloda.remove(karta1)
    $ karta2=renpy.random.choice(list(koloda))
    $ koloda.remove(karta2)
    $ karta3=renpy.random.choice(list(koloda))
    $ koloda.remove(karta3)
    $ karta4=renpy.random.choice(list(koloda))
    $ koloda.remove(karta4)
    $ karta5=renpy.random.choice(list(koloda))
    $ koloda.remove(karta5)
    $ karta6=renpy.random.choice(list(koloda))
    $ koloda.remove(karta6)
    $ karta7=renpy.random.choice(list(koloda))
    $ koloda.remove(karta7)
    $ karta8=0
    $ karta9=0
    $ karta10=0
    $ karta11=0
    $ karta12=0
    $ kozir=renpy.random.choice(list(koloda))
    $ koloda.remove(kozir)
    $ igkozir=max(karta1,karta2,karta3,karta4,karta5,karta6,karta7)
    $ cpukozir=max(kart1,kart2,kart3,kart4,kart5,kart6,kart7)
    if igkozir>cpukozir:
        $ dhod=1
    else:
        $ dhod=0
    $ kartah=0
label khodp:
    if dhod==0:
        jump khod2ip
    if kartah/100==kozir/100:
        $ kozir=kartah
        $ globals()[("karta%s"%(knmb))]=0
        $ dhod=0
        $ igkarn=set([karta1,karta2,karta3,karta4,karta5,karta6,karta7,karta8,karta9,karta10,karta11,karta12])
        $ igkarn.discard(0)
        if len(igkarn)<1:
            jump pgwin
        jump khod2ip
    elif kartah%100==kozir%100:
        $ kozir=kartah
        $ globals()[("karta%s"%(knmb))]=0
        $ dhod=0
        $ igkarn=set([karta1,karta2,karta3,karta4,karta5,karta6,karta7,karta8,karta9,karta10,karta11,karta12])
        $ igkarn.discard(0)
        if len(igkarn)<1:
            jump pgwin
        jump khod2ip
label pgme:
    show screen c77
    e "..."
    jump pgme
label khod2ip:
    $ cpukarn=set([])
    if kozir/100==kart1/100:
        $ cpukarn.add(kart1)
    if kozir/100==kart2/100:
        $ cpukarn.add(kart2)
    if kozir/100==kart3/100:
        $ cpukarn.add(kart3)
    if kozir/100==kart4/100:
        $ cpukarn.add(kart4)
    if kozir/100==kart5/100:
        $ cpukarn.add(kart5)
    if kozir/100==kart6/100:
        $ cpukarn.add(kart6)
    if kozir/100==kart7/100:
        $ cpukarn.add(kart7)
    if kozir/100==kart8/100:
        $ cpukarn.add(kart8)
    if kozir/100==kart9/100:
        $ cpukarn.add(kart9)
    if kozir/100==kart10/100:
        $ cpukarn.add(kart10)
    if kozir/100==kart11/100:
        $ cpukarn.add(kart11)
    if kozir/100==kart12/100:
        $ cpukarn.add(kart12)
    if kozir%100==kart1%100:
        $ cpukarn.add(kart1)
    if kozir%100==kart2%100:
        $ cpukarn.add(kart2)
    if kozir%100==kart3%100:
        $ cpukarn.add(kart3)
    if kozir%100==kart4%100:
        $ cpukarn.add(kart4)
    if kozir%100==kart5%100:
        $ cpukarn.add(kart5)
    if kozir%100==kart6%100:
        $ cpukarn.add(kart6)
    if kozir%100==kart7%100:
        $ cpukarn.add(kart7)
    if kozir%100==kart8%100:
        $ cpukarn.add(kart8)
    if kozir%100==kart9%100:
        $ cpukarn.add(kart9)
    if kozir%100==kart10%100:
        $ cpukarn.add(kart10)
    if kozir%100==kart11%100:
        $ cpukarn.add(kart11)
    if kozir%100==kart12%100:
        $ cpukarn.add(kart12)
    if len(cpukarn)<1:
        if len(koloda)<1:
            if igpass==1:
                if kart1+kart2+kart3+kart4+kart5+kart6+kart7>karta1+karta2+karta3+karta4+karta5+karta6+karta7:
                    jump pgwin
                jump pglose
            jump pppas
        $ kartavz=renpy.random.choice(list(koloda))
        $ koloda.remove(kartavz)
        if kart1==0:
            $ kart1=kartavz
        elif kart2==0:
            $ kart2=kartavz
        elif kart3==0:
            $ kart3=kartavz
        elif kart4==0:
            $ kart4=kartavz
        elif kart5==0:
            $ kart5=kartavz
        elif kart6==0:
            $ kart6=kartavz
        elif kart7==0:
            $ kart7=kartavz
        elif kart8==0:
            $ kart8=kartavz
        elif kart9==0:
            $ kart9=kartavz
        elif kart10==0:
            $ kart10=kartavz
        elif kart11==0:
            $ kart11=kartavz
        elif kart12==0:
            $ kart12=kartavz
        else:
            jump pgwin
        jump khod2ip
    $ kozir=renpy.random.choice(list(cpukarn))
    if kozir==kart1:
        $ kart1=0
    elif kozir==kart2:
        $ kart2=0
    elif kozir==kart3:
        $ kart3=0
    elif kozir==kart4:
        $ kart4=0
    elif kozir==kart5:
        $ kart5=0
    elif kozir==kart6:
        $ kart6=0
    elif kozir==kart7:
        $ kart7=0
    elif kozir==kart8:
        $ kart8=0
    elif kozir==kart9:
        $ kart9=0
    elif kozir==kart10:
        $ kart10=0
    elif kozir==kart11:
        $ kart11=0
    else:
        $ kart12=0
    $ cpukarn=set([kart1,kart2,kart3,kart4,kart5,kart6,kart7,kart8,kart9,kart10,kart11,kart12])
    $ cpukarn.discard(0)
    if len(cpukarn)<1:
        jump pglose
label pppas:
    $ dhod=1
    $ igpass=0
    jump pgme
label khodvр:
    $ kartavz=renpy.random.choice(list(koloda))
    $ koloda.remove(kartavz)
    if karta1==0:
        $ karta1=kartavz
    elif karta2==0:
        $ karta2=kartavz
    elif karta3==0:
        $ karta3=kartavz
    elif karta4==0:
        $ karta4=kartavz
    elif karta5==0:
        $ karta5=kartavz
    elif karta6==0:
        $ karta6=kartavz
    elif karta7==0:
        $ karta7=kartavz
    elif karta8==0:
        $ karta8=kartavz
    elif karta9==0:
        $ karta9=kartavz
    elif karta10==0:
        $ karta10=kartavz
    elif karta11==0:
        $ karta11=kartavz
    elif karta12==0:
        $ karta12=kartavz
    else:
        jump pglose
    jump pgme
label pglose:
    hide screen c77
    e "Loss"
    return
label pgwin:
    hide screen c77
    e "Victory"
    return
Download the finished version (only the buttons there in Russian are made) https://vk.com/doc189145553_451441774?h ... c0cff9b871
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

7) Memoria

#7 Post by Andredron » Wed May 23, 2018 4:44 am

Image
http://renpyfordummies.blogspot.ru/2015/08/memoria.html Download the finished project
Finished a little mini-game to memorize. Now the program checks the folder "images" for files of the type "card _ *. Png", where "*" - preferably the letter of the English alphabet. Required pictures are "card_back.png" and "card_empty.png" (card shirt and empty picture). If the picture-cards are small (<2, not including the empty and the shirt), then the text mode (img_mode = False) will turn on. If you set the field to 3x3 (ww, hh = 3, 3), then one cell will remain empty.

Code: Select all

init python:

    # DEFAULT GAME SETTINGS:

    # default card type set
    all_cards = ['A', 'B', 'C']
    # width and height of the field
    ww = 3
    hh = 3
    # how many cards can be opened for 1 turn
    max_c = 2
    # text size in the card for text mode
    card_size = 48
    # time allocated for the passage
    max_time = 25
    # pause before the cards disappear
    wait = 0.5
    # mode of cards with images, not with the text
    img_mode = True

    values_list = []
    temp = []
    # we announce picture cards
    # must be in the format "images / card _ *. png"
    # required "card_back.png" and "card_empty.png"
    for fn in renpy.list_files ():
        if fn.startswith ("images / card_") and fn.endswith ((". png")):
            name = fn [12: -4]
            renpy.image ("card" + name, fn)
            if name! = "empty" and name! = "back":
                temp.append (str (name))
    # if the picture found> 1,
    # then change the set of card types, but the file names
    if len (temp)> 1:
        all_cards = temp
    else:
        # otherwise turn on the text mode,
        # because the pictures are very small
        img_mode = False

    # the function of initializing the playing field
    def cards_init ():
        global values_list
        values_list = []
        while len (values_list) + max_c <= ww * hh:
            current_card = renpy.random.choice (all_cards)
            for i in range (0, max_c):
                values_list.append (current_card)
        renpy.random.shuffle (values_list)
        while len (values_list) <ww * hh:
            values_list.append ('empty')

# screen game
screen memo_scr:
    # timer
    timer 1.0 action If (memo_timer> 1, SetVariable ("memo_timer", memo_timer - 1), Jump ("memo_game_lose")) repeat True
    # field
    grid ww hh:
        align (.5, .5) # in the center
        for card in cards_list:
            button:
                left_padding 0
                right_padding 0
                top_padding 0
                bottom_padding 0
                background None
                if card ["c_value"] == 'empty':
                    if img_mode:
                        add "card empty"
                    else:
                        text "" size card_size
                else:
                    if card ["c_chosen"]:
                        if img_mode:
                            add "card" + card ["c_value"]
                        else:
                            text card ["c_value"] size card_size
                    else:
                        if img_mode:
                            add "card back"
                        else:
                            text "#" size card_size
                # pressing the button-card
                action If ((card ["c_chosen"] or not can_click), None, [SetDict (cards_list [card ["c_number"]], "c_chosen", True), Return (card ["c_number"])])
    text str (memo_timer) xalign .5 yalign 0.0 size card_size

# the game itself
label memoria_game:
    $ cards_init ()
    $ cards_list = []
    python:
        for i in range (0, len (values_list)):
            if values_list [i] == 'empty':
                cards_list.append ({"c_number": i, "c_value": values_list [i], "c_chosen": True})
            else:
                cards_list.append ({"c_number": i, "c_value": values_list [i], "c_chosen": False})
    $ memo_timer = max_time
    # show the game screen
    show screen memo_scr
    # main game loop
    label memo_game_loop:
        $ can_click = True
        $ turned_cards_numbers = []
        $ turned_cards_values ​​= []
        $ turns_left = max_c
        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
        # prevent opening of extra cards
        $ can_click = False
        if turned_cards_values.count (turned_cards_values ​​[0])! = len (turned_cards_values):
            $ renpy.pause (wait, hard = True)
            python:
                for i in range (0, len (turned_cards_numbers)):
                    cards_list [turned_cards_numbers [i]] ["c_chosen"] = False
        else:
            $ renpy.pause (wait, hard = True)
            python:
                for i in range (0, len (turned_cards_numbers)):
                    cards_list [turned_cards_numbers [i]] ["c_value"] = 'empty'
                for j in cards_list:
                    if j ["c_chosen"] == False:
                        renpy.jump ("memo_game_loop")
                renpy.jump ("memo_game_win")
        jump memo_game_loop

# loss
label memo_game_lose:
    hide screen memo_scr
    $ renpy.pause (0.1, hard = True)
    centered "{size = 36} Vdul! Re-Try. {/ size}"
    jump memoria_game
    
# winnings
label memo_game_win:
     hide screen memo_scr
     $ renpy.pause (0.1, hard = True)
     centered "{size = 36} {b} Winning! {/ b} {/ size}"
     return

# start-up example
# label start:
     # scene black
     # $ max_time = 60
     # $ ww, hh = 4, 4
     # call memoria_game
     # return
    
    
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

8) 2048

#8 Post by Andredron » Wed May 23, 2018 5:02 am

Image
Download the finished project http://renpyfordummies.blogspot.ru/2018/04/2048.html
###by 7dots Ruslan Nebykov
###license: cc by-sa
###free use, when specifying the author
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
ComputerArt.Club
Veteran
Posts: 228
Joined: Mon May 22, 2017 8:12 am
Completed: Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: 8 mini games

#9 Post by ComputerArt.Club » Thu May 24, 2018 4:44 am

Cool! Do these work with the newest version of Renpy?

User avatar
gas
Veteran
Posts: 414
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: 8 mini games

#10 Post by gas » Thu May 24, 2018 2:57 pm

3 in 1 can be really streamlined using some particular python method. I'll try for as it's a nice input.
10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

Re: 8 mini games

#11 Post by Andredron » Thu May 24, 2018 3:47 pm

ComputerArt.Club wrote:
Thu May 24, 2018 4:44 am
Cool! Do these work with the newest version of Renpy?
On new versions they (games) work, trouble if there is a grid. They are all in one corner going to gui. 2 solutions are

1) Wise and use grid instead of hbox and vbox

2) Forgot what they write, like

Code: Select all

grid 4 3:
    xfill True
    yfill True
    ......
Last edited by Andredron on Thu May 24, 2018 4:26 pm, edited 1 time in total.
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

Re: 8 mini games

#12 Post by Andredron » Thu May 24, 2018 3:53 pm

I would be glad, but here as in the saying:
Hatiko waited 6 years and I will wait
viewtopic.php?f=8&t=50002
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

User avatar
Andredron
Regular
Posts: 85
Joined: Thu Dec 28, 2017 2:37 pm
Organization: https://vk.com/renpy
Location: Russia
Contact:

9) QTE

#13 Post by Andredron » Sat Jun 02, 2018 8:23 am

Image

The game is qte. You need to click on certain buttons, earning points for a while. Each repetition deletes points.
Download https://m.vk.com/doc189145553_44265737 ... 657dc8d136
I know - I have a HORRIBLE ENGLISH
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 01.06.18

Post Reply

Who is online

Users browsing this forum: No registered users