#game-development

1 messages Β· Page 64 of 1

spare phoenix
#

@warm cradle

#

pygame.image.load("file name")

#

ive never done it my self but that should work

warm cradle
#

@spare phoenix how do i set the image to the background of my game??

spare phoenix
#

do image = pygame.image.load

#

then draw the image onto the screen

#

by doing screen.blit(image, (x, y))

#

hope that makes sense

#

@warm cradle

warm cradle
spare phoenix
#

make sure u import os at the beginning

#

@warm cradle

warm cradle
#

@spare phoenix still got the same error

#

@spare phoenix i fixxed it

spare phoenix
#

@warm cradle good

mossy harness
#

uh

#

game devs

#

just wondering

#

or at least i want to confirm this

#

drawing the sprites and assets first, and then making the game is an awful design principal, correct?

dawn quiver
#

visual studio @warm cradle

spare phoenix
#

can someone help me convert python script to exe file

warm cradle
#

anyone know how to add hitboxes and collision

spare phoenix
#

id saw jus use raw codes

#

such as if statements using the x and y cordinates

#

but if you really want to get complex there is a coliision method on the pygame website

spiral holly
#

that is for windows

dawn quiver
#

hello i am new to python i have been watching an tutorial on youtube
on how to make pong on python i did what he did and it still doesnt work
can anyone help me?

spare phoenix
#

I’ve watched the video your talking about

#

It’s made in the turtle module which I do not know much about

#

However I made a pong game using pygame which is much better and there are plenty of tutorials online

#

@dawn quiver

#

In terms of your code I think you need to define black. Do black = (0, 0, 0) at the top

#

You also need to define white

dawn quiver
#

how

#

@spare phoenix

spare phoenix
#

Dm

#

I can explain in more detail

dawn quiver
#

in the buttom

spare phoenix
#

Direct message me

zinc ibex
#

Hey Guys,
I am new to Python
Do you guys have any suggestions for a beginner who wants to design games?

warm cradle
potent ice
#

Not enough information to answer that

vestal vessel
#

how do i make my mmo server more scalable

#

??

#

for instance, in a scenario when i update the state for a player action and send the packets to like other players in the server, the server crashes....

#

😟

vestal vessel
#

nvm πŸ˜„

warm cradle
tranquil girder
#

Where is player() defined? Because you're trying to call that function with those four numbers

warm cradle
tranquil girder
#

Look after cHeight in __init__, it's followed by ,

warm cradle
#

@tranquil girder i removed it but it still gives me the same error

warm cradle
#

Can I just send someone my code?

potent ice
warm cradle
#

@potent ice yes

potent ice
#

Then use it πŸ™‚

#

paste code, hit save, share link here

warm cradle
potent ice
#

problem now is?

warm cradle
olive parcel
#

@warm cradle you wrote __int__ instead of __init__

warm cradle
#

@olive parcel ty so much! i was getting so frustrated lol

slender glacier
#
import sys
a,b=map(int,sys.argv[1:])
b-=1
c=a*2+4
r=range(1,c)
print("\n".join("".join(" "[c-i<j>i:]if(j!=2+a!=i!=j)&(c!=i+j)else str(b:=b+1)[-1]for j in r)for i in r))``` is there a way to get this shorter @silver stratus @full otter
#

i reduced it to 168

spare phoenix
#

anyone wanna work on a game together

dawn quiver
#

Helloooooo

#

Dp

mortal yew
#

would I be better off using pygobect (gtk) or pygame for a clicker?

lusty oyster
#

if youd like to make a game with pygame with me dm me

#

ill look

#

delete it now

slender tulip
#

Wdym?

lusty oyster
#

now

slender tulip
#

Whats wrong with it?

lusty oyster
#

fake virus

slender tulip
#

So its not bad right?

#

Its a project ive been working on

lusty oyster
#

still it could scare someone

#

and thats not good

slender tulip
#

Its for halloween :[

lusty oyster
#

STILL

#

and you said game

slender tulip
#

It is im going to make it playable

graceful marsh
#

!warn 611032279103307798 you've been told repeatedly not to discuss your shady projects here. Is that the only reason you come here for? don't post 3gb download links of whatever it is you're making

frank fieldBOT
#

:incoming_envelope: :ok_hand: applied warning to @slender tulip.

rancid cliff
#

This is not for a game but i used pygame for this i am a beginner and it is not working
if "play me some music " in query:
pygame.mixer.music.load("D:\(File link)\badguy.mp3")
pygame.mixer.music.play("loops=0")

#

it is not playing the song

rancid cliff
#

nvm the file name had .mp3 so i had to type .mp3.mp3

merry plaza
#

test

dawn quiver
dawn quiver
#

Any of you ever check out the Tuxemon project? It's an open source Pokemon-style game written in Python:

#

I'm only learning Python, so I can't assess the quality of the code or anything, seems like a cool idea though.

small bridge
#

idk where to get support but im asking here cause its game development anyways i cant figure out how to get the pygame module to be in thonny i clicked the setup file 100 times asked google 1000000 times dm me if yk

merry echo
#

@small bridge How are you installing it? You should be using the pip module. Do pip install pygame in the command line to install

azure shuttle
#

My Pygame doesn’t ever work when I try to import it

dawn quiver
#

did u install it

#

sudo pip install pygame in the terminal

#

"sudo pip install pygame"

#

its ez same to say hello !

azure shuttle
#

it said it downloaded, yet it gave me a directory error and then when I try to run it in python, it wont import

spare phoenix
#

how can i check if mouse has been clicked on certain part of screen in pygame

fierce wraith
#

@azure shuttle can you post the error

azure shuttle
#

Too tired rn

#

3:00 am

knotty knot
#

Hi here! New to this sub :D

#

I mean, server, sorry lol been using Reddit a lot

#

I wanna get started with game development using Python, where do you guys suggest I begin?
I have developed a game and published it using Unity(coded in C#).
Would appreciate if y'all could tell me more anout thisπŸ˜…

magic rain
#

Hey Phantom im new to python myself but you can check out pygame.org its a good start

dawn quiver
#

@azure shuttle if youre on linux ya there is that problem because pygame isnt properly connected to pip. You would have to specify a version like pip install pygame==1.9.6. Worked for me.

#

Send the error of pygame pls

#

Moon light

#

I m on Linux and my pygame work really good

#

Or u can install in the site

#

There is a site where u can install the last version (2.7)

#

Write install pygame and u can install the version that u want

#

It's ezzzzzzzzzzzz

#

Clap

#

πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘

#

πŸ‘Œ

azure shuttle
#

Im on a macOS

zealous blade
#

hey guys could I get a bit of help?

#

I'm trying to draw something with pygame but it's not working...

#

here's my script

frank fieldBOT
#

Hey @zealous blade!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

β€’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

β€’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

tranquil girder
#

what is not working?

zealous blade
#

it's just not drawing anything

#

but I don't have any errors

frank fieldBOT
#

Hey @zealous blade!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

β€’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

β€’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

zealous blade
#

how can I send my script?

#

because I can't send .txt files

#

ok well here's the main game loop

#

def draw_window(win, bird):
win.blit(BG_IMG,(0, 0))
bird.draw(win)
pygame.display.update

def main():
bird = Bird(200, 200)
win = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))

run = True;

while run:
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
    
    draw_window(win, bird)


pygame.quit()
quit()

main()

dawn quiver
#
def draw_window(win, bird):
    win.blit(BG_IMG,(0, 0))
    bird.draw(win)
    pygame.display.update


def main():
    bird = Bird(200, 200)
    win = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))

    run = True;

    while run:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False

        draw_window(win, bird)


    pygame.quit()
    quit()


main()```
#

mhm

merry echo
#

Theres no parenthesis in line 4, and it would be helpful to show what bird.draw() do

wind smelt
#

what do you think how hard will it be to code among us in pygame

merry echo
#

Gameplay-wise, it wouldn't be the worst, but I think the hardest part would be networking

merry echo
dreamy swan
#

maybe it was actually drawn that way?

merry echo
#

No its a filter for custom designs in Animal Crossing New Horizons

dreamy swan
#

ah

merry echo
dawn quiver
#

i have been following this youtubers tutorial

#

the red rect wont show up

mint zenith
#

Looks like you have an infinite loop on lines 17-18

#

run never gets set to False, so the loop will go on forever and everything below line 18 will never execute

#

