WinColl 0.9.6__tar.gz → 0.9.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {wincoll-0.9.6 → wincoll-0.9.7}/PKG-INFO +1 -1
  2. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/PKG-INFO +1 -1
  3. {wincoll-0.9.6 → wincoll-0.9.7}/pyproject.toml +2 -1
  4. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/__init__.py +108 -87
  5. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/locale/el/LC_MESSAGES/wincoll.mo +0 -0
  6. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/locale/fr/LC_MESSAGES/wincoll.mo +0 -0
  7. {wincoll-0.9.6 → wincoll-0.9.7}/README.md +0 -0
  8. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/SOURCES.txt +0 -0
  9. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/dependency_links.txt +0 -0
  10. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/entry_points.txt +0 -0
  11. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/requires.txt +0 -0
  12. {wincoll-0.9.6 → wincoll-0.9.7}/WinColl.egg-info/top_level.txt +0 -0
  13. {wincoll-0.9.6 → wincoll-0.9.7}/setup.cfg +0 -0
  14. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/Collect.wav +0 -0
  15. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/Slide.wav +0 -0
  16. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/Splat.wav +0 -0
  17. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/Unlock.wav +0 -0
  18. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/__main__.py +0 -0
  19. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/acorn-mode-1.ttf +0 -0
  20. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/diamond.png +0 -0
  21. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/langdetect.py +0 -0
  22. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/01.tmx +0 -0
  23. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/02.tmx +0 -0
  24. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/03.tmx +0 -0
  25. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/04.tmx +0 -0
  26. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/05.tmx +0 -0
  27. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/06.tmx +0 -0
  28. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Blob.png +0 -0
  29. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Brick.png +0 -0
  30. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Diamond.png +0 -0
  31. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Earth.png +0 -0
  32. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Gap.png +0 -0
  33. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Key.png +0 -0
  34. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Rock.png +0 -0
  35. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Safe.png +0 -0
  36. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/Win.png +0 -0
  37. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/levels/WinColl.tsx +0 -0
  38. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/locale/fr/LC_MESSAGES/argparse.mo +0 -0
  39. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/ptext.py +0 -0
  40. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/splat.png +0 -0
  41. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/title.png +0 -0
  42. {wincoll-0.9.6 → wincoll-0.9.7}/wincoll/warnings_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: WinColl
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: Simple rocks-and-diamonds game
5
5
  Author-email: Reuben Thomas <rrt@sc3d.org>
6
6
  License: GPL v3 or later
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: WinColl
3
- Version: 0.9.6
3
+ Version: 0.9.7
4
4
  Summary: Simple rocks-and-diamonds game
5
5
  Author-email: Reuben Thomas <rrt@sc3d.org>
6
6
  License: GPL v3 or later
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "WinColl"
3
- version = "0.9.6"
3
+ version = "0.9.7"
4
4
  description = "Simple rocks-and-diamonds game"
5
5
  license = {text = "GPL v3 or later"}
