from ..constants import SCREEN_SIZE
from ..widgets import ImageButton
-from ..turnip import Turnip
+from ..turnip import Turnip, TurnipInvalidPosition
class DayScene(BaseScene):
self._harvested = gamestate.harvested
self._tool = None
for turnip_data in gamestate.turnips:
- turnip = Turnip(**turnip_data)
+ turnip = Turnip(space=self._space, **turnip_data)
# Turnips grow at dawn
seeds = turnip.grow()
if seeds:
if self._tool == "seed":
if self._seeds > 0:
# plant seed
- turnip = Turnip(age=0, pos=ev.pos)
- self._turnips.append(turnip)
- self._seeds -= 1
- self._update_toolbar
+ # We don't want top-left to equal the mouse position,
+ # since that looks weird, but we don't want to center
+ # the turnip under the mouse either, since that
+ # causes issues as well, so we compromise
+ pos = (ev.pos[0] - 8, ev.pos[1] - 8)
+ try:
+ turnip = Turnip(age=0, pos=pos, space=self._space)
+ self._turnips.append(turnip)
+ self._seeds -= 1
+ self._update_toolbar()
+ except TurnipInvalidPosition as e:
+ # TODO: Add error sound or something
+ pass
else:
# Not tool, so check lights
self._lights.toggle_nearest(ev.pos, surfpos=True)