#game-development

1 messages · Page 69 of 1

last moon
#

smh

#

that's circling around (.2843, -.0660)

#

so not quite the origin but close enough

torn heath
last moon
#

that's pretty neat

torn heath
#

oh thx

last moon
#

im pretty sure turtles have a speed cap tho

torn heath
#

let me try to make something else, cause i want to do it seing u do it

last moon
#

"very fast" being the quickest without it being instant

torn heath
#

ye

last moon
torn heath
#

well i am gonna try to make something and i need ideas

last moon
#

try fractals

torn heath
#

what are those

#

it's been a while since i have touched turtle

last moon
#
for i in range(1, 200)
enemy.left(45 + i%4)
enemy.backward(100 - i//2) ```
#

the %

#

higher the divisor, the more intricate?

torn heath
#

ohh

brave widget
#

btw it doesn't need to be the exact origin becuase

#

remember there is going to be a hitbox

#

i hope i didn't was the time for that lol

last moon
#

ya sorry I'm kind of getting distracted

brave widget
#

no no

last moon
#

I'll get you your spiral enventually

brave widget
#

your already going out of your way to help lol

#

I'm already extemely thankful because you've spent like the past 2-3 hours trying to help lol

#

I'm just stressed out because a 5 week assignment is compressed into 3 days lol

last moon
#

it's no problem I'm having fun with this

#

ah ya that sucks

brave widget
#

and I have no prior knowledge

#

so it was quite stressful becauase

#

my school region decided to have a hybrid learning enviornment where we would go to school for 2 days, and the rest would be ascynchronyse learning, and

#

our semsters normally had 4 courses and would last 4 months each, its not compressed to 4 semesters each containing 2 courses and each semester lasts 2 months

mossy harness
#

@last moon

#

so

#

what you want to do

#

you take the point for a circle

#

you know how to do that?

last moon
#

spiral into the origin starting at -250, 250

#

lmao barely

mossy harness
#

loop through each angle and x = sin(angle) * circle_radius and y = cos(angle) * circle_radius

#

plus that in and you get the point of a circle

#

and so each step you increase the radius

last moon
#

what if I use left/backward/etc/etc?

mossy harness
#

wdym

last moon
#

where the input is an angle

#

turtle

mossy harness
#

oh

#

um

#

lets see

#

start at something like 0, 0

#

yeah

#

0, 0

#

and then step through some amounts of rotations

#

increasing the angle each time by some amount

#

each step, increase the radius by some amount

#

then get x, y coords

#

and subtract the previous coords from that

#

and thats how much you move

last moon
#

oh so I need to iterate until the spiral hits -250, 250 and run through the range backwards

mossy harness
#

if you want to have a 2d spiral, yes

last moon
#

that's the plan

mossy harness
#

eh

#

i wouldnt reccomend setting a point as the end thing

#

i think it would be better to set the params, then tweak them as you like

last moon
#

that's what i've been trying to do
idk I need to walk throught the math for a sec

#

so the initial radius needs to be the sqrt(250^2+250^2)

#

like where the turtle starts

mossy harness
#

initial radius would be zero

last moon
#

ig it's x,y coords so that doesn't matter

mossy harness
#

final radius would be that amount

last moon
#

no it needs to be the other way around

#

unless I draw it backwards

#

which is the same thing

mossy harness
#

are you looking to set the spiral to go to a certain point?

#

or are you just trying to make a spiral in general?

last moon
#

ya (-250,250) -> (0,0)

#

last coords should preferably be at least (0,0) ± 1

mossy harness
#

oh woops cosine is for x sine is for y

#

ok

#

so

brave widget
#

How big should I make the hitbox for the turtle because I think that would reduce some of the issues

#

or not tbh idek

mossy harness
#

what i would reccomend doing is taking that last point, taking the distance from the last to first point, dividing by the amounts spirals you want, dividing by the steps per spiral, then using that as the radius increase per step @late quartz

last moon
#

how do you take the inverse cos/sin in py?

mossy harness
#

acos / asin

#

so

#

math.acos/math.asin

last moon
#

decided to use polar coords and convert them

#
a = 0
b = 1
for i in range(200, 1, -1):
    phi = i
    rho = a + b*phi
    x = rho * math.cos(phi)
    y = rho * math.sin(phi)
    enemy.goto(x, y)```
#

just need to tweak a,b

brave widget
#

oh wow

#

btw thanks once again, I'm going to call it a night, its almost 2 am and I got school tmr

last moon
#

alright have a good one, ping me tomorrow, I'll have it figured out hopefully by then

brave widget
#

alright

#

btw I don't want to discourage but wouldn't that be too many cycles?

last moon
#

probably lol

brave widget
#

I would say if its just 5-10 it would be more than enough, and we don't need it to go directly to the center because remember we are working with a hitbox

#

so as long as the last spiral is close enough for the two hitboxes to touch, we should be fine lol

last moon
#

@brave widget py first = True a = 0 b = 1.5 freq = 3 multiplier = 4 exponent = 9/10 _min, _max, _step = 250, 1, -1 for i in range(_min, _max, _step): phi = i / freq rho = a + b * phi**(exponent) * multiplier x = rho * math.cos(phi) y = rho * math.sin(phi) if first: enemy.up() enemy.goto(x, y) enemy.down() first = False enemy.goto(x,y)

#

so it doesn't start at -250, 250 specifically

#

but you can tweak the range so it's close

#
_min, _max, _step = 250, 1, -1
a = 0
b = 1.5
freq = 9
multiplier = 10
exponent = 9/10``` that seems to work pretty well
torn heath
#

nice

#

is there a way to get the exact location of a point?

last moon
#

turt.xcor()

#

or y

torn heath
#

thx

#

i am gonna make a race track

#

lol

#

not a race track but like a swmming pool racing thingy

#

where turtles are gonna race

dawn quiver
#

guys i need help with an code!

#
    print("We're no strangers to love")
    print("You know the rules and so do I")
    print("A full commitment's what I'm thinking of")
    print("You wouldn't get this from any other guy")
    print("I just wanna tell you how I'm feeling")
    print("Gotta make you understand")
    print("Never gonna give you up")
    print("Never gonna let you down")
    print("Never gonna run around and desert you")
    print("Never gonna make you cry")
    print("Never gonna say goodbye")
    print("Never gonna tell a lie and hurt you")```
#

rick_roll()

last moon
#

what's the issue? @dawn quiver

little eagle
#
import pygame

pygame.init()
screen = pygame.display.set_mode((1000,800))
screen.fill ((0,0,45))
ball = pygame.image.load('circle.png')
def ball_come():
    screen.blit(ball,(ballx,bally))
x = 300
y = 30

ballx = 500
bally = 400
ballspeed = 1
ballspeed_2 = 1

ai_stick_y = 400

font = pygame.font.Font('freesansbold.ttf', 50)


shape = pygame.surface.Surface((250,250))

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

    stick_1 = pygame.draw.rect(screen, (0, 255, 0),(1000, 400,100,200),50)
    stick_2 = pygame.draw.rect(screen, (0, 255, 0), (0, ai_stick_y, 50, 200),)
    #go = font.render("Click up arrow to start   ", True, (255, 255, 255))

    #screen.blit(go, (x, y))
    clock = pygame.time.Clock()
    #clock.tick(100)
    ballx -= 0.3
    bally -= 0.3
    ai_stick_y -= 1
    ball_come()


    pygame.display.update()```
That is my code and my problem is :
#

A dough like thing when try to move

#

just a pong game

#

help me

last moon
#

imma take a wild guess and say you're adding the blit on top of the last one

little eagle
#

so what should i do ?

last moon
#

idk pygame but I'm assuming you'll have to redraw the background + paddles + new ball pos

little eagle
#

ok

last moon
#

you can see it's happening to the paddles as well so you have to update those

#

it might be a bit easier if you stick the sprites in class instances

little eagle
#

ok

modern marsh
#

hi game developers

dawn quiver
#

hi gamers

olive parcel
#

@little eagle you want to use screen.fill() to clear the frame and then redraw the elements

glass forge
#

hi

#

im having issues with pygame instalation in ubuntu 16.04

#

i tried every command possible

#

nothing works

flat dew
#

python3 -m pip install pygame?

glass forge
#

yes ofc

flat dew
#

Replace python3 with python and py

#

Try all three

glass forge
#

python3 -m pip install pygame?
@flat dew no module named pip

#

i have pip and pip3

#

python3.7

#

20.4 i think

flat dew
#

If you are using pip install without the python, you need to use pip3. but sometimes just using pip3 installs pygame in a different version of Python that the program is not using

#

So, use python -m in front of pip in order to specify that you want to use the pip that is a module command in that specific Python version

glass forge
#

Successfully installed pygame-2.0.0
You are using pip version 8.1.1, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

#

but then i type

#

python3 -m pygame.examples.aliens

#

/usr/local/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No module named 'pygame')

