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.
"I'm going to rotate this circle."
show circle:
xalign 0.7 yalign 0.6
call turnCircle
label turnCircle:
show circle:
xalign 0.7 yalign 0.6
linear 0.15 rotate -= 60
return
This will rotate the circle counter-clockwise by 60.
Now I wish to repeat this, so that instead of -60 it goes to -120, all the way until it has made a full circle.
How would I do that?
Hello Exiscoming, what is your circle? A pic or something that Renpy can draw?
I put it this way to rotate a pic (warp001, quadratic, not screen size resolution, and I made the edges black and use a black bg so the outer borders are not to see when it is spinning) of a whirl in clockwise direction. It took me quite a time to find out:
Hey M-77 thank you for your reply! So I'll give you a bit more detail on what I'm working on.
The turning image is suppose to be the chamber of a revolver.
Everytime I click, I need it to rotate -60 degrees, which means it has to remember what rotation it's on currently and subtract another -60 from that.
Like turning the rotation number into a variable. Something like this:
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
I don't know if that code works, I have very limited experience managing that kind of things and perhaps someone could help you with that... But I see a problem: you declare the variable but never update it, so it will allways be -60.
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
Exiscoming wrote: ↑Fri Mar 15, 2019 5:01 am
Hey Matalla,
Thank you for your reply. That was my original idea aswell, but this gives an error message.
I think the error could be that the code doesn't tell what to do with the variable, judging by M-77 and philat's example the variable with the value should be preceded by rotate.
#! /python26/python.exe
#! coding: utf-8
"""
Simple demonstration on rotating an Image!
"""
import pygame
from pygame.locals import *
pygame.init()
SCREENSIZE = (640, 640)
screen = pygame.display.set_mode(SCREENSIZE, 0, 32)
pygame.display.set_caption("Angle: 0°")
scrcenter = screen.get_rect().center
print scrcenter
print type(scrcenter)
# Prepare Background and Arrow:
bg = pygame.Surface(SCREENSIZE)
bg.fill((120,120,120))
arrow = pygame.Surface((120,120), SRCALPHA)
pygame.draw.rect(arrow, (255, 0, 0), (0, 0, 120, 120))
# We need an image to rotate:
rotarrow = arrow.copy()
angle = 0
# We define centerpoints for the images/sprites.
CENTER = screen.get_rect().center
ACENTER = arrow.get_rect().center
ABS_CENTER = (CENTER[0] - ACENTER[0], CENTER[1] - ACENTER[1])
#
keepGoing = True
clock = pygame.time.Clock()
while keepGoing:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
keepGoing = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
keepGoing = False
elif event.key == pygame.K_RIGHT:
angle -= 5
rotarrow = pygame.transform.rotate(arrow, angle)
elif event.key == pygame.K_LEFT:
angle += 5
rotarrow = pygame.transform.rotate(arrow, angle)
# Get centerpoint of current rect
ROTCENTER = rotarrow.get_rect().center
ABS_CENTER = (CENTER[0] - ROTCENTER[0], CENTER[1]-ROTCENTER[1])
# display current angle for info:
pygame.display.set_caption("Angle: " + str(angle) + "°")
screen.blit(bg, (0,0))
screen.blit(rotarrow, ABS_CENTER)
pygame.display.flip()
Maybe you can ape after this method. Or implement it in Renpy. This rotate a arrow on a clock at %5 + or - angle when the left or right mouse button is hit.