Perhaps you meant to put code past line 18 inside the while loop too (by indenting it inwards by 1 level)

dawn quiver
#

can anyone help me learn pygame

dawn quiver
#

is my code right

dawn quiver
#

I usually use pycharm but it seems ok

#

Also for the pygame.draw.square use pygame.draw.rect

#

If you need help learning pygame I recommend TechWithTim or readthedocs.io

#

whats pycharm

#

?

#

@soft minnow

#

@dawn quiver

#

Pycharm is a Python IDE; Here's the link

dawn quiver
#

can someone help me?

#

i want to implement the ability to aim using a mouse causing the character to point something at that direction

hasty sand
#

hi there, im trying to code a character creator for my terminal text adventure game and i really could use some help. i want the user of the program to be able to create as many characters as they like and then view the stats of a character by typing ? @character_name into the prompt. i have a function that creates a new instance of the class playable_character and then appends the instance to a list named playable_characters.

the part of the code that is supposed to provide the inspect functionality:
elif '?' in user_input.split()[0]: if '@' in user_input.split()[1]: pc_name = user_input.split()[1].replace('@', '') pcs.index(pc_name) if pc_name in pcs else -1 print("@@@") eval(pc_name).show_stats()
my character creation function:
def create_pc(): character_name = input(" What is thy name?\n> ") # append the new pc to the list of playable characters pcs.append(pc(character_name))

my show_stats function (i tried using it as a class method and as a normal function outside of the player class - instead of passing self the function then takes a character object):
def show_stats(self): print(" Edge", self.edge, "| Heart", self.heart, "| Iron", self.iron, "| Shadow", self.shadow, "| Wits", self.wits, "| Harm", self.harm, "\n Momentum", self.momentum, "| Health", self.health, "| Spirit", self.spirit, "| Supply", self.supply)

my implementation of the functionality described yields a name error: 'character_name' not defined. my diagnosis of the problem is that the playable_character is not available in the namespace (at least thats what i gathered from my stack overflow searches). so when trying to call the function that is supposed to show the stats for that character it results in that Name Error. I appreciate any help very much, thank you. πŸ˜…

tranquil girder
#

Maybe it's the eval? Why not do pcs[pc_name].show_stats()?

hasty sand
#

this gives me the following error:
TypeError: list indices must be integers or slices, not str

#

i changed this part of the elif statement like so:
elif '?' in user_input.split()[0]: if '@' in user_input.split()[1]: pc_name = user_input.split()[1].replace('@', '') for pc in pcs: if pc_name == pc.name: # eval(pc.name).show_stats() pcs[pc_name].show_stats()

tranquil girder
#

Oh, my bad. I assumed it was a dict

#

you can use the return value from pcs.index from the line above then

#

pc_name is just a string

#

so eval(pc_name) won't do anything

hasty sand
#

you can use the return value from pcs.index from the line above then
@tranquil girder can you eloborate please?

#

like so?
for pc in pcs: if pc_name == pc.name: pcs.index(pc.name).show_stats()

tranquil girder
hasty sand
#

this gives the error:
ValueError: 'pc_name' is not in list

#

pcs.index(pc.name).show_stats() gave me the same error

#

by the way thank you for responding πŸ™‚

#

πŸ™

tranquil girder
#

get the index in the list like you already did
then get the element in the pcs list with that index
list[index]

hasty sand
#

this is the largest program i have written so far, im learning a lot in the process, but im also way in over my head if you cant tellπŸ˜‚

split tulip
#

I'm trying to get several objects to spin around a player. I create them just fine, but calculating their position is giving me some trouble.

`def floatWeapons(player, weapons, iteration=100):
if iteration:
iteration -= 1
else:
print('finished running')
for weapon in weapons:
weapon.teleport(player.origin)
weapon.remove
return
x,y,z = player.origin
r,ΞΈ = cartesianToPolar(x,y)
for i in range(0, len(weapons)):
x2,y2 = polarToCartesian(r+60,ΞΈ + ((math.pi/2)/6 * (i+1)))
weapons[i].teleport(origin=Vector(x2, y2, z + 60))
Delay(.02, floatWeapons, (player, weapons, iteration))

def cartesianToPolar(x,y):
return math.sqrt(x2 + y2), math.atan(y/x)

def polarToCartesian(r,ΞΈ):
return r * math.cos(ΞΈ), r * math.sin(ΞΈ)`

hollow mica
#
x,y,z = player.origin
r,ΞΈ = cartesianToPolar(x,y)

why do you calculate polar coordinates of a player?

split tulip
#

the weapons are being placed relative to the player

#

r + (distance away from player)

hollow mica
#

r,ΞΈ revolves around (0, 0, 0) point of the world

#

for every weapon, calculate relative cartesian coordinates first:

rel_weapon_pos = weapon.pos - player.origin

then transform these relative coords to polar

#

In your code you rotate weapons around world origin, 60 points farther than player

#

also, cartesianToPolar can raise division by zero error in expression y/x

split tulip
#

good observation...

hollow mica
split tulip
#

I would have a collection of food objects

#

Food objects would theoretically have a location attribute

#

Assuming the AI knows where all the food is, iterate over all the objects, calculate distance, sort the results, and move to the lowest value

hollow mica
#

@prime juniper There're lots of spatial tree datastructures, easiest of them are quad/oct trees. They optimize reading (finding nearest food) and make writing somewhat slower (adding food). But for the user it looks like "a list" with ability to add and remove.

split tulip
#

I'd go with neumond's suggestion though. It has the benefit of having pre-calculated values, although if your AI moves a lot it could be more (time) costly

tranquil girder
#

I recommend using a dict, @hasty sand, if you don't need to be able to have several characters with the same name

hasty sand
#

I recommend using a dict, @hasty sand, if you don't need to be able to have several characters with the same name
@tranquil girder

I will look into that with a fresh mind, ty okhandbutflipped

torpid silo
#

Can I set rect in a pygame.sprite.Sprite object to something to skip rendering?

spare phoenix
#

need pygame develepors for project

hasty sand
#

@tranquil girder

get the index in the list like you already did
then get the element in the pcs list with that index
list[index]
i think i did what you suggested, the tip to make the list of pcs a dictionary was golden, it works now, like i wanted it too. thank you very muchπŸ₯³ that made my day man☺️

jovial quartz
#

does somebody know how to randomize some coordinates for an item in a limited area?

dreamy swan
#

maybe just have it pick two random numbers in a range and use that as coords?

hollow mica
#

@jovial quartz depends on area shape and density distribution

small bridge
#

pip install pygame
File "<pyshell>", line 1
pip install pygame
^
SyntaxError: invalid syntax

this is in thonny with python 3.7.7 please help i want to add pygame

#

is the command wrong?

#

did download pip lol

#

didnt*

merry echo
#

You’re probably running it inside the python shell, which is for python code

#

You should do it in your terminal

small bridge
#

sh ty

#

ah ty*

#

still no clue videos?? T_T

valid seal
#

You're trying to run the command in the python shell

#

You should be running it in your command line

valid seal
#

Anyone got any good ideas on how to prevent having to draw a scene every cycle in arcade

#

Cause I'm just drawing squares and the frames realllllly go down

#

I assume i should be using sprites or something but just wondering what people would suggest

#

actually yeah I'll just go with the sprite idea

valid seal
#

Another question

#

window.set_update_rate(1/30) for some reason this throws an error whenever i try to set it below 30 fps

#

TypeError: must be real number, not tuple

#

I already know how i could probably make a workaround

#

But just wondering why this is

lusty oyster
#

@valid seal I believe it is because it thinks you are trying to divide the number because it is lower than the average frame rate. I’d try to find a workaround which I’m not sure I will be able to help you with.

dense creek
#

is there any way of resizing an image in pyglet?

lusty oyster
#

I’m not familiar with it so IDRK but ask google or YouTube.

#

I know pygame works though.

dense creek
#

yeah

#

i am switching my game code from pygame to pyglet

#

as pyglet has 3D stuff

lusty oyster
#

Oh ok. Well I’m sorry because Idk pyglet.

dense creek
#

alright. PIL is always a way.

lusty oyster
#

If you would like to make a game with me with python, and have knowledge of pygame DM me and we can make a game together.

valid seal
#

Ah yeah that may be why

#

Anyway a workaround is pretty easy so i just used that

lusty oyster
#

What did you use?

#

Just so I can help in future.

#

If other people ask.