flat dew
#

WHat command did you use for installing pygame

glass forge
#

Try all three
@flat dew you mean py -m pip install pygame
?

#

command not found

flat dew
#

Yeah

#

Sometimes py works

#

py

#

If you have many versions

#

Of python

#

installed

tranquil girder
#

I thought py was for windows, not linux

glass forge
#

WHat command did you use for installing pygame
@flat dew i tried everything i found in forums

tranquil girder
#

python3 and pip3 is correct on ubuntu

flat dew
#
python3 pygame.examples.aliens.py```
```pip3 install pygame
python3 pygame.examples.aliens.py```
#

Run those?

#

And try

glass forge
#

no module named pip

#

😦

#

pip -V and pip3 -V works though

#

the second script you say

#

Requirement already satisfied: pygame in ./.local/lib/python3.7/site-packages (2.0.0)

#

i think theres a problem with the directories

#

where everything is installed and stuff

#

but sounds odd

olive parcel
#

@glass forge it looks like you have multiple versions of Python and pip3 corresponds to a different one for you than python3

#

Maybe try running with python3.7 instead

#

Or uninstall and reinstall Python to clean up the mess

glass forge
#

Or uninstall and reinstall Python to clean up the mess
@olive parcel this seems more neat

#

i have python 3.7 though

olive parcel
#

You might have more than one 3.7 for all I know

glass forge
#

someone told me to type this

#

/usr/local/lib/python3.7 -m pip install pygame==1.9

#

You might have more than one 3.7 for all I know
@olive parcel idk , it doesnt seem

olive parcel
#

Those are different Python installations than the ones that come from the Ubuntu repositories.

#

That's the problem

#

If you type python3 you might get the system version, and if you type /usr/local/bin/python3.7 you might get the version in /usr/local

glass forge
#

pythn -V

olive parcel
#

I would suggest deleting all Python versions in /usr/local/bin and /usr/local/lib and just using your system installation

glass forge
#

3.5.2

#

python3 -V

#

3.9.0

olive parcel
#

Or just explicitly running python3.9 all the time then

#

python3.9 -m pip install pygame and python3.9 pygame.examples.aliens.py

#

If you get an error saying that there's no module called pip, do python3.9 -m ensurepip

glass forge
#

/usr/local/bin/python3.7

#

no such directory

olive parcel
#

Anyway, just pick which Python installation you want to use and stick with it

glass forge
#

someone just told me this : PyGame 1.9 is not compatible with Python 3.8, 3.9 or 3.10 alpha

#

can i just delete them from the directory? i mena with right button --- delete

olive parcel
#

Probably not, how did you install them?

glass forge
#

Or just explicitly running python3.9 all the time then
@olive parcel

olive parcel
#

Did you compile Python 3.9 from source?

#

Because it looks like it's broken

glass forge
#

Probably not, how did you install them?
@olive parcel command scripts . 3.9 downloading a zip file from pygames webiste

olive parcel
#

How did you install Python 3.9? Not from PyGame's website I assume?

glass forge
#

Because it looks like it's broken
@olive parcel i downloaded as a zip file

#

mmm

#

perhaps i messed up something

#

lol

#

now idk

#

can i just unistall it?

olive parcel
#

Depends on how you installed it… if you built Python from source, which it does look like, then calling "sudo make uninstall" inside the source code directory is the best way to do it

#

If you no longer have the source code directory, well, then… I guess you would just need to carefully manually delete a bunch of locations within /usr/local

glass forge
#

local/bin or local/lib ?

olive parcel
#

Neither

#

Try locate pybuilddir.txt

glass forge
#

/home/igna/Downloads/Python-3.9.0/pybuilddir.txt

olive parcel
#

Okay, great, do cd /home/igna/Downloads/Python-3.9.0 and then sudo make uninstall

glass forge
#

its also here : /usr/local/include/python3.9/

olive parcel
#

Yeah, that's not the one

glass forge
#

make: *** No rule to make target 'uninstall'. Stop.

#

😭

olive parcel
#

Erm, maybe it's deinstall instead of uninstall ?

#

You're inside /home/igna/Downloads/Python-3.9.0/ right?

glass forge
#

yep

#

~/Downloads/Python-3.9.0$ sudo make deinstall
make: *** No rule to make target 'deinstall'. Stop.

#

~/Downloads/Python-3.9.0$ sudo make uninstall
make: *** No rule to make target 'uninstall'. Stop.

olive parcel
#

@glass forge

sudo rm -f /usr/local/bin/python3.9
sudo rm -f /usr/local/bin/pip3.9
sudo rm -f /usr/local/bin/pip3
sudo rm -f /usr/local/bin/python3
sudo rm -rf /usr/local/include/python3.9
sudo rm -f /usr/local/lib/libpython3.9.a
sudo rm -rf /usr/local/lib/python3.9
glass forge
#

i think its done

#

before

#

when i type python3 -V

#

3.9.0

#

now

#

No such file or directory
}

olive parcel
#

Okay, good. You should still have python3.7 or python3.5 or whatever else you had before

glass forge
#

now i should install pygame?

olive parcel
#

You can certainly try

glass forge
#

it works!

#

but it crashs

#

idk why

#

when i pres space bar

#

(shoots a missile)

#

and crushes

#

its a space invaders game

olive parcel
#

I have no idea (and please try not to hit "enter" after every three words)

glass forge
#

ohh

#

sorry

#

fuck

#

Thank you for the help!

olive parcel
#

No problem

brave widget
#

@last moon Hey, sorry to ping you, I didn't know what time zone your in so I waited till the first time you responded to me yesterday

glass forge
#

sorry to bother again

#

any help with this? : ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
it displays evrytime i want to run a game using pygame , from the terminal
i found this answer but idk what to put there. import os os.environ['SDL_AUDIODRIVER'] = 'dsp'

last moon
#

no problem what's up?

glass forge
#

This appears ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred

#

Everytime I try to run a game

#

That uses pygame

last moon
#

ah sorry idk about that I was talking to @brave widget

glass forge
#

Ooh

brave widget
#

Hey, I'm having an issue

#

so I have a bullet that is shot from my turtle

#

but once Input the formula for the spiral formula, it says there is an error with the bullet state

brave widget
#

That's the original code for the bullet but the enemy doesn't move at all

#

Thats the one with the enemy movement added in

tranquil girder
#

as the error says, bulletstate is not defined anywhere

brave widget
#

it works for the first image tho

last moon
#

line 105?

#

you not using the global bulletstate

#

also find a way to not use global
you'll end up with more issues than you need

brave widget
#

oh

#

The tutorial was using it, but lemme see what I can do

willow mirage
#

Hey guys, I need some help here please.
First of all, I don't really know in which channel I should ask for help, so I apologize if this is the wrong one.
Here is the deal:
I'm trying to merge two images with python.
I've searched the web, and came to a (sort of) little script for doing it. Here it is:

#

But the problem is that my IDE tells me that PIL doesn't have any "image" method.

#

I think that my PIL installation went a bit wrong, but how can I fix it, please ?

last moon
#

Image not image, it's a class

willow mirage
brave widget
#

Import, the issue is with the second picture, idk why tho

last moon
#

ah so PIL's __init__.py's a bit odd, it's not actually importing Image.py or any other file

#

just call from PIL import * or from PIL import Image

#

im trying to figure out if there's another way but I haven't seen a library modeled like this in a while

willow mirage
#

With from PIL import Image, it works !

#

Thanks a lot !

last moon
#

import PIL.features as pil that seems to work idk if anything is left out tho

brave widget
#

I can't get it to work 😓

#

Idk how to fix this

last moon
#

getting rid of global?

brave widget
#

no i mean it works with the first image

#

where I didn't input the movement for the enemy

#

but when I do that, it give me the error message

last moon
#

the same message?

brave widget
#

wait lemme take ss of what happens

frank fieldBOT
#

:incoming_envelope: :ok_hand: applied mute to @brave widget until 2020-11-07 00:26 (9 minutes and 58 seconds) (reason: newlines rule: sent 115 newlines in 10s).

blissful dock
#

!unmute 240210899263160320

frank fieldBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @brave widget.

blissful dock
#

!paste use this for longer code

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.

brave widget
#

Oops

#

ty vivax

blissful dock
#

np 😄

brave widget
#

I posted the code before and after inputing the movement for the enemy

last moon
#

what's the issue with it?

brave widget
#

when i try shooting the bullet for the second code, it tells me that bulletstate is not defined

last moon
#

!traceback

frank fieldBOT
#

Please provide a full traceback to your exception in order for us to identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / 0
ZeroDivisionError: integer division or modulo by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (e.g. ZeroDivisionError)
• Make note of the line number, and navigate there in your program.
• Try to understand why the error occurred.

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

last moon
#

@brave widget what's the traceback?

brave widget
#

oh

#

oops

#

File "C:\Users\wajda\Downloads\Code.py", line 75, in fire_bullet
if bulletstate == "ready":
NameError: name 'bulletstate' is not defined

last moon
#

pass it as a arg

#

def fire_bullet(bulletstate):

brave widget
#

My brain hurts lol

#

I'm going to take a break from this and do physics lol

#

I can't think straight

last moon
#

far enough

brave widget
#

idk I can't even figure out how to pass it as an arg now

last moon
#
def fire_bullet(bulletstate):
  ...
fire_bullet(bulletstate)```
brave widget
#

you know when you try on smth for a long while ... and you become incapable of thinking lol

#

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\wajda\AppData\Local\Programs\Python\Python39\lib\tkinter_init_.py", line 1885, in call
return self.func(*args)
File "C:\Users\wajda\AppData\Local\Programs\Python\Python39\lib\turtle.py", line 687, in eventfun
fun()
TypeError: fire_bullet() missing 1 required positional argument: 'bulletstate'

last moon
#

call it with bulletstate

#
fire_bullet(bulletstate)```
brave widget
#

i can't

#

lol

#

i'm just braindead

#

I'm going ot physics, I'll be back in like an hour lol

last moon
#

anyone know how to update the window after drawing polygons with arcade?
I can't call .draw() because it's not a sprite, and I seemingly can't crate it as a sprite without an actual texture
Is there some GL workaround or am I missing something

merry echo
#

What are you using to draw the polygons?

#

arcade.create_polygon()?

last moon
#

arcade.draw_polygon_outline()

#

so that'd be an issue

merry echo
#

That should already draw the polygon, what do you mean by update?

last moon
#

I need to draw more

#

on click

storm cradle
#

Guys I need help with something in pygame

#

Guys I need help: I'm running this little program that loads images to the screen in fullscreen mode but once it loads the program it will not exit by any key combination and it's a black screen. I end up having to reset the computer to complete whatever else I was doing. Can I DM anyone to help bc my code is long???

#


def draw_floor():
    screen.blit(floor_surface,(floor_x_position,900)) # puts two surfaces on screen and creates fluid left movement 
    screen.blit(floor_surface,(floor_x_position + 576,900))


pygame.init()
screen = pygame.display.set_mode((576,1024)) # create display surface
clock = pygame.time.Clock()


bg_surface = pygame.image.load("background-day.png").convert() # import first image
bg_surface = pygame.transform.scale2x(bg_surface) # takes one surface, doubles the size, and returns it

floor_surface = pygame.image.load("base.png").convert() #import image
floor_surface = pygame.transform.scale2x(floor_surface) #scale floor surface
floor_x_position = 0


while True:
    for event in pygame.event.get(): # pygame looks for events happening currently such as moving your mouse or closing a window
        if event.type == pygame.QUIT: # closing the game 
            pygame.quit() # uninitializng game
            sys.exit() # shuts down game completely
            
    screen.blit(bg_surface,(0,0)) # use blit method to put one surface on another
    floor_x_position -= 1 # will make floor move to right
    draw_floor()
    if floor_x_position <= -576:
        floor_x_position = 0

            
    pygame.display.update # Draws it from screen from while loop
    clock.tick(120) # Limit frame rate per sec ```
#

I'm on mac OS btw.

cold storm
#
travel = 100
start = [0,100]
point = start
travelList = [ [1,0],[0,-1], [-1,0],[0,1] ]
i=0
while current < travel:
     point+=travelList[i]
     draw(point)
else:
     travel*=.9
     
     i+=1
     if i>3:
        i=0
if travel<1:
   break
#

@late quartz

#

travel over-100 pixel turn -> travel 90 -> turn -> travel 80 -> turn

#

I don't know how to rotate a 2d orientation though

#

a list could work

#

[ (1,0),(0,-1), (-1,0),(0,1) ]

#

that should work eh

#

for your fibanachi thing?

little eagle
#

I'm on mac OS btw.
@storm cradle same

quasi atlas
#

hi, how do i display long text in pygame without it getting cut out? (please ping me)

dawn quiver
#

hello bois

austere shoal
#

hello

#

i need help with my code

onyx wren
#

is it to do with games?

quasi atlas
#

hi, how do i display long text in pygame without it getting cut out? (please ping me)

severe saffron
#

wym

#

you want it to get wrappde?

#

wrapped

#

@quasi atlas

quasi atlas
#

yeah @severe saffron

storm minnow
#

im trying to do screen.blit(square.png(50, 50)) and its saying that

#

it needs to be pygame.surface

#

what do I do?

fluid gull
#

quick question, not trying to be disrespectful. do you guys view python game development as like a novelty or learning instrument, or are you trying to actually make real games using python?

#

games are incredibly dependent on performance and i can't imagine python ever being the best tool for the job in that arena

olive parcel
#

One approach is to use Python for game logic while relying on an engine written in C++ with Python bindings (this is more or less the model of Panda3D)

sterile dust
#

Need some help with pygame 😦 Was just codeing for fun and turns out I was basically codeing Spaceinvaders. After about 1hr I noticed I hadent run the code once and when I did, basically nothing was working. I can see all of the graphics, but i could not move the "space ship"and no mobs were spawning. Heres the code if anyone can help: https://paste.pythondiscord.com/xiwufazevi.rb

dawn quiver
#

so I'm working on an Anti-Cheat plugin for game developers to use, does anyone know of some good package libraries that could help? (this may sound like a stupid question)

dawn quiver
#

According to me I would say first learn how to hack your game

#

Then work according to that

#

And I don't think so there might be any way to make anti cheat plugins for other games using python maybe there are but I am not sure of it

dawn quiver
#

Is Pyxel malicious

brisk shard
#

hello how do I make my game have several themes that users can choose from? I’d want them to be able to select light mode or dark mode, and this will apply in the menu and the whole game itself. I’m familiar with creating separate themes in pygame but I’m not sure what the best way is so that selection of either theme can change other assets in the game

still pumice
#

im having trouble with jump mechs and dk what the fix is im in help-copper

tender sandal
dawn quiver
#

Is it feasible to use bpy to make games

elfin frost
#

any ideas how could I add any robot or this kuka one to pybullet?

#

I got that ROS files and URDF

hollow compass
#

I was struggling to get pygame installed, can anyone help?

cold storm
#

URDF @elfin frost

#

oh

#

you should be able to open the thing using the command line I bet

clever turtle
#

any ideas how could I add any robot or this kuka one to pybullet?
@elfin frost how did you make that?

dawn quiver
#

For game development in python which module is the best?

last moon
#

2d or 3d

proper coral
#

hello

#

For game development in python which module is the best?
..

#

also, pygame 2.0 is out ; what are the benefits over pygame

#

2d or 3d
@last moon both

frank fieldBOT
#

Hey @dawn quiver!

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
#

I recommend ursina, but I'm biased :)

sterile dust
#

Hey ho, im currently working on a Space Invaders game/ Meteor Shower game and everything is basically working as it should, except shooting the laser. Instead of shooting it draws a line following the ship. Any suggestions how I can fix this?

proper coral
#

well

#

i have not even started game dev

#

but imo the laser image should be deleted

#

as soon as it changes position

sterile dust
#

hmm, okey, Imma try that now

#

Still doesent work 😦

elfin frost
#

laser image?

#

@elfin frost how did you make that?
@clever turtle >???????????????????????????????????????????????

wind smelt
#

hey

#

is there a way to get the mask of a rectangle in pygame?

#

because i have a player (which is a rect) and some enemys which are circle and i want to check for collision

sterile dust
#

Nope, dont think so

sterile dust
#

Im haveing som problems with my shooting mechanism and collision detection, can someone please help me?

