0

Essentially, what is happening is that every other attempt to load my main game file, the kernel crashes. I'm not sure what the problem is exactly (because I'm not getting any feedback pointing to an error), but since I have begun incorporating a font into my game, the kernel has been crashing regularly.

I have commented out all the code pertaining to rendering and initializing the font, and the kernel and game I am working on runs great. I primarily use Spyder if that's relevant.

import pygame

pygame.font.init()

class Player(object):

    font = pygame.font.SysFont('Arial', 15)

    text = [font.render('Cricket', True, (0, 0, 0)),
            font.render('ATK', True, (0, 0, 0)),
            font.render('MG', True, (0, 0, 0)),
            font.render('', True, (255, 255, 255)),
            font.render('', True, (255, 255, 255))]

    def __init__(self):
       blah blah

    def display_UI(self, _display_surf):

        pygame.draw.rect(_display_surf, self.ui_display_color, (self.ui_rect))

        _display_surf.blit(self.text[0], (128, 12))
        _display_surf.blit(self.text[1], (128, 48))

        _display_surf.blit(self.health_bar[self.health_count], (self.health_bar_x, self.health_bar_y))

Somewhere in here is essentially where the problem is, or at least I would imagine so, unless there's a problem with updating a library, but I'm really not sure because I have had no feedback.

I'm hoping this is an easy fix, but I really have no idea what's going on. Like I said, every other time, my main game file which I have imported this class to, runs fine, renders the font, and no errors are found. Other times, the error "Kernel died, restarting" happens. Thanks for any and all feedback.

martineau
  • 119,623
  • 25
  • 170
  • 301
John
  • 15
  • 5
  • I forgot to include this at the top: import pygame pygame.font.init() class Player(object): – John Apr 28 '19 at 20:01
  • 1
    try to run it directly in terminal/console/cmd.exe without Spyder. Maybe you will see error message. And you will be sure that problem is your code, not `Spyder` – furas Apr 28 '19 at 20:04
  • I just launched it through the command prompt with absolutely no issues several times, so I am willing to bet, it's more than likely an issue with Spyder. I'm still unsure how to fix this particular issue, but I appreciate your help and this will definitely help me figure out where to go from here! – John Apr 29 '19 at 19:00
  • you can run Spyder in command prompt and maybe it will display some error message. And then you can send it to [Spyder's Issues](https://github.com/spyder-ide/spyder/issues). Currently you can only use different IDE (ie, [PyCharm](https://www.jetbrains.com/pycharm/), [Visual Studio Code](https://code.visualstudio.com/), etc.) or text editor (ie. Notepad, Notepad++, Vim, Emacs, Sublime Text, Geany, etc.) – furas Apr 29 '19 at 21:42

0 Answers0