valid seal
#
        if self.paused:
            self.paused -= delta_time
            if self.paused <= 0:
                self.paused = 0
            return
#

Basically just that in the on_update

#

so i can do like

lusty oyster
#

Oh ok.

valid seal
#

self.paused = 1 and it'll pause for 1 second

#

so i can just set it to update every x seconds

lusty oyster
#

Yes.

slender glacier
#

any example of how to make loading sign with arcade?

spare phoenix
#

any pygame devs instersted in working on a project

dawn quiver
#

maybe me

#

but i m not a very very good in pygame

#

I must work on pygame

untold bramble
#

Is there a "descriptors for dummies" book out there? I been trying to read about them but my brain goes fuzzy

#

I get the idea that if I have an object with properties I can change the attributes using get, set, delete

#

But there are a lot more scary big words in the definitions i read

dawn quiver
#

Hi dp can u create a server for the creation of the game with the team

small bridge
#

@south forge define command line?

torpid silo
#

My favorite PyGame method name is Surface.get_rect()

wild root
#

Is there a way to move a polygon similar to the way a rectangle is moved?

knotty knot
#

Hey Phantom im new to python myself but you can check out pygame.org its a good start
@magic rain Thanks, will check it out soon :-)

dawn quiver
#

Dp i dont arrive to send u message

#

I did a server for our game but i dont arrive to invite u

#

Pls do a server for our game

uncut roost
solemn basin
lusty oyster
#

What won’t

lusty oyster
#

@uncut roost did you download pygame?

uncut roost
#

@lusty oyster yes

#

i can import pygame on pycharm but not on vsc

sacred trout
#

By default pycharm installs your modules in a virtual environement so you would have to use the same for vscode

timber bolt
#

Drop code

proud tundra
#

404 Error#9696

steel geyser
#

You can't use async for a function name. It's the name of a keyword.

timber bolt
#

Change the async function

proud tundra
#

how to change async function can u tech me the tutorial

dense creek
#

any ideas why it won't change color?
@solemn basin pygame.display.update() is outside the game loop. Cut and Paste it in

slender glacier
#

So i want to keep a view for 20 seconds and then autmatically switch it
how can i do this
this is what i have tried
https://emkc.org/s/KBaaNn

dawn quiver
#

Dp_Dontmiss pls send me an invitation bc i have a bug and i can't speak with u and invite u

sacred trout
#

Magnifique pseudo πŸ₯° πŸ˜‚

dawn quiver
#

cimer

#

@spare phoenix pls send me an invitation

#

@spare phoenix I can't speak with u andinvite u

#

@spare phoenix my girlfriend has create a server for speak both

#

@spare phoenix so pls accept

#

@spare phoenix Ah sorry she didnt invite u

#

@spare phoenix She will do that

neon hinge
#

Uh

#

That's a lot of pings

solemn basin
#

@solemn basin pygame.display.update() is outside the game loop. Cut and Paste it in
@dense creek alright thanks

eager gate
#

Hi everyone. I'm participating in my first PyWeek and using PyGame for my game.

#

I have this issue: When 2 keys are pressed simultaneously I can detect them with pygame.key.get_pressed() but not with event polling (pygame.event.get()).

#

with event polling only the last key pressed generates KEYDOWN events and the other one is completely ignored even after releasing the last key.

#

Is this a bug in pygame?

frank fieldBOT
eager gate
#

Thanks a lot!

mint zenith
#

You should see an event for each key, you just have to process the events one at a time

eager gate
#

This is Python 3.8.0 and PyGame 1.9.6

mint zenith
#

But using get_pressed is probably more convenient anyway

eager gate
#

Apparently it's the only way that works. I'm baffled no one in the PyGame community identifies this as an issue. I use an event loop to process all events but I can't get them all.

mint zenith
#

Well, you should get an event for each key. The events shouldn't disappear

eager gate
#

If you have PyGame experience, could you take a qiuck look at my posted code to see if there's some obvious mistake from my part? it's simple enough that I think should just work.

mint zenith
#

It looks fine

#

Which two keys are you trying to detect?

#

Even if you do a simple ```py
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
print("key down ", event.key)
elif event.type == pygame.KEYUP:
print("key up ", event.key)

and press some keys at the same time, you should see an event for each key
eager gate
#

RIGHT + SPACE (forward jump)

#

or LEFT + SPACE (backward jump)

mint zenith
#

Is it either moving or jumping, but not both?

eager gate
#

right. I tested the simple loop you suggest. Pressing any 2 keys, only reports events for the one pressed last.

mint zenith
#

I tested the same thing, and I get an event for both keys

eager gate
#

Maybe it's a version or OS thing. I'm in Linux. PyGame 1.9.6. Python 3.8.0

#

I converted the code to use get_pressed() and it works that way. So I guess I'll just use that.

#

Thanks @mint zenith

mint zenith
#

I was testing on Windows for what it's worth

eager gate
#

Well, I actually get both events. However, one of the keys reports one event and nothing more while it's still being pressed.

#

I press RIGHT and hold, then press SPACE immediately after.

#

events go like this:

#

right, space, space, space, space, ..., space

#

while it should be:

#

right, space, right, space, right, space, ...

#

while keeping both pressed.

mint zenith
#

Not sure what you mean. The events only get reported twice: once for key up and once for key down

#

For the events to repeat like that, you'd have to spam the keys rather than hold them continuously.

eager gate
#

I set key repetition, but I guess the issue is there. ( pygame.key.set_repeat(1,100) )

mint zenith
#

Yeah maybe. I actually didn't notice you did that.

sharp needle
#

what types of games can you make with python?

#

like sonic?

dawn quiver
#

Pls dp_dontmiss accept the invitation

tender saddle
#

Can i make a game in unity with python

olive parcel
#

Seems so, with a third-party addon

barren sky
#

i'm making a non-gui guess game and in the following code, even if I enter yes, it says I don't understand that. Same goes for no

`else:
print(f'You lost! Correct answer was {sec_num1}')
time.sleep(1.1)

play = str(input("Play again?(enter 'yes' or 'no') ").lower)

while play != 'no':
    if play == 'yes':
        from levels import guess_1
    else:
        print("I don't understand that.")
        quit()`
#

plz anybody help

#

plz

tranquil girder
#

It's .lower()

barren sky
#

It's .lower()
@tranquil girder oh yeah now i see

#

thx

tranquil girder
#

You should try printing play, that way you can easily see what's wrong

barren sky
#

ok

lone crypt
#

while play !=no @barren sky

dawn quiver
#

Dp Pls accept the invitation of kermit pld

#

S

#

@Dp_Dontmiss Pls accept

#

The invitation on the server at ah

#

H

#

Pls sp

#

Dp

#

Dp

#

Plsssss

naive prairie
#

Can anyone help me fixing my game problem?

torn heath
#

dont ask to ask

naive prairie
#

Okay

#

I'm making a dinosaur game. But I'm unable to make the collusion

#

How can i make the dinosaur collide with the trees and then game over?

spare phoenix
#

use x and y coordinates

#

for example

#

if dinox >= treex:

proper peak
#

not really.

#

pretty much just a,b = a+lst[0], b+lst[1], and that's pretty ugly.

#

If you need to do stuff like that, don't have them be separate variables at all, but instead something like numpy vectors.

lime copper
#

anyone know a server for pygame

dawn quiver
#

lmao

#

you can talk about pygame here

lime copper
#

but like a dedicated server to it

brittle orchid
#

can someone help me pls

#

`import tkinter
import random

colours = ['Red', 'Blue', 'Green', 'Pink', 'Black',
'Yellow', 'Orange', 'White', 'Purple', 'Brown']
score = 0
timeleft = 60

def startGame(event):
if timeleft == 60:
countdown()
nextColour()

def nextColour():
global score
global timeleft
if timeleft > 0:
e.focus_set()
if e.get().lower90 == colours[1].lower():
score += 1
e.delete(0, tkinter.END)
random.shuffle(colours)
label.config(fg=str(colours[1]), text=str(colours[0]))
scoreLable.config(text="Score: " + str(score))

def countdown():
global timeleft
if timeleft > 0:
timeleft -= 1
timeLabel.config(text="Time left: " + str(timeleft))
timeLabel.after(1000, countdown)

root = tkinter.Tk()
root.tilte("The Colour Game")
root.geometry("375x200")

instrutions = tkinter.Label(root, text="Type the colour of the words and not the word text",
font=('Helvetica1', 12))
instruction.pack()

scoreLabel = tkinter.Label(root, text="Press enter to start",
font=('Helvetical', 12))
scoreLabel.pack()

timeLabel = tkinter.Label(root, text="Time left: " + str(timeleft),
font=('Helvetical', 12))
timeLabel.pack()

label = tkinter.Label(root, font=('Helvetica', 60))
label.pack()

e = tkinter.Entry(root)

root.bind('<Return>', startGame)
e.pack()

e.focus_set()

root.mainloop()`

#

line 34

#

@prime juniper now it is line 39

#

i am using python IDLEis that ok?

#

@prime juniper srry to bother u again but if run it and then what i what donsnt show and there is a load of error codes as well

ionic depot
#

Use VS ( visual studio) @brittle orchid

brittle orchid
#

i try but i cant any more it crashes my laptop

ionic depot
#

Hmm

#

That's sad

brittle orchid
#

ik so i use python IDLE now

proper peak
#

Use VS ( visual studio) @brittle orchid
@ionic depot VS Code, mind. Visual Studio is a different IDE that's far, far heavier πŸ˜›

ionic depot
#

Right

brittle orchid
#

oh ok

#

i would it is good for things like this

#

i would start learning it @prime juniper

#

it is something hady to learn if u want to do GUI stuff and like that

#

like to open websites using Tkinter

#

Is it possible if some one can help me with my code

#

pls

#

thanks @prime juniper
my code now works

#

i did see that but i dont see how i could do that

#

do u have an idea what to do?

#

ok i cope with it as it is for the min but i will keep on trying difrent things

eager iris
#

i need help installing pygame on vscode

#

i put pip install pygame into the terminal and it said: 'pip' is not recognized as an internal or external command, operable program or batch file.

hushed osprey
#

Do you have python installed?

eager iris
#

yes

#

3.8.5

hushed osprey
#

use py -m pip install pygame

eager iris
#

oh!

#

wait

#

wow!

#

thank you! ❀️

dawn quiver
rotund magnet
#

I’m looking to create an online quiz buzzer system that I can use to activate macros on when system when individuals buzz in. Does any have any idea for a best way to do this?

loud jay
#

I have started learning game development using pygame recently. I am confuse about pygame.ACTIVEEVENT. Please can anyone tell me the use of it?

frank fieldBOT
barren sky
hasty sand
#

i have a PlayerCharacter Class that has class attributes holding the PCs stats (like momentum, which represents how well the PC is doing on his quest. momentum changes depending on what happens in the game, for example momentum is decremented as the result of an action the PC takes). I want to set maximum and minimum values for these types of class attributes (momentum cannot be greater than 10 and not be lower than -6), but have not been able to implement it so far. i tried using a lambda function to always return a value in a specific range, but if i assign the lambda function to the class attribute, obviously the function is being returned instead of the value. Any advice?πŸ˜‡ πŸ™

stark anvil
#

i have a PlayerCharacter Class that has class attributes holding the PCs stats (like momentum, which represents how well the PC is doing on his quest. momentum changes depending on what happens in the game, for example momentum is decremented as the result of an action the PC takes). I want to set maximum and minimum values for these types of class attributes (momentum cannot be greater than 10 and not be lower than -6), but have not been able to implement it so far. i tried using a lambda function to always return a value in a specific range, but if i assign the lambda function to the class attribute, obviously the function is being returned instead of the value. Any advice?πŸ˜‡ πŸ™
@hasty sand so basically you want to validate what can go into the attribute?

hasty sand
#

@stark anvil the type of the attribute does not change. in the case of momentum it will always be an integer between -6 and 10. i want to make sure that it never can go outside of this range, eg: if an action of the PC lowers their momentum to -7, it will be -6.

stark anvil
#

yeah, so basically

#

what I said

#

have you heard of properties?

hasty sand
#

thats what im reading right now

#

about properties

stark anvil
#

@prime juniper no, no setters.

#

use properties.

hasty sand
#

yep

#

as im reading up on them they seem superior to setter and getter functions

stark anvil
#
>>> class Player:
...
...     def __init__(self):
...         self._attribute = 5
...
...     @property
...     def attribute(self):
...         return self._attribute
...
...     @attribute.setter
...     def attribute(self, value):
...         self._attribute = max(min(value, 10), -6)
...
...     def __repr__(self):
...         return f'Player with attribute {self.attribute}'
...
>>> p = Player()
>>> p
Player with attribute 5
>>> p.attribute = -3
>>> p
Player with attribute -3
>>> p.attribute = -10
>>> p
Player with attribute -6
>>> p.attribute = 20
>>> p
Player with attribute 10
#

example for you @hasty sand

hasty sand
#

ahhh

#

thats great thank you

stark anvil
#

yw

slender glacier
#

i am trying to make this in arcade (a inventory system), any ideas how to do it

eager iris
#
pygame.init()

win = pygame.display.set_mode((10000, 10000))

pygame.display.set_caption("E")```
#

this returns Module 'pygame' has no 'init' member

#

pls help

dawn quiver
#

any fix

uncut karma
#

@eager iris what version of pygame and python are you running?

eager iris
#

scroll up

#

3.8.5 python

#

@dawn quiver can you scroll up and screenshot again

uncut karma
#

pygame?

eager iris
#

how do i check that?

dawn quiver
eager iris
#

one more

#

sorry

#

lol

#

ok

uncut karma
#
print(pygame.__version__)
eager iris
#

returns undefined variable pygame

#

when i do import

uncut karma
#

did you install it?...

eager iris
#

yeah

#

it worked like 5 mins ago

uncut karma
#

try pip show pygame

eager iris
#

ok

dawn quiver
#

@eager iris

eager iris
#

pip not recgonized

uncut karma
#

πŸ™‚

dawn quiver
eager iris
#

oh ok

#

wait

#

simple fix

#

do screen.blit(screen,(0, 0)

#

@dawn quiver

#

@uncut karma wait what

dawn quiver
#

ok

eager iris
#

i think

#

idrk

dawn quiver
uncut karma
#

...

#

@dawn quiver Man, i told you multiple times - learn how to code first, learn how to read errors

dawn quiver
#

@eager iris

#

i already read the errors

uncut karma
#

Yeah

dawn quiver
#

i just tried

#

every fix i know

#

so i am asking on how to fix it

uncut karma
#

It clearly says argument 1 must be pygame.Surface, not int

eager iris
#

ya

dawn quiver
#

you dumb Ass

uncut karma
#

So you can't

dawn quiver
#

w8

uncut karma
#

...

dawn quiver
#

i needto do

#

something

eager iris
#

do screen.blit(screen,(0, 0)
i said do this

#

you dumb Ass
wait what

uncut karma
#

yeah

eager iris
#

wha

dawn quiver
#

i already did the screen.blit

#

(screen,(0,00

ionic depot
#

@dawn quiver what game are you making?

strong raptor
#

i hated working with pygame

#

if i had the skills i would make a better python game library

brittle orchid
#

Does anyone know how to download pygame?

strong raptor
#

pip install not working?

#

@brittle orchid

#

python -m pip install pygame at the command line

#

for windows at least

brittle orchid
#

Ok i will have a look

dawn quiver
#

I hate pygame

#

Pyglet is better imo, especially if you know how to use decorators and such

dense creek
#

Pygame is good in itself but is very limited. I had to switch from pygame to pyglet

dawn quiver
#

@dense creek pyglet whats that?

dense creek
#

It's another game module

dawn quiver
#

is it better than pygame?

#

i like pygame but the indention is making me crazy

dense creek
#

It supports both 2D and 3D

dawn quiver
#

and the caps and :()

dense creek
#

What ide are you using?

dawn quiver
#

online ide

dense creek
#

See if you could do pyglet

#

For me, it's better

dawn quiver
#

er ok

dense creek
#

The coordinates start from bottom left corner

eager iris
#

anyone have some inspiration

dawn quiver
#

pls Dp_dontmiss accept the invitation

ionic depot
#

Lmao

#

He's not forced to do it , if he doesn't want to

hasty sand
#

@stark anvil thanks for the tip again. i have been reading a lot about the property decorarter and checked out the code sample that you provided for me. i got it working in a seperate file:
`class Player:

def __init__(self):
    self._momentum = 2

{at}property
def momentum(self):
    return self._momentum

@momentum.setter
def momentum(self, value):
    self._momentum = max(min(value, 10), -6)

def face_danger(self):
    print(self.momentum)
    self.momentum += -20
    print(self.momentum)

pcs = {}
name = 'eric'
pcs[name] = Player()
print(pcs)
pcs.get(name, {}).face_danger()`

when i implement it in my game file it raises an attribute error when trying to resolve self.momentum += 20:
AttributeError: 'PC' object has no attribute 'momentum'
why can i not call the setter on self?
Im really confused as to what is going exactly, maybe you can help me out again?πŸ˜…

i got it working by not using property at all.
self.momentum += -20 momentum = self.momentum self.momentum = max(min(momentum, 10), -6)
i created a new function as a class method of PC since i need this logic a bunch of times, so its not too bad i guess?
however i was wondering if there is a better way involving properties
had to remove the proper syntax because of discords tagging

eager iris
#
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 0, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 100, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 200, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 300, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 400, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 500, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 600, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 700, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 50, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 150, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 250, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 350, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 450, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 550, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 650, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 700, 50, 50))

#

this is a function that i have for drawing a finish line

#

i also have a player

#

is there any way to make the player appear on top of the finish line?

#

yeah i tried that

#
    
    keys = pygame.key.get_pressed()

    if keys[pygame.K_RIGHT] and x < screenwidth - 100:
        x += vel
    if keys[pygame.K_LEFT] and x > 0:
        x -= vel
    if keys[pygame.K_UP] and  y > 0:
        y -= vel
    if keys[pygame.K_DOWN] and y < screenheight - 100:
        y += vel
    if keys[pygame.K_SPACE]:
        pygame.quit()

    win.fill((255,255,255))

    pygame.draw.rect(win, (0, 255, 0), (x, y, width, height)) #here player```
#

@prime juniper

ionic depot
#

@eager iris so , what's the problem?

#

Cause I got lost

eager iris
#

i want it to draw the player on top of the squares

#

@ionic depot

ionic depot
#

And you can't do that?

#

I mean , you don't know how?

#

You have to specify the position

#

x = ...

#

And y = ...

#

@eager iris

#

Let's make it straight

#

What do you want to make

#

A simple race game , right?

eager iris
#

ya

ionic depot
#

Your player can move?

eager iris
#

yes

ionic depot
#

You drew the finish line

eager iris
#

yes

ionic depot
#

And you want to change the position of the player

#

Right?

eager iris
#

uhh

#

no

#

i know how to do that

#

i just want the player to show up on top of the finish line

#

cuz right now its under and the player is being covered by it

#

yea

ionic depot
#

Oh

#

I understand now

eager iris
#

yes

ionic depot
#

You want your player to appear on the finish line

#

Like it stands there

#

@prime juniper

eager iris
#

um

#

yeah basically

ionic depot
#

You managed to do the code?

eager iris
#

uh

#

yes

ionic depot
#

I asked @prime juniper

eager iris
#

ok

ionic depot
#

Okay , let me think

#

You have to make those block to appear under your player

#

I know

#

But you sent a ss

eager iris
#

i tried drawing the finish line before the player in the loop, but it didn't work

ionic depot
#

With the actual result

eager iris
#

ss?

ionic depot
#

Whatever it is

#

:))

#

Let me take my laptop and figure out the problem

eager iris
#

um

#

ok

#

should i paste you my code?

#

you'll probably barf lol

ionic depot
#

Um , yeah

#

The finish line

#

Preferably

eager iris
#

ok

#
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 0, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 100, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 200, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 300, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 400, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 500, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 600, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 100, 700, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 50, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 150, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 250, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 350, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 450, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 550, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 650, 50, 50))
    pygame.draw.rect(win,(0,0,0), (screenwidth - 50, 700, 50, 50))

@eager iris

#

@ionic depot

ionic depot
#

Ok

#

This is gonna take couple of minutes

stark anvil
#

@hasty sand in general you should not tag specific people for new questions

#

anyway, I’m p sure you made an instance of the wrong class

#

otherwise it should work

#

also, use three backticks for code blocks

merry echo
#

You would have to draw the finish line first

frigid knoll
#

hi can someone help me formulate something plz

#

im looking to use basic python 3

#

and classes

#

im looking to make an app that registers input, compares it against a database, and sends out result based on matches

#

a game-type thing where the game will print text and request user input

dawn quiver
#

text based? @frigid knoll

frigid knoll
#

i dunno, im just trying to learn classes

dawn quiver
#

HELP

#

ME

#

lol

dawn quiver
#

HELP
@dawn quiver bro , you put the condition , but no a event for the condition .

#

@dawn quiver i fixed it

#

i used another way to make my character move

#

@dawn quiver i fixed it
@dawn quiver what do you want to make , more exactly ?

#

soo I'm new here , in this group , because i want to study deeply the game dev with python , I will make a RPG like some dungeon to search in a labyrinth

#

the masterpiece of this idea , it's that labyrinth generate randomly , for every new game

#

what can recomend me ?

#

what book for read ?

#

what video to watch?

#

i am making

#

an score based

#

game

#

like asteroid

#

and necromancer

#

like asteroid
@dawn quiver you should tell me before , take this :https://www.youtube.com/watch?v=FfWpgLFMI7w&list=WL&index=8 maybe can help you

Learn how to use Pygame to code games with Python. In this full tutorial course, you will learn Pygame by building a space invaders game. The course will help you understand the main game development concepts like moving characters, shooting bullets, and more.

πŸ’» Code: https:/...

β–Ά Play video
#

this have the principles of the movement sistem

#

i dont need it anymore

#

i already found a way to do it

#

@dawn quiver

dawn quiver
#

pls meme

hasty sand
#

@stark anvil sorry about that. thanks again for pointing me in the right direction, seems like i just needed a clear head. by now i figured it out using the property decorator πŸ₯³ i have also implemented the same logic using the property decorator for 3 different class attributes that work the same (health, spirit, supply), they have different maximums and minimums. works like a charm now😍

lusty oyster
#

Does anyone want to make a pygame with me?

#

dm me

ionic depot
#

what game exactly @lusty oyster

lusty oyster
#

a 2d game

#

about anything

#

we will decide

ionic depot
#

idk what to say

lusty oyster
#

dm me

hasty sand
#

hello πŸ™‚ i need some help with a classmethod that im trying to code. this is my class so far:

class Vow:
    def __init__(self):
        self._name = ""
        self._rank = 0
        self._description = ""
        self._progress = 0

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, value):
        self._name = value
    
    @property
    def rank(self):
        return self._rank

    @rank.setter
    def rank(self, value):
        if self.rank < 0 or self.rank > 5:
            # user should input the rank again
        self._rank = value

    @property
    def description(self):
        return self._description
    
    @description.setter
    def description(self, value):
        self._description = value

    @property
    def progress(self):
        return self._progress

    @progress.setter
    def progress(self, value):
        self._progress = value

    @classmethod
    def swear_an_iron_vow(self):
        self.name = input("Give this quest a name: ")
        self.rank = int(input("Give this quest a rank: "))
        self.description = input("Give this quest a description: ")
        self.progress = 0

iron_vow = Vow()
swear_an_iron_vow = Vow.swear_an_iron_vow()
print(iron_vow.name, iron_vow.description, iron_vow.rank)

**i want to make sure that the rank of an iron vow is always between 1 and 5. **
since the player provides the rank when swearing an iron vow i thought the range check for rank should occur in the rank.setter? am i mistaken? should i just implement a check in the classfunction after the player provided a rank? tyπŸ™

somber bramble
#

guys, any good source of "balance" in multiplayer games?

#

i'm developing a browser game that is by far unbalanced

#

excel is not handling such problem

#

hahaha

hasty sand
#

@somber bramble he is talking about card games, but the conceptual approach he takes to balance is very nice. i think balance is often a problem regarding agency. an unbalanced game removes player agency because there are to few playing styles that are optimal or at least viable. removing player agency is bad for games since they are all about that. one way to balance your game might be to focus on winning playstyles in the game that you have, disregarding the rest. a game like rock paper scissors for example has only 3 play styles but it is balanced because each play style is countered by one of the other two. so the fun of rock paper scissors is guessing what your opponent chooses. even though there might be less variety in rock paper scissors than in rock paper scissors lizard spock it might be more fun because of it.

somber bramble
#

i'll watch it, my game is space based, so there will be races, each race with different approaches with different playstyles, some will be able to start colonizing when they start, others don't, the main problem is equalizing the economics :X

#