wind smelt
#

can you send the code? @sterile dust

waxen nebula
#

anyone got any recommendations for a noob who wants to try making games using python. Whats a good framework to use?

dawn quiver
#

pygame

frank spear
#

I have a pygame related question

dawn quiver
#

@waxen nebula

brave widget
#

Hey, I'm running into this error in turtle and I have no clue what it means:
tkinter.TclError: bad screen distance "(8.815368133829546+0.22569957494980106j)"

frank spear
#

When generating a map in my game it does not spawn underneath my character causing him to fall into the void

waxen nebula
#

cool thx

cold storm
#

upbge is super fun to code python in

#

@dawn quiver

#

in 0.3.0 - eevee

#

and right now I am working with the other developers to support XR

#

I am more py / front end guy

frank spear
#

so

#

I was wondering if you guys have any suggestions

tranquil girder
#

change the spawn position?

frank spear
#

hmm y'think that'd work in a 2-d platformer?

frank spear
#

well i think the problem is my map spawns far away from the character

last moon
#

@brave widget how are you getting imaginary numbers???

last moon
#

wait no I'd understand imaginary numbers

#

how are you getting complex numbers?!

wind smelt
#

Hey got a question
can someone help me with the mask function in pygame
i implemented it in the code and i got no errors but i never have a collision xD

    def check_ball_collision(self):
        player_mask = player.get_mask()
        ball_mask = pygame.mask.from_surface(self.ball_img)

        b1_left_offset = (self.x_left - player.x, self.y1_left - player.y)
        b2_left_offset = (self.x_left - player.x, self.y2_left - player.y)
        b1_right_offset = (self.x_right - player.x, self.y1_right - player.y)
        b2_right_offset = (self.x_right - player.x, self.y2_right - player.y)

        b1_left_point = player_mask.overlap(ball_mask, b1_left_offset)
        b2_left_point = player_mask.overlap(ball_mask, b2_left_offset)
        b1_right_point = player_mask.overlap(ball_mask, b1_right_offset)
        b2_right_point = player_mask.overlap(ball_mask, b2_right_offset)

        if b1_left_point or b2_left_point or b1_right_point or b2_right_point:
            return True

        return False ```
well thats probably not really possible to understand without context
#

so the b1 and b2_left balls are the both balls on the left
the balls keep in there row and just move left and right
and i want to check for collision between those balls and the red rect

tranquil wind
wind smelt
#

Probably a little too long for python general but I can try :D

dawn quiver
#

@last moon both
@proper coral yes with and without pyopengl

#

got some tutorials ill like to reccomend

last moon
#

I'd suggest learning arcade

dawn quiver
#

yes

last moon
#

if you're doing 2d

dawn quiver
#

thee's alos ursina, panda, Harfang etc.

last moon
#

for 3d, pyglet or panda3d

dawn quiver
#

for 3d

#

also URSINA

last moon
#

it does look decent

dawn quiver
#

yes

proper coral
#

imma start with 2d first

#

so arcade it is?

#

and what if im a beginner

#

who only knows GUI

#

@dawn quiver

#

ping mee :))

dawn quiver
#

well pygame has easy window support

#

just 11 lines of code maybe 12

last moon
#

arcade's a great place to start + you'll start learning OOP with it

dawn quiver
#

yes

#

then move o to pygame

#

and some small ide recommendations are thonny (pip install thonny)

#

a small recommenadtion

#

pip3 install thonny

last moon
#

just in general or for game dev?

dawn quiver
#

thonny? it is for everything

last moon
#

the debugger looks great for absolute beginners but stepping through it seems like it would get annoying for more complex stuff

dawn quiver
#

just general py dev

#

but im a beginner and this is perfect 4 me

last moon
#

I mean if it works it works

#

can you create breakpoints?

dawn quiver
#

umm lemme check

#

yess

#

Double click on line num in editor

last moon
#

git control?

dawn quiver
#

no it is basic

#

it has micropython and esp8266 support too

#

no move this to a discussion which is related to this

last moon
#

I saw that it's the default for the pi or was
have you used it with pygame?

proper coral
#

i have vs code and i love it

#

so arcade first

#

and then pygame right?

#

aight

last moon
#

if you understand arcade at a decent level, it might be worth it to look at arcade.gl first

proper coral
#

ok thanks 🙂

#

pip install arcade?

last moon
#

should be yep

proper coral
#

ok

last moon
proper coral
#

should i do the learn tab or tutorial tab?

#

oh nvm

last moon
#

the tutorials look fairly extensive too

dawn quiver
#

also learn.arcade.academy

#

yes, www.learn.arcade.academy

waxen patio
#

hello guys should i learn pygame ?

#

and if yes do you have any tutorial?

floral tartan
#

hello guys should i learn pygame ?
@waxen patio Yes pygame is very easy for beginners

#

and if yes do you have any tutorial?
@waxen patio Yes there are many good tutorials on youtube just search "Pygame Tutorials"

waxen patio
#

@floral tartan so i cant do a 2d big project with this?

sturdy forge
#

I actually made a tictactoe game , its kind of long , so how do I send that?

sterile dust
#

Im currently working on a little collision system, but collision is only detected at the right and upper side of a rect, any tips on how to solve this?

if mob.x < ship.x < mob.x + mob.width:
    if mob.y < ship.y < mob.y + 
       mob.height:                            mobs.remove(mob)
            hp -= 10
sturdy forge
#

what is mob?

sterile dust
#

basically a meteor moving down the screen

#

So I want to chech if the ship crashes with a meteor

sturdy forge
#

I think you should send whole code,

sterile dust
#

Hers the link to all the code

sturdy forge
#

I will actually have to see a few tutorials to understand

rapid imp
#

Hey

dawn quiver
#

Can anybody help me with pygame?

marsh dust
#

@sterile dust just an idea, tell me if I'm wrong but i believe you need to create two separate collision boxes around both the ship and your mobs, so that when they intersect it is detected. You would have to outline the boxes by specifying the size and make them follow the centre point of the ship and mob. That is my my best guess at helping...

dawn quiver
#

My character doesn't move when I press the keys:

import pygame
import sys
from pygame.locals import *

clock = pygame.time.Clock()

# ----- Initiates Pygame -----
pygame.init()

# ----- Size of the window -----
WINDOW_SIZE = (400, 400)

# ----- Initiates the window -----
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 32)

player_image = pygame.image.load('sprites/player/player_idle.png')

moving_left = False
moving_right = False

player_location = [50, 50]

# ----- Game loop -----
while True:

    screen.blit(player_image, (50, 50))
    if moving_right:
        player_location[0] += 4
    if moving_left:
        player_location[0] -= 4

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

        # ----- Right Key -----

        if event.type == KEYDOWN:
            if event.key == K_RIGHT:
                moving_right = True
        if event.type == KEYUP:
            if event.key == K_RIGHT:
                moving_right = False

        # ----- Left Key -----

        if event.type == KEYDOWN:
            if event.key == K_LEFT:
                moving_left = True
        if event.type == KEYUP:
            if event.key == K_LEFT:
                moving_left = False

    pygame.display.update()
    clock.tick(60)  # Maintain 60 FPS
marsh dust
#

@dawn quiver try this (pressed_right/left is moving_left/right):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
pressed_left = True
elif event.key == pygame.K_RIGHT:
pressed_right = True
elif event.type == pygame.KEYUP: # check for key releases
if event.key == pygame.K_LEFT: # left arrow turns left
pressed_left = False
elif event.key == pygame.K_RIGHT: # right arrow turns right
pressed_right = False

dawn quiver
#

so do i just have to do add pygame to the inputs?

marsh dust
#

you should have a set speed variable that you can add when the conditions are met

#

yes

#

for checking keys, at least when running pygame, yes. I believe so.

maiden egret
#

Sure he has to

dawn quiver
#

not works when i add pygame to everyone

maiden egret
#

Something like

#

x -= vel

marsh dust
#

vel being player speed?

maiden egret
#

Sure

#

Velocity

#

And you dont have to use the key up events

#

And he doesnt even have to use the Booleans

#

moving_right = True etc

marsh dust
#

it is true that he can add velocity in the direction he wants when key pressed straight away. In my short experience it was easier to have them separate in case i wanted to change the key binds later.

maiden egret
#

Ok i like it more the other way...

sterile dust
#

@marsh dust Thank you, will try

lone crypt
#

good morning.

proper coral
#

wow

#

arcade docs are so damn good for beginners

#

so well thought out

#

i wish other docs were like that

proper coral
#

hello

#

i have a problem

#

when running a very simple arcade file

#

i get an error

#
RuntimeError: The current Numpy installation ('C:\\Python\\Python38\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86```
#

