Gizmotronn / python-learning

Learning about python for future projects
https://github.com/acord-robotics/python-learning
4 stars 3 forks source link

Errors in python on VScode and pasting whole code into idle #5

Closed Gizmotronn closed 5 years ago

Gizmotronn commented 5 years ago

Referencing https://github.com/orgs/acord-robotics/teams/python-development/discussions/2

import pygame, sys # import pygame libraries into program, so we can access them. Also importing the sys libaries which are used to exit the game
from pygame.locals import *

""" Misc comments that don't fit
Line 19 - "global DISPLAYSURF" - # Creates the main surface that will be used throughout the program. Pygame draws objects onto surfaces. 
            We make the variable "global" so it can be edited/modified later throughout the program
"""

# Controlling the speed (FPS) of the program
FPS = 200 # Change this value to slow down/speed up game

# Global variables used throughout the program
# Game window
WINDOWWIDTH = 400
WINDOWHEIGHT = 300

# Writing the main function of the Pong program
def main(): # declaring the function - main function
    pygame.init() # initialising pygame
    global DISPLAYSURF # Creates the main surface that will be used throughout the program. Pygame draws objects onto surfaces

According to VSCode, there are 5 errors here. However, when pasting into IDLE one line at a time, it works. Does this mean that when the program is pasted one line at a time it still works as a single program, and how do I fix this? I'm using the python extension for vscode as I prefer vscode to pycharm

error finding Pong - FPS,Window config in IDLE   vscode
Gizmotronn commented 5 years ago

Typing in exit() to the console(terminal) before clicking the run file in terminal button appears to be the fix

exit()
Gizmotronn commented 5 years ago

I reinstalled the extension. I will re-open this issue if it happens again. Thanks to CodeGeeks on Discord!