but thanks πŸ˜„

brittle orchid
#

@strong raptor u know yesterday that i asked how to download pygame i have tryed it but it still doesnt work even though i have downloaded it off its website

spare phoenix
#

any pygame devs who want to work with me and a team of devs to build the next upcoming game.

ionic depot
#

@dawn quiver end game text?

#

After the game ends?

last moon
#

How are you displaying the text

ionic depot
#

@spare phoenix of any level of knowledge?

last moon
#

Rip famous last words

#

@dawn quiver What function are you using?

#

String formatting would clean that up a bit

#

let me rephrase again

#

what function are you using to 'print' the text to the window

#

ty

spare phoenix
#

@ionic depot intermediate level python/pygame knowledge is preffered.

ionic depot
#

Sad :))

spare phoenix
#

why?

ionic depot
#

Cause I'm not that experienced

#

FeelsBadMan

last moon
#

@dawn quiver can you send the part with the screen.blit

#

where are you getting console_arrow_rect\_* from

#

I get that ya

#

but if the values are incorrect/negative that'd explain it

#

and your calling pygame.font.init()?

#

actually nvm ya that doesn't need to be there

#

would "{}\n".format(commands[console_text]) work?

#
output = game_font2.render("{}\n".format(commands[console_text]),                              True, white)```
#

sorry I'm not to familiar with pygame

#

would you not have to update the screen

#

I'm pretty sure you have to pass the blit() to an 'update' function

#

"PyGame's built-in dawning functions and the .blit() method for instance return a Rect, so you can simply pass it to the display.update() function in order to update only the "new" drawn area."

#

but you'd have to pass the blit to update() in order to update the window

#

because as far as I can see you're just building one

ionic depot
#

This is confusing

#

Send it

#

Much better

last moon
#

Ya so (I could be wrong someone correct me) I think you're not actually initializing the blits

#

idk actually sorry pygame without oop confuses me

#

where are you getting again from

#

can you add something like print("error") after the if again:?

#

could be that it's not going into the condition at all

#

or a breakpoint would work too ig

ionic depot
#

Can you draw what you want to get out of your code?

#

On a paper

last moon
#

where are you getting draw_again from then

#

is that %100 working

#

like it's not displaying any sort of error

#

actually can you send the whole script so I can run it?

#

!paste

frank fieldBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

last moon
#

na just the script you're working on

#

na just the one you're working on

#

I can change the sprites

ionic depot
#

Ok

last moon
#

try if event.type == pygame.KEYDOWN:

#

I think you need it everywhere

#

no but like event.type will return pygame.'event that happended'

#

unless you have something like KEYDOWN = pygame.KEYDOWN you'll need to change each one

#

hm then I'm not sure sorry

shrewd verge
#

hello
I have a camera class which moves with the character, is there anyway i can make everything on the camera bigger? If i just try to transform the size, it gives me bigger sprites, but the camera starts from the top left and is not focused on my character. Additionally, collisions dont work

#

im using pygame, and pytmx for my map

strong raptor
#

@brittle orchid hmmn

#

can you open the command prompt?

#

Go to start menu, type "cmd", hit enter

#

From there, type the following:

#

python -m pip install pygame

#

you DO NOT need to go to any website and download any files

#

the command does it all

#

@brittle orchid

#

after that's done, you can just import pygame to use it in your scripts

#

if you need help @ me

blissful pewter
#

Hey, I'm making a space invaders game with pygame, can you tell me how do I do collisions of bullets with enemies??

#

Thanks in advance:)

tardy sage
#

I am not using pygame but am making a very small section of a game and am having trouble

#

I'm trying to calculate hit chance in the most simple way and it is not working at all.

#

I've tried a hundred different ways of doing the same thing and none of them have worked

#

import random #Imports random class

randhit = random.randint(0, 10)

crit = 10

if randhit < 4:
print('Miss!')
else:
pass
if randhit > 5 and crit:
print('Hit!')
elif randhit == 10:
print("That was a critical!")

print (randhit)

#

Here, it says invalid syntax because of the line "if randhit >5 and crit"

#

But why?

#

If both of those things are True boolean, it should print the line "Hit" right?

#

I get this with the lesser than operator as well.

#

"if randhit is greater than 5 and less than critical, which equals 10, print the line "hit""

#

Why is that invalid syntax?

#

I tried using randrange, randint, random.choice

#

none of those work because it says that I can't compare an integer with a range

#

What's the point in even using a range then?

#

if randhit < 4:
print('Miss!')
elif randhit > 5 and crit:
print('Hit!')
elif randhit == 10:
print("That was a critical!")

print (randhit)

#

.

Changing the code to his now works, but when I hit a 10, it still just prints out 'Hit!' instead of 'That was a critical!'

#

I've spent about 12 hours off and on searching google

#

and nobody can tell me what I'm doing wrong, or what to use

#

import random #Imports random class

randhit = random.randint(0, 2)

crit = 2
hit = 1
miss = 0

if randhit == crit:
print('You hit a critical!')
elif randhit == hit:
print('You hit!')
elif randhit == miss:
print('You missed.')

print(randhit)

#

This is the only thing I can get to work, but I want the critical to not be a 25% chance, I want it to be lower

umbral ocean
#

lvl1_enemies = ('s1', 'z1')
chr_exp = 0
def experience(self):
global chr_exp
if str(self) in lvl1_enemies:
chr_exp += 15
return chr_exp
else:
print("wrong")
self is y(comes from a battle def it is too long to put in here so i cant. Think that there are two types of enemies and there are three diffrent levels of them and one of them fights with you) At the end of the battle chr_exp should go up diffrently by the level of the enemies not the type. Print wrong statement is there because i use it to learn if statment works or not. Apparently it doesn't working. I know i can code it individually with if and elif statements but its too repetitive. I repeat i just get 'wrong' as a result (if str(self) in lvl1_enemies:) doesn't work. What should i do? (I tried it with for and while loop as well they didn't work if there is a method works with them tell me about them as well please!!) s1 = Skeleton('Skeleton', 80, 0, 5, 0)
z1 = Zombie('Zombie', 100, 20, 5, 3) these are what will be self/y specifically s1 and z1

frigid knoll
#

hi there, what does "self" mean in terms of writing classes?

#

it always asks me like when i type ```py
pLayer.name(self=)

^^^^ what is that "self" bit?

#

i asked google he said stfu

tranquil robin
#

What exactly is queue?

#

I'm making a text based game written in python, but I want to display sprites using pygame. Would I need threading to achieve this or would a queue be good enough?

near wedge
#

@frigid knoll I'm pretty sure that self= is invalid Python; I don't know where you picked that up from. You can just use pLayer.name()

#

@tranquil robin A queue is a list/array-like data structure usually used for pushing stuff into one end and popping from another. I am not sure what it has to do with displaying sprites in PyGame though.

#

Also, needing threading for displaying sprites sounds like asking if you need an airplane to get to the grocery store. I highly doubt you'll need to do some threading (of your own, don't know about PyGame internals).

frigid knoll
#

i know sry, its because i was using ```py
class pLayer:

def __init__(self):
    user.append(input(">>> " + user[0] + " . . . "))

def name(self): # <---- i was putting self right there
    user.append(input(">>> What is your name? . . . "))
near wedge
#

Ah, yes, that is the correct spot for self.

#

The first item passed into an instance method is the instance itself.

#

You could really use any name for the first argument, but self is the convention.

tranquil robin
#
import threading
import queue

pygame.init()
screen = pygame.display.set_mode((300, 300))
quit_game = False

commands = queue.Queue()

pos = pygame.Vector2(10, 10)

m = {'w': (0, -10),
     'a': (-10, 0),
     's': (0, 10),
     'd': (10, 0)}

class Input(threading.Thread):
  def run(self):
    while not quit_game:
      command = input()
      commands.put(command)

i = Input()
i.start()

old_pos = []

while not quit_game:
  try:
    command = commands.get(False)
  except queue.Empty:
    command = None

  if command in m:
    old_pos.append((int(pos.x), int(pos.y)))
    pos += m[command]

  for e in pygame.event.get():
    if e.type == pygame.QUIT:
      print("press enter to exit")
      quit_game = True

  screen.fill((0, 0, 0))
  for p in old_pos:
      pygame.draw.circle(screen, (75, 0, 0), p, 10, 2)
  pygame.draw.circle(screen, (200, 0, 0), (int(pos.x), int(pos.y)), 10, 2)
  pygame.display.flip()


#

Here's a threading code for displaying a circle on a separate screen when you press either 'w' 's' 'a' or 'd'

near wedge
#

@tranquil robin any particular reason to use input()? PyGame should have a non - blocking way to get inputs.

#

However, from a high level, what you have should work, and is a basic producer-consumer pattern. It just seems overly complicated for basic stuff.

tranquil robin
#

It's a threading code I got from someone else

#
    global location
    #print(room.get('Main Hall', 'item'))
    while adventure == True:
        for x in npc:
            print(x)
            npc_Action(x[0])
        desc = room.get(location, 'desc')
        exits = room.get(location, 'exits')
        if room.get(location, 'visit') == "False":
            globals()[room.get(location, 'event')]()
        print(desc)
        print(exits)
        global advaction
        advaction = input('>')
        if advaction == "quit":
            sys.exit(0)
        print(advaction)
        explore_Dungeon()```