6
6
  authors = [
@@ -75,6 +75,7 @@ disable = [
75
75
  "too-many-locals",
76
76
  "too-many-nested-blocks",
77
77
  "too-many-positional-arguments",
78
+ "too-many-statements",
78
79
  ]
79
80
  enable = [
80
81
  "useless-suppression",
@@ -41,6 +41,7 @@ os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
41
41
  with warnings.catch_warnings():
42
42
  warnings.simplefilter("ignore")
43
43
  import pygame
44
+ from pygame import Vector2
44
45
  import pyscroll # type: ignore
45
46
  import pytmx # type: ignore
46
47
  from . import ptext
@@ -167,7 +168,8 @@ def handle_global_keys(event: pygame.event.Event) -> None:
167
168
  pygame.display.toggle_fullscreen()
168
169
 
169
170
 
170
- FRAMES_PER_SECOND = 10
171
+ FRAMES_PER_SECOND = 50
172
+ SCROLL_FRAMES_PER_SECOND = 10
171
173
 
172
174
 
173
175
  def scale_surface(surface: pygame.Surface) -> pygame.Surface:
@@ -213,7 +215,7 @@ class WincollGame:
213
215
  self.group = pyscroll.PyscrollGroup(map_layer=self.map_layer)
214
216
 
215
217
  self.hero = Win()
216
- self.hero.position = pygame.Vector2(0, 0)
218
+ self.hero.position = Vector2(0, 0)
217
219
  self.group.add(self.hero)
218
220
  self.diamonds = 0
219
221
  self.survey()
@@ -222,7 +224,7 @@ class WincollGame:
222
224
  self.restart_level()
223
225
  self.save_position()
224
226
 
225
- def get(self, pos: pygame.Vector2) -> int:
227
+ def get(self, pos: Vector2) -> int:
226
228
  # Anything outside the map is a brick
227
229
  x, y = int(pos.x), int(pos.y)
228
230
  if not ((0 <= x < level_size) and (0 <= y < level_size)):
@@ -232,7 +234,7 @@ class WincollGame:
232
234
  block = self.gids[TilesetGids.GAP]
233
235
  return block # type: ignore[no-any-return]
234
236
 
235
- def set(self, pos: pygame.Vector2, gid: int) -> None:
237
+ def set(self, pos: Vector2, gid: int) -> None:
236
238
  self.map_blocks[int(pos.y)][int(pos.x)] = gid
237
239
  # Update map
238
240
  # FIXME: We invoke protected methods and access protected members.
@@ -254,7 +256,7 @@ class WincollGame:
254
256
  map_blocks = pickle.load(fh)
255
257
  for row, blocks in enumerate(map_blocks):
256
258
  for col, block in enumerate(blocks):
257
- self.set(pygame.Vector2(col, row), block)
259
+ self.set(Vector2(col, row), block)
258
260
  self.survey()
259
261
 
260
262
  def survey(self) -> None:
@@ -268,7 +270,7 @@ class WincollGame:
268
270
  ):
269
271
  self.diamonds += 1
270
272
  elif block == self.gids[TilesetGids.WIN]:
271
- self.hero.position = pygame.Vector2(col, row)
273
+ self.hero.position = Vector2(col, row)
272
274
  self.set(self.hero.position, self.gids[TilesetGids.WIN_PLACE])
273
275
 
274
276
  def unlock(self) -> None:
@@ -276,7 +278,7 @@ class WincollGame:
276
278
  for row, blocks in enumerate(self.map_blocks):
277
279
  for col, block in enumerate(blocks):
278
280
  if block == self.gids[TilesetGids.SAFE]:
279
- self.set(pygame.Vector2(col, row), self.gids[TilesetGids.DIAMOND])
281
+ self.set(Vector2(col, row), self.gids[TilesetGids.DIAMOND])
280
282
  UNLOCK_SOUND.play()
281
283
 
282
284
  def draw(self) -> None:
@@ -296,68 +298,80 @@ class WincollGame:
296
298
  if axes >= 2: # Hopefully 0=L/R and 1=U/D
297
299
  lr = joystick.get_axis(0)
298
300
  if lr < -0.5:
299
- self.hero.velocity = pygame.Vector2(-1, 0)
301
+ self.hero.velocity = Vector2(-1, 0)
300
302
  elif lr > 0.5:
301
- self.hero.velocity = pygame.Vector2(1, 0)
303
+ self.hero.velocity = Vector2(1, 0)
302
304
  ud = joystick.get_axis(1)
303
305
  if ud < -0.5:
304
- self.hero.velocity = pygame.Vector2(0, -1)
306
+ self.hero.velocity = Vector2(0, -1)
305
307
  elif ud > 0.5:
306
- self.hero.velocity = pygame.Vector2(0, 1)
308
+ self.hero.velocity = Vector2(0, 1)
307
309
 
308
310
  def handle_input(self) -> None:
309
311
  pressed = pygame.key.get_pressed()
310
- self.hero.velocity = pygame.Vector2(0, 0)
312
+ dx, dy = (0, 0)
311
313
  if pressed[pygame.K_LEFT] or pressed[pygame.K_z]:
312
- self.hero.velocity = pygame.Vector2(-1, 0)
313
- elif pressed[pygame.K_RIGHT] or pressed[pygame.K_x]:
314
- self.hero.velocity = pygame.Vector2(1, 0)
315
- elif pressed[pygame.K_UP] or pressed[pygame.K_QUOTE]:
316
- self.hero.velocity = pygame.Vector2(0, -1)
317
- elif pressed[pygame.K_DOWN] or pressed[pygame.K_SLASH]:
318
- self.hero.velocity = pygame.Vector2(0, 1)
319
- elif pressed[pygame.K_l]:
314
+ dx -= 1
315
+ if pressed[pygame.K_RIGHT] or pressed[pygame.K_x]:
316
+ dx += 1
317
+ if pressed[pygame.K_UP] or pressed[pygame.K_QUOTE]:
318
+ dy -= 1
319
+ if pressed[pygame.K_DOWN] or pressed[pygame.K_SLASH]:
320
+ dy += 1
321
+ if dx != 0 and self.can_move(Vector2(dx, 0)):
322
+ self.hero.velocity = Vector2(dx, 0)
323
+ elif dy != 0 and self.can_move(Vector2(0, dy)):
324
+ self.hero.velocity = Vector2(0, dy)
325
+ if pressed[pygame.K_l]:
320
326
  flash_background()
321
327
  self.load_position()
322
328
  elif pressed[pygame.K_s]:
323
329
  flash_background()
324
330
  self.save_position()
325
- elif pressed[pygame.K_r]:
331
+ if pressed[pygame.K_r]:
326
332
  flash_background()
327
333
  self.restart_level()
328
- elif pressed[pygame.K_q]:
334
+ if pressed[pygame.K_q]:
329
335
  self.quit = True
330
336
  self.handle_joysticks()
331
337
 
332
- def process_move(self) -> None:
338
+ def can_move(self, velocity: Vector2) -> bool:
339
+ newpos = self.hero.position + velocity
340
+ block = self.get(newpos)
341
+ if block in (
342
+ self.gids[TilesetGids.GAP],
343
+ self.gids[TilesetGids.EARTH],
344
+ self.gids[TilesetGids.DIAMOND],
345
+ self.gids[TilesetGids.KEY],
346
+ ):
347
+ return True
348
+ if block == self.gids[TilesetGids.ROCK]:
349
+ new_rockpos = self.hero.position + (self.hero.velocity * 2)
350
+ return (
351
+ self.hero.velocity.y == 0
352
+ and self.get(new_rockpos) == self.gids[TilesetGids.GAP]
353
+ )
354
+ return False
355
+
356
+ def do_move(self) -> None:
333
357
  newpos = self.hero.position + self.hero.velocity
334
358
  block = self.get(newpos)
335
- if block in (self.gids[TilesetGids.GAP], self.gids[TilesetGids.EARTH]):
336
- pass
337
- elif block == self.gids[TilesetGids.DIAMOND]:
359
+ if block == self.gids[TilesetGids.DIAMOND]:
338
360
  COLLECT_SOUND.play()
339
361
  self.diamonds -= 1
340
362
  elif block == self.gids[TilesetGids.KEY]:
341
363
  self.unlock()
342
364
  elif block == self.gids[TilesetGids.ROCK]:
343
365
  new_rockpos = self.hero.position + (self.hero.velocity * 2)
344
- if (
345
- self.hero.velocity.y == 0
346
- and self.get(new_rockpos) == self.gids[TilesetGids.GAP]
347
- ):
348
- self.set(new_rockpos, self.gids[TilesetGids.ROCK])
349
- else:
350
- self.hero.velocity = pygame.Vector2(0, 0)
351
- else:
352
- self.hero.velocity = pygame.Vector2(0, 0)
366
+ self.set(new_rockpos, self.gids[TilesetGids.ROCK])
353
367
  self.set(self.hero.position, self.gids[TilesetGids.GAP])
354
368
  self.set(
355
369
  self.hero.position + self.hero.velocity, self.gids[TilesetGids.WIN_PLACE]
356
370
  )
357
371
 
358
- def can_roll(self, pos: pygame.Vector2) -> bool:
372
+ def can_roll(self, pos: Vector2) -> bool:
359
373
  side_block = self.get(pos)
360
- side_below_block = self.get(pos + pygame.Vector2(0, 1))
374
+ side_below_block = self.get(pos + Vector2(0, 1))
361
375
  return (
362
376
  side_block == self.gids[TilesetGids.GAP]
363
377
  and side_below_block == self.gids[TilesetGids.GAP]
@@ -366,8 +380,8 @@ class WincollGame:
366
380
  def rockfall(self) -> None:
367
381
  new_fall = False
368
382
 
369
- def fall(oldpos: pygame.Vector2, newpos: pygame.Vector2) -> None:
370
- block_below = self.get(newpos + pygame.Vector2(0, 1))
383
+ def fall(oldpos: Vector2, newpos: Vector2) -> None:
384
+ block_below = self.get(newpos + Vector2(0, 1))
371
385
  if block_below == self.gids[TilesetGids.WIN_PLACE]:
372
386
  self.dead = True
373
387
  self.set(oldpos, self.gids[TilesetGids.GAP])
@@ -381,8 +395,8 @@ class WincollGame:
381
395
  for row, blocks in reversed(list(enumerate(self.map_blocks))):
382
396
  for col, block in enumerate(blocks):
383
397
  if block == self.gids[TilesetGids.ROCK]:
384
- pos = pygame.Vector2(col, row)
385
- pos_below = pos + pygame.Vector2(0, 1)
398
+ pos = Vector2(col, row)
399
+ pos_below = pos + Vector2(0, 1)
386
400
  block_below = self.get(pos_below)
387
401
  if block_below == self.gids[TilesetGids.GAP]:
388
402
  fall(pos, pos_below)
@@ -392,13 +406,13 @@ class WincollGame:
392
406
  self.gids[TilesetGids.DIAMOND],
393
407
  self.gids[TilesetGids.BLOB],
394
408
  ):
395
- pos_left = pos + pygame.Vector2(-1, 0)
409
+ pos_left = pos + Vector2(-1, 0)
396
410
  if self.can_roll(pos_left):
397
- fall(pos, pos_left + pygame.Vector2(0, 1))
411
+ fall(pos, pos_left + Vector2(0, 1))
398
412
  else:
399
- pos_right = pos + pygame.Vector2(1, 0)
413
+ pos_right = pos + Vector2(1, 0)
400
414
  if self.can_roll(pos_right):
401
- fall(pos, pos_right + pygame.Vector2(0, 1))
415
+ fall(pos, pos_right + Vector2(0, 1))
402
416
 
403
417
  if new_fall is False:
404
418
  self.falling = False
@@ -440,58 +454,65 @@ class WincollGame:
440
454
 
441
455
  def run(self) -> None:
442
456
  clock = pygame.time.Clock()
443
-
444
- try:
445
- while self.level <= levels:
446
- self.start_level()
447
- self.show_status()
448
- self.show_screen()
449
- while self.diamonds > 0:
450
- self.load_position()
451
- while not self.dead and self.diamonds > 0:
452
- clock.tick(FRAMES_PER_SECOND)
453
- self.hero.velocity = pygame.Vector2(0, 0)
454
- handle_quit_event()
455
- for event in pygame.event.get(pygame.KEYDOWN):
457
+ while not self.quit and self.level <= levels:
458
+ self.start_level()
459
+ self.show_status()
460
+ self.show_screen()
461
+ while not self.quit and self.diamonds > 0:
462
+ self.load_position()
463
+ subframes = 4 # FIXME: global constant
464
+ subframe = 0
465
+ while not self.quit and not self.dead and self.diamonds > 0:
466
+ clock.tick(FRAMES_PER_SECOND)
467
+ for event in pygame.event.get():
468
+ if event.type == pygame.QUIT:
469
+ quit_game()
470
+ elif event.type == pygame.KEYDOWN:
456
471
  handle_global_keys(event)
472
+ elif event.type == pygame.JOYDEVICEADDED:
473
+ joy = pygame.joystick.Joystick(event.device_index)
474
+ self.joysticks[joy.get_instance_id()] = joy
475
+ elif event.type == pygame.JOYDEVICEREMOVED:
476
+ del self.joysticks[event.instance_id]
477
+ if self.hero.velocity == Vector2(0, 0):
457
478
  self.handle_input()
458
- if self.quit:
459
- self.quit = False
460
- return
461
- self.process_move()
479
+ if self.hero.velocity != Vector2(0, 0):
480
+ self.do_move()
481
+ subframe = 0
482
+ if subframe == subframes - 1:
462
483
  self.rockfall()
463
- subframes = 4
464
- for _subframe in range(subframes):
465
- self.group.update(1 / subframes)
466
- self.draw()
467
- self.show_status()
468
- self.show_screen()
469
- pygame.time.wait(1000 // FRAMES_PER_SECOND // subframes)
470
- if self.dead:
471
- SLIDE_SOUND.stop()
472
- SPLAT_SOUND.play()
473
- self.game_surface.blit(
474
- SPLAT_IMAGE,
475
- self.game_to_screen(
476
- int(self.hero.position.x), int(self.hero.position.y)
477
- ),
478
- )
479
- self.show_status()
480
- self.show_screen()
481
- pygame.time.wait(1000)
482
- self.dead = False
483
- self.level += 1
484
+ self.group.update(1 / subframes)
485
+ self.draw()
486
+ self.show_status()
487
+ self.show_screen()
488
+ pygame.time.wait(1000 // SCROLL_FRAMES_PER_SECOND // subframes)
489
+ subframe = (subframe + 1) % subframes
490
+ if subframe == 0:
491
+ self.hero.velocity = Vector2(0, 0)
492
+ SLIDE_SOUND.stop()
493
+ if self.dead:
494
+ SPLAT_SOUND.play()
495
+ self.game_surface.blit(
496
+ SPLAT_IMAGE,
497
+ self.game_to_screen(
498
+ int(self.hero.position.x), int(self.hero.position.y)
499
+ ),
500
+ )
501
+ self.show_status()
502
+ self.show_screen()
503
+ pygame.time.wait(1000)
504
+ self.dead = False
505
+ self.level += 1
506
+ if self.level > levels:
484
507
  self.splurge(Win().image)
485
- finally:
486
- SLIDE_SOUND.stop()
487
508
 
488
509
 
489
510
  class Win(pygame.sprite.Sprite): # pylint: disable=too-few-public-methods
490
511
  def __init__(self) -> None:
491
512
  pygame.sprite.Sprite.__init__(self)
492
513
  self.image = load_image("levels/Win.png")
493
- self.velocity = pygame.Vector2(0, 0)
494
- self.position = pygame.Vector2(0, 0)
514
+ self.velocity = Vector2(0, 0)
515
+ self.position = Vector2(0, 0)
495
516
  self.rect = self.image.get_rect()
496
517
 
497
518
  def update(self, dt: float) -> None:
index 24a01a8..56dfa89 100644
Binary file
index eb09046..ae3bf2a 100644
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes