jackfrued / jackfrued/Python-100-Days
Day10 大球吃小球初始bug优化
Open
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
获得鼠标初始位置x, y,界面的高宽h, w,
当 h,w - y, x < radius or h,w - y,x >(h - self.radius, w - self.radius)
【即初始位置的小球部分在界面外】
小球无法正常运动
修改def move()代码如下,优化此问题:
def move(self, screen):
self.x += self.sx
self.y += self.sy
temp_sx = self.sx
temp_sy = self.sy
w, h = pygame.display.get_surface().get_size()
if w - self.x <= self.radius:
self.sx = -abs(self.sx)
elif w - self.x <= w - self.radius:
self.sx = temp_sx
else:
self.sx = abs(self.sx)
if h - self.y <= self.radius:
self.sy = -abs(self.sy)
elif h - self.y <= h - self.radius:
self.sy = temp_sy
else:
self.sy = abs(self.sy)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Day 10 ball class and its move(self, screen) method, then compare its boundary handling with the conditions and replacement shown in the issue. Run the game with a ball initially partly outside the screen and confirm it can move normally and respond to the screen edges.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100