Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display Globar Variable
#1
I'm building a simple racing game and I want to display a count of wall hits. I print count in the console and everything is OK (the number is changing) but doesn't change when I print on the screen.

https://github.com/Nomit83/RaceGame

If someone can look into my code and tell me what I'm doing wrong.
Reply
#2
you should make sure to use consistent names as linux is case sensitive
Error:
metulburr@ubuntu:~/Downloads/RaceGame-master$ python3.6 main.py 0 100.0 Traceback (most recent call last): File "main.py", line 107, in <module> g.run() File "main.py", line 66, in run self.draw() File "main.py", line 78, in draw self.draw_text('RESTARTS {}'.format(PLAYER_ONE_COUNT), self.title_font, 20, RED,WIDTH - 10, 5, align="ne") File "main.py", line 18, in draw_text font = pg.font.Font(font_name, size) OSError: unable to read font file 'img/VCR_OSD_MONO.TTF'
I would use the player class to have an attribute count that retains the number of wall hits that players has done. This would be better suited for a couple of reasons. 1) you plan on having more than one player and 2) its not static data and will be changing mid game. Your settings file would be better suited as static data that does not change mid game.

Your game class is well organized. However your player one file is not. It has the wall and collision global function in it. Your also using global in a class which is kind of weird. Why did you decided to the collision should be out of the player class?
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 45,906 May-06-2023, 08:14 AM
Last Post: pramod08728
  Store variable data and display sum after 60 seconds the_dude 11 3,442 Dec-16-2021, 07:07 PM
Last Post: deanhystad
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,222 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020