May-06-2023, 06:29 PM
(This post was last modified: May-06-2023, 06:51 PM by deanhystad.)
Im sorry i tried it yesterday (back there it works). Thats the correct link (for now :D) https://github.com/wired88/Best-Space-Invaders-.git
For the reason that it does not work here is the code for the Boss (Death-Star):
@deanhystead
@Larz60+
the code is for counting when the alens shoud shoot
#2 than i create a bullet and add it to the bullet group
#3 here i say if the time (the death star is shootuing) > cooldown(2sec):
the timer is 0 so it can begin again ( and till the 2seconds over the method add every loop run a bullet to grop so that it looks like a laser beam)
I mean its very logical to understand why the game is running so slow but like i sayd in the post above i dont know how to handle the laser beam without adding multiple bullets.
For the reason that it does not work here is the code for the Boss (Death-Star):
@deanhystead
@Larz60+
class BossSpaceship(Spaceships): def __init__(self, x, y): image = "death-star.png" speed = 1 lives = 3 shoot_count = 600 cooldown = 2000 speed_y = 100 sound = 'death-star_shoot_sound.mp3' super().__init__(image, speed, lives, shoot_count, x, y, cooldown, 2, sound, speed_y) def shoot(self, current_time, h_group, bullet_group, volume): if current_time - self.last_shot > self.shoot_count and len(h_group) > 0: #1 shooting_sound = mixer.Sound(f'sounds/{self.sound}') shooting_sound.play() shooting_sound.set_volume(volume) bullet = Bullet(self.rect.centerx, self.rect.bottom, "death_star_laser1.png", math.pi/2, 10, 0) bullet_group.add(bullet) #2 if current_time - self.last_shot > self.cooldown: #3 self.last_shot = current_time#1 current time is definied in game loop(with a different name) and says current_time = pygame.time.get_ticks()
the code is for counting when the alens shoud shoot
#2 than i create a bullet and add it to the bullet group
#3 here i say if the time (the death star is shootuing) > cooldown(2sec):
the timer is 0 so it can begin again ( and till the 2seconds over the method add every loop run a bullet to grop so that it looks like a laser beam)
I mean its very logical to understand why the game is running so slow but like i sayd in the post above i dont know how to handle the laser beam without adding multiple bullets.
deanhystad write May-06-2023, 06:51 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.