#

This is the main loop of my text based game

shadow dock
#

hi all

#

I am making a game ike mc in python

#

but I dont know to to add controls

#

Can someone hep me

#

please

dawn quiver
#

have you used pyglet before @shadow dock

shadow dock
#

Yes

forest oak
#

Hi, I want to make a simple Minecraft terrain generation clone with Pyglet. There are some clones of "Minecraft" with it, so I want to do it too. I also need to learn OpenGL. However I can't find any good resources to learn from. Many tutorials just don't explain anything and I end up with copying the code from them, without any understanding. I will appreciate any tips! ❀️

slender glacier
#

can we insert a video into python arcade?

umbral ocean
#

s1 = Skeleton('Skeleton', 80, 0, 5, 0)
z1 = Zombie('Zombie', 100, 20, 5, 3)

#

class Zombie(Enemy):
def init(self, Name,Health,Mana,Ad,Ap):
Enemy.init(self, Name,Health,Mana,Ad,Ap)

#

lvl1_enemies = ('s1', 'z1')
chr_exp = 0
def experience(self):
global chr_exp
if str(self) in lvl1_enemies:
chr_exp += 15
return chr_exp
else:
print("wrong")

#

class Enemy:
def init(self, Name,Health,Mana,Ad,Ap):
self.name = Name
self.health = Health
self.mana = Mana
self.ad = Ad
self.ap = Ap

def normal_attack(self):
    print(f"{self.name} attacked you with a normal attack")
    return self.ad *random.choice(multipliers_enemy)
#

def battle(x, y):
print(f"Encountered with a {y.name}")
while x.health and y.health > 0:
command = input("> ").lower()
if command == "a":
y.health = y.health - x.base_attack()
print(f"Remaining {y.name} health is {y.health}")
x.mana += 5
if y.health > 0:
x.health = x.health - enemy_attack(y)
else:
break
print(f"Remaining Health and Mana are {x.health} {x.mana}")
return print(f"{y.name} is dead"), print(f"Remaining Health and Mana are {x.health} {x.mana}"),experince(y)

lusty oyster
#

So I have

def drawDecor():
    for i in range(10):
        grassBlock_pos[0] -= 100
        win.blit(grassBlock, grassBlock_pos)
#

but the grassblocks do not go across the screen like intended

#

also Ik that this will lag

tidal magnet
#

so im having an error that it cant load my icon and when i play the game it still doesnt load it, but when i go to the file in the file explorer and open it it displays the icon. here is a vid.

#

and here is my code too but watch the vid first.

#
import pygame

pygame.init()

screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Space Invaders")

icon = pygame.image.load("ufo.png")
pygame.display.set_icon(icon)

running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

#

pls tag me so i know someone replied and im a begginer at pygame and python thats why i dont know this easy thing which is hard for me. πŸ™‚

umbral ocean
#

s1 = Skeleton('Skeleton', 80, 0, 5, 0)
z1 = Zombie('Zombie', 100, 20, 5, 3)
[1:30 PM]
class Zombie(Enemy):
def init(self, Name,Health,Mana,Ad,Ap):
Enemy.init(self, Name,Health,Mana,Ad,Ap)
[1:30 PM]
lvl1_enemies = ('s1', 'z1')
chr_exp = 0
def experience(self):
global chr_exp
if str(self) in lvl1_enemies:
chr_exp += 15
return chr_exp
else:
print("wrong")

lusty oyster
#

what is the error @tidal magnet

tidal magnet
#

@lusty oyster it wont display the icon when i run it using vs code but when i go to the file explorer and open it from their it displays the icon. To undertsand me cleare go to the other message and their is a vid watch it and then ull understand.

brittle orchid
#

@strong raptor
i have tryed that but it comes up with this

ModuleNotFoundError: No module named 'pygame'

tidal magnet
#

@lusty oyster ?

grand kraken
#

Hi I’m bones I’m looking for members who could help me make this game in roblox studio

#

Please dm me for more info

west egret
#

sigh You do realize you're going to get kicked or something right

#

you're just slightly rephrasing the question so that it doesn't sound like recruitment anymore

strong raptor
#

@brittle orchid not sure then. @ someone else maybe they know more than me

ionic depot
#

@west egret lmao

#

@tidal magnet what's the prob

#

I could probably help you

#

running(or 'game_over') = false
while not running:
for event... :
if event.type == pygame.QUIT:
running (or 'game_over') = true

#

Try this one

#

@tidal magnet

rigid brook
#

i was trying OPEN GL and I am running into some issues

#
import OpenGL as GL
import pygame

from OpenGL.GL import *
from OpenGL.GLU import *

verticies = (
    (0, 2, 0),
    (2, 2, 0),
    (2, 0, 0),
    (0, 0, 0),
    (0, 0, 2),
    (0, 2, 2),
    (2, 2, 2),
    (2, 0, 2)
)
edges=(
    (0,1),
    (0,5),
    (1,2),
    (1,6),
    (2,3),
    (2,7),
    (0,3),
    (3,4),
    (4,7),
    (6,7),
    (5,6),
    (4,5)
)



def Cube():
    glBegin(GL_LINES)
    for edge in edges:
        for vertex in edge:
            glVertex3fv(verticies[vertex])
    glEnd()

def main():
    pygame.init()
    display = (800,600)
    pygame.display.set_mode(display, DOUBLEBUF|OPEN_GL)
    gluPerspective(45,  (display[0]/display[1]), 0.1, 50.0)
    glTranslatef(0.0,0.0, -5)

    glRotatef(0,0,0,0)
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
        Cube()
        pygame.display.flip()
        pygame.time.wait(10)

