From: Skullheadx <704277@pdsb.net> Date: Sun, 10 Jul 2022 01:27:16 +0000 (-0400) Subject: forget X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.js?a=commitdiff_plain;h=7da3a169caa7c2fb78a3fcb9846be0c8b49edc57;p=Pygame-Jam.git forget --- diff --git a/Actors.py b/Actors.py index b5cb6a8..16bc893 100644 --- a/Actors.py +++ b/Actors.py @@ -1,14 +1,29 @@ +from datetime import datetime,timedelta +import threading + from Setup import * from PhysicsBody import PhysicsBody class Actor: width, height = 50, 100 colour = (76, 82, 92) +<<<<<<< Updated upstream speed = 0.2 jump_strength = 1 gravity = 0.098 friction = 0.9 +======= + speed = 0.6 + jump_strength = 1 + gravity = 0.2 + friction = 0.2 + coyote_time_amount = timedelta(milliseconds=100) # seconds after walking off ground that it still counts + jump_buffer = [] + variable_jump_time = timedelta(milliseconds=125) # how long to hold jump so we go higher + terminal_velocity = 15 + +>>>>>>> Stashed changes def __init__(self, pos, collision_layer, collision_mask): self.position = pg.Vector2(pos) @@ -27,6 +42,22 @@ class Actor: self.movable = False +<<<<<<< Updated upstream +======= + self.jumping = False + self.coyote_time = datetime.utcnow() + self.hold_jump = datetime.utcnow() + + def update(self, delta): + if self.jumping: + if self.on_ground: + self.jumping = False + + + + self.stun_time -= delta + self.stun_time = max(self.stun_time, 0) +>>>>>>> Stashed changes def update(self, delta): for area in self.areas.values(): @@ -41,7 +72,16 @@ class Actor: self.velocity.x *= self.friction # Apply gravity +<<<<<<< Updated upstream self.velocity.y += self.gravity +======= + if self.jumping and self.velocity.y > 0: + self.velocity.y += self.gravity * 2 + else: + self.velocity.y += self.gravity + self.velocity.x = max(min(self.velocity.x, self.terminal_velocity),-self.terminal_velocity) + self.velocity.y = max(min(self.velocity.y, self.terminal_velocity),-self.terminal_velocity) +>>>>>>> Stashed changes def is_dead(self,reason=None): if self.health <= 0: @@ -71,6 +111,7 @@ class Actor: self.jump() def jump(self): +<<<<<<< Updated upstream if self.on_ground: self.velocity.y = -self.jump_strength @@ -84,6 +125,22 @@ class Actor: else: v = vel self.velocity += (math.copysign(2,v.x), v.y-1) +======= + if self.stun_time == 0: + pass + if (self.on_ground and not self.jumping) or (datetime.utcnow() - self.hold_jump <= self.variable_jump_time): + self.velocity.y = -self.jump_strength + if not self.jumping: + self.hold_jump = datetime.utcnow() + self.jumping = True + # elif not (datetime.utcnow() - self.hold_jump <= self.variable_jump_time): + + def dash_left(self): + pass + + def dash_right(self): + pass +>>>>>>> Stashed changes def move_left(self, customSpeed = speed): self.velocity.x = -customSpeed @@ -93,8 +150,10 @@ class Actor: self.velocity.x = self.speed def move_and_collide(self, pos, vel, delta): + initial_pos = pos pos.x += vel.x * delta collision_rect = self.get_collision_rect(pos) + for mask in self.collision_mask: for thing in mask: if thing == self: @@ -108,6 +167,7 @@ class Actor: vel.x = min(vel.x, 0) elif vel.x < 0: pos.x = thing.position.x + thing.width +<<<<<<< Updated upstream vel.x = max(vel.x, 0) ======= if vel.x > 0: @@ -128,11 +188,23 @@ class Actor: print(thing, thing.movable, vel) >>>>>>> Stashed changes collision_rect = self.get_collision_rect(pos) +======= + # vel.x = max(vel.x, 0) + # collision_rect = self.get_collision_rect(pos) + + + if datetime.utcnow() - self.coyote_time >= self.coyote_time_amount or self.jumping: + self.on_ground = False +>>>>>>> Stashed changes - self.on_ground = False pos.y += vel.y * delta +<<<<<<< Updated upstream collision_rect = self.get_collision_rect(pos) for mask in self.collision_mask: +======= + collision_rect = self.get_collision_rect((initial_pos[0], pos.y)) + for mask in self.collision_mask: +>>>>>>> Stashed changes for thing in mask: if thing == self: continue @@ -147,10 +219,13 @@ class Actor: pos.y = thing.position.y - self.height vel.y = min(vel.y, 0) self.on_ground = True + self.coyote_time = datetime.utcnow() elif vel.y < 0: pos.y = thing.position.y + thing.height vel.y = max(vel.y, 0) - collision_rect = self.get_collision_rect(pos) + # collision_rect = self.get_collision_rect(pos) + + return pos, vel diff --git a/Assets/world/SKY.png b/Assets/world/SKY.png new file mode 100644 index 0000000..bea5b67 Binary files /dev/null and b/Assets/world/SKY.png differ diff --git a/Assets/world/decor/Rock.png b/Assets/world/decor/Rock.png new file mode 100644 index 0000000..2fc6f98 Binary files /dev/null and b/Assets/world/decor/Rock.png differ diff --git a/Enemy.py b/Enemy.py index 0eb663d..f6fa8f1 100644 --- a/Enemy.py +++ b/Enemy.py @@ -20,7 +20,13 @@ class Enemy(Actor): self.movable = True self.dizzy_time = 0 +<<<<<<< Updated upstream self.weapon = Melee(self.position, (-Melee.width/2, Melee.height/2), (0, Melee.height), self.width,-1) +======= + # self.health = 0 # for debugging without getting killed + + self.weapon = Melee(self.position, (-Melee.width/2 + 7, Melee.height/2 + self.height/3 - 8), (-5,Melee.height), self.width,-1, -10) +>>>>>>> Stashed changes def update(self, delta, target=None): super().update(delta) diff --git a/Game.py b/Game.py index e25fc47..9cd5d75 100644 --- a/Game.py +++ b/Game.py @@ -37,7 +37,16 @@ class Game: # self.pet.update(delta, self.player, self.camera_pos) def draw(self, surf): +<<<<<<< Updated upstream screen.fill((255, 255, 255)) +======= + screen.fill((0, 191, 255)) + # screen.fill((255,255,255)) + # sky = pg.image.load("Assets/world/SKY.png") + # surf.blit(sky,(0,0)) + + self.world.draw(surf) +>>>>>>> Stashed changes for enemy in self.enemies: enemy.draw(surf) for block in self.blocks: diff --git a/Levels/Level1.txt b/Levels/Level1.txt new file mode 100644 index 0000000..bd67621 --- /dev/null +++ b/Levels/Level1.txt @@ -0,0 +1,15 @@ +none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world +1400.0,700.0|1300.0,750.0|1350.0,700.0|1300.0,700.0|1250.0,700.0|1250.0,750.0|1200.0,700.0|1050.0,700.0|1000.0,700.0|950.0,700.0|900.0,700.0|850.0,700.0|800.0,700.0|750.0,700.0|700.0,700.0|650.0,700.0|600.0,700.0|550.0,700.0|500.0,700.0|450.0,700.0|400.0,700.0|350.0,700.0|300.0,700.0|250.0,700.0|200.0,700.0|150.0,700.0|100.0,700.0|50.0,700.0|0.0,700.0|0.0,750.0|50.0,750.0|100.0,750.0|1100.0,700.0|1150.0,700.0|1200.0,750.0|1150.0,750.0|1100.0,750.0|1050.0,750.0|1000.0,750.0|800.0,750.0|750.0,750.0|700.0,750.0|650.0,750.0|600.0,750.0|250.0,750.0|200.0,750.0|150.0,750.0|1450.0,650.0|1500.0,650.0|1750.0,650.0|1800.0,650.0|1850.0,650.0|1900.0,650.0|1950.0,650.0|2000.0,650.0|2050.0,650.0|2050.0,700.0|2000.0,700.0|1950.0,700.0|1900.0,700.0|1850.0,700.0|1800.0,700.0|1700.0,650.0|1650.0,650.0|1600.0,650.0|1550.0,650.0|1750.0,700.0|1700.0,700.0|1650.0,700.0|1600.0,700.0|1550.0,700.0|1500.0,700.0|1450.0,700.0|2100.0,700.0|2500.0,700.0|2500.0,650.0|2500.0,600.0|2550.0,600.0|2550.0,650.0|2550.0,700.0|2600.0,700.0|2600.0,650.0|2600.0,600.0|2450.0,750.0|2650.0,750.0|2600.0,750.0|2550.0,750.0|2500.0,750.0|2300.0,800.0|2350.0,800.0|2400.0,800.0|2450.0,800.0|2500.0,800.0|2550.0,800.0|2600.0,800.0|2650.0,800.0|2650.0,850.0|2600.0,850.0|2250.0,800.0|2250.0,850.0|2300.0,850.0|2350.0,850.0|2400.0,850.0|2450.0,850.0|2500.0,850.0|2550.0,850.0|2650.0,900.0|2600.0,900.0|2550.0,900.0|2500.0,900.0|2450.0,900.0|2400.0,900.0|2350.0,900.0|2300.0,900.0|2250.0,900.0|2200.0,900.0|2150.0,900.0|2100.0,900.0|2050.0,900.0|2000.0,900.0|1950.0,900.0|1900.0,900.0|1750.0,900.0|1700.0,900.0|1650.0,900.0|1600.0,900.0|1550.0,900.0|1500.0,900.0|1450.0,900.0|1400.0,900.0|1350.0,900.0|1300.0,900.0|1250.0,900.0|1200.0,900.0|1150.0,900.0|1100.0,900.0|1050.0,900.0|1000.0,900.0|950.0,900.0|900.0,900.0|850.0,900.0|800.0,900.0|750.0,900.0|700.0,900.0|650.0,900.0|600.0,900.0|550.0,900.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,900.0|50.0,900.0|100.0,900.0|150.0,900.0|200.0,900.0|250.0,900.0|300.0,900.0|350.0,900.0|400.0,900.0|450.0,900.0|500.0,900.0|500.0,850.0|550.0,850.0|600.0,850.0|650.0,850.0|700.0,850.0|750.0,850.0|800.0,850.0|850.0,850.0|900.0,850.0|1000.0,850.0|1050.0,850.0|1100.0,850.0|1150.0,850.0|1200.0,850.0|1250.0,850.0|1300.0,850.0|1350.0,850.0|1400.0,850.0|1450.0,850.0|1500.0,850.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|950.0,850.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,800.0|2200.0,800.0|2200.0,850.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1300.0,800.0|1250.0,800.0|1200.0,800.0|1150.0,800.0|1100.0,800.0|1050.0,800.0|1000.0,800.0|750.0,800.0|700.0,800.0|650.0,800.0|600.0,800.0|250.0,800.0|200.0,800.0|150.0,800.0|100.0,800.0|50.0,800.0|0.0,800.0|300.0,750.0|350.0,750.0|400.0,750.0|450.0,750.0|500.0,750.0|550.0,750.0|850.0,750.0|900.0,750.0|950.0,750.0|1350.0,750.0|1400.0,750.0|1450.0,750.0|1500.0,750.0|1550.0,750.0|1600.0,750.0|1650.0,750.0|1700.0,750.0|1750.0,750.0|1800.0,750.0|1850.0,750.0|1900.0,750.0|1950.0,750.0|2000.0,750.0|2050.0,750.0|2100.0,750.0|2150.0,750.0|1350.0,800.0|2100.0,650.0|950.0,800.0|900.0,800.0|850.0,800.0|800.0,800.0|550.0,800.0|500.0,800.0|450.0,800.0|400.0,800.0|350.0,800.0|300.0,800.0|800.0,550.0|750.0,550.0|750.0,600.0|800.0,600.0|850.0,600.0|1700.0,850.0|1600.0,950.0|1650.0,950.0|1700.0,950.0|1600.0,1000.0|1650.0,1000.0|1700.0,1000.0|1750.0,1000.0|1800.0,1000.0|1850.0,1000.0|1850.0,900.0|1800.0,900.0|1750.0,950.0|1800.0,950.0|1850.0,950.0|1900.0,950.0|1900.0,1000.0|1950.0,1000.0|2000.0,1000.0|1950.0,950.0|2000.0,950.0|2050.0,950.0|2200.0,1000.0|2150.0,1000.0|2100.0,1000.0|2050.0,1000.0|2100.0,950.0|2150.0,950.0|2200.0,950.0|2250.0,950.0|2300.0,950.0|2350.0,950.0|2400.0,950.0|2450.0,950.0|2500.0,950.0|2550.0,950.0|2600.0,950.0|2650.0,950.0|2650.0,1000.0|2600.0,1000.0|2550.0,1000.0|2500.0,1000.0|2450.0,1000.0|2400.0,1000.0|2350.0,1000.0|2300.0,1000.0|2250.0,1000.0|0.0,650.0|50.0,650.0|100.0,650.0|150.0,650.0|200.0,650.0|250.0,650.0|300.0,650.0|350.0,650.0|400.0,650.0|450.0,650.0|500.0,650.0|550.0,650.0|600.0,650.0|650.0,650.0|700.0,650.0|750.0,650.0|800.0,650.0|850.0,650.0|900.0,650.0|950.0,650.0|1000.0,650.0|1050.0,650.0|1100.0,650.0|1150.0,650.0|1200.0,650.0|1250.0,650.0|1300.0,650.0|1350.0,650.0|1400.0,650.0|1450.0,600.0|1500.0,600.0|1550.0,600.0|1600.0,600.0|1650.0,600.0|1700.0,600.0|1750.0,600.0|1800.0,600.0|1850.0,600.0|1900.0,600.0|1950.0,600.0|2000.0,600.0|2050.0,600.0|2100.0,600.0|2150.0,650.0|2150.0,700.0|2200.0,750.0|2250.0,750.0|2300.0,750.0|2350.0,750.0|2550.0,550.0|2600.0,550.0|2650.0,550.0|2650.0,600.0|2650.0,650.0|2650.0,700.0|700.0,600.0|2050.0,550.0|2400.0,750.0|2450.0,600.0|2450.0,650.0|2450.0,700.0|2500.0,550.0 +DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONE|DIRT|STONE|STONE|STONE|STONEDIRT|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|DIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONE|STONE|STONE|PLAYER|ENEMY|STONEDIRT|STONE|STONE|STONE|STONE + + + + + + + + + + + + diff --git a/Player.py b/Player.py index 437e20d..12e606a 100644 --- a/Player.py +++ b/Player.py @@ -7,14 +7,51 @@ from Actors import Actor class Player(Actor): width, height = 25, 50 colour = (52, 94, 235) +<<<<<<< Updated upstream speed = 0.2 jump_strength = 0.9 gravity = 0.098 friction = 0.7 +======= +>>>>>>> Stashed changes def __init__(self, pos, collision_layer, collision_mask): super().__init__(pos, collision_layer, collision_mask) +<<<<<<< Updated upstream # self.areas = {"body":Area(self.position, pg.Vector2(0, self.height/2),self.width, self.height/2,Actor)} +======= + # self.initial_position = pg.Vector2(pos) + self.dashCooldown = timedelta(seconds=2, microseconds=500000) + self.timeBetweenDoublePress = timedelta(seconds=0, microseconds=500000) + self.dashSpeed = 10 + + self.dashPossible = True + self.lastDash = datetime.utcnow() + self.lastPressedLeft = datetime.utcnow() + self.lastValueL = False + self.lastPressedRight = datetime.utcnow() + self.lastValueR = False + self.areas = {"body": Area(self.position, pg.Vector2(0, self.height / 2), self.width, self.height / 2, Actor), + "head": Area(self.position, pg.Vector2(self.width * 1 / 3 * 1 / 2, -2), self.width * 2 / 3, 25, + Actor)} + + self.potion_cooldown = 0 + self.starting_potions = 999 + self.potion_bag = [Potion(self)] + for i in range(self.starting_potions): + self.potion_bag.append(Potion(self)) # use one liner + + self.weapon = Melee(self.position, (-Melee.width / 2 + 7, Melee.height / 2 + self.height / 3 - 8), + (-5, Melee.height), self.width, -1, -25) + self.targets = can_hurt + + self.direction = -1 + + self.state = "IDLE" + self.current_frame = 0 + self.display = self.idle_frames[0] + self.display_offsets = {"weapon": pg.Vector2(0, 0)} +>>>>>>> Stashed changes def update(self, delta): super().update(delta) @@ -23,8 +60,45 @@ class Player(Actor): self.handle_input() # Deals with collision and applying velocity +<<<<<<< Updated upstream self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity, delta) return self.velocity * delta +======= + self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta) + + prev_direction = self.direction + if self.velocity.x == 0: + self.direction = 0 + else: + self.direction = math.copysign(1, self.velocity.x) + self.weapon.update(delta, self.position, self.direction) + + if self.state == "IDLE": + frame = math.floor(self.current_frame) + if self.direction == 1: + self.display = self.idle_frames[math.floor(frame)] + elif self.direction == -1: + self.display = pg.transform.flip(self.idle_frames[math.floor(frame)], True, False) + else: + if prev_direction == 1: + self.display = self.idle_frames[math.floor(frame)] + elif prev_direction == -1: + self.display = pg.transform.flip(self.idle_frames[math.floor(frame)], True, False) + self.direction = prev_direction + # 1 - 10 up, 11 down by 1, 12 - 18 down by 2, 19-20 down 1 FIX THIS + frame += 1 + if 1 < frame < 10: + self.display_offsets["weapon"] = pg.Vector2(0, 2) + elif frame == 11 or frame == 19 or frame == 20: + self.display_offsets["weapon"] = pg.Vector2(0, 1) + else: + self.display_offsets["weapon"] = pg.Vector2(0, 0) + self.current_frame = (self.current_frame + 0.1) % len(self.idle_frames) + + print() + return self.position - pg.Vector2(SCREEN_WIDTH/3, SCREEN_HEIGHT / 2) + +>>>>>>> Stashed changes def handle_input(self): pressed = pygame.key.get_pressed() diff --git a/Setup.py b/Setup.py index c3dfdcf..8b17df9 100644 --- a/Setup.py +++ b/Setup.py @@ -27,9 +27,25 @@ def rotate(pos, img, angle, pivot): rot_rect = rot_img.get_rect(center=vec) return rot_img, rot_rect -camera_offset = pg.Vector2(0,0) +camera_offset = center.copy() + +MAP_WIDTH, MAP_HEIGHT = 10000,10000 def get_display_rect(collision_rect): + camera_offset.x = max(0, min(camera_offset.x, MAP_WIDTH - SCREEN_WIDTH)) + camera_offset.y = max(0, min(camera_offset.y, MAP_HEIGHT - SCREEN_HEIGHT)) + pos = collision_rect.topleft width, height = collision_rect.w, collision_rect.h return pg.Rect(pos - camera_offset, (width, height)) +<<<<<<< Updated upstream +======= + # return pg.Rect(pos, (width, height)) + +def get_display_point(vec): + camera_offset.x = max(0, min(camera_offset.x, MAP_WIDTH - SCREEN_WIDTH)) + camera_offset.y = max(0, min(camera_offset.y, MAP_HEIGHT - SCREEN_HEIGHT)) + return vec - camera_offset + +from Area import Area +>>>>>>> Stashed changes