why am i getting this

#

and how do i solve it?

#

ping me 🙂

#

this is my code btw

#
import tkinter as tk

arcade.open_window(500, 500, window_title="HELLO")
arcade.set_background_color(arcade.csscolor.GRAY)
arcade.start_render()
arcade.draw_rectangle_filled(250, 150, 500, 300, arcade.csscolor.GREEN)


arcade.finish_render()
arcade.run()```
potent ice
#

@proper coral That is a problem with numpy. If you have 1.19.4 you might want to downgrade to 1.19.3

proper coral
#

ahh ok

#

how exactly do i downgrade

#

i know upgrading

#

ahh nvm got it

#

thanks :))

floral tartan
#

@floral tartan so i cant do a 2d big project with this?
@waxen patio maybe but you have to be an expert at that before trying your hand at big ones

rotund hearth
#

how do I develop a game?

#

I have no clue

#

how do I get pygame?

#

hmm

severe saffron
#

@dawn quiver you never use the player_location variable it seems

dawn quiver
#

u could start w godot@rotund hearth

#

or using pygame or most python game engine that i think, blender

#

Or start by creating a simple game

#

In python

rotund hearth
#

Ok thanks

dawn quiver
#

how would I do something like this

#

the contiune thing doesn't work for this for some reason

#

also basicly cirlces is a dict filled with the object circle

dawn quiver
#

I'm trying to do a contiune loop because the loop gets stuck in the for event loop

#

u could start w godot@rotund hearth
@dawn quiver godot isn't too friendly with beginers and even after I started learning pygame I couldn't really figure it out too well so idk

solar sail
#
def checkClick():
  mouse_pos = pygame.mouse.get_pos()
  for event in pygame.event.get():
    if event.type == pygame.MOUSEBUTTONDOWN:
      for c in circles:
        click = circles[c].sprite.collidepoint(mouse_pos)
        if click:
          circles[c].color [255,0,0]

@dawn quiver I think it might've been the order of iterating through the circles and events

#

try that?

dawn quiver
#

wb c?

solar sail
#

edited

dawn quiver
#

oh

#

that might work ig

#

I'll try it

#

tysm it works

solar sail
#

no problem

#

From my experiences with pygame, you often want to limit how many timesyou are calling event.get() (maybe to like once an update or so)

jade wadi
#

i am not using pygame or anything

#

i just need some genuine feedback

sweet condor
#

You made that in python without pygame? Lordy I'm struggling to learn python with pygame currently… that seems so impressive to me

proper coral
#

wow

#

@jade wadi which module

crisp junco
#

i just need some genuine feedback
@jade wadi This is really amazing brother!

fierce wraith
#

@sweet condor @proper coral
It's not python, it's the unity3d game engine

proper coral
#

oh

dawn quiver
#

yep and it's uses C#

rapid imp
#

hi

jade wadi
#

@crisp junco thank you so much

#

@dawn quiver it uses Unity And C#

#

what can i do to improve, guys?

crisp junco
#

@sweet condor @proper coral
It's not python, it's the unity3d game engine
@fierce wraith yeah

proper coral
#

Ping

novel snow
#

Does aneone know whate r the graphics code editor in d coder online in androied I cant seem to find it ?

jade wadi
#

what do you mean? can you explain a bit more?

pliant basin
#

I made a game for android, ran the code in pydroid3, and it works, but my joystick is going opposite direction

import pygame
from pygame.locals import *
from math import atan2, degrees, cos, sin, radians
class Joystick:
	def __init__(self, x, y, r, color, stick_color):
		self.is_move = False
		self.color = color
		self.stick_color = stick_color
		self.x = x
		self.y = y
		self.r = r
		self.stick_r = r // 3
		self.stick_x = x
		self.stick_y = y
	
	def _move_stick(self, x, y):
		distance = abs(self.x - x) + abs(self.y - y)
		
		if(distance > self.r):
			distance = self.r
		self.stick_x = int(self.x + distance * cos(radians(self.angle)))
		self.stick_y = int(self.y + distance * sin(radians(self.angle)))
	
	
	def _find_angle(self, x, y):
		delta = [1, 0]
		
		vector = [self.stick_x - x, self.stick_y - y]
		
		self.angle = degrees(atan2(delta[0] * vector[1] - delta[1] * vector[0], delta[0] * vector[0] + delta[1] * vector[1]))
		if(self.angle < 0):
			self.angle += 360
		
	
	def draw(self, surface):
		pygame.draw.circle(surface, self.color, (self.x, self.y), self.r)
		pygame.draw.circle(surface, self.stick_color, (self.stick_x, self.stick_y), self.stick_r)
	
	
	def on_touch(self, event):
		if(event.type == MOUSEBUTTONDOWN):
			x, y = list(map(int, pygame.mouse.get_pos()))
			if(abs(self.stick_x - x) + abs(self.stick_y - y) <= self.stick_r):
				self.is_move = True
			else:
				self.is_move = False
		
		elif(event.type == MOUSEMOTION):
			if(self.is_move):
				x, y = list(map(int, pygame.mouse.get_pos()))
				
				self._find_angle(x, y)
				self._move_stick(x, y)
		
		elif(event.type == MOUSEBUTTONUP):
			self.is_move = False
			self.stick_x = self.x
			self.stick_y = self.y
	
	
	@property
	def distance(self):
		return abs(self.x - self.stick_x) + abs(self.y - self.stick_y)
j=Joystick(200,200,100,(25,255,255),(255,255,255))
r=pygame.display.set_mode((18,8))
while 1:
	r.fill((0,0,0))
	j.draw(r)
	for ev in pygame.event.get():
		j.on_touch(ev)
	pygame.display.flip()```
spring prawn
#

Guys I Have a Doubt

#

Does Pygame work on Mac?

versed agate
#

hi

#

yes it does

#

guys

#

i have a problem

#

i asked this q in many places but ididnt get any help

#

Hi guys
I made a space invaders game using python - pygame
And it worked well in my pc
I put it to github so my friends could see and use it too
But then I realised that they were telling that the space bar button doesn't work for shooting
I tried identifying the prob but couldn't find it
Now here is the code on GitHub https://github.com/sudo-nikhil/Space-Invaders
GitHub
sudo-nikhil/Space-Invaders
If someone could please clone it and identify why only the space bar doesn't work but when i clone and run the same code on my pc, the space bar works! it would be helpful
I am a 14 year ol beginner in python so please don't judge my code quality
Please ping me if anyone finds a solution to fix
Thanks!

#

its fine if anyone of u dont want to help this long message might be overwelming 😭

spring prawn
#

Can I Execute .bat File in a mac?

versed agate
#

No

#

batch files are only for windows

spring prawn
#

Ok

versed agate
#

np

dawn quiver
#

@versed agate The game is working perfectly fine for me

#

also a useful tip: make a requirements.txt file on your root and
pip freeze > requirements.txt and it will make a list of all the libs you use in your virtual env, and then the user could just pip install -r requirements.txt

dawn quiver
#

i am not using pygame or anything
@jade wadi how the fuck?

#

that's some

#

crazy shit

#

that'd be crazy with pygame

#

so without pygame

#

it's even crazier

wind smelt
#

That's quite simple with unity isn't it?

frank spear
#

hey guys

#

I'm trying to create simple enemy AI in a 2d platformer

#

I just want them to simply move left to right y'know

#

I'm kinda stuck though even with the tutorials online

wind smelt
#

You want it to be clever?

#

Or just to move randomly left and right?

frank spear
#

just left and right

#

nothing special

#

I already made the sprites and all

sage bluff
#

@jade wadi which module
@proper coral dude its unity

#

not pygame

#

or any python xd

frank spear
#

?

cold storm
brave widget
#

Hey I need some help. (for turtle)
I have my bullets and character motion inside a main while look and I have the bullets shooting in the direction of the player. But if the character changes direction while the bullet is being shot, the bullet starts to follow the (x,y) cors for the new direction

versed agate
#

@versed agate The game is working perfectly fine for me
@dawn quiver hi! Looks like it works for us but but I checked it with two other laptops with 4 threads and it didn't so idk

jade owl
#

I sorta got dragging to work from the deck in solitaire woo

#

still buggy as it deletes the drawn cards from the deck and you can't let go of the card, but we got a base of dragging done.

