Closed BlackRam-oss closed 4 months ago
You should just be able to import pygame_sdl2 into Ren'Py with.
init python:
import pygame_sdl2
yes it is true it is already within renpy, however this does not work
import pygame_sdl2 as pygame
pygame.import_as_pygame()
pygame._optional_imports()
def main():
# Initialize pygame_sdl2
pygame.init()
pygame.mixer.get_init()
another problem is display.mode_ok
pygame.init()
bestdepth = pygame.display.mode_ok(600, 32, 32)
screen = pygame.display.set_mode(600, 32, bestdepth)
https://github.com/renpy/pygame_sdl2/blob/master/src/pygame_sdl2/display.pyx#L657
the function is this I don't understand why it gives me this error
@renpytom Sorry to insist, but I would like to understand if I am making a mistake in using this library or it is a possible implementation.
And if so, can I help in any way? (I don't specialize in python, but I work as a programmer)
I need to create Renpy minigames that already exist in pygame. this Issue would help me a lot
That traceback looks like a straight-forward Python error on your end. 600
is in integer, rather than a tuple representing a size.
I'd suggest reviewing the pygame
documentation and updating your code to call these functions with valid arguments.
https://www.pygame.org/docs/ref/display.html#pygame.display.list_modes https://www.pygame.org/docs/ref/display.html#pygame.display.mode_ok https://www.pygame.org/docs/ref/display.html#pygame.display.set_mode
This doesn't appear to be an issue with renpy
or pygame_sdl2
.
@mal
Yes sorry you are right, I don't know why I was passing those parameters. in fact now display works.
the only thing is that i think the optional imports are not working. as shown in a previous comment. (although on these imports I am not essential, however if I know there is another way to import this would help me a lot)
import pygame_sdl2 as pygame
pygame.import_as_pygame()
pygame._optional_imports()
def main():
# Initialize pygame_sdl2
pygame.init()
pygame.mixer.get_init()
While running game code:
File "game/script.rpy", line 31, in script
$ score = aliens.main()
File "game/script.rpy", line 31, in script
$ score = aliens.main()
File "game/script.rpy", line 31, in <module>
$ score = aliens.main()
NotImplementedError: Could not import pygame_sdl2.mixer: No module named 'pygame_sdl2.mixer'
Sorry to ask another question but it's the latest problem I have getting my little pygame to work on renpy that has been bugging me for a while.
ie: once i finish the game i don't know how to switch from pygame screen to renpy screen
#import basic pygame_sdl2 modules
import pygame_sdl2 as pygame
pygame.import_as_pygame()
pygame._optional_imports()
def main():
# Initialize pygame_sdl2
pygame.init()
screen = pygame.display.set_mode((100,100), 32, 32)
pygame.time.wait(1000)
# * https://github.com/renpy/renpy/issues/4347
# * renpytom tell me to use:
renpy.display_reset() # but not work
# ! BOOM:
renpy.call("start")
return
Hi, I was trying to import pygame_sdl2 into renpy project.
to do this i downloaded the library from here https://github.com/renpy/pygame_sdl2/tree/master/src/pygame_sdl2 (I failed with pip)
(I tried to follow the read me instructions, but I don't think they are up to date)
this works for py files, but not for pyx files.
checking in the init.py file.
I noticed that the compiler can't find the .pyx libraries.
i know what pyx files are, but i have never developed with it. searching a bit on the internet i realized that i had to add the Cython library,
but nothing changed.
could you give me some suggestions?