def gameLogic(): global score, GameOver # create black screen screen.fill((0, 0, 0)) screen.blit(background_img, (0, 0)) Inputs() Player.Update(screen, player_img) Enemy.Update(screen, enemy_img) Bullet.Update(screen, bullet_img) for i in range(num_of_enemy): for j in range(Bullet.MaxSize): on_EnemyCollision = Collision(Bullet.bullet_x[j], Bullet.bullet_y[j], Enemy.enemy_x[i], Enemy.enemy_y[i]) if (on_EnemyCollision): collided_Enemy = i explosion_Sound.play() Bullet.Reset(j) score += 100 Enemy.Reset(collided_Enemy) on_collisionWithPlayer = Collision(Player.pos_X, Player.pos_Y, Enemy.enemy_x[i], Enemy.enemy_y[i]) if (on_collisionWithPlayer): GameOver = True explosion_Sound.play()
def update(frameTime): global jimmy if (frameTime < 0.1): Bullet.Update(frameTime) StageManager.Update(frameTime) jimmy.Update(frameTime) for i in Bullet.BulletList: jimmy.CollisionCheck_Bullet(i) for i in StageManager.MonsterList[StageManager.curStage]: jimmy.CollisionCheck_Character(i) for i in Bullet.BulletList: for j in StageManager.MonsterList[StageManager.curStage]: j.CollisionCheck_Bullet(i) EffectManager.Update(frameTime) CoinManager.Update(frameTime, jimmy) #수정해주기 if not jimmy.alive: delay(0.2) game_framework.change_state(bad_end_state) if StageManager.happy_end: delay(0.2) game_framework.change_state(happy_end_state) delay(0.01)