<div id="mb_0">
<div>First off, here is the code I am working with so far.</div>
<div> </div>
<div>import random<br>from livewires import games, color</div>
<p>games.init(screen_width = 640, screen_height = 480, fps = 50)</p>
<p>controls = "Use The Arrow Keys to Move and the Spacebar to Shoot"</p>
<p> </p>
<p>game_controls = games.Message(value = controls,<br> size = 25,<br> color = color.black,<br> x = 320,<br> y = 240,<br> lifetime = 250)<br>
Motivation_status = "Motivation:"</p>
<p> </p>
<p>motivation_text = games.Text(value = Motivation_status,<br> size = 20,<br> color = color.black,<br> x = 30,<br> y = 30)<br> <br>
<br>motivation = 5</p>
<p>score = games.Text(value = motivation, size = 25, color = color.black,<br> x = 90, y = 30)</p>
<p>class Evil_stickman(games.Sprite):</p>
<p> missile_wait = 0<br> def update(self):<br> <br> self.shoot()</p>
<p> def shoot(self):<br> if self.missile_wait > 0:<br> self.missile_wait -= 1<br> if self.missile_wait == 0:<br> missile_image = games.load_image("Missile.bmp", transparent = True)<br>
new_missile = Bad_Missile(image = missile_image, x = self.x - 10, y = self.y - 3, angle = 270)<br> games.screen.add(new_missile) <br> self.missile_wait = 20<br> <br> def Die(self):<br>
self.destroy()<br> <br>class Rolling(games.Sprite):</p>
<p> def update(self):</p>
<p><br> if self.x > 0:<br> self.x -= 1<br> self.angle += 2<br> else:<br> self.destroy()</p>
<p><br>class Missile(games.Sprite):</p>
<p> </p>
<p><br> def update(self): <br> </p>
<p> if self.x < 640:<br> self.x += 2<br> else:<br> self.destroy()</p>
<p>class Bad_Missile(games.Sprite):</p>
<p><br> def update(self): <br> </p>
<p> if self.x > 0:<br> self.x -= 2<br> else:<br> self.destroy()</p>
<p>class Stickman(games.Sprite):</p>
<p> missile_wait = 0<br> level_number = 1<br> def update(self):</p>
<p> if games.keyboard.is_pressed(games.K_RIGHT):</p>
<p> self.x += 1<br> if self.missile_wait > 0:<br> self.missile_wait -= 1</p>
<p> if games.keyboard.is_pressed(games.K_LEFT):<br> if self.x >= 0:<br> self.x -= 1<br> <br> if games.keyboard.is_pressed(games.K_q):<br> games.screen.quit() </p>
<p> if games.keyboard.is_pressed(games.K_UP):<br> if self.y >= 280:<br> self.y -= 1 <br> <br> if games.keyboard.is_pressed(games.K_DOWN):<br> if self.y <= 460:<br>
self.y += 1 <br> </p>
<p> if games.keyboard.is_pressed(games.K_SPACE) and self.missile_wait == 0:<br> missile_image = games.load_image("Missile.bmp", transparent = True)<br> new_missile = Missile(image = missile_image, x = self.x + 20, y = self.y - 2, angle = 90)<br>
games.screen.add(new_missile)<br> self.missile_wait = 25</p>
<p> if self.level_number == 1:<br> evilstick_image = games.load_image("badguy.bmp", transparent = True)</p>
<p><br> <br> new_evilstick01 = Evil_stickman(image = evilstick_image, x = 580, y = 400)<br> games.screen.add(new_evilstick01) </p>
<p> </p>
<p> </p>
<p> if motivation == 0:<br> self.destroy()<br> <br>class Introduction(games.Sprite):</p>
<p> def update(self):<br> if games.keyboard.is_pressed(games.K_RETURN):<br> self.destroy() <br> games.screen.add(the_stick)<br> games.screen.add(game_controls)</p>
<p><br>intro_sprite_image = games.load_image("Introduction.bmp", transparent = False)<br>intro_sequence = Introduction(image = intro_sprite_image, x = 340, y = 240)</p>
<p>games.screen.add(intro_sequence)</p>
<p><br>wall_image = games.load_image("the-map.bmp", transparent = False)<br>games.screen.background = wall_image</p>
<p>stickman_image = games.load_image("stickman.bmp", transparent = True)<br>the_stick = Stickman(image = stickman_image, x = 60, y = 380, angle = 90)</p>
<p> </p>
<p><br>games.screen.mainloop()<br> </p>
<p>The Evil_stickman class seems to have a problem with it. I have added the missile delay in the hope that he would fire missiles about 2 times every second, but instead, he shoots a constant stream. In addition, he slows my entire game down. What is the problem with the code? And how might I go about fixing it?</p>
</div>