library not initialized pygame

2021-05-04 Thread Quentin Bock
code:
#imports and variable for loop
import pygame
running = True

#initializes pygame
pygame.init()
pygame.mixer.init()
pygame.font.init()

#creates the pygame window
screen = pygame.display.set_mode((1200, 800))

#Title and Icon of window
pygame.display.set_caption("3.02 Project")
icon = pygame.image.load('3.02 icon.png')
pygame.display.set_icon(icon)

#setting up font
pygame.font.init()
font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16)
font_x = 10
font_y = 40
items_picked_up = 0
items_left = 3

def main():
global running, event

#Game Loop
while running:
#sets screen color to black
screen.fill((0, 0, 0))

#checks if the user exits the window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()

def music():
pygame.mixer.init()
pygame.font.init()
pygame.mixer.music.load('onoken - load.mp3')  #places song into
queue
pygame.mixer.music.play(10, 0, 3)  #fist number indicates the
loop amount, second is the offset of the song, third is fading the song in
song_text = font.render("Song: onoken - load", True, (255, 255,
255))
screen.blit(song_text, (10, 750))
music()

def display_instruction(x, y):
pygame.font.init()
pygame.mixer.init()
instructions = font.render("Each level contains 3 items you
must pick up in each room.", True, (255, 255, 255))
instructions_2 = font.render("When you have picked up 3 items,
you will advance to the next room, there are 3.", True, (255, 255, 255))
instructions_3 = font.render("You will be able to change the
direction you are looking in the room, this allows you to find different
objects.", True, (255, 255, 255))

screen.blit(instructions, (10, 40))
screen.blit(instructions_2, (10, 60))
screen.blit(instructions_3, (10, 80))

display_instruction(font_x, font_y)
pygame.display.update()

main()

if you try to run this, I'm aware that the icon and music file will not
load because you don't have the file on your device, but if it somehow
works for you please let me know, and if you think there's any difference
between my code and when you ran it I need this figured out. Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


library not initialized (pygame)

2021-05-02 Thread Quentin Bock
Code:
#imports and variables for game
import pygame
from pygame import mixer
running = True

#initializes pygame
pygame.init()

#creates the pygame window
screen = pygame.display.set_mode((1200, 800))

#Title and Icon of window
pygame.display.set_caption("3.02 Project")
icon = pygame.image.load('3.02 icon.png')
pygame.display.set_icon(icon)

#setting up font
pygame.font.init()
font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16)
font_x = 10
font_y = 40
items_picked_up = 0
items_left = 3

def main():
global running, event

#Game Loop
while running:
#sets screen color to black
screen.fill((0, 0, 0))

#checks if the user exits the window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()

def display_instruction(x, y):
instructions = font.render("Each level contains 3 items you
must pick up in each room.", True, (255, 255, 255))
instructions_2 = font.render("When you have picked up 3 items,
you will advance to the next room, there are 3.", True, (255, 255, 255))
instructions_3 = font.render("You will be able to change the
direction you are looking in the room, this allows you to find different
objects.", True, (255, 255, 255))
clear = font.render("Click to clear the text.", True, (255,
255, 255))
screen.blit(instructions, (10, 40))
screen.blit(instructions_2, (10, 60))
screen.blit(instructions_3, (10, 80))
screen.blit(clear, (10, 120))

if event.type == pygame.MOUSEBUTTONDOWN:
if event.type == pygame.MOUSEBUTTONUP:
screen.fill(pygame.Color('black'))  # clears the screen text

display_instruction(font_x, font_y)
pygame.display.update()


main()

the error apparently comes from the first instructions variable saying
library not initialized not sure why, its worked before but not now :/
-- 
https://mail.python.org/mailman/listinfo/python-list


text displays on screen only when I click to exit the program

2021-04-30 Thread Quentin Bock
code with comments for context:

#Create a text based game where the user must find 3 items before
completing a level
#imports and variables for game
import pygame
from pygame import mixer
running = True
#initializes pygame
pygame.init()

#creates the pygame window
screen = pygame.display.set_mode((1200, 800))

#Title and Icon of window
pygame.display.set_caption("3.02 Project")
icon = pygame.image.load('3.02 icon.png')
pygame.display.set_icon(icon)

#setting up font
pygame.font.init()
font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16)
font_x = 10
font_y = 40
items_picked_up = 0
items_left = 3

#functions to be called later in program
def display_instruction(x, y):
instructions = font.render("Each level contains 3 items you must pick
up in each room."
   "When you have picked up 3 items, you will
advance to the next room, there are 3 rooms.", True, (255, 255, 255))
screen.blit(instructions, (10, 40))

def main():
global running

#Game Loop
while running:
#sets screen color to black
screen.fill((0, 0, 0))

#checks if the user quits or exits the window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

display_instruction(font_x, font_y)
pygame.display.update()


main()



please excuse the def main() thing, this doesn't follow a tutorial this is
all on my own, and I don't know why the text displays when I close the
python window.
I appreciate all help :)


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


need help with a translation issue

2021-04-17 Thread Quentin Bock
I'm trying to take the user input and let them change the target language
or dest
code:

from deep_translator import GoogleTranslator
import googletrans
import sys

language_list = googletrans.LANGUAGES
print(language_list)

feedback = input("Would you like to translate a sentence of your own?
(yes/no)")

if feedback == 'no':
sys.exit()

while feedback == 'yes':

user_choice = input ("Enter a language (the abbreviation or correctly
spelled name of the language): ").lower()

user_sentence = input("Enter a sentence you want translated: ")

user_translation = GoogleTranslator(source='en',
target=user_choice).translate(user_sentence)

print(user_translation)

feedback = input ("Would you like to translate a sentence of your own?
(yes/no)")

if feedback == 'no':
sys.exit()
when ran, this will bring an error saying that your inputted language is
not supported
why is this?
-- 
https://mail.python.org/mailman/listinfo/python-list


setting user input equal to target language in Google Translator

2021-04-16 Thread Quentin Bock
is it possible to set the target language of a translation to be the input
from a user?
I have tried inputting specific abbreviations that would normally be
accepted as the target language but it remains in Icelandic and I would
like to change the target language based on the user's input without
creating hundred of scenarios for each inputted language or country.
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Quentin Bock
I receive this error when I try to open a file
The file (what I'm trying to open) is in the same folder as the program I'm
trying to open it from; why is it saying no such file or directory?

this is the only part of the code that causes the error

file = open('Egils Saga 1-15.txt', "r")

file.close()
-- 
https://mail.python.org/mailman/listinfo/python-list


translating external files type thing

2021-04-13 Thread Quentin Bock
okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file
to English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


googletrans problems in python

2021-04-13 Thread Quentin Bock
so I've been experiencing problems with googletrans in python and just
found a solution that actually works for me. If you have not tried this
option and are having problems with googletrans try this method:

*This may work for some and not other I'm too sure


install googletrans 3.1.0
using pip it should be like this
pip install googeltrans==3.1.0a0
this should give a working googletrans to those like me who were struggling
with finding a working version of it.
-- 
https://mail.python.org/mailman/listinfo/python-list


googletrans in python

2021-04-12 Thread Quentin Bock
Can someone explain the basics of googletrans in python?
I want to make a program that translates stories into English, but I'm not
sure how to get a translation printed. Also, is this needed to be done in
an HTML file inside python?
If so can someone provide basic code for a translation and how that should
be written and work?
Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


firewall in python

2021-03-28 Thread Quentin Bock
Is it possible to create a firewall inside python and then run that instead
of the windows defender firewall? If so how would that work or how would
that be made?
Thanks :)


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


thought

2021-03-21 Thread Quentin Bock
Note: Previous comments have been made on this, this is my reply to another
response of this question.
I would have it so, the "admin" of the program would be able to change if
devices are allowed on that network, and would also be able to remove and
make certain devices always receive a password to input. It would not
involve reconfiguring the router, it would involve the devices attempting
to connect to it, but it wouldn't reconfigure the router itself; this would
merely provide another layer of security upon your wifi. I think that
certain features might rely on the reconfiguration of the router, but for
my question no I don't think it would.



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


thought

2021-03-21 Thread Quentin Bock
I had a recent thought about someone's wifi/network connection and password.
Could it be possible to create a program that will randomize a new password
every 24 hours (letters and numbers) and when the program is opened (or
notification would be sent) you can see the new password to log into the
wifi?
If so what would be required to do this, and what skillset would you need
to write this code if possible. If this isn't possible with python, then
what program is it possible with?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


file location/directory

2021-03-14 Thread Quentin Bock
how can I change the path that python takes to run certain files, I'm
starting to create game and I want those in separate folders, so how can I
change it so that python runs the program with the files from that folder?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame font issue

2021-03-13 Thread Quentin Bock
Code that contains the problem:

score_value = 0
font = pygame.font.SysFont('freesansbold.ttf', 32)

error:
in font_constructor  font = Font(fontpath, size)
pygame.error: font not initialized
Can someone explain why it's saying font not initialized and provide a
solution?
I have tried typing in the direct file path of the font but that didn't
work, nor did using SysFont
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame "font not intialized"

2021-03-12 Thread Quentin Bock
my code is almost identical to this so I hope it's okay that I don't
include all of my code
error message:
font = pygame.font.Font('freesansbold.ttf', 32)
pygame.error: font not initialized

Tutorial Link: https://www.youtube.com/watch?v=FfWpgLFMI7w
Timestamp to this part of the video:  1:55:08
-- 
https://mail.python.org/mailman/listinfo/python-list


"unexpected argument"

2021-03-09 Thread Quentin Bock
Error 1:
Space Invaders.py:90: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if bullet_state is "fire":

Error 2:
line 66, in 
if event.key == pygame.K_SPACE:
AttributeError: 'Event' object has no attribute 'key'

Code:
import pygame
import random
# Space Invaders!

background = pygame.image.load('space_invader_background.png')
# Title and Icon
pygame.display.set_caption ("Space Invaders")
icon = pygame.image.load ('space-invaders.png')
pygame.display.set_icon (icon)
# Player
player_Image = pygame.image.load ('player.png')
player_X = 370
player_Y = 480
player_X_change = 0

# Enemy
enemy_Image = pygame.image.load ('invader_enemy.png.')
enemy_X = random.randint(0, 800)
enemy_Y = random.randint(50, 150)
enemy_X_change = 5
enemy_Y_change = 35

# Bullet
bullet_Image = pygame.image.load ('bullet.png')
bullet_X = 0
bullet_Y = 480
bullet_X_change = 0
bullet_Y_change = 10
bullet_state = "ready"

def player(x, y):
screen.blit (player_Image, (x, y))


def enemy(x, y):
screen.blit (enemy_Image, (x, y))


def fire_bullet():
global bullet_state
bullet_state = "fire"
screen.blit(bullet_Image, (x + 16, y + 10))

# Game Loop


pygame.init()
screen = pygame.display.set_mode ((800, 600))
running = True
while running:

screen.fill ((0, 0, 0))
screen.blit(background, (0, 0))
for event in pygame.event.get ():
if event.type == pygame.QUIT:
running = False

# Check whether keystroke is being pressed

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
player_X_change = -6
if event.key == pygame.K_RIGHT:
player_X_change = 6

if event.key == pygame.K_SPACE:
fire_bullet(player_X, bullet_Y)

if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
player_X_change = 0
#Player Movement and Boundaries
player_X += player_X_change

if player_X <= 0:
player_X = 0
elif player_X >= 736:
player_X = 736
#Enemy Movement and Boundaries
enemy_X += enemy_X_change

if enemy_X <= 0:
enemy_X_change = 4
enemy_Y += enemy_Y_change
elif enemy_X >= 736:
enemy_X_change = -4
enemy_Y += enemy_Y_change

# Bullet Movement
if bullet_state == "fire":
fire_bullet(player_X, bullet_Y)
bullet_Y -= bullet_Y_change

player(player_X, player_Y)
enemy(enemy_X, enemy_Y)
pygame.display.update()

Why is it saying unexpected argument?
Youtube Tutorial I'm Following:
https://www.youtube.com/watch?v=FfWpgLFMI7w
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame errors

2021-03-06 Thread Quentin Bock
#Space Invaders!
#Title and Icon
pygame.display.set_caption("Space Invaders")
icon = pygame.image.load('space-invaders.png')
pygame.display.set_icon(icon)
#Player
player_Image = pygame.image.load('player.png')
player_X = 370
player_Y = 480

def player():
screen.blit(player_Image, player_X, player_Y)


#Game Loop
pygame.init()
screen = pygame.display.set_mode((800, 600))
running = True
while running:

screen.fill((128, 128, 128))

for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
player()
pygame.display.update()

The window will not display the icon, saying, "invalid destination for blit"

Is this an indentation error? I don't understand why this position
would be invalid.

link to tutorial I'm following:

https://www.youtube.com/watch?v=FfWpgLFMI7w
-- 
https://mail.python.org/mailman/listinfo/python-list


trouble using pygame

2021-03-05 Thread Quentin Bock
So, I recently downloaded the pygame module, this code is from a youtube
tutorial by the way, I am following along the tutorial, the error involves
the pygame.init() and also says this:

import pygame

# Initialize Pygame
pygame.init()

#create the screen
screen = pygame.display.set_mode((800, 600))

# Game Loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.quit():
running = False

The error says "partially initialized module 'pygame' has no attribute
'init' (most likely due to a circular import)

If someone could also explain what a circular import is and how to
avoid them within the future that would be great

Thanks :)

Here is a link to the tutorial  as well just in case someone wants to see it:

https://www.youtube.com/watch?v=FfWpgLFMI7w
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem with printing statement when condition is false

2021-03-04 Thread Quentin Bock
Okay so, this is my biggest project, I'm not advanced in Python in any
way so don't expect it to be perfect. I made a trivia game and for the most
part, it works but I can't get it to print "Incorrect" and then what the
answer was for all but one of my questions and I don't know why. I use
PyCharm as my IDE for his just as a heads up. I won't paste the code into
this because it's 164 lines so I will attach a file copy, please don't send
back the edited file only write them out and where I need to fix them,
thank you!
Stay Safe Everyone! :)


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


How can I make this more complex?

2020-11-09 Thread Quentin Bock
grade = input("Enter your grade: ")
if grade >= 90:
print("You got an A ")
if grade >= 80:
print("You got a B ")
if grade >= 70:
print("You got a C")
if grade >= 60:
print("You got a D ")
if grade >= 50:
print("You failed")




How can I make this to say if your grade is 90 or higher BUT less than 100
you got an A,
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: returning totals in functions of math

2020-11-08 Thread Quentin Bock
Ok, I don't know how to change add to accept an arbitrary number of
arguments (I'm pretty new) and as for total = 1 idk but it worked for other
versions of this (multiplication), and figured it might work for this one,
do you have any tips on what a better number might be for the total to
equal?

On Sun, 8 Nov 2020 at 14:37, <2qdxy4rzwzuui...@potatochowder.com> wrote:

> On 2020-11-08 at 19:00:34 +,
> Peter Pearson  wrote:
>
> > On Sun, 8 Nov 2020 13:50:19 -0500, Quentin Bock 
> wrote:
> > > Errors say that add takes 1 positional argument but 3 were given? Does
> this
> > > limit how many numbers I can have or do I need other variables?
> > > Here is what I have:
> > > def add(numbers):
> > >total = 1
> > >for x in numbers:
> > >   total += x
> > >return total
> > > print(add(1999, -672, 84))
> >
> > Your function "add" expects a single argument that is a list
> > of numbers.  You're passing it three arguments, each a number.
> > Try add([1999, -672, 84]).
>
> Or change add to accept an arbitrary number of arguments and collect
> them into a tuple:
>
> def add(*numbers):
> # then the rest of the function as before
>
> BTW, why initialize total to 1?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


answer not correct

2020-11-08 Thread Quentin Bock
*def add(numbers):*
*   total = 1*
*   for x in numbers:*
*  total += 1*
*   return total*
*print(add[1999, -672, 64]))*

*the answer I get is 4 but it should be 1,411*
-- 
https://mail.python.org/mailman/listinfo/python-list


returning totals in functions of math

2020-11-08 Thread Quentin Bock
Errors say that add takes 1 positional argument but 3 were given? Does this
limit how many numbers I can have or do I need other variables?
Here is what I have:
def add(numbers):
   total = 1
   for x in numbers:
  total += x
   return total
print(add(1999, -672, 84))

I have a multiply function above it but that was solved and I'm trying to
figure everything out for each of the different math functions.
Thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Help

2020-11-03 Thread Quentin Bock
So, I'm newer to Python and I'm messing around with math functions and
multiplication, etc. here is my line of code:
def multiply(numbers):
  total = 1
 for x in numbers:
 total *= x
 return total
print(multiply((8, 2, 3, -1, 7)))

When I run this, my answer is 8 but it should be 336 can some help ._.
-- 
https://mail.python.org/mailman/listinfo/python-list