Page 1 of 1

Is it possible to create a simple drawing minigame?

Posted: Wed Jan 24, 2018 6:50 pm
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 >-<

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

Posted: Wed Jan 24, 2018 8:40 pm
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

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

Posted: Thu Jan 25, 2018 6:12 am
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.

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

Posted: Thu Jan 25, 2018 9:30 am
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.

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

Posted: Sat Jun 09, 2018 12:02 am
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.