Giter Site home page Giter Site logo

font declaration error about masendor HOT 24 OPEN

remance avatar remance commented on May 16, 2024
font declaration error

from masendor.

Comments (24)

Python-Sargent avatar Python-Sargent commented on May 16, 2024

This may be an error with normal pygame messing with pygame_ce.

For example, I get this error, which descriptly says (with a comment) that it's for pygame_ce:

self.battle_map.draw_image(self.battle_base_map, self.battle_feature_map, place_name_map, self.camp_pos)
  File "C:\Users\user\Documents\Masendor\Masendor-0.7.3.1\engine\battlemap\battlemap.py", line 242, in draw_image
    self.image = pygame.transform.gaussian_blur(self.image, radius=4)  # pygame.ce only, a bit faster
AttributeError: module 'pygame.transform' has no attribute 'gaussian_blur'

you may want to import these differently to fix this, I'm not sure how pygame_ce works.

Note: I'm using the package version for now.

And I can't just uninstall pygame as I use it for some of my other projects.

from masendor.

remance avatar remance commented on May 16, 2024

Hmm yeah those errors are likely to be because of Pygame and pygame-ce being installed both. Your system probably pick pygame for the game. Maybe it is better to stick with Pygame. I assume the package version works fine for you?

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

No, since I'm using the package version I'm not sure what you saying.

I'm not sure how I should get it to work with just pygame.

delete the gaussion_blur() line in battlemap.py?

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

I commented all calls to the blur function, and I get:

pickle.dump(new_data, handle)
  File "C:\Users\user\Documents\Masendor\Masendor-0.7.3.1\engine\data\datacacher.py", line 53, in __getstate__
    return (pygame.image.tobytes(self.surface, "RGBA"), self.surface.get_size())
AttributeError: module 'pygame.image' has no attribute 'tobytes'

Another pygame_ce usage, maybe.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

any way to import pygame_ce in main instead of change all the calls in the various files?

from masendor.

remance avatar remance commented on May 16, 2024

any way to import pygame_ce in main instead of change all the calls in the various files?

I am not sure. It should be easy to change requirements and some part of code from using pygame-ce to just pygame. But probably not possible to do specific import like you mentioned.

from masendor.

remance avatar remance commented on May 16, 2024

Ok the new update change pygame-ce requirement to pygame and fix parts of the error you reported. The game should work now on your end. Let me know how it goes.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

Still getting the tobytes error:

File "C:\Users\user\Documents\GitHub\Masendor\engine\data\datacacher.py", line 53, in __getstate__
    return (pygame.image.tobytes(self.surface, "RGBA"), self.surface.get_size())
AttributeError: module 'pygame.image' has no attribute 'tobytes'

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

I also had to fix the missing files error again, but it was pretty easy to do.

From what it looks like all the files are there but aren't named in a way that the engine is looking for.

from masendor.

remance avatar remance commented on May 16, 2024

Hmm weird, I never get this error before. By the way you probably should uninstall pygame-ce now in case there are conflicts with normal pygame. Also for reference, what OS are you using?

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

I'm using Windows 10 because my PC is broke. It's an old Lenovo laptop.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

Another bug here, must be a nil variable or something:

File "C:\Users\user\Documents\GitHub\Masendor\engine\game\create_troop_sprite_pool.py", line 308, in create_sprite
    animation_sprite_pool[sprite_id] = load_pickle_with_surfaces(cache_file_path)
  File "C:\Users\user\Documents\GitHub\Masendor\engine\data\datacacher.py", line 36, in load_pickle_with_surfaces
    data = pickle.load(handle)
EOFError: Ran out of input

from masendor.

remance avatar remance commented on May 16, 2024
EOFError: Ran out of input

Seem to be an issue of empty cache file. Maybe the game crashed or closed while the cache data being stored. A quick fix would be to remove cache folder in the game folder. But thanks for mentioning this, need to add a function to catch this error in game code so the game can recreate cache file again.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

Deleting cache doesn't do anything. Also, I don't think it was because of a crash corruption, seeing as I've never gotten far enough to totally load anything that should be cached.

from masendor.

remance avatar remance commented on May 16, 2024

That is weird because "data = pickle.load(handle)" is for cache file loading.

Still getting the tobytes error:

File "C:\Users\user\Documents\GitHub\Masendor\engine\data\datacacher.py", line 53, in __getstate__
    return (pygame.image.tobytes(self.surface, "RGBA"), self.surface.get_size())
AttributeError: module 'pygame.image' has no attribute 'tobytes'

Do you still get this error also? Can you post your python package? Maybe it is issue of incompatible pygame version.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

I'm using everything latest.

I'm not sure what else is causing it to crash.

Python 3.10.4
Name: pygame
Version: 2.5.0
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: [email protected]
License: LGPL
Location: c:\users\user\appdata\local\programs\python\python310\lib\site-packages
Requires:
Required-by: pgzero

from masendor.

remance avatar remance commented on May 16, 2024

The error makes no sense because tobytes is a function for pygame.image for both normal Pygame and Pygame-ce. Maybe worth making new clean virtual environment?

https://pyga.me/docs/ref/image.html#pygame.image.tobytes

https://www.pygame.org/docs/ref/image.html#pygame.image.tobytes

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

pardon my stupidity, but why do people put 'extra' dots (.) in URLs, is that a european thing or somthing?

Also, I using vanilla Python 3, so it's not with a virtualenv, I'm using the version I installed on the system.

from masendor.

remance avatar remance commented on May 16, 2024

Dunno about URL extra dots to be honest. Probably related to domain or specific HTML structure or something.

I would recommend you setup virtualenv for each project or maybe, one for your working and one for other purposes. That way it will be much easier to avoid package issues and a bit easier to organise.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

Same error with virtualenv.

Not sure what's wrong.

Note: I followed your advice and this is a local virtualenv, in the Masendor directory.

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

I reset it and changed the requirements.txt to show pygame_ce~=2.3.1.

Re-ran the pip install in a new virtualenv, and crashed like before.

from masendor.

remance avatar remance commented on May 16, 2024

So it crash for both pygame-ce and normal pygame? Both same error? I assume it the AttributeError: module 'pygame.image' has no attribute 'tobytes'

from masendor.

Python-Sargent avatar Python-Sargent commented on May 16, 2024

Yes, sorry for not being clear.

from masendor.

remance avatar remance commented on May 16, 2024

Very weird for sure, wonder what the issue stem from.

from masendor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.