Re: Audiogame Map with Python

The problem may be the order in which your doing your checks, for example if you try and check if the current position in maplist - 1 is "w" without first checking if thats in bounds of the map, it will throw a list index out of range exception. Try putting your out of bounds checks ahead of your type checks, for example:

                # Moving east
                if event.key == pygame.K_RIGHT:
                    if (self.currentPosition[1]+1 > len(self.mapList[0])-1
                        or self.mapList[self.currentPosition[0]][self.currentPosition[1]+1] == "w"):
                        s().output("Wall, can't go that way", interrupt=True)
                    elif self.mapList[self.currentPosition[0]][self.currentPosition[1]+1] == "p":
                        self.currentPosition[1] += 1
                        s().output("path", interrupt=True)


_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector

Reply via email to