#

it's a good thing this is just for fun.

dawn quiver
#

How do you guys structure your game.py and all your modules and classes?

#

I am making a game and it's going amazing but I have hit this wall where I just don't know how to organize all this mess

#

and don't know how to do it differently

#

it's a rogue-like engine, not necessarily for rogue-like, but you get the picture

#

I want it modular, compact, easy to read, for the sake of productivity

fervent rose
#

For the code part, I usually separate the engine, the level-related code (loading, unloading, major level gameplay), the sprite (different objects that can go in your levels), gameplay elements and UI stuff

#

And I put all the art related stuff in a totally different folder, and separate them too

rapid imp
#

Hey

frigid tartan
#

hey which software is used to make games in python ???

next lichen
#

Pygame

#

Cocoa2d

#

Unity

flat dew
#

Pyglet?

lament hamlet
#

I wrote a terminal game engine. You can write fun little games like pong in it. https://github.com/cmcmarrow/tamcolors what do you guys think of it?

GitHub

tamcolors standardizes console color output across multiple platforms. It also can get keyboard inputs without interrupting the console output and can run a console application at ~25 FPS. - cmcmar...

agile finch
#

is it possible to use the pygame module without having python installed? I'm trying to make a game as portable as possible, but I can't think of a way to make the game playable on computers without python and pip

tranquil knot
#

make it an exe @agile finch

agile finch
#

how would that solve importing the pygame module?

tranquil knot
#

you wouldnt need to, since its stored in an exe.........i think

agile finch
#

oh

lament hamlet
agile finch
#

alright thank you!

lament hamlet
#

@versed agate I put in a fix for you

versed agate
#

Hi @lament hamlet , thx, I have replied to your comment

#

I wrote a terminal game engine. You can write fun little games like pong in it. https://github.com/cmcmarrow/tamcolors what do you guys think of it?
@lament hamlet thats amazing and i will surely chekc it out!

GitHub

tamcolors standardizes console color output across multiple platforms. It also can get keyboard inputs without interrupting the console output and can run a console application at ~25 FPS. - cmcmar...

frank spear
#

hey guys, I'm trying to code the enemies in my 2-D game and I want them to simply move left to right, here's the code it have so far...

#
#Enemy Movements
    enemy_movement = [1, 0]
    enemy_movement[1] += enemy_x_momentum
    enemy_x_momentum += 0.2
    if collisions['left']:
        enemy_movement = [-1, 0]
        enemy_movement[1] += enemy_x_momentum
        enemy_x_momentum += 0.2
    if enemy_y_momentum > 3:
        enemy_y_momentum = 3

    enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
    
    if collisions['bottom']:
        enemy_x_momentum = 0
        air_timer = 0
    else:
        air_timer += 1

    display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
#

my problem is that the enemy only moves right, but does not move back left

#

any ideas?

sweet condor
#

@frank spear I'm not 100% sure what's going on there but two things stand out to me:
You add 0.2 to enemy_x_momentum twice, before and in the if statement detecting left collisions
You never test for collisions on the right

frank spear
#

I see, I changed it up so it looks like this now,

#
#Enemy Movements
    enemy_movement = [1, 0]
    enemy_movement[1] += enemy_x_momentum
    enemy_x_momentum += 0.2
    if collisions['right'] == True:
        enemy_movement[0] *= [-1, 0]
        enemy_movement[1] += enemy_x_momentum
    if collisions['left'] == True:
        enemy_movement[0] *= [1, 0]
        enemy_movement[1] += enemy_x_momentum
    if enemy_y_momentum > 3:
        enemy_y_momentum = 3

    enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
    
    if collisions['bottom']:
        enemy_x_momentum = 0
        air_timer = 0

    display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
#

It tests for both left and righthand collisions now

#

but, the enemy still only walks to the far right and stops after colliding,it doesn't walk back

elfin frost
#

any pybullet dev here? I wana have small talk about what is possible or what is not in that env 😄

elfin frost
#

it is mostly physics engine, but I want to do some static stuff

dawn quiver
#

what is the best minecraft bot module? need bots to test my server.

dawn raptor
#

why i get this?

dawn quiver
#

cmd => pip install fivem

#

or something like C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts\pip.exe install fivem

dawn raptor
#

@dawn quiver

dawn quiver
#

I think you need to configure it to the scripting program you're using

dawn raptor
#

😦

frank spear
#

so

#

I made some changes to my original enemy AI

#

but I still can't seem to get them to move back and forth after colliding with an object

#
#Enemy Movements
    enemy_movement = [1, 0]
    enemy_movement[1] += enemy_x_momentum
    enemy_x_momentum += 0.2
    

    enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
    
    if collisions['right']:
        enemy_movement[1] = [-1, 0]
    if collisions['left']:
        enemy_movement[1] = [1, 0]
    if enemy_y_momentum > 3:
        enemy_y_momentum = 3
    if collisions['bottom']:
        enemy_x_momentum = 0
        air_timer = 0
      
        
    display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
#

there it is

#

any ideas?

livid dove
#

@frank spear it's hard to tell what is happening here without more code, but you seem to be changing enemy_movement[1] from an integer into a list

#

and in your previous code you were using enemy_movement[0] to store your direction

#

it's very hard to tell what you're doing here without more code

frank spear
#

here lemme show you

#

def move(rect, movement, tiles):
    collision_types = {'top': False, 'bottom': False, 'right': False, 'left': False}
    rect.x += movement[0]
    hit_list = collision_test(rect, tiles)
    for tile in hit_list:
        if movement[0] > 0:
            rect.right = tile.left
            collision_types['right'] = True
        elif movement[0] < 0:
            rect.left = tile.right
            collision_types['left'] = True
    rect.y += movement[1]
    hit_list = collision_test(rect, tiles)
    for tile in hit_list:
        if movement[1] > 0:
            rect.bottom = tile.top
            collision_types['bottom'] = True
        elif movement[1] < 0:
            rect.top = tile.bottom
            collision_types['top'] = True
    return rect, collision_types
#

this is the code for collisions here

#

I'm using this to determine the directions in which the enemy is hitting the block

#
enemy_rect = pygame.Rect(50, 50, enemy_image.get_width(), enemy_image.get_height())```
#

this here is the hitbox for the enemy, for obvious reasons

flat dew
#

Is the enemy at (50, 50) all the time?

frank spear
#

and the first code I gave you tests which sides of the block the enemy is hitting and is supposed to have them turn around

#

well no but I'll change it to a randint after i get it to work so it spawns randomly

flat dew
#

But for now the enemy doesn't ever MOVE right?

frank spear
#

it moves...but only to the far right then it stops once it hits a block

livid dove
#

You seem to be switching your x and y values in the first code

#

which would cause x movement to be zero

#

if I'm looking at this correctly

#

movement and enemy_movement both have a direction and momentum, are structured the same?

frank spear
#

playr_movement and enemy_movement?

#

yes

livid dove
#

"nevermind

#

still a bit confused tbh

frank spear
#

no your right

#

they a structured similarly

flat dew
#

So what is the problem with your code right now?

livid dove
#

his player is supposed to switch directions when they collide to the right

frank spear
#

the enemy is supposed to move from left to right when it collides with the blocks

livid dove
#

In your first code you are using enemy_movement to calculate enemy_rect, then blitting the image based on the new rect?

#

except when you change enemy_movement, enemy_rect had already been calculated prior to that

#

maybe this is the problem

#

enemy_rect is not going to save the changes made to enemy_movement until you recalculate enemy_rect

frank spear
#

hm

#

I see

#

so I should implement enemy_rect to the collision code as well?

livid dove
#
    
    if collisions['right']:
        enemy_movement[1] = [-1, 0]
    if collisions['left']:
        enemy_movement[1] = [1, 0]
    if enemy_y_momentum > 3:
        enemy_y_momentum = 3
    if collisions['bottom']:
        enemy_x_momentum = 0
        air_timer = 0```
#

are these ifs supposed to effect enemy_rect?

frank spear
#

they are supposed to check for possible colllisions

livid dove
#

display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))

#

except as soon as you do this, none of those ifs changed anything

#

because you only changed enemy_movement and enemy_momentum

#

post more code

frank spear
#

ok

livid dove
#

your code is just really wierd

#

I do a lot of grid stuff but this is wierd

#

no offense

frank spear
#

sorry

#

this is really my first time trying pygame

livid dove
#

it's ok

frank spear
#

okay so here's some more code

