Is it possible to create a simple drawing minigame?

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
Moonimations
Newbie
Posts: 3
Joined: Wed Jan 10, 2018 1:19 pm
Tumblr: Moonmonologue
Contact:

Is it possible to create a simple drawing minigame?

#1 Post by Moonimations »

Is there any way to do this in Renpy? (Or Python?) Plus I want to save the image the player makes in the persistent data so the game can pull it up later.

Either have the player draw an image themselves(like in Paint but of course only a black line) or click (or drag?) shapes to create something on a canvas.

I'm not that good with coding yet(my second 'big' game) so I decided to ask here to see if it is possible within the timeframe I have. :D (I do have a plan B luckily to simplify it to a choice menu, but that's less fun for the player..)

Thanks for reading >-<

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

Re: Is it possible to create a simple drawing minigame?

#2 Post by Imperf3kt »

It might be possible with the python paint module
http://www.object-craft.com.au/projects ... mples.html

I see no reason why it can't be done somehow. After all, the 'free photoshop' program 'Gimp' is powered by Python, albeit at a more complex level than the paint module
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Moonimations
Newbie
Posts: 3
Joined: Wed Jan 10, 2018 1:19 pm
Tumblr: Moonmonologue
Contact:

Re: Is it possible to create a simple drawing minigame?

#3 Post by Moonimations »

Imperf3kt wrote: Wed Jan 24, 2018 8:40 pm It might be possible with the python paint module
http://www.object-craft.com.au/projects ... mples.html

I see no reason why it can't be done somehow. After all, the 'free photoshop' program 'Gimp' is powered by Python, albeit at a more complex level than the paint module
Thank you so much! This is a good start to try figuring it out.

I tried importing the code(I threw the module in both a folder called paint and the files in the game directory to see if it was a reference issue), but it gave me this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 97, in script
    init python:
  File "game/script.rpy", line 98, in <module>
    import paint
ImportError: No module named paint

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 97, in script
    init python:
  File "C:\Users\Gebruiker\Desktop\renpy-6.99.14-sdk\renpy\ast.py", line 848, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Gebruiker\Desktop\renpy-6.99.14-sdk\renpy\python.py", line 1804, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 98, in <module>
    import paint
ImportError: No module named paint

Windows-8-6.2.9200
Ren'Py 6.99.14.3135
testing 1.0
The code in the script.rpy file is:

Code: Select all

label normal:
    $ persistent.second = False
# this persistent is not important lol it is to test a mainmenu screenswap
    scene black
    
    "Let's draw something!"
    
init python:
    import paint
    image = paint.image(100, 80)
    image.stroke(paint.line(10, 10, 90, 70).dash(0, (10, 5)), paint.rgb(0xff,0,0), 10)
    rect = paint.rect(20, 10, 70, 50)
    image.fill(rect, paint.rgb(0xff,0xff,0))
    image.stroke(rect, paint.rgb(0,0xff,0), 5)
    image.stroke(paint.arc(10, 20, 60, 70, 270, 180), paint.rgba(0,0,0xff,0x40), 5)
    arial = paint.font('arial.ttf', 24, 30)
    image.text(arial, 15, 70, paint.rgb(0,0,0), 'Hooray')
    image.write_png('intro.png')
    
    
    "This was a succes!"
    

label next:
    scene black
When I try to add a 'jump next' line it gives me an error too. Is it a spacing issue with the block? Only the 'import' part is brown and the others are only black. (Aside the succes text) I'll try to add a button and maybe label the drawpart, but that won't help if it won't mport in the first place.

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: Is it possible to create a simple drawing minigame?

#4 Post by Remix »

Paint uses C files as a platform base, so is not easy to use inside Ren'py (you would need to bundle the C code and dependencies inside the Ren'py core and recompile, making sure the C code was compatible for all platforms that Ren'py runs on - pretty complex stuff and, even if you got it working it would need to be done for every new release if you upgraded Ren'py)

Most people, if they import external python modules, tend to choose only those that have pure python implementations and few dependencies.

Though there are a few options using Ren'py's Image classes (you could basically track various clicks/choices and compose a composite image using numerous overlay images - still pretty complex, more likely to work than using C code though) you might do better just trying to implement a pygame paint program inside your script.

Realistically though, there is no easy way to do what you want and every option will require a good level of programming experience or familiarity with Ren'py.
Frameworks & Scriptlets:

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

Re: Is it possible to create a simple drawing minigame?

#5 Post by ComputerArt.Club »

Were you successful in doing this? This is something I have often wanted to do myself. If someone succeeds, a cookbook entry would be awesome or any kind of simple run through of what worked for you.

Post Reply

Who is online

Users browsing this forum: bonnie_641, NeonNights