Git Product home page Git Product logo

Comments (8)

mb6ockatf avatar mb6ockatf commented on June 13, 2024 2

@IvanIsak2000 btw are you Russian? Just noticed your Windows interface is Russian

from doodle-jump.

mb6ockatf avatar mb6ockatf commented on June 13, 2024 1

@mb6ockatf

I don't understand, the main.py file is in src, is that correct?

image

Yes, that's correct. And this file main.py is supposed to be launched from project's root folder
i.e.

$ pwd  # check current directory path
/home/username/projects/doodle-jump  # we're in project's root
$ python3 src/main.py  # launch the game
# starts successfully

Otherwise, relative imports don't work. Here's an error you get:

$ pwd  # check current directory path
/home/mb6ockatf/projects/doodle-jump/src  # note, we're now in `doodle-jump/src`
$ python3 main.py  # raises an error, as it cannot access resources in `doodle-jump/data`
file 'data/bird_left.png' not found
Traceback (most recent call last):
  File "/home/username/projects/doodle-jump/src/main.py", line 108, in <module>
    gamekeeper = Gamekeeper()
  File "/home/username/projects/doodle-jump/src/main.py", line 35, in __init__
    self.hopalong = Hopalong(self.players, sprite_name, display_sizes)
  File "/home/username/projects/doodle-jump/src/sprites/hopalong.py", line 36, in __init__
    sprite_left = load_image(self.name + "_left.png")
  File "/home/username/projects/doodle-jump/src/tools/funcs.py", line 16, in load_image
    image = pygame.image.load(fullname)
FileNotFoundError: No file 'data/bird_left.png' found in working directory '/home/username/projects/doodle-jump/src'.

I tried my best when organising imports in this project. If you find a way to improve it, @IvanIsak2000, please create a PR for that

from doodle-jump.

mb6ockatf avatar mb6ockatf commented on June 13, 2024 1

Conclusion

What can be done:

  • specify the way the game is supposed to be launched more precisely in README.md

  • improve imports

  • create a bash script in project's root, and write in README.md that the game is supposed to be launched this way

One of these should fix it

from doodle-jump.

mb6ockatf avatar mb6ockatf commented on June 13, 2024

@IvanIsak2000 please check if you're running python3 src/main.py in project's root folder, not python3 main.py in /src folder.
That's because sprites are located out of /src folder, in /data

from doodle-jump.

IvanIsak2000 avatar IvanIsak2000 commented on June 13, 2024

@IvanIsak2000 please check if you're running python3 src/main.py in project's root folder, not python3 main.py in /src folder. That's because sprites are located out of /src folder, in /data

That's right, I open main and gives an error :(

from doodle-jump.

IvanIsak2000 avatar IvanIsak2000 commented on June 13, 2024

@mb6ockatf

I don't understand, the main.py file is in src, is that correct?

image

from doodle-jump.

IvanIsak2000 avatar IvanIsak2000 commented on June 13, 2024

@mb6ockatf
I don't understand, the main.py file is in src, is that correct?
image

Yes, that's correct. And this file main.py is supposed to be launched from project's root folder i.e.

$ pwd  # check current directory path
/home/username/projects/doodle-jump  # we're in project's root
$ python3 src/main.py  # launch the game
# starts successfully

Otherwise, relative imports don't work. Here's an error you get:

$ pwd  # check current directory path
/home/mb6ockatf/projects/doodle-jump/src  # note, we're now in `doodle-jump/src`
$ python3 main.py  # raises an error, as it cannot access resources in `doodle-jump/data`
file 'data/bird_left.png' not found
Traceback (most recent call last):
  File "/home/username/projects/doodle-jump/src/main.py", line 108, in <module>
    gamekeeper = Gamekeeper()
  File "/home/username/projects/doodle-jump/src/main.py", line 35, in __init__
    self.hopalong = Hopalong(self.players, sprite_name, display_sizes)
  File "/home/username/projects/doodle-jump/src/sprites/hopalong.py", line 36, in __init__
    sprite_left = load_image(self.name + "_left.png")
  File "/home/username/projects/doodle-jump/src/tools/funcs.py", line 16, in load_image
    image = pygame.image.load(fullname)
FileNotFoundError: No file 'data/bird_left.png' found in working directory '/home/username/projects/doodle-jump/src'.

I tried my best when organising imports in this project. If you find a way to improve it, @IvanIsak2000, please create a PR for that

OK, I launched the app, as you said, it's great!

from doodle-jump.

mb6ockatf avatar mb6ockatf commented on June 13, 2024

actialy fixed in #30

from doodle-jump.

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.