Done!

I got everything I'd hoped for finished on Saturday. The high-scores save, and the menus are complete, and I got around to adding changeable units (except for the revs – everything internally (except the engine torque curve) is calculated in rad/s, but I don't think many people would use this option!).

I don't think there is anything in particular that people might need to know before playing the game, other than what's already in README.md, but feel free to leave a comment on this post if you have any questions.

(log in to comment)

Comments

Hi LeopardShark,


I'm getting a crash when trying to click on a level to start "choose a level": the game hangs for about 20 seconds, then:

Traceback (most recent call last):

  File "main.py", line 200, in <module>

    main()

  File "main.py", line 55, in main

    if level_select(LOADING):

  File "main.py", line 126, in level_select

    game.play_level(S, level, leveldata[level][2], scores[level], leveldata[level][1], int(leveldata[level][0]), LOADING)

  File "game.py", line 79, in play_level

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

  File "game.py", line 79, in <listcomp>

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

IndexError: list index out of range


Any pointers? I'm running on osx 10.13, python 3.6.2.


Hi mit-mit,

I think I know, very roughly, what is causing this, as a similar bug happened during development a couple of times. Basically, when the game loads a track (which is stored as an image), it searches through it for twelve pixels of specific colours to determine where the checkpoints and start-finish are. This error means that it couldn't find all of them. In development that meant I'd placed the checkpoints wrong on the images, but since I re-downloaded and checked it on my machine (and I couldn't reproduce it), I think there are two other likely causes for this problem:
  1. The track image files are somehow corrupted.
  2. The image is not loading properly.
  3. There is some difference in how colour in Pygame surfaces is handled on OS X.
Trying a different track might fix it if the image is corrupted. Do you see the loading bar (like this https://i.imgur.com/txuS4gU.png) scroll across? You could also try adding "    print([checks, checkpoints, CHECK_COLS, mapsize])" to the 73rd line of game.py, which you can see here:
    for checkpoint in checkpoints:
      checks[checkpoint[0]].append(checkpoint[1])
print([checks, checkpoints, CHECK_COLS, mapsize]) # ADDED LINE
    leave = False

The output might be useful.
Thanks you!

Sorry for the somewhat late reply.
Here's the print I get back:


[[[], [(2862, 4544), (2903, 4460)], [(17, 99), (97, 146)], [(4482, 620), (4571, 594)], [], []], [(2, (17, 99)), (2, (97, 146)), (1, (2862, 4544)), (1, (2903, 4460)), (3, (4482, 620)), (3, (4571, 594))], {-256: 0, 65280: 1, 16776960: 2, 16711680: 3, -65536: 4, -16777216: 5}, (7053, 4556)]

I don't get a load screen at all: I click on the track and the screen straight away freezes: same happens on all tracks.


This is weird: The coloured checkpoints it couldn't find are those with a blue value pixel of 255. It seemed that Pygame map_rgb()'d those colours to negative values, which seems to break the checking for some reason. I think this is a Pygame bug, but this version should work-around it. I've changed all the checkpoints' colour values to have zero as the blue component, so they should all map properly.
I unfortunately can't get any of the tracks to work :( this is the error I've gotten:

```

  File "main.py", line 200, in <module>

    main()

  File "main.py", line 55, in main

    if level_select(LOADING):

  File "main.py", line 126, in level_select

    game.play_level(S, level, leveldata[level][2], scores[level], leveldata[level][1], int(leveldata[level][0]), LOADING)

  File "/Users/naly/Downloads/SixthGear/game.py", line 79, in play_level

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

  File "/Users/naly/Downloads/SixthGear/game.py", line 79, in <listcomp>

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

IndexError: list index out of range  File "main.py", line 200, in <module>

    main()

  File "main.py", line 55, in main

    if level_select(LOADING):

  File "main.py", line 126, in level_select

    game.play_level(S, level, leveldata[level][2], scores[level], leveldata[level][1], int(leveldata[level][0]), LOADING)

  File "/Users/naly/Downloads/SixthGear/game.py", line 79, in play_level

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

  File "/Users/naly/Downloads/SixthGear/game.py", line 79, in <listcomp>

    pos = [(checks[0][0][i] + checks[0][1][i]) / 2 for i in range(2)]

IndexError: list index out of range

```

Ah nevermind, should have read the other comment first!
Working now!


I've had this issue before. It's not technically a bug, but it's definitely unexpected behavior. The PNG image specification allows for built-in optional color correction, which means when you load a PNG image, the actual RGB pixel values may depend on your system's color settings, although in theory it should look more like the original image when displayed. For whatever reason in Pygame it only gets applied on Mac. My recommendation if you're going to use RGB values from images for level data, use BMPs, which don't have this feature.
OK, thank you. I'll bear that in mind in future!