Drag Mobile Phone to take Photo

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Mirenzo
Regular
Posts: 28
Joined: Sat Jan 20, 2018 5:12 pm
Contact:

Drag Mobile Phone to take Photo

#1 Post by Mirenzo » Mon Jun 25, 2018 10:04 am

Hi all, please there is somewhere an example of how to drag my Phone screen with mouse to take photo and maybe zoom with mouse wheel? Thanks in advance.

User avatar
Andredron
Miko-Class Veteran
Posts: 535
Joined: Thu Dec 28, 2017 2:37 pm
Completed: Kimi ga nozomu renpy-port(demo), Albatross Koukairoku(demo)
Projects: Sisters ~Natsu no Saigo no Hi~(renpy-port)
Location: Russia
Contact:

Re: Drag Mobile Phone to take Photo

#2 Post by Andredron » Mon Jun 25, 2018 10:31 am

I'm writing a Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18

Help me to register in QQ International

Honest Critique

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Drag Mobile Phone to take Photo

#3 Post by kivik » Mon Jun 25, 2018 1:30 pm

Can you clarify what you mean? What you described is very vague - when you say drag your phone screen, are you saying a phone screen inside your game? When you say take a photo do you mean it switches to camera mode or it takes a photo immediately? When you say zoom, do you mean zooming in camera mode?

Try to explain in details - or better yet use images to explain exactly what you're trying to achieve and we may better understand you and be more able to help :) Otherwise we may come up with an interpretation of what we think you want, that's nothing like what you had in mind.

In fact I half wonder if you're actually saying make your actual phone with a Renpy game running on it to take a photo - the mention of mouse makes me think not but I know you can get a mouse working on Android phones...

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Drag Mobile Phone to take Photo

#4 Post by Remix » Mon Jun 25, 2018 4:25 pm

I've not seen any code examples that do what you want.

Perhaps follow Andredron's advice and check out viewport, along with drag n drop, atl or image manipulation and key binding
Frameworks & Scriptlets:

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

Re: Drag Mobile Phone to take Photo

#5 Post by Imperf3kt » Mon Jun 25, 2018 7:32 pm

IIRC, Pytom once replied to a similar request about using a camera to take a shot to be used as your side image.

I don't recall the exact words, but I believe the answer was something along the lines of 'no, bad idea'
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Drag Mobile Phone to take Photo

#6 Post by xavimat » Tue Jun 26, 2018 2:21 pm

Mirenzo has a screen with the image of a cellphone. He wants to drag it on the screen and take a "photo" of the part of the background image that the cellphone is showing. I think this can be done with drag, screenshot and crop. But I'm not sure about the zooming part. Can we put the mousewheel as key in the screen and trigger an action to zoom?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

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

Re: Drag Mobile Phone to take Photo

#7 Post by Imperf3kt » Tue Jun 26, 2018 4:57 pm

Why snap a screenshot, crop and zoom it?
Just fake it. Use a pre-prepared image and pretend the photo was taken.

Or is this something the user chooses, so the possible photos are limitless(ish)?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: Drag Mobile Phone to take Photo

#8 Post by xavimat » Tue Jun 26, 2018 5:19 pm

Imperf3kt wrote:
Tue Jun 26, 2018 4:57 pm
Just fake it. Use a pre-prepared image and pretend the photo was taken.
Yes, this is my conclusion after trying to do it real.
I haven't tried the zoom feature.

Code here. Downloadable at the end:
(All positions/sizes of draggables should be adjusted)

Code: Select all

default photo_list = []
default person = ""
default x = 500
default y = 200

init python:

    def cell_dragged(drags, drop):

        store.x = drags[0].x
        store.y = drags[0].y

        if not drop:
            return

        return drop.drag_name

screen take_photo():

    add "people_fit"

    draggroup:

        # The cellphone.
        drag:
            child "cell"
            droppable False
            dragged cell_dragged
            xpos x ypos y

        # The targets.
        drag:
            drag_name "one"
            idle_child Solid("#0000", xysize=(50,50))
            # Just trying to see when the drag is droppable:
            selected_idle_child Solid("#0004", xysize=(50,50))
            draggable False
            pos (121, 43)

        drag:
            drag_name "two"
            child Solid("#0000", xysize=(50,50))
            draggable False
            pos (100, 257)

        drag:
            drag_name "three"
            child Solid("#0000", xysize=(50,50))
            draggable False
            pos (592, 217)

        drag:
            drag_name "four"
            child Solid("#0000", xysize=(50,50))
            draggable False
            pos (708, 56)

        drag:
            drag_name "five"
            child Solid("#0000", xysize=(50,50))
            draggable False
            pos (1070, 9)

    hbox:
        yalign 1.0 spacing 10
        for i in photo_list:
            frame:
                add i

    frame:
        align (1.0,1.0)
        has hbox
        textbutton "Take a Photo" action Return("photo")
        textbutton "Exit" action Return("exit")

image white = Solid("#fff")

label start:
    scene black with None

    jump taking_photos

label taking_photos:

    call screen take_photo

    $ result = _return

    if result in ["one", "two", "three", "four", "five"]:
        $ person = result
        jump taking_photos

    elif result == "photo":
        if person and person not in photo_list:
            $ photo_list.append(person)
            play sound "picture.ogg"
            scene white with dissolve

        jump taking_photos

    scene black with None

    $ person = ""

    "We can go on from here..."

    return
game.zip
(926.6 KiB) Downloaded 14 times
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Mirenzo
Regular
Posts: 28
Joined: Sat Jan 20, 2018 5:12 pm
Contact:

Re: Drag Mobile Phone to take Photo

#9 Post by Mirenzo » Tue Jun 26, 2018 8:01 pm

I'll try to explain myself better with some images:Image Imagehttps://attachments.f95zone.com/2018/06 ... empio3.jpg[/img] Image Image. That's what any cellphone do. About a pre-prepared image, how can i know where and when my players decide to take a photo? The only thing i can do is disable the camera from my Phone and make that available only when i want.

Gamerz
Newbie
Posts: 1
Joined: Wed Jun 27, 2018 11:20 am
Contact:

Re: Drag Mobile Phone to take Photo

#10 Post by Gamerz » Wed Jun 27, 2018 11:26 am

Finally! Cleared

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

Re: Drag Mobile Phone to take Photo

#11 Post by Alex » Wed Jun 27, 2018 12:35 pm

Mirenzo wrote:
Tue Jun 26, 2018 8:01 pm
...About a pre-prepared image, how can i know where and when my players decide to take a photo? The only thing i can do is disable the camera from my Phone and make that available only when i want.
Just a thought, if player would be able to take photo of any part of a game screen, how would you evaluate is this the 'right' photo or not?

As for design of this game - draw some transparent space in the middle of the cellphone and try xavimat's code.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], span4ev