GameBox 0.1.0__tar.gz → 0.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameBox
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: GameBox is a beginner-friendly Python package built on top of pygame, designed to make 2D game development faster and easier. It provides ready-to-use modules, utilities, and abstractions that let new developers create polished games without needing advanced coding knowledge—while still offering the flexibility for experienced coders to customize and extend.
5
5
  Author-email: Sam Fertig <sfertig007@gmail.com>
6
6
  License-Expression: MIT
@@ -3,7 +3,7 @@ requires = ["hatchling >= 1.26"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "GameBox"
6
- version = "0.1.0"
6
+ version = "0.1.2"
7
7
  authors = [
8
8
  { name="Sam Fertig", email="sfertig007@gmail.com" },
9
9
  ]
@@ -12,12 +12,20 @@ class Rect:
12
12
  self.collision = collision
13
13
 
14
14
  def update(self):
15
- rect = pygame.Rect(self.x - Global.cam.x
16
- , self.y - Global.cam.y
17
- , self.width, self.height)
15
+ if (Global.cam.follow) != (self):
16
+ x = self.x - Global.cam.x
17
+ y = self.y - Global.cam.y
18
+ elif (Global.cam.follow) == (self):
19
+ x = self.x
20
+ y = self.y
21
+
22
+ rect = pygame.Rect(x, y, self.width, self.height)
18
23
  if self.collision: Global.collisions.append(rect)
19
24
  pygame.draw.rect(Global.screen, self.color, rect)
20
25
 
21
26
  def move(self, x, y):
22
- self.x += x
23
- self.y += y
27
+ if (Global.cam.follow) != (self):
28
+ self.x += x
29
+ self.y += y
30
+ else:
31
+ Global.cam.move(x, y)
@@ -25,7 +25,7 @@ class Player:
25
25
  self.physics.update()
26
26
  #debug rect
27
27
  rect = pygame.Rect(self.x, self.y, self.dim[0], self.dim[1])
28
- pygame.draw.rect(Global.screen, "green", rect)
28
+ pygame.draw.rect(Global.screen, self.color, rect)
29
29
 
30
30
  #movement
31
31
  def top_down_movement(self):
@@ -22,12 +22,11 @@ class _playerPhysics:
22
22
 
23
23
  def update(self):
24
24
  self.ckeck_is_on_ground()
25
- self.fixVelocities()
26
25
  x, y = self.check_collisions()
27
- if type(Global.cam.follow) != type(self.player):
26
+ if (Global.cam.follow) != (self.player):
28
27
  self.player.x = x
29
28
  self.player.y = y
30
- elif type(Global.cam.follow) == type(self.player):
29
+ elif (Global.cam.follow) == (self.player):
31
30
  dx = -(self.player.x - x)
32
31
  dy = -(self.player.y - y)
33
32
  Global.cam.move(self.vx, self.vy)
@@ -0,0 +1,29 @@
1
+ from src.GameBox import *
2
+ import pygame
3
+
4
+ width, height = 800, 600
5
+ win = Game(width, height, "blue", "First Game!")
6
+
7
+ cam = Cammera()
8
+
9
+ player = Player((width / 2, 375), (50, 50), "green", True)
10
+ player.add_physics(1.0, 3.0, 16, 7.0, 0.5)
11
+
12
+ floor = Rect((0, height-50), (width, 50), "yellow", True)
13
+
14
+ rect = Rect((0, 0), (50, 50), "red", True)
15
+
16
+ cam.set_follow_target(floor)
17
+
18
+ running = True
19
+ while running:
20
+ for event in pygame.event.get():
21
+ if event.type == pygame.QUIT:
22
+ running = False
23
+
24
+ player.platforming_movement()
25
+ floor.move(-0.5, -0.5)
26
+
27
+ win.update(60)
28
+
29
+ pygame.quit()
@@ -1,31 +0,0 @@
1
- from src.GameBox import *
2
- import pygame
3
-
4
- width, height = 1400, 800
5
- game = Game(width, height, (124, 204, 201))
6
-
7
- cam = Cammera()
8
-
9
- player = Player((width / 2, 500), (50, 50), (0, 255, 0), True)
10
-
11
- player.add_physics(1.0, 3.0, 16, 7.0, 0.5)
12
-
13
- rect = Rect((0, 700), (width*20, 100), (255, 0, 0), True)
14
-
15
- cam.set_follow_target(player)
16
-
17
- running = True
18
-
19
- while running:
20
- for event in pygame.event.get():
21
- if event.type == pygame.QUIT:
22
- running = False
23
-
24
- player.platforming_movement()
25
-
26
- game.update()
27
-
28
-
29
-
30
- pygame.quit()
31
- quit()
File without changes
File without changes
File without changes
File without changes