#
enemy_y_momentum = 0
enemy_x_momentum = 0
enemy2_y_momentum = 0
enemy2_x_momentum = 0
air_timer = 0

true_scroll = [0,0]


player_rect = pygame.Rect(50, 50, player_image.get_width(), player_image.get_height())
enemy_rect = pygame.Rect(50, 50, enemy_image.get_width(), enemy_image.get_height())```
#

that set up the hitboxes

#

and the variables for momentum

livid dove
#

so wait is this not a tile-based grid?

frank spear
#

well It's a 2-d platformer, are you asking to see how I made the map?

livid dove
#

nvm

frank spear
#

I see

#

no It isn't a tile-based game

livid dove
#

ok so first, I'm not sure why Rect is getting 3 arguments, it's supposed to be x,y,x,y or (x,y),(x,y)

#

unless get_width is returning width and height?

frank spear
#

player_image.get_height gets the height

#

those two numbers spawn the actaul character and enemy

livid dove
#

sorry, I didn't see the 2nd line of that, nemvermind

frank spear
#

no problem

livid dove
#

I think I am the wrong person to help, sorry

frank spear
#

That's okay thank you anyways

livid dove
#

you'll figure it out. Things like this are part of programming life 🙂

#

The help channels are good too

livid dove
#

anyone have experience making android games with python, using recent technology?

#

I want to know if anyone has found a good way since it is still a new thing

#

something without many limitations and only knowledge of python needed

#

something I can release as a professional app

#

native UI and/or cross platform is a plus

#

game dev/gpu capabilities are a plus but not necessary

#

by "good way" I mean advice from somebody who has tried different libraries and actually finished a game

#

I need to get this game out ASAP

#

I once used Kivy and compiled an android app using linux. It is not suitable for professional work

#

It might be better now, but it's still not native. If it works good with pygame now I might try it again

#

but honestly I would rather use something else

#

and how is the new pygame for that matter?

dawn quiver
#

i am using pygame and,
I want to include some game physics in my game......
are there any good libraries for the same??

potent ice
#

pymunk is widely used unless you are making simple physics yourself

dawn quiver
#

nah, i don't have that much time to make physics myself

#

i have simulated gravity tho

sand granite
#
import pygame

class PhysicObj(object):
    def __init__(self, x, y, w, h):
        self.rect = pygame.Rect(x, y, w, h)

    def __init__(self, pos, size):
        self.rect = pygame.Rect(pos, size)
    
    def move(self, movement, platforms):
        pass


p = PhysicObj(10, 20, 30, 40)
p = PhysicObj((10, 20), (20, 30))
``` e.g this doesn't work

Traceback (most recent call last):
File "physic.py", line 14, in <module>
p = PhysicObj(10, 20, 30, 40)
TypeError: init() takes 3 positional arguments but 5 were given

honest monolith
#

they probably check the parameter types, you can't do overloading

sharp hornet
#

do everybody use just pygame because i dont have pygame.
I make games by importing the turtle module does anybody else do like that?

#

I make games by the turtle module*

dawn quiver
#

@sharp hornet imo turtle is not good for gamedev

#

atleast i used it to learn for and while loops years back 😅

fair tulip
#

@sand granite overloading is not typically the go-to.

you can setup a (self, *args, **kwargs) method

#
PhysicObj(pos=(10,20), size=(20,30))
PhysicObj(10, 20, 20, 30)
#

to access pos or size

#

kwargs["pos"], kwargs["size"],
kwargs.get("pos") to check if pos was a given keyword argument
kwargs,get("size") to check if size was a given keyword argument

#

or, to futher extend your method.
try doing this

p = PhysicObj(10, 20, 30, 40)
p = PhysicObj(*(10,20), *(20,30))
cold storm
idle sandal
#

could someone test this for me?

waxen nebula
#

@idle sandal it gave me a cmd with text was that what it was suppose to do?

idle sandal
#

yes

waxen nebula
#

okay yeah

sand granite
#

thanks for help

lusty vector
#

Im currently making a memory game, does anyone know how to make printed text disappear

rigid quiver
#

ok so i open pygame window in pycharm and it opens up for a second then closes, i just strated pyggame

rigid quiver
#
x = 50
y = 50
width = 40
height = 60
vel = 5

run = True
while run:
    pygame.time.delay(100)

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

    pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))

pygame.quit()
``` why is 'win' not a correct param im following a tutorial
last moon
#

you haven't started the window

#

or inited anything actually

#

so before any mechanics, you need pygame.init() to start the window
and window/win/surface/whatever you want to call it = pygame.display.set_mode(arguments)

next lichen
#

Im currently making a memory game, does anyone know how to make printed text disappear
@lusty vector

#

Re fill that surface

waxen nebula
#

where can I download pygame for windows?

potent ice
#

You use the pip tool

#

pip install pygame

waxen nebula
#

👍

sharp hornet
#

@dawn quiver Yes I know but i am not able to install pygame its showing error when i try to install package thats why I make the turtle programs.But its also good i used it to make a game “Snake Game”

kind shuttle
#

hey ^^ , can i ask u guys somethings ? when i run my file .exe it open the microsoft store , can i fix it ?

#

i cant test game TT

ivory crystal
#

I wish I knew, but alas, I have not accended unto the level of game development yet

last moon
#

is that even python?

kind shuttle
#

yeah

#

lib file

last moon
kind shuttle
#

i have installed py

last moon
#

the right version?

kind shuttle
#

newest version

last moon
#

is that the version the game is running tho?

kind shuttle
#

yeah

last moon
#

it might be a dependency issue idk

#

the only time I've gotten that is when I don't have py installed

#

it's sending you to the ms py page right?

kind shuttle
#

wait me for a second

#

i found something be changed in my computer

#

that make the exe change its target

#

i need to handle it first

#

maybe its the problems

last moon
#

idk what you mean by that but maybe

kind shuttle
#

yeah , i got that new when my fire wall called me

reef path
#

can anyone help me with a little piece of my code over DMs? it's not complicated but im lost

unique narwhal
#

How can I create an input box in pygame? Just like entry in Tkinter

dawn quiver
#

@unique narwhal that can be difficult but still we can make it

unique narwhal
#

I actually found a source code

dawn quiver
#

Of actually?

unique narwhal
dawn quiver
#

Oh nyc

#

Thanks I'll also use @unique narwhal

unique narwhal
#

np :)

dawn quiver
#

I'm getting an error,
pygame.Rect.move_ip () should return a rect but for me it returns None

block-breaker-game $ python .\main.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[328, 721]
Traceback (most recent call last):
  File ".\main.py", line 79, in <module>
    if circle_rec.topleft == ball_pos.topleft:
AttributeError: 'NoneType' object has no attribute 'topleft'

This is the error I'm getting

frank fieldBOT
dawn quiver
#

@dawn quiver Can you post your code at the pastebin or something?

#

I can't copy it.

#

I'm new to that so idk

#

I will try though

#

@dawn quiver here you go, any help will be appreciated

#

@dawn quiver Why are you using move_ip? In PyGame Doc Same as the Rect.move() method, but operates in place., that means, returns nothing.

#

Ohh

#

Thank you, I'll try it

#

@dawn quiver that did nothing

#

Also, even if you change to Rect.move it won't work either.

#

Of course.

#

Why?

#

ball_pos is a list, so it doesn't has topleft attribute.

#

So, we should provide topleft?

#

You should learn how the PyGame coordinates works, you are mixing x and y coordinates with top, left, bottom, right and its variations

#

I know them

#

Its variations means topleft, topright, etc

#

Yeha I know @dawn quiver

#

But for move_ip, should we provide topleft as the parameter?

#

@dawn quiver

#

@dawn quiver The top right coordinate of a Surface is (width, 0). If you want to move to the center of the surface, for example, then you have to move in the negative x direction, but in the positive y direction rather than the negative y direction.

#

@dawn quiver I am actually trying to make a breakout type of game

last moon
#

you could/should move ball into a class

dawn quiver
#

So the circle rec is the ball

#

And it moves to random poses

#

That's why move_ip

#

you could/should move ball into a class
@last moon actually I want to do it without classes

#

Else I would have used classes only

last moon
#

why not?

dawn quiver
#

It's like a challenge to myself

last moon
#

what are you trying to do with the main loop?

#

grogus is right tho, pygame.gfxdraw.filled_circle(win, circle_rec.left, circle_rec.top, 20, CYAN) should be
pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN) and etc

dawn quiver
#

grogus is right tho, pygame.gfxdraw.filled_circle(win, circle_rec.left, circle_rec.top, 20, CYAN) should be
pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN) and etc
@last moon oh

#

In the main loop actually, I check for events and move the paddle

#

And also

#

Move the ball continuously to a random pos

last moon
#
if right and player_rect.right < 1364:
  player_rect.right += speed
elif left and player_rect.left > 2:
  player_rect.left -= speed```
