Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

PyGame (Ball-E) error

Hi!

I am trying to implement a pygame in OS, so that participants can play this game after they finished completing a survey.

The game is Ball-E, taken from here: https://www.pygame.org/project/1072/1916

The survey works fine, but the game does not. Once I press on the button I created for the game, the game flashes on the screen for a very short time and then i get the error message below.

Any help is much appreciated.

Cheers!


item-stack: survey[run].Games[run].Games_loop[run].Ball_e[run]

exception type: ValueError

exception message: subsurface rectangle outside surface area

item: Ball_e

time: Wed Oct 30 14:42:13 2019

phase: run


Traceback (also in debug window)


File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 116, in run

self.workspace._exec(self.crun)

File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\base_python_workspace.py", line 124, in _exec

exec(bytecode, self._globals)

Inline script, line 191, in <module>

Inline script, line 178, in main

ValueError: subsurface rectangle outside surface area

Comments

  • Hi,

    Can you share your experiment here? Then we might able to get to the bottom of what is going awry here.

    Eduard

  • Hi,

    Thanks for the reply!

    I've uploaded a simple version of the survey. To advance, please use the space bar and/or fill in the information required. :)

    Paula

  • edited November 2019

    Later edit: deleted.

  • Hi Paula,

    sorry for the delay. Does your last post mean the problem is resolved?

    Thanks,

    Eduard

  • Hi Eduard,

    No: unfortunately, I was not able to solve it.

    Any input would be much appreciated.

    Paula

  • edited November 2019

    Hi Paula,

    I looked at your code and I found the problem. However, as I don't know how this game is supposed to work exactly, and the code is too complex to get it just from looking at it, I can't fix it for you. So, I can describe it, and you have to figure out yourself what to do about it.

    The issue is that the surface rotatedhas a different size than the rectangle subrect  (newimg = rotated.subsurface(subrect)

    # these are the sub rect dimensions
    <rect(-34, -33, 84, 83)>
    # these are the rotated dimensions
    <rect(0, 0, 16, 16)>
    

    If you want to create a subsurface of a surface (rotated), it must be contained (maybe even the same) as the parent surface. So, basically your script scrashes because you want to create a subsurface of an object that lies outside its scope. To fix it, you have to make the subrect be contained in rotated. Whether you better change one or the other, I can't tell you.

    Does that make sense?

    I upload a version of the game, in which I arbitrarily changed the surfaces and could make the screen appear. Whether the game works as you wish it to work, I don't know (lines that I changed are 181-187

    .


    Best,

    Eduard

  • Hi Eduard,

    Thank you VERY much for your help.

    Your fix worked perfectly just by keeping the change you made in lines 181-187.

    Cheers,

    Paula

  • I edited the script a bit more and in the end managed to enlarge the subsurface to get a larger ball image based on your explanation.

    Thanks again for the help!

Sign In or Register to comment.