Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:34:32+00:00 2026-05-14T08:34:32+00:00

# INTIALISATION import pygame, math, sys from pygame.locals import * screen = pygame.display.set_mode((1024, 768))

  • 0
# INTIALISATION
import pygame, math, sys
from pygame.locals import *
screen = pygame.display.set_mode((1024, 768))
car = pygame.image.load('car.png')
clock = pygame.time.Clock()
k_up = k_down = k_left = k_right = 0
speed = direction = 0
position = (100, 100)
TURN_SPEED = 5
ACCELERATION = 2
MAX_FORWARD_SPEED = 10
MAX_REVERSE_SPEED = ­5
BLACK = (0,0,0)
while 1:
    # USER INPUT
    clock.tick(30)
    for event in pygame.event.get():
        if not hasattr(event, 'key'): continue
        down = event.type == KEYDOWN     # key down or up?
        if event.key == K_RIGHT: k_right = down * ­5
        elif event.key == K_LEFT: k_left = down * 5
        elif event.key == K_UP: k_up = down * 2
        elif event.key == K_DOWN: k_down = down * ­2
        elif event.key == K_ESCAPE: sys.exit(0)     # quit the game
    screen.fill(BLACK)
    # SIMULATION
    # .. new speed and direction based on acceleration and turn
    speed += (k_up + k_down)
    if speed > MAX_FORWARD_SPEED: speed = MAX_FORWARD_SPEED
    if speed < MAX_REVERSE_SPEED: speed = MAX_REVERSE_SPEED
    direction += (k_right + k_left)
    # .. new position based on current position, speed and direction
    x, y = position
    rad = direction * math.pi / 180
    x += ­speed*math.sin(rad)
    y += ­speed*math.cos(rad)
    position = (x, y)
    # RENDERING
    # .. rotate the car image for direction
    rotated = pygame.transform.rotate(car, direction)
    # .. position the car on screen
    rect = rotated.get_rect()
    rect.center = position
    # .. render the car to screen
    screen.blit(rotated, rect)
    pygame.display.flip()
    enter code here

the error i get is this Non-ASCII character ‘\xc2’ in file race1.py on line 13, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Not able to understand what the error is and how to get rid of it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:34:32+00:00Added an answer on May 14, 2026 at 8:34 am

    As Greg says, you have a non-ascii character in your code – what looks like a minus sign in front of the 5 on line 13. It is called ‘soft hyphen’. This character appears in a few locations in your code instead of minus signs. Delete these characters and replace with minus signs.

    Your code above doesn’t show the character. Don’t know why. When I copy and paste it into a text editor I can see the character.

    If you put an encoding comment at the top of you code, for example:

    # -*- coding: utf-8 -*-
    

    You will get a syntax error with the ‘soft hyphen’. So you need to replace them all with minus signs. (Then you won’t need the encoding comment at the top of the code.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues loading an image from an XML file. // // BookDetailViewController.m
I have some lisp initialisation code: (eval-when (:compile-toplevel :load-toplevel :execute) (require 'asdf)) (eval-when (:compile-toplevel
I made a custom cell with a XIB: .h #import <UIKit/UIKit.h> @interface TWCustomCell :
Hi I have the following class called CalculatorOperations: #import CalculatorOperations.h @implementation CalculatorOperations +(float)add:(float)numOne with:(float)numTwo{
I have a superclass Question: import <Foundation/Foundation.h> #import Answer.h @interface Question : NSObject {
I'm reading Pro Android 2 which contains an excellent Service example as follows: import
I am trying to write a parser class derived from the Python argparse ArgumentParser
#import <UIKit/UIKit.h> typedef enum { CellTypeTextInput, CellTypePicker }CellType; @interface TVCellWithProperties : UITableViewCell { CellType
I have a question about inner-workings of Python sub-interpreter initialization (from Python/C API) and
I'm developing an iPhone app. I have the following class: #import Triangulo.h @implementation Triangulo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.