I'm fairly sure that's not how you move it either
#

you're grabbing the right/left edges of the circle

#

not the x pos

dawn quiver
#

Ohhhh

last moon
#
if event.type == KEYDOWN:
  if event.key == K_q:
    terminate()
  if event.key == K_RIGHT or event.key == K_d:
    right = True
  elif event.key == K_LEFT or event.key == K_a:
    left = True
``` you can also get rid of the redundant `False`'s here
dawn quiver
#

Hey guys.

#

I have a question.

#
if player_location[1] > WINDOW_SIZE[1]-player_image.get_height():
        player_y_momentum = -player_y_momentum
    else:
        player_y_momentum += 0.3
    player_location[1] += player_y_momentum
    ```
#

what do the [0] and [1] mean after player_location?

#

I am following a tutorial but don't understand.

#

Alright

#

Thanks

severe igloo
#

Anybody know how to pause in arcade?

#

Like how I could make a pause function? (Ping me please)

dawn quiver
#

hi can someone help me with a part of a code? it is a check so that I do not step on a list of lists, for a naval battle the game ((I am learning Python and I think an senior would find it quickly)) sorry if it isn't the channel

frank fieldBOT
dawn quiver
willow mirage
#

Hey guys ! I am trying to do a tricky thing with PIL:
I need to make a square image become round
In a photo edition software, I would usually do a round selection on a square, and remove everything that is out of it
How can I do that with PIL, please ?
Here is an example:

#

(The first image is the result I want to get, the second one is the image where I start from)

dawn quiver
lament hamlet
dawn quiver
#

@dawn quiver
@lament hamlet is there a name to it?

lament hamlet
#

@dawn quiver not that I know of. But its O(N*2) which is way better than O(N^2).

#

You can rewrite it to be O(N)

#

@dawn quiver

dawn quiver
#

have no idea what O(N*2), O(N^2), or O(N) mean

#

but O(N) looks easier to digest

lament hamlet
#

I would read something like this -> https://stackabuse.com/big-o-notation-and-algorithm-analysis-with-python-examples/ its is called Big O it gives you an idea on how fast something is

dawn quiver
#

thanks

dawn quiver
#

Thanks @last moon , the issue AttributeError: 'NoneType' object has no attribute 'topleft' was resolved, but I got another problem

#
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File ".\main.py", line 97, in <module>
    draw()
  File ".\main.py", line 51, in draw
    pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN)
OverflowError: signed short integer is greater than maximum
#

I did what you suggested

#

here is the code

last moon
#

im assuming that means either circle_rec.x or circle_rec.y is too large

#

I don't see any handling for vertical movement

dawn quiver
#

I don't see any handling for vertical movement
@last moon like what do you mean

#

Should add exception for that?

last moon
#
if right and player_rect.right < 1364:
  player_rect.x += speed
elif left and player_rect.left > 2:
  player_rect.x -= speed```
#

you have handling for the horizontal

#

not the vertical

dawn quiver
#

that is the bottom paddle

#

like in breakout

last moon
#

ok then you don't have any handling

#

the ball isn't going to collide with the window, it's going to keep going

dawn quiver
#

like in breakout

#

the paddle moves only in horizontal

#

not vertical

#

so

#

ohhh

last moon
#

OverflowError: signed short integer is greater than maximum
I'm assuming this is because your circle_rec is trying to be drawn outside the window

dawn quiver
#

oh

#

I see it now

#

I'll add exception around move_ip() itself

mortal pier
#

Hey guys I would like to ask about how to delay a function for 2seconds (its like a skill cooldown)

fierce wraith
#

@willow mirage i would do that by masking off the rest of the image using a mask like this.
Pillow has a great function called putalpha that will set the mask as the alpha value for the image.

#
mask = Image.open('mask.png').convert('L')
im = Image.open('image.png')
mask = mask.resize((im.size), Image.ANTIALIAS)

im.putalpha(mask)

im.save("out.png")
#

here is the full script after playing with it a bit:

from PIL import Image

mask = Image.open("mask.png")
mask = mask.split()[-1]
im = Image.open("image.png")
mask = mask.resize((im.size), Image.ANTIALIAS)
im.putalpha(mask)

im.save("out.png")
willow mirage
#

Thanks a lot Leterax ! I will try to do as you said ! Have a great day 😄

still olive
#

Why i cant import Clock from kivy.clock ?

ImportError: cannot import name 'Сlock' from 'kivy.clock'
#

python 3.9.0

fierce wraith
#

np Azuoo 😉 let me know if you run into any problems or need some more help!

pliant olive
#

hi there, im currently working on a game through the coding engine "renpy", and i'm stuck - let's say i have a list of words, and i want to choose random words and put them in a choice menu. is there a way to do it without making a pre-set menu?
also, i wanna guarantee there will always be one word that already appeared and one that did not.

dawn quiver
#

mmm

dawn quiver
#

i don t understand what do u want to do

#

can u reapeat in other words please ?

unique narwhal
#

Hey, lately I've been working on a little game which his main idea is images falling from the sky,
and you have to catch them with moving right and left.
I am struggeling now to get the objects to fall from the sky each xxx seconds, without getting the code lagging with threads. Can anyone suggest an idea to implement this?

#

pygame library ↑

#

@ for answer

severe saffron
#

array of current images which you add one to if the current time is such that it's been long enough?

#

@unique narwhal

solar sail
#

@unique narwhal add a counter variable that updates every tick or so. And then every Z ticks, create a new image?

#

This shouldn't be too laggy especially if your game is running at a set fps

somber creek
#

im am trying to recreate this game and was wondering what would be the most efficient way to make the buttons in tkinter?

dawn quiver
#

Cool video I figured somebody would appreciate. Doesn’t have that many views, but it is official Behind the scenes of the most recent modern warfare Activision studio. Absolutely amazing how these guys bring real life into a 3-D virtual environment.

somber creek
#

im am trying to recreate this game and was wondering what would be the most efficient way to make the buttons in tkinter?
http://kolor.moro.es/

KOLOR GAME

Kolor Game is a free browser game where you have to be as fast as possible by guessing colors in order to score high.

fierce wraith
#

@unique narwhal the python scheduling library would be great for thus

#

It's called sched

somber creek
#

@fierce wraith Would that also work in tkinter?

last moon
#

@somber creek you could 'easily' do it in tkinter or pyqt/pyside2

somber creek
#

how could I easily do it in tkinter?

last moon
#

I said 'easily' but you need an update function
looks like tkinter.Frame.after is used for that if you use OOP
create buttons wt colours and handle the logic based on which button is pressed
after pressing, update the frame with new colours

somber creek
#

ok but how would I make the round buttons?

last moon
#

ikd I'm not familiar with tkinter

#

just do that but with circles

somber creek
#

Ive already made circles and then tried to to put buttons behind the circle but that did not work

last moon
#

the buttons should be attached to the circles otherwise you'll have to update the screen + define which colour is behind which button

#

but you can load an image onto the button which im assuming will be easier

#

might have to play around with randomization tho because you won't be able to change the colour unless you reload the image

#

so you can move the button instead

#

and the button will be directly correlated with that colour

somber creek
#

Ive also been able to put circles onto the button

#

but the problem is I get errors when trying to do multiple even when assigning variables?

#

@last moon

last moon
#

what error are you getting?

#

@somber creek

somber creek
#

oh nvm i figured out that I can use a canvas to upload multiple images, but if I wanted to access only 1 of the image i would have to put canvas.image name right?

last moon
#

no clue

somber creek
#

ok but thanks anyways

waxen nebula
#

So if pygames is used to make 2D games what’s a good one to make 3D games? @ me if answer me 😀

patent ruin
#

There's Panda3D. Haven't used it though. So I cannot tell you enough about it.

#

@waxen nebula forgot to do this

last moon
#

panda is pretty good from what I've seen

#

pyglet's another great option, gets into c programming a bit too

#

you can use pyglet\OpenGL through arcade too, so having some pre-built features with access to the libraries

waxen nebula
#

Wow thanks all look into both thanks 🙏🏻