main()```
my Code
#

i was trying to make a cube

#

😦

#
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "Glstreamer.py", line 60, in <module>
    main()
  File "Glstreamer.py", line 44, in main
    pygame.display.set_mode(display, DOUBLEBUF|OPEN_GL)
NameError: name 'DOUBLEBUF' is not defined

the error

ancient olive
#

hey im new to python can you make games with it

ionic depot
#

@ancient olive yes , ofc

valid wyvern
#

I want to learn how to make games fast with python independently can I get help for it

ionic depot
#

What game do you want to make?

#

@valid wyvern

valid wyvern
#

Any game

ionic depot
#

Snake game?

#

It's easy

valid wyvern
#

But a platform game would be preffered

ionic depot
#

What exactly

valid wyvern
#

Like a endless runner or one where the Player must dodge obstacles like undertale

ionic depot
#

Oh

#

You said you are a beginner?

valid wyvern
#

Yep

ionic depot
#

Have you done any projects before?

#

Simple or advanced

valid wyvern
#

But I've made snake game
A ping pong game

But they were from a tutorial and I want to learn to do it off the top of my head

ionic depot
#

Oh , so you want tips

valid wyvern
#

Yep and a tutorial to guide me

#

:)

ionic depot
#

Hmm

valid wyvern
#

Cuz like I would prefer a long one where I actually learn things and not just Hello world

#

i was trying to make a cube
@rigid brook :(

rigid brook
#

lol i fixed the Issue

#

it was wrong imports

dawn quiver
#

which library do i need to make chess with django

ripe sage
#

hey any one can suggest how to make chess with DJANGO with some graphics .....means which library we gonna use

fresh fiber
#

beginner here trying to get into game designing, whats the difference between python game development and c++ game development. which is better?

#

@prime juniper thank you for the answer, is it better to start with c++ or python if you're a complete beginner with no prior experience in coding except HTML, CSS and a little bit of python?

stark anvil
#

you can consider a game engine

#

like Unity.

last moon
#

^ /unreal

stark anvil
#

@fresh fiber

last moon
#

Python game dev’ll probably be a bit easier if you have experience with py but like sfdsf mentioned, you’ll be limited by the library

#

That being said libraries like pyglet (+ others) use low level stuff like OpenGL

untold bramble
#

hi all. do you guys know of any packages that involve NLP for the purposes of text adventure games? I was thinking about Facade's use of NLP. i would love to see more of that or maybe just mod facade to create another story.

#

There's monumental room for Facade-like games.

dawn quiver
#

eh I downloaded a pygame flappy bird looked at the code and said nope and never touched it again this channel is not for me.

#

that much code should never be in a game so little as flappy bird.

ionic depot
#

@dawn quiver that's the reality

#

Other big games have millions lines of code

#

Are you new in this programming thing @dawn quiver?

#

@dawn quiver Btw , how many lines of code does your flappy bird game has?

dawn quiver
#

I didnt count atleast 50

#

just for a quick animation and a random set of pipes obviously with gravity and controls but still

#

but they werent like 3 word lines they were packed

ionic depot
#

How old are you?

dawn quiver
#

13

#

listen, my age shouldnt matter I personally dont like people who think im not "old enough" or "experienced" enough to know how to code or learn.

ionic depot
#

Yeah , the age doesn't matter

dawn quiver
#

well for coding atleast maybe not other things-

#

lets not go there πŸ™‚

ionic depot
#

what brought you to the python world?

#

Some kind of influence

#

Or from pure curiosity

#

?

olive quail
#

13
@dawn quiver samee

dawn quiver
#

@ionic depot oh me I wanna be a dev

ionic depot
#

@olive quail what about you

dawn quiver
#

I have been coding for like 3 years and im off to a good start.

ionic depot
#

How many projects do you have ?

dawn quiver
#

over 20

ionic depot
#

And in what programming language?

dawn quiver
#

node.js and python

ionic depot
#

And you find flappy bird hard to make?

dawn quiver
#

yes.

ionic depot
#

That's impossible

dawn quiver
#

something about pygame just isnt in my list of capable things

olive quail
#

Tried to make a bot once with java script once without knowing it at all, and quit that after like a week, I'm trying to make another but but this time I'm using python, but I don't know python at all so I have to watch videos for it lol, planning on trying to learn it but with school idk @ionic depot

ionic depot
#

Is one of the most easiest games out there

dawn quiver
#

dude I took one look at it and said no.

olive quail
#

My Grammer sucks

dawn quiver
#

all the different functions ima stick to c# in unity

ionic depot
#

Can you show the code?

dawn quiver
#

yea lemme find it again

ionic depot
#

Yeah , c++ and others are better at this topic

#

Python too

prisma beacon
#

Error it is showing is.... There is no module named 'pygame'........
After I written import pygame...... Why???

ionic depot
#

But it's limited

dawn quiver
#

python just isnt meant for games. unless we talking og mario graphics

ionic depot
#

@prisma beacon pip install pygame

#

@dawn quiver right

prisma beacon
#

Means.... From where...

dawn quiver
#

cmd...

#

or vs

ionic depot
#

@olive quail try to learn python in free time

dawn quiver
#

personally I love to code bots but I have moved to much bigger things...

ionic depot
#

Yeah

#

That's the hardest step you could take

dawn quiver
#

theres a bot for everything yea you get credit but better to use someone elses bot thats already more known and then you dont gotta pay for servers

ionic depot
#

To move from small thing to bigger ones

prisma beacon
#

Can i get a source of of a game.... I want to learn it...... Just a begginer

ionic depot
#

Yeah , sure @prisma beacon

#

One sec

dawn quiver
#

oh for me it was easy I didnt start with bots I started with big things... then moved down then back up

ionic depot
prisma beacon
#

Thanks broo

ionic depot
#

One more thing

dawn quiver
#

ok well snake game is easy

#

im talking flappy bird

#

IT SHOULD BE EASY TO

ionic depot
#

There are some issues with first stpes

#

@dawn quiver send the code

#

I want to see it

dawn quiver
#

alr

#

thats the one I did

#

not did

#

you know what I mean

ionic depot
#

Right

dawn quiver
#

it dont even got a menu and it still complex

ionic depot
#

Old code

#

7 years

olive quail
#

Jesus that's old

ionic depot
#

You should find tutorials from 2018 to 2020

#

Those are the newest ones

#

And the easiest

#

Cause python evolved

dawn quiver
#

ohhh thats why i looked at it and wanted to never see pygame again

#

makes sense.

ionic depot
#

Don't search for projects on git hub

#

Most of them are hard to understand

dawn quiver
#

no there not

#

lmfao

ionic depot
#

YouTube is a good source to find projects

dawn quiver
#

readmes are usually useless but I know what most functions do.

ionic depot
#

But , I advise you to not follow them

#

Just understand them

#

And make your own code

prisma beacon
#

Where to give command to pip install pygame??????

ionic depot
#

Vs or cmd

olive quail
#

Why so many question marks?

ionic depot
#

:))

olive quail
#

lol

ionic depot
#

Cause he's desperately fixing that prob

prisma beacon
#

cmd means????????????

ionic depot
#

A beginner thing

olive quail
#

Fair

ionic depot
#

Hmm , how to explain

#

It's much easier on Vs code

#

@prisma beacon download Vs code first

prisma beacon
#

Then Vs means?????

ionic depot
#

Visual studio

prisma beacon
#

From where should I download it

ionic depot
#

Google

#

Ofc

#

It shouldn't take you more than 10 min

olive quail
ionic depot
#

:))

#

@olive quail are you trying to make bots?

#

Or game bots

prisma beacon
#

First I have install pygame module..... Or just directly open Vs

ionic depot
#

Open vs

#

Download python

prisma beacon
#

I have pycharm

dawn quiver
#

yea about me making my own code I do as I told you 20+ projects games in python just arent my strong suit

ionic depot
#

Hmm , I don't like pycharm

#

Vs code is much easier to use

prisma beacon
#

Okk

ionic depot
#

@dawn quiver but you did in other programming languages

prisma beacon
#

After downloading python in Vs.... What I should do

ionic depot
#

I don't understand that :))

dawn quiver
#

I make tools im not allowed to discuss here not really games I just wanted to make some I could play offline for boredom and yea I think unity is a great engine for games I can easily make em in that

ionic depot
#

Learn the basics if you're not familiar

#

With python

prisma beacon
#

I should run my program in Vs then.... It will not say error in import pygame

olive quail
#

@olive quail are you trying to make bots?
@ionic depot discoed bots lol, just not at my computer so I don't know whats wrong with code rn or what I wanna add

#

At some point I wanna try to make a game but lol

#

I can't apell

#

Spell

ionic depot
#

@olive quail lol

olive quail
#

Why do you ask?

ionic depot
#

From curiosity

olive quail
#

Ah

ionic depot
#

Have you tried to make a game bot before?

#

AI or bot

olive quail
#

No u haven't, don't really know what a gamebot is, well besides its prob a bot in a game or ai or somthing

#

Idk coding lol

ionic depot
#

Oh , okay

stiff panther
#

Hello

prisma beacon
#

Hi

#

Dheeraj ask lord the problem

stiff panther
#

Hello @ionic depot we want to ask that how shoud we add sound effects to our game

ionic depot
#

@stiff panther

round drift
#

Does PyGame have Vsync?

dawn quiver
#

πŸ™‚

ionic depot
#

Does pygame has life?

forest oak
#

Hi, I am working with tutorial and I can't get camera rotation to work. It works when I rotate (even though the screen rotation is the same), because my flying direction is changed. Here's my code -

frank fieldBOT
#

Hey @forest oak!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

β€’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

β€’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

ionic depot
#

Good to know

prisma beacon
#

Hey can i get a advance game source code.... I want to try learn it. 😁

dawn quiver
#

what i need to do in this code?

import os
import pyautogui as p

os.system('echo hello')

p.typewrite("h")
ionic depot
#

@prisma beacon like what

grand spire
#

@prisma beacon I can send you my Space Invaders like game I'm working on, it's nowhere near finished, nor 'advanced' but it might be what you are looking for

paper birch
#

how do i get pycharm in the game activity thing

grand spire
#

Go to discord settings > Game Activity > you should be able to select it if it's running

#

or click add game, point to the program