This one, but the game 'Kissing booth' which is a game of click and hold throws the following error when I hold the button for the maximum time -
Code: Select all
I'm sorry, but an uncaught exception occurred.
While loading <renpy.display.im.Crop object at 0x00000000054ad0d0>:
File "game/script.rpy", line 304, in script
python:
File "game/script.rpy", line 309, in <module>
winner = ui.interact(suppress_overlay=True, suppress_window=True)
File "game/kissing_booth.rpy", line 55, in render
eileen = renpy.render( temp_meter, width, height, st, at)
error: subsurface rectangle outside surface area.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 304, in script
python:
File "renpy-8.1.1-sdk\renpy\ast.py", line 1138, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "renpy-8.1.1-sdk\renpy\python.py", line 1122, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/script.rpy", line 309, in <module>
winner = ui.interact(suppress_overlay=True, suppress_window=True)
File "renpy-8.1.1-sdk\renpy\ui.py", line 299, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "renpy-8.1.1-sdk\renpy\display\core.py", line 3579, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
File "renpy-8.1.1-sdk\renpy\display\core.py", line 4172, in interact_core
self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
File "renpy-8.1.1-sdk\renpy\display\core.py", line 2779, in draw_screen
surftree = renpy.display.render.render_screen(
File "render.pyx", line 492, in renpy.display.render.render_screen
File "render.pyx", line 266, in renpy.display.render.render
File "renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
surf = render(child, width, height, cst, cat)
File "render.pyx", line 170, in renpy.display.render.render
File "render.pyx", line 266, in renpy.display.render.render
File "renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
surf = render(child, width, height, cst, cat)
File "render.pyx", line 170, in renpy.display.render.render
File "render.pyx", line 266, in renpy.display.render.render
File "renpy-8.1.1-sdk\renpy\display\layout.py", line 886, in render
surf = render(child, width, height, cst, cat)
File "render.pyx", line 170, in renpy.display.render.render
File "render.pyx", line 266, in renpy.display.render.render
File "game/kissing_booth.rpy", line 55, in render
eileen = renpy.render( temp_meter, width, height, st, at)
File "render.pyx", line 170, in renpy.display.render.render
File "render.pyx", line 266, in renpy.display.render.render
File "renpy-8.1.1-sdk\renpy\display\im.py", line 676, in render
return cache.get(self, render=True)
File "renpy-8.1.1-sdk\renpy\display\im.py", line 330, in get
surf = image.load()
File "renpy-8.1.1-sdk\renpy\display\im.py", line 1192, in load
return cache.get(self.image).subsurface((self.x*os, self.y*os,
File "src/pygame_sdl2/surface.pyx", line 642, in pygame_sdl2.surface.Surface.subsurface
error: subsurface rectangle outside surface area.
Windows-10-10.0.22000 AMD64
Ren'Py 8.1.1.23060707
Fall Fair 0.0
Wed Jul 12 16:21:40 2023
Code: Select all
init:
python:
import math
from vec2d import vec2d
class KissingBoothDisplayable(renpy.Displayable):
def __init__(self, time_limit, time_target):
renpy.Displayable.__init__(self)
self.time_limit = time_limit
self.time_target = time_target
# Some displayables we use.
self.panel = Image("images/panel.png")
self.meter = Image("images/meter.png")
self.arrow = Image("images/arrow.png")
self.ctb = Text("Click and Hold to start kissing.", size=36, drop_shadow=(2,2), drop_shadow_color="#C0C0C0")
# The sizes of some of the images.
self.METER_WIDTH = 50.0
self.METER_HEIGHT = 400.0
# Started.
self.started = False
# The time of the past render-frame.
self.oldst = None
self.time_passed = 0.0
def score(self):
return math.fabs(self.time_target-self.time_passed)
# draws the screen.
def render(self, width, height, st, at):
# Figure out the time elapsed since the previous frame.
if self.oldst is None and self.started:
self.oldst = st
if self.started:
self.time_passed = st - self.oldst
# The Render object we'll be drawing into.
r = renpy.Render(width, height)
pixel_height = self.METER_HEIGHT * (self.time_passed/self.time_limit)
target_height = self.METER_HEIGHT - (self.METER_HEIGHT * (float(self.time_target)/float(self.time_limit)))
eileen = renpy.render( self.panel, width, height, st, at)
ew, eh = eileen.get_size()
r.blit(eileen, (width*0.75 - ew / 2, height/2 - eh/ 2))
temp_meter = im.Crop(self.meter,0,self.METER_HEIGHT-pixel_height,self.METER_WIDTH,pixel_height)
eileen = renpy.render( temp_meter, width, height, st, at)
r.blit(eileen, (width*0.75 - self.METER_WIDTH / 2, height/2 + self.METER_HEIGHT/ 2-pixel_height))
meter = renpy.render( self.arrow, width, height, st, at)
ew, eh = meter.get_size()
r.blit(meter, (width*0.75 - self.METER_WIDTH / 2, (height/2) - (self.METER_HEIGHT/ 2) + target_height - (eh / 2)))
# Show the "Click to Begin" label.
if self.started == False:
ctb = renpy.render(self.ctb, 800, 600, st, at)
cw, ch = ctb.get_size()
r.blit(ctb, (width*0.5 - cw / 2, height*0.25 - ch/2))
# Ask that we be re-rendered ASAP, so we can show the next
# frame.
renpy.redraw(self, 0)
# Return the Render object.
return r
# Handles events.
def event(self, ev, x, y, st):
import pygame
# Mousebutton down == start the game by setting stuck to
# false.
if ev.type == pygame.MOUSEBUTTONDOWN and ev.button == 1:
self.started = True
if ev.type == pygame.MOUSEBUTTONUP and ev.button == 1 and self.started:
return self.score()
if self.started:
if self.time_passed < self.time_limit:
raise renpy.IgnoreEvent()
else:
return self.score()
else:
raise renpy.IgnoreEvent()
Code: Select all
label kissing_booth:
scene bg gym full
$ customers = 0
$ booth_shifts += 1
label kb_customer:
if alignment > 0 and donations > 20 and booth_shifts == 2 and customers == 4:
hide customer
show robert normal behind table
mc "I didn't expect to see you here."
robert "Everyone needs to do their part for all the clubs."
"Robert leans in:"
robert "Plus, I suspect I will enjoy it."
scene robert_kiss
"..."
jump choose_game
elif alignment < 0 and experiences > 20 and booth_shifts == 2 and customers == 4:
hide customer
show kyle normal behind table
mc "This must be my lucky day!"
kyle "No. Actually I think it is mine."
scene kyle_kiss
"..."
jump choose_game
elif alignment == 0 and tickets > 50 and booth_shifts == 2 and customers == 4:
hide customer
show mark normal behind table
mc "What are you doing here?"
"Mark pushes his glasses up his nose."
mark "Just helping out for the sake of the Drama Club."
mc "For the sake of the Drama Club."
jump choose_game
else:
show customer
show table
python:
customers += 1
tips = 0
randfloat = renpy.random.random() * 2.0 + 0.5
ui.add(KissingBoothDisplayable(2.5,randfloat))
winner = ui.interact(suppress_overlay=True, suppress_window=True)
window show None
python:
if winner < 0.1:
tips = int((0.1 - winner) * 50)
tickets += tips
"You earned [tips] tickets in tips."
if customers < 5:
jump kb_customer
jump choose_game
There's one vector 2d file for all the mathematical operands. I'm not sure if it's involved with the error or not.