#game-development

1 messages · Page 56 of 1

mild helm
#

And I need help

potent ice
#

You would have to ask the question to potentially get any response

supple surge
#

lol

potent ice
#

Maybe also help channels would be better if you are a beginner

#

Make a well formulated question with a code snippet

#

No one is going to respond to someone just asking to get help because they don't know if they can answer your questions.

#

The help snippet above is helpful to read. Read though it to get the most out of this server. Especially if you need help 🙂

dawn quiver
#

Someone made online 2d game In Python?

potent ice
#

Kind of. Depends what you mean by "online".

dawn quiver
#

multiplayer

#

@potent ice Do you?

potent ice
#

yes?

pliant dust
#

So, along that same idea, how would you be able to take input from a computer that is, for example, 2 hours away? Would a server have to be used, or is there something with Python that could do this on its own?

potent ice
#

Probably easier with a server unless you want to do a deep dive into the p2p world

#

You could of course configure your router to forward some port to a computer in your network, but you never know when your IP address will change, so that will also require you to update a dns entry if it changes.

rose cloud
#
while True:
#if start == True:
  y = target.ycor()
  target.sety(y - 2)

without the # this dosnt work, how to resolve?

frozen knoll
#

Do you need to indent the last three lines? The if has to be indented a tap-stop. Then lines below it two stops.

rose cloud
#

its ment so the target only moves when start is activated, and the indent inst the problem xd its just how i wrote it in disc

#

without the # when start is true, it just crashes

#

with no errors. ping me pls if u know

pliant dust
#

@rose cloud , my guess would be that the function has an error in it, or something is possibly misspelled. The syntax of the if statement looks right, so that would be the next place to look.

frank fieldBOT
rose cloud
trim drum
#

is kivy underrated?

potent ice
#

probably

foggy python
elder forum
#

Like sprites?
@potent ice yes

#

how do i make sprites in pygame

potent ice
#

There are lot of tutorials out there if you search

elder forum
#

yeah most of the docs didnt work for me

#

maybe its because i was looking up textures

#

not sprites

#

forgot sprites was the name of a object with a texture

merry echo
#

I like the water physics, really cool! How are you doing those? heightmaps or physics engine?

foggy python
#

I just have a list of heights for the surface of water. Then I make those levels bounce up and down while also having points pulling nearby points closer.

elder forum
#

how do i get images loaded and used by sprites? ive copied this pygame.sprite inherited class, but it takes in a color, not a image/texture. ```py
class Block(pygame.sprite.Sprite):

def __init__(self, color, width, height):
    super().__init__()
    self.image = pygame.Surface([width, height])
    self.image.fill(color)
    self.rect = self.image.get_rect()```
merry echo
#

instead of setting self.image to a Surface and filling it with color, use pygame.image.load("/path/to/image_file.png") instead
Or for better structure in your code, load the images you are using onto variables and use those instead of calling pygame.image.load() everytime

elder forum
#

ah

#

ill try that thankyou

#

@merry echo have i read your message wrong? i have py self.image(image) with image being a pygame.image.load

#

ah i figured it out

#

thankyou

undone anvil
#

Unity or Unreal ?

elder forum
#

pygame

undone anvil
#

Invalid answer

#

Unity or Unreal ?

elder forum
#

there is no question word, so i cant answer

#

what, when, why, who, etc

#

you arent asking a question

undone anvil
#

Invalid answer

merry echo
#

What is this a game show

elder forum
#

^

undone anvil
#

S h o u l d, I, l e a r n, u n I t y, o r, u n r e a l ?

elder forum
#

depends on what your interested in what games you want to make

undone anvil
#

2d

elder forum
#

unreal doesnt support 2d

#

so probably unity

merry echo
#

There's so many variables when picking a game engine (preferred language, engine strengths and weakness, what platform you're making the game, etc.), that you're better off telling us what your use case is

undone anvil
#

What is your favorite ?

elder forum
#

who are you asking, him or me

undone anvil
#

Both

elder forum
#

also, salami, i have class Invader in another python file im importing, but for some reason its unrecognized

#

i find unreal too large to use, its more for big companies and big games to me

#

i prefer unity because i usually work on my own or in small teams

undone anvil
#

Should I learn c# if I want to learn unity ?

merry echo
#

Unreal is in C++ and Unity in C#/JS

elder forum
#

unity is in js?

#

since when?

merry echo
#

Unity supports JS

elder forum
#

oh, didnt know that

merry echo
#

Though performance wise, C# might be a better choice

elder forum
#

salami, how do i call a constructor for a class in python?

#

ive forgotten, im trying to do this and im gettin errors for it invaders.add(Invader(invaderTexture, 1000, 1000))

undone anvil
#

Ok... and should I learn c++ if I want to learn unreal ?

merry echo
#

yes

elder forum
#

depends

#

they have blueprint

#

but

undone anvil
#

Ok. Should I learn c# to learn unity or do unreal with the c++ that I already know ?

merry echo
#

What languages do you know?

elder forum
#

up to you

undone anvil
#

C++, python

elder forum
#

depends what you want to do

#

in game dev

merry echo
#

You could look at other game frameworks that's in c++ or python

undone anvil
#

Ok. Thx

elder forum
#

got this in 1 file

#
import pygame

class Invader(pygame.sprite.Sprite):
 
    def __init__(self, image, width, height):
        super().__init__()
        self.image = image
        self.rect = self.image.get_rect()```
#

and import invader which is the name of the file this is in

#

creating an invader yields an unknown error

#

Invader isnt recognized

#
import pygame
import invader

pygame.init()

width = 800
height = 600
WHITE = (255, 255, 255)
RED = (255, 0, 0)
screen = pygame.display.set_mode((width, height))

invaderTexture = pygame.image.load("invader.png")

invaders = pygame.sprite.Group()
invaders.add(Invader(invaderTexture, 1000, 1000))

running = True
while running:
    for event in pygame.event.get():
        if event == pygame.QUIT:
            running = false

    screen.fill((WHITE))
    
    sprites.draw(screen)

    pygame.display.update()```
merry echo
#

you are only importing the file with import invader, so when you want to use your Invader class, you would do invader.Invader() instead

#

or if you don't want to do that, do from invader import Invader

elder forum
#

ah

#

i remember thats a thing in python

#

thankyou

merry echo
#

that's assuming they're both on the same folder

elder forum
#

yeah ofc

#

id have to sudo into a directory if i had it in another folder

#

btw how can i assign different class values to other values without assigning the entire class

#

pseudocode:

#

self.rect.width *= widthMultiplier

#

.width isnt a real thing

#

is there a way to do this?

#

i cant just append .width because i cant find a way to access each variable at a tiem

fervent rose
#

unreal doesnt support 2d
@elder forum and poor Paper2D?

elder forum
#

is paper2D a 3rd party thing?

#

ah

fervent rose
#

Nope

elder forum
#

my bad, didnt mean to mislead him i just havent used unreal engine much for a while

#

didnt know they had a 2D thing

fervent rose
#

That’s okay 🙂

merry echo
#

Even if they didn't, workarounds exist to render your 3D scene into 2D

#

I don't quite get what are you doing with .width

#

You want to change a class' .width variable?

elder forum
#

im just trying to assign the value of Rect's width to something else

#

so, yes

merry echo
#

The Rect is in your invader class?

elder forum
#

yes

#

self.rect

#

its uh

#

from the base class

#

pygame.sprite

merry echo
#

Since its in a Group class, you would have to get your invader class there first, like so invaders[index]

#

then accessing the width variable would be invaders[index].rect.width

elder forum
#

my point is that

#

rect.width isnt a thing

merry echo
#

how so

elder forum
#

hm

#

hold on

#

for some reason my app is crashing

#

ah wait

#

i might have figured it out

#

hold on

#
class Invader(pygame.sprite.Sprite):
 
    def __init__(self, image, widthMultiplier, heightMultiplier):
        super().__init__()
        self.image = image
        self.rect = self.image.get_rect()
        print(self.rect.width)
        self.rect.width *= 2
        print(self.rect.width)```
#

so ive confirmed that the rects width does get increased when i multiply it

#

but im not sure why the width doesnt seem to affect how it shows up on screen

#

it takes the width of the image, multiplys it by 2, but in the render, it still shows the images real width

#

do i have to multiply the image size or something?

#

so, in pygame, does the image size have to be the size you want it to be on screen, as opposed to being able to scale the image up and down in pygame?

#

or can i scale the image with pygame?

pliant dust
#

@elder forum I believe you need to you the scale functions(I don’t know the syntax completely, but I believe it is Pygame.transform.scale().

#

Probably will just have to look it up.

elder forum
#

hmok

elder forum
#

class Invader(pygame.sprite.Sprite):

```py

def init(self, image, widthMultiplier, heightMultiplier):
super().init()
self.image = image
self.image = pygame.Surface([widthMultiplier, heightMultiplier])
self.rect = self.image.get_rect()
pygame.transform.scale(self.rect, (200, 200))```

#

still trying to figure out how to scale a sprite.

#

transform.scale requires a surface, but when i add self.image = pygame.Surface([widthMultiplier, heightMultiplier]) to turn it into a surface, it removes the sprites image.

#
class Invader(pygame.sprite.Sprite):
 
    def __init__(self, image, widthMultiplier, heightMultiplier):
        super().__init__()
        self.image = image
        pygame.transform.scale(self.image, (200, 200))
        self.rect = self.image.get_rect()```
#

new development on the issue

#

my code looks like this, transform.scale does not make a difference.

pliant dust
#

Have you tried putting this outside of a class, and then hard coding it in? (Then transferring to a class, or just removing the scaling and putting that into the main loop) It’s possible it needs a display update, or it’s just not taking the scaling inside of the class.

lost needle
#

pygame.transform.scale returns the new, scaled image

#

you're not assigning it anywhere so it gets thrown away

#

I'd also suggest keeping track of the original image if you need it, to make sure you don't repeatedly transform the same image too much, which will make artifacts

dense marsh
#

hey can anyone here help me with something

potent ice
#

@dense marsh A lot easier to help if you share more information. Do you have a stack trace for example?

dense marsh
#

stack trace?

#

im pretty sure it has something to do with the while loop above running = True

potent ice
#

You say it keeps crashing

#

What does that mean?

frank fieldBOT
#

Hey @delicate smelt!

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

delicate smelt
#

upon goes my tic tac toe game

dawn quiver
#

So I'm working on a Space Invaders type game, and I'm trying to make the ship stop when it hits the wall, but it keeps on going. Heres the first part of the code(had to split up because it was too long)
import sys

import pygame


class Settings:
    def __init__(self):
        self.screen_width = 1200
        self.screen_height = 800
        self.bg_color = (230, 230, 230)
        self.ship_speed = 1.5


class Ship:
    def __init__(self, ai_settings, screen):
        self.ai_settings = ai_settings
        self.screen = screen
        self.image = pygame.image.load('C:\\Users\\mrgam\\Desktop\\ship.bmp')
        self.rect = self.image.get_rect()
        self.screen_rect = screen.get_rect()
        self.rect.centerx = self.screen_rect.centerx
        self.rect.bottom = self.screen_rect.bottom
        self.moving_left = False
        self.moving_right = False
        self.center = float(self.rect.centerx)
        self.ship_speed = 1.5

    def boundaries(self):
        self.rect.centerx = self.center
        if  self.moving_right and self.rect.right < self.screen_rect.right:
            self.center += self.ai_settings.ship_speed
        if self.moving_left and self.rect.left < self.screen_rect.left:
            self.center -= self.ai_settings.ship_speed

    def update(self):
        if self.moving_right:
            self.rect.centerx += 1
        if self.moving_left == True:
            self.rect.centerx -= 1

    def blitme(self):
        self.screen.blit(self.image, self.rect)


def ai_settings():
    pass


def run_game():
    pygame.init()
    screen_settings = Settings()
    screen = pygame.display.set_mode((screen_settings.screen_width, screen_settings.screen_height))
    pygame.display.set_caption("Alien Invasion")
    bg_color = (230, 230, 230)
    ship = Ship(ai_settings, screen)```
#

And the second part:

while True:
        def check_events():
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RIGHT:
                        ship.moving_right = True
                    if event.key == pygame.K_LEFT:
                        ship.moving_left = True
                elif event.type == pygame.KEYUP:
                    if event.key == pygame.K_RIGHT:
                        ship.moving_right = False
                    if event.key == pygame.K_LEFT:
                        ship.moving_left = False
                if event.type == pygame.KEYUP:
                    if event.key == pygame.K_RIGHT:
                        ship.moving_right = False
                elif event.type == pygame.KEYUP:
                    if event.key == pygame.K_LEFT:
                        ship.moving_left = False

        ship.update()
        screen.fill(bg_color)
        ship.blitme()
        pygame.display.flip()
        check_events()
    boundaries()


run_game()```
#

Plz help!

merry echo
#

Just set the ship's left if it hits the screen's left to the screen's left, and vice versa with the right

dawn quiver
#

My pygame window crashes immediately can someone send me a fixed version of my code so I can study the changes

#

it wont let me post it

#

im very sorry

#

ill create a github

merry echo
#

!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.

dawn quiver
merry echo
#

If it's just one file you can paste it here, if not, then yea make a github

dawn quiver
#

oops

#

too late

#

do you want me to take it down?

merry echo
#

No

dawn quiver
#

thank you

merry echo
#

Is there any errors printed in the console?

dawn quiver
#

Not in sublime

#

I haven't run it in anything else

#

do you want to dm because other people might have an issue and I don't want it to get lost

opal wing
#

just looking at your code, off the top your identation looks incorrect. There's a part of ball_animation function that is not idented.

dawn quiver
#

this is my 1st time coding

#

i used a tutorial

opal wing
#

that's ok, everyone starts at nothing

dawn quiver
#

thank you

opal wing
#

but yeah, in python identation is important. If it's not idented properly, like in your code, that piece of code will be executed first

#

and ball.right is not defined on startup, so most likely this is where it crashes

dawn quiver
#

I don't quite understand?

#

so I have to define ball 1st?

opal wing
#

there's a bit of code starting on line 16 that is not idented to the function

#

so from pov of python interpreter, your function ends on line 15

dawn quiver
#

i see

opal wing
#

then because that part of code has 0 identation it's executed before anything else.

dawn quiver
#

but if i build the code with the indented fixed

#

it comes up with an error

opal wing
#

Personally I suggest making a main method and then calling it through main

dawn quiver
#

So what should include in the main?

opal wing
#

it likely uncovers another bug

merry echo
#

What's the error

opal wing
#

in the main for now simply put everything you want to run first, like the stuff outside of your functions

dawn quiver
#

and the error text is

#

!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.

dawn quiver
#

thats the error message

merry echo
#

I ran your code with fixed indentation, and a blank window pops up with black background

#

Yeah your indentation is wrong

dawn quiver
#

how do i fix it

#

manually?

merry echo
#

The standard is 4 spaces each indent, sublime should handle that if your press tab

opal wing
#

NameError: name 'quiet' is not defined

dawn quiver
#

i dont have quiet in my code

opal wing
#

yeah you're right. It might be caused by previous errors. Try to fix identation first

dawn quiver
#

i think i fixed the indetions

#

!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.

dawn quiver
opal wing
#

there's still something wrong. Look at your first function. The lines should all start at the same column

#

it looks like it's possibly double tabbed? Or you somehow used tabs and spaces interchangably

dawn quiver
#

the import pygame, sys, random?

opal wing
#

no, def ball_animation()

#

your lines 4-15 appear to be double tabbed, maybe

#

then 16-21 look ok

merry echo
#

Look at the spacing

dawn quiver
#

why is there a 2 line space between import and def?

opal wing
#

I think pycharm complains otherwise

dawn quiver
#

o

merry echo
#

Don't look at that look at the indentation

opal wing
#

but that's just a warning, it doesn't matter. Do look at the identation because python cares about that. It doesn't care about blank lines

dawn quiver
#

ok

#

I KNOW WHAT I DID WRONG

#

i thought after: there was an indention

#

but its HALF an indention

#

i think

#

i hope

#

and salami i tried your code but the game window looks like this

merry echo
#

yeah missed some indentation

#

sorry haven't used pygame

dawn quiver
#

yes so far

#

but when its done it should count down and the numbers on the side shouldnt rocket up

#

1 more question

#

actually 2

#
  1. How do you learn the indentions
  2. How do you install the turtle module
merry echo
#

you usually install modules with pip

#

for ex.: pip install module_name

dawn quiver
#

i tried that

#

it comes up with an error

#

!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.

dawn quiver
#

That's the error i get in cmd

opal wing
#

that looks like a python compatibility errors

#

and second, are you sure you're installing the right turtle? That package is a http proxy

dawn quiver
#

i ran pip install turtle

merry echo
#

I think turtle requires tkinter

dawn quiver
#

C:\Users\Blank>pip install tkinter
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
ERROR: No matching distribution found for tkinter

opal wing
#

what do you get when you simply try to import turtle?

#

it looks like it's a part of a standard lib

merry echo
#

nvm thats a default python lib

dawn quiver
#

wdym simply import?

#

thats what i get when i run pip install turtle

#

C:\Users\BLANK>pip install turtle
Collecting turtle
Using cached turtle-0.0.2.tar.gz (11 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\BLANK\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\BLANK\AppData\Local\Temp\pip-install-xb4lz8e5\turtle\setup.py'"'"'; file='"'"'C:\Users\BLANK\AppData\Local\Temp\pip-install-xb4lz8e5\turtle\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\BLANK\AppData\Local\Temp\pip-pip-egg-info-4yj1meml'
cwd: C:\Users\BLANK\AppData\Local\Temp\pip-install-xb4lz8e5\turtle
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\BLANK\AppData\Local\Temp\pip-install-xb4lz8e5\turtle\setup.py", line 40
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

opal wing
#

in your file, instead of having
import pygame, sys, random
add
import pygame, sys, random, turtle

dawn quiver
#

no this isnt for my game

#

just wanted to know how to because i lot of the tutorials i tried to follow used it instead of pygame

opal wing
#

that's ok, try it to see if it finds it. The turtle you want is built into python. The turtle you're trying to install is something else entirely

#

if it doesn't find it, you'll get an error

#

if it doesn't complain, that means it imported it properly

dawn quiver
#

it dosent complain

#

and my other question was how do i learn the correct indentions

#

sorry if im being slightly (really) annoying

merry echo
#

There's articles on the web about that, they'd explain it better than I do

dawn quiver
#

ok

dawn quiver
#

last question i promise

#

where should i start if i want to create games without tutoirals

#

tutorials and any help

opal wing
#

honestly, once you get the basics like flow control down, come up with an idea and google for solutions like your life depends on it

dawn quiver
#

lol

#

thanks for your help!

#

bye

#

any of you know what twine is?

#

What's the best way to do this with functions?

#

I'm making a gui game that uses logic in each "scene", and a menu pops up which controls going to the next one

#

but how would i do that?

#

i'm not gonna manually define a hundred functions, and redefine them to be part of a dictionary

urban aspen
#

um

#

well you don't

#

You're not gonna have a dictionary with a hundred functions in the first place

#

also try out this code

#
ls = []
@ls.append
def square(x):
  return x**2
print(ls)
dawn quiver
#

okay a decorator

urban aspen
#

Alright my guess is that you're trying to recreate something like detroit become human where there are multiple paths

elder forum
#

how do i get the dimensions of a surface object?

potent ice
#

Keeping the api docs open can save you a lot of time

elder forum
#

thankyou @potent ice

potent ice
#

Basic drawing and sprites in pygame

elder forum
#

ah ok

manic canopy
#

How I make android or ios application?

#

or game

dawn quiver
#

Can someone help me fix this issue

#

Where if i build my code in sublime

#

it dosent automatically open my pygame window

#

whereas in the tutorial i follow

#

it does

pliant dust
#

@dawn quiver I’ve noticed this issue with Pygame, if I understand you correctly. You need to open your IDLE console, and in the files button open the python file you want. Then run it. For this reason, I’ve stopped using sublime and just started using the python file itself to code.

merry echo
#

So what text editor are you using now? Couldn't you instead run your file with your terminal?

worthy sentinel
#

is there any library of python for minecraft pocket edition server quieries?

pliant dust
#

@merry echo I’m using whatever text editor opens up whenever you open a new file with the IDLE. It’s just what I’ve found to work for me.

swift hare
#

Can I display python code on html or pho with our using flask ?

autumn seal
#

Hi guys whats the best framework to use for a 2d rpg?

frozen knoll
#

Lots of options. Here's an example using Arcade.

autumn seal
#

ok

dawn quiver
#

Is pygame easy to learn?

frozen knoll
#

That's one of the reasons it is popular. In my biased opinion it is a bit aged though, as its been around for a while.

#

Still a good library,.

sonic escarp
#

Speaking of that, are there any good tutorials for a beginner for python? I know the very basics and syntax of the language, but Id like to make a simple game for some practice

frozen knoll
sonic escarp
#

Thanks, Ill check it out

flat sail
#

Hello, can someone help me?

#

I'm trying to insert some input text in the pygame screen, only that the text overlaps and stretches in two sides instead of just to the right, do you have any advice on how to fix it?

foggy python
merry echo
#

That FPS tho 100+ 😮

#

@flat sail What do you mean by stretching in two sides? Does the text go in both directions when you add characters? Or is the text actually stretched? If you could post the code snippet on how you're rendering it, it would help to diagnose the problem

foggy python
#

it almost doubles if I run it in Pygame 2 instead of 1.9.x

frozen knoll
#

That's awesome work @foggy python

foggy python
#

thanks

muted violet
#

did you use pygame to build that

potent ice
#

Pygame2 is shaping up nicely. going to try dev8 version soon. I think that even exposes all sdl2 window features

rain lava
#

Hi
Do u have any advices or help for a guy that wants to make a game or any websites that help to learn python game development

foggy python
#

@muted violet yep

muted violet
#

wow

#

@foggy python where did you learn pygame from

foggy python
#

Mostly the documentation.

flat sail
#

@merry echo when I write some text, it goes on both sides

#

@merry echo if u want i can send u in a private message my code

rain lava
#

Guys I have a question

#

How to change the background

#

?

dawn quiver
#

You blit an image/ the background in the middle of the screen (0,0) at the start of the loop

#

kinda like filling the background, but bliting

rain lava
#

Thnx man

merry echo
#

@flat sail Then your rendering it centered, or it is by default. Try adding the width of the text halved when rendering your text

pliant dust
#

Question for all the music people; I am wanting to create my own audio files for pygame, and have an electric keyboard that I can connect to my computer. The problem is that I honestly don't know what programs to use, or how to set it up to take the keyboard input(I'm using a DGX-230 Yamaha). I tried using "MidiEditor" and converting the files to Wav, but that was... buggy to say the least. I would like to know what people use, and if it is possible to connect the keyboard to them. Thanks!

frozen knoll
#

You probably need to run your audio out from the keyboard to the audio/mic in from your computer. Then use a program like audacity to record.

pliant dust
#

I’ve downloaded Audacity, but I can’t find the keyboard for input. The keyboard connects with a usb to the computer, and some weird looking box shape to the keyboard. I’m probably missing a setting to have the keyboard recognized as an input device.

lunar tangle
#

So I made this in an effort to reverse engineer Perlin Noise:

It randomly shuffles through similar looking systems.

#

The question I have is that this takes for EVER to actually make. It's a 2D array of X-pixels by Y-pixels.

#

Is there any way to maybe make this more effecient?

#

Currently the process is:

go through a row, make random colors somewhat similar to the one next to and above the pixel it's at now.

Get a ratio scale of these values

Draw the ratio * 255 as the RGB values

dawn quiver
#

@foggy python that's lit

merry echo
#

@lunar tangle What are you using to edit the individual pixels? If you're doing it by setting each individual pixel (like surface.set_at), I could see how that would be slow. Try using PixelArray if you haven't already. That might give a speed improvement
https://www.pygame.org/docs/ref/pixelarray.html

frozen knoll
#

That seems like this kind of thing that would be perfect for an OpenGL shader if you wanted super-fast performance.

#

Or I wonder if numpy would have options that would be good.

lunar tangle
#

I used surface.set_at and that led to issues with anything over 600x600.

merry echo
#

Yeah setting pixels individually ought to be slow, try PixelArray and see if that improves it

lunar tangle
#

How would this work when I want to change the resolution?

#

I had it with set_at, then I changed it to drawing rectangles the size of the resolution

merry echo
#

You mean like responsive? It changes when you resize it?

#

If so, either you set the size of what you're drawing to the new window and redraw it, or just draw only what has not been drawn yet if it is resized larger than initial, and crop it if its resized smaller.

#

PixelArray just wraps Surface on top of it, you could access it with .surface. So, there shouldn't much change need if you're going to switch to PixelArray.

lunar tangle
#

No like, If I want the squares to be 4px by 4px

#

Currently I can do high res or a lower res with less actual blocks

#

same size

merry echo
#

Oh ok then, you could just resize the Surface with transform.scale which should return another Surface that you could use

#

I'd advise you poke around the pygame doc site to help you get around pygame better

flat sail
#

@merry echo could you remind me the sintax to manage the width when rendering my text?

rain lava
#

Anybody can help me with sprites and animations 😅

merry echo
#

!ask

frank fieldBOT
#

Asking good questions will yield a much higher chance of a quick response:

• Don't ask to ask your question, just go ahead and tell us your problem.
• Don't ask if anyone is knowledgeable in some area, filtering serves no purpose.
• Try to solve the problem on your own first, we're not going to write code for you.
• Show us the code you've tried and any errors or unexpected results it's giving.
• Be patient while we're helping you.

You can find a much more detailed explanation on our website.

merry echo
#

Tell us your problem directly

daring shore
#

Which algorithm can I use to find, which cells are occupancied by polygon object (just rotated rect)? Now I find topLeft and bottomRight cell of bounding rect of this polygon and select all cells between this two cells, but some of the cells shouldn't be selected in this case (red cells on image)

frozen knoll
#

I do this with Spatial hashing in Arcade:

#

Or, something similar:

daring shore
#

So do you check for each cell if there is a collision?

frozen knoll
#

I haven't worked on the code in a while, but I think yes.

#

Figure out the bounds, then check each square for an intersection.

visual axle
#

does anyone know why my map turns out like this when i try to load it?

fervent rose
#

@daring shore you could also test if each border line is inside a square, this should be pretty trivial

daring shore
#

@fervent rose how? I think its not that trivial

fervent rose
#

Something like the Liang–Barsky algorithm could work

#

I mean, that's trivial wth the power of google in your hands 😄

#

Cohen-Sutherland might work too

daring shore
#

thanks

foggy python
#

@visual axle why are you asking that here?

visual axle
#

idk bro

#

it says discussing game dev and pygame right? so it should be fine

#

im just really stuck rn and im kinda desperate to finish this

frozen knoll
#

I've been working on a tutorial for using full 2D physics in a platformer with Arcade 2.4. If anyone wants to look at it, and maybe give feedback, I'd love to hear it. I'm want to get the right mix of power, and ease-of-use.

rain lava
#

Any help for sprites and animations?

dawn quiver
#

DaFluffyPotato has a great video tutorial about animations

#

He also discusses sprites in the video

foggy python
#

@visual axle that requires context from my tutorial though. Have tried comparing it against my code to look for differences?

dawn quiver
#

Man don't you just love reading the source code from different pygame projects

gray girder
#

everyone should check out Ursina Engine, its a neat project. Beginner friendly too.

grand imp
#

Automatic import of .psd and .blend files
whoa

#

MIT license
whoaa

iron galleon
visual axle
#

@foggy python yeah I tried but I couldn’t find anything because I added a lot more code, so I didn’t know what was affecting it

rain lava
#

Guys how I can make an image as an object that a player can walk on and how I can create a map?

foggy python
#

@visual axle slowly get rid of it till you find out what broke it.

visual axle
#

i have an idea on what's causing it but i have no clue how to fix it @foggy python

foggy python
#

try stuff until you figure it out

#

That’s generally how programming goes

#

People generally won’t help you with questions where you’re asking people to debug your logic.

pliant dust
#

@visual axle check you map/tile generator.

dawn quiver
#

@rain lava create a Rect object as the player and blit a sprite over the player's rectangle. You can use colliderect to see if the player is colliding with the tiles' rects. Here is a video on how to make the tiles and collisions work: https://www.youtube.com/watch?v=HCWI2f7tQnY&t=477s (or you could use the Pygame.sprite.Sprite function)

pliant dust
#

@rain lava another option is using the Pygame.sprite.Sprite function, and using sprite groups to check for collision between two groups/sprites. “Kids can code” does a tutorial on how this function works.

merry echo
#

@foggy pythonHey man cool stuff, btw, what made you choose pygame over other game frameworks (pyglet, arcade, kiwi etc.)?

solid obsidian
#

would this be the proper play to discuss adversarial search trees? Specifically minmax?

#

Im working on creating a connectfour game and want to add a computer to play against

foggy python
#

@merry echo I wouldn’t use arcade because I prefer the “do it yourself stuff”. As for the others, it’s mostly because it’s what I started on.

merry echo
#

I'm the same thing too, last game jam, had to make my own platformer physics since I didn't like the one in arcade.

#

How about perfomance?

quaint fog
#

how do you add a bullet hit effet (spark or a hole) in a game

frozen knoll
#

What game engine? Pygame, Arcade, Kivy, ?

quaint fog
#

pygame

foggy python
#

Pygame’s performance is good enough for me. If I want more, I can switch to PyOpenGL.

quaint fog
#

basically what i want it to do is if it touches a wall it makes a spark

#

like a normal gun would do

#

or bullet

dawn quiver
#

when the bullet rect collides with the rect you can delete the bullet and add particles. If you want to learn how to add particles, just search it on whatever search engine you use.

merry echo
#

Its over

#

The game jam channel is gone 😭

neon hinge
#

Doing game-related stuff is still very much on our minds. It's been amazing to see so many people talking about and working on games in Python.

#

And there are very nice people active in the python game framework community

#

It's something we really like and want to support as well

merry echo
#

Adios game jam

#

salute

idle imp
#

Is it recommended to use OOP with pygame?

fervent rose
#

Yup, every game should use OOP at some point, or it will be impossible to manage at some point

merry echo
prisma ginkgo
#

whoahh that looks cool

merry echo
idle imp
#

looks cool

fervent rose
#

That’s really cool, thanks for those links!

shadow tusk
#

@merry echo really good!!!

frozen knoll
#

Agreed, love it!

dawn quiver
#

(not sure if this is the right channel) so im kinda a beginner in python, I'm coding a pong game and I can't fugure out what my mistake is. Prolly some stupid small mistake but can sum1 skim thru my code and tell me if they can catch what I did wrong? pls dm me if ur willing to help cuz it wont let me send the file here

fervent rose
#

Unreal Engine 5 have just being revelated!!!

frozen knoll
#

@dawn quiver You can use pastebin or a similar tool to place code for others to read.

merry echo
#

Wooo! Another engine that my pc can't run 😅

merry echo
#

What problem are you exactly having?

frozen knoll
#

Oh my god that UE 5 engine looks nice.

merry echo
#

@dawn quiver you shouldn't be adding here but multiplying instead *= by -1, which reverses the ball

#

Same goes with the other three directions

dawn quiver
#

so where exactly do i make all the changes

#

sorry im dumb

#

??

merry echo
#

change the += to *=

dawn quiver
#

okay i did

#

same thing

merry echo
#

What are you trying to achieve

#

@fervent rose I was waiting for him to show the triangles close-up, but he didn't 😢

fervent rose
#

I bet you can't even see them haha

merry echo
#

I doubt a brick from there could even run in my computer

fervent rose
#

Well, we will still have LODs for less powerful hardware, and they will still have an uncredible boost

#

There are some pretty nice annoucement at the end of page too

#

Now you need to give epic royalties only if you earn more than a million

olive grail
#

im trying to make an incremental game like cookie clicker, just can't figure out how to increase the price of a "building" after you buy one by a certain amount

still shard
#

price = price + amount

#

@olive grail

olive grail
#

is there a way to increase it over time?

still shard
#

yes, call the code all x seconds

olive grail
#

oh thanks

merry echo
#

Price=Base cost×1.15^(M−F)
where M – the number of that type of building currently owned;
F – the number of that type of building you have for free (cursors and grandmas you get from Starter kit and Starter kitchen prestige upgrades.)

toxic sinew
#

hey all, whats the best game engine for using python?

#

(use your personal definition of best, seeing as I don't know)

frozen knoll
#

What are you looking for out of a game engine?

#

Kivy is good for android.

toxic sinew
#

just looking for fun... i know how to use python, just finished making a discord bot kind of looking for a new project

frozen knoll
#

Arcade and Pygame are good to get started with in 2D (I'm biased to Arcade)

#

Arcade has a lot of examples you can look through there.

toxic sinew
#

awesome! ty 🙂

pliant dust
#

Question about python, and coding. Should I be using a computer that isn’t “important”? (All computers are important, being an expensive piece of equipment) Like, is there any concern of running a code and suddenly the computer falls apart and I lose all the information stored on it?

ionic stone
#

Fortunately you will not achieve it until you will actually code something that will do it. So it's almost impossible

iron galleon
#

using a version control system, like git, and uploading your code to a remote server, like GitHub, is a good way to get around that

#

@pliant dust

#

but i would personally code in a decent computer; makes the experience much better

idle imp
reef holly
#

You need to update the screen with pugame.display.update()

idle imp
#

ohh ofc

#

and i call that right before the while loop right?

uneven eagle
#

I think you call it after you finish drawing all of your sprites.

pliant dust
#

The update should come at the end of the while loop, it’s the last thing you want to happen, and you want it to happen every frame, or atleast whenever something changes.

idle imp
#

ahhh i see

#

i got it ty guys

rotund folio
#

im trying to make a program in pygame, where if u click you draw a dot and then a second click will draw a dot and connect the two, and so on

#

i got the mouse input down, but im not sure how to do the whole reading if there was a previous dot

uneven eagle
#

Maybe record the previous location of the previous dot...?

#

¯_(ツ)_/¯

rotund folio
#

ooh, how would i go about doing that?

idle imp
#

perhaps u could add the coordinates of every click to a list, and add a check so that the program knows there was a previous dot if the list is not empty

rotund folio
#

good idea, ill give it a go

rotund folio
#

ah yes, it all worked out! thanks!

frozen knoll
#

Updated this tutorial to show how to support ladders in an Arcade platformer:

dawn quiver
#

Whenever I try to pick up a block that has already been thrown, I get an error, con someone help with this?

#

The error is indexError: pop index out of range
This gets the index of the block that I am going to pick up:

# Checks if player is touching a block and pressing down arrow to remove a block and add a block above the player's head
    if collisions["left"] and pick_block or collisions["right"] and pick_block:
        for tile in xcollisions:
            if pick_block_count == 0:
                if not holding_block:
                    tpb = tile
                    tile_pops.append(tile_rects.index(tile))
                    holding_block = True
                    pick_block_count += 1
    else:
        xcollisions = 0
# Removes the tile that is picked up
    for tile in tile_pops:
        tile_rects.pop(tile)
        drectp = display_rects.pop(tile)

That above removes the block, but the problem is that I loaded the game map above it redefining the tile_rects variable, making the index of the thrown tile out of the range

I can dm the full code if you need it

frozen knoll
#

What game library are you using?

dawn quiver
#

pygame

merry echo
#

@dawn quiver Doesn't pop() take an index? You're passing the tile object instead

#

remove() might be what you wanted to use

sly swan
#

Does anyone know how to make a shape constantly move in one direction without having to hold down button in pygame?

merry echo
#

have an x, y velocity variable and add it to the shape's x, y position every frame

#

instead of checking when a button is pressed

sly swan
#

Thanks

#

How do I add it every frame?

merry echo
#

inside your loop

#

do it there

sly swan
#

ok thanks

little summit
#

What kind of game are you making?

sly swan
#

Becuase I am a beginner its just a game where enemies try to touch you and you have to try and escape

little summit
#

Oh ok

sly swan
#

have an x, y velocity variable and add it to the shape's x, y position every frame
@merry echo What would that look like?

#

I keep trying it but it says this:

#

SyntaxError: cannot assign to operator

#

How can I fix this?

merry echo
#

You could post the part where the error is so we could diagnose it better

#

The error message should tell you where that line is

sly swan
#

Do I need a separate velocity x and velocity y coordinate?

merry echo
#

Yes

sly swan
#

ok

#

but couldnt i just do this:

#

while run:
snake.x -= snake.vel

merry echo
#

that's just for the x axis

#

if you want your sprite to go up and down you'd want one for the y axis too

sly swan
#

ok

dawn quiver
#

@merry echo this line gets the index of the tile I want to pop:

 tile_pops.append(tile_rects.index(tile))
merry echo
#

Ah I see, you're removing from tile_pops, right?

#

How are you finding the collisions

dawn quiver
#

I am removing from tile_rects. I have a for loop that removes the block for every item in the tile_pops list

#

I can send you my code if you need to see it

muted plaza
#

i wasnt sure what channel to put this in but i am trying to make an auth software that is hwid locked, how would i do it?

celest wasp
#

Hey just joined. I'm brand new to programming, started learning Godot about 6 weeks ago, and realized I needed to learn a bit more about languages so I started studying python. Based on your experience, is python a good language to learn for a first timer if they are looking to be able to make complex 2d games?

I want to know if since I'm learning python to help me in Godot(GDScript) if there is a significant learning curve for python game dev compared to Godot, and if you could quantify that difference in time, even better.

#

I should also add that I decided to learn godot to make a simple card game for ios, and that it's possible I may develop for both mobile and desktop on a long term basis, but that's still kind of unclear at this point since it's a bit early to tell if I'm any good at it

potent ice
#

Some general programming experience certainly don't hurt. GDScript is very similar to python

#

There are other lower level libraries as well of course, but they will require a higher time investment.

#

pygame and pyglet being the more popular ones.

#

@celest wasp I guess it doesn't really matter were you start. Just get started 😄

dawn quiver
#

I cant seem to run arcade

potent ice
#

Any error message?

dawn quiver
#

wait ill send pic

#

some open gl error it says

celest wasp
#

hey thanks -- I have some books that mentioned pygame and arcade, and that depending on what you want to put in your game you'll choose one over the other. So you're saying for development if I wanted to make use of what I learn right now(since I'm learning it to make sense of the programming part in Godot) once I finish my Godot project I should start with arcade because of simplicity? or because of it being better for 2d?

potent ice
#

@dawn quiver Looks like your computer don't support opengl 3.3, so it won't work. It could just be a driver thing also. Find out what GPU you have.

dawn quiver
#

how to find it

potent ice
#

@celest wasp What game/graphics library you chose not that important. What you learn will translate to other libraries later. I just thought arcade might be a less brutal start 😄

#

@dawn quiver No idea on windows. A quick search should solve that

dawn quiver
#

ok

#

@potent ice my open gl is version 3.1

potent ice
#

ah right. you need OpenGL 3.3 / DX10 support for arcade

dawn quiver
#

Doesn't it tell version 2.0 required

#

I had this exact same problem with kivy

#

i fixed it by changing some environmental variables

#

the kivy one

potent ice
#

It says glCreateProgram is not available so there must be something weird with your drivers

dawn quiver
#

oh

potent ice
#

Kivy is using OpenGL 2.1 on desktop

dawn quiver
#

oh

potent ice
#

The intel hd 2000 is about 10 years old. You will have support with most integrated gpus that are 7 years old or less.

#

I know opengl drivers for hd 2000 and 3000 are very bad in windows

dawn quiver
#

but games like minecraft is working properly

#

isnt that also based on opengl

fervent rose
#

MC uses a java library

potent ice
#

Yes, but they are using an older version (2.x)

dawn quiver
#

Oh

fervent rose
#

I could spell its name, but I’d probably get it wrong haha

dawn quiver
#

Lol

fervent rose
#

I think is LWJGL yay I got it right

potent ice
#

Arcade relies heavily on more advanced shaders to push more work to the gpu

dawn quiver
#

Oh

potent ice
#

For example.. it's using geometry shaders for drawing shapes

#

So instead of generating a circles, arc or ellipse in python this is done on the gpu instead. Much faster

#

But you can use pyglet 1.5 and pygame. Both are also good options.

celest wasp
#

@potent ice ok so just not as brutal. thanks again!

potent ice
#

@celest wasp No problem. Could be a good idea to make something a bit more boring in pure python first before jumping on a game/graphics library

fervent rose
#

So instead of generating a circles, arc or ellipse in python this is done on the gpu instead. Much faster
We said MC 😉

celest wasp
#

yeah I have arrived at the point where I understand most of the meaning of the language, I just don't have the problem solving down yet, so I've realized having simple projects to learn that aspect have been critical in moving past having no idea where to start.

potent ice
#

Then definitely go arcade for now. Lots of good tutorials

celest wasp
#

seems like there just isn't a way to learn that aside from just trying to make something and realizing what you dont know lol

potent ice
#

It's not a waste of time even if you don't end up using arcade later

celest wasp
#

is it useful to learn arcade at the same time with python? because python has some things that don't exist in godot and I thought maybe going all in on game dev in python just to learn how to do it in godot might be confusing, whereas if I just stick to the code aspect in python I can still learn godot habits without getting confused

potent ice
#

see the link above

#

That is exactly what you talk about here

#

It teaches programming with python and arcade at the same time.

celest wasp
#

ahhh ok cool

#

its a twofer

potent ice
#

Just be aware that the current arcade 2.3 may be a bit slow when it comes to shapes, but the soon to be released 2.4 has major improvements.

celest wasp
#

I know gdscript was made very similar to python so that's why I reasoned out learning python since documentation on gdscript and godot is limited.

potent ice
#

Yeah you are not the first person with this conclusion 😄

celest wasp
#

but I just didn't know enough about godot development processes to know if game dev in other engines would teach me something I could use in godot

#

from what I read everyone says godot can be easier for newcomers, which I find ironic since I've had to go to a more complex language and system in order to learn how to use godot lol

potent ice
#

Worst case python can be used for almost anything so it's a very useful skill to have anyway

fervent rose
#

Even if your work isn’t about programming, python is still a very useful skill to have

celest wasp
#

yeah ideally I'll just be working on simple apps and then maybe a complex desktop game if I can get the nerve up

#

in the long run

fervent rose
#

And if you want to do some game dev, but more from an artist side, python will be very valuable

celest wasp
#

hows that? I'm curious because that's pretty much my background -- musician, graphic design

potent ice
#

Start simple so you don't burn yourself on some gigantic project you'll be wanting to completely rewrite in 3 months anyway

#

Talking from personal experience there 😄

celest wasp
#

lol yeah thats why my first project is just a card game. Even just doing a card game I've had to start with smaller projects just to learn how to make the card game.

#

and it doesn't even have any real game mechanics it's just a storyboard game

fervent rose
#

If it does run, that’s a really good start

celest wasp
#

I'd like to think so. So far in godot I've got a script to manage the cards and instance the card nodes, and then now I'm just stuck on the ui design to set up how the cards actually look in the layout, and how to set up menus and other ui stuff. So that's why I started on python stuff, because the ui stuff in godot is a little heavier on understanding the math of what you're doing.

#

it's made me realize I might have got a little further ahead than my experience merits

#

I could have kept going, but it's likely I'd have a buggy game in the end

potent ice
#

I think you are describing a situation all of us bump into in the learning process here 😄

celest wasp
#

haha great! at least I'm getting somewhere

potent ice
#

The great thing is that what you learn will translate to other software/languages and areas. If you get a bit deeper into it you'll see many doors opening.. even in areas you did not expect.

#

and you can always ask questions in this community if stuck

celest wasp
#

yeah I was reading through some books ( i didn't end up getting them though because I'm not interested in the end goal) on python used for machine learning, data science, all that stuff seems pretty popular these days

merry echo
#

you can use packages like pyinstaller and auto py to exe

#

If you could specify what problem you have we could help with that

merry echo
#

Do you already know python basics and are looking for a library to make you game in?

fluid lintel
#

hello !!

#

helo anyone

solar stone
#

hello @fluid lintel

fluid lintel
#

hello

#

i've been working on a tutorial on games

#

and now i'm done !!

solar stone
#

good

#

Im new on this channel and I havent any knowledge of Python and I would like to learn something

celest wasp
#

btw @potent ice that link you gave me looks great for tutorials, but I can't find the project files the guy keeps mentioning anywhere on the website

#

do you know anything about that?

fluid lintel
#

@solar stone i could help

solar stone
#

ok

fluid lintel
#

well i just have to find a way to post my game

solar stone
#

what's the first thing what I need to know

fluid lintel
#

needs 2 people to play it

solar stone
#

ok

fluid lintel
#

but i am currently making one about battling with robot's

solar stone
#

good

fluid lintel
#

basicaly it has a lot of tech !!

solar stone
#

in wich part is your game @fluid lintel

fluid lintel
#

every part

solar stone
#

but I wanna see it

fluid lintel
#

oh i can send you photos of the game i have made

#

hold oon

solar stone
#

ok

#

how is Python?

#

is more difficult than Java or another programming language?

fluid lintel
#

no python is the easiest language i have ever encountered

#

and is very powerful

#

hold on i will be back having something urgent to do

solar stone
#

I ask that cause Im programmer but I program in Java and Javascript

fluid lintel
#

me too

#

infact let me show you how easy it is

solar stone
#

ok

#

how can u show me @fluid lintel ?

fluid lintel
#

i will show you a simple hello world prompt in Java

#

and in Python

solar stone
#

oh

fluid lintel
#

sure !

#

just wrap it up good

#

yeah yet to show you my game

solar stone
#

u use eclipse to code?

#

or u use Netbeans?

#

I mean when u program on Java

fluid lintel
#

eclipse

#

this is the game i developed

solar stone
#

good

fluid lintel
solar stone
#

I use netbeans

fluid lintel
#

this is the game

solar stone
#

good

fluid lintel
#

thx

#

so i will find a way to post it

frank fieldBOT
zealous umbra
#

Hi I'm getting this really weird PyGame error

#

even though I've successfully installed PyGame, it says: builtins.ModuleNotFoundError: No module named 'pygame'

frozen knoll
#

Either you don't have it loaded in your VM, or you might have created a file called pygame.py

#

What are you running it from?

#

Command line, pycharm, etc?

zealous umbra
#

Wing101

#

this is what my terminal says : Python 3.7.6 (default, Jan 8 2020, 13:42:34)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.

#

Basically I was trying to learn how to use the conda environment but I don't know how to close it so maybe that's the problem?

frozen knoll
#

I forget how Wing manages virtual environments, but I'm guessing you installed pygame in one spot, and it is using a different virtual environment. Or you've got a regular Python install, and an Anaconda one.

zealous umbra
#

they have a built in terminal to run script

frozen knoll
#

You might try doing a pip install pygame from that terminal.

zealous umbra
#

you cant

#

its just for code output

frozen knoll
#

Ah, 'fraid I'm not going to be much help then. Sorry. Maybe someone else will chime in.

zealous umbra
#

thanks I appreciate the help

maiden kelp
#

what programming language should i learn first ?

zealous umbra
#

python

maiden kelp
#

and how long does it take to learn it >

frozen knoll
zealous umbra
#

okay what are you interested in when it comes to programming?

frozen knoll
#

Learning is always an on-going process.

zealous umbra
#

Because python is a good beginner language because of how easy the syntax is to pick up

#

and how the logic works in python

maiden kelp
#

k

zealous umbra
#

But I mean it depends on what you want to do with your coding skills

#

like if you want to do ML ---> python, if you want to do web dev ---> javascript, html, css

potent ice
#

The first programming language you pick up takes some time to master. Once you know one language.. other ones will be easier to pick up.

fluid lintel
#

yeah

#

i know javascript, java, python

maiden kelp
#

coool

#

i had a run of the mill basketball coach teach us python

#

couldn't understand anything so i decided to stat=rt learning online

potent ice
#

Think my path is : BASIC -> Asm -> Pascal -> C/C++ -> Java -> C# -> Python

frozen knoll
#

Similar to mine. Although I spent a lot of time with Forth.

potent ice
#

ooh

frozen knoll
#

Programming is fun, hope you have a good time learning it.

maiden kelp
#

hmm

#

got any good websites so i can learn from

frozen knoll
maiden kelp
#

so it gives you the basics; I can see

potent ice
#

If you like more visual learning that one is a winner

maiden kelp
#

cool

#

it kind if feels anoying

#

since i have schol online and some AP exams around the cornner

frozen knoll
#

The other way to do it is just look at the example code:

#

And play around with it while learning. Then look things up,.

#

...as you need to.

maiden kelp
#

what do you mean "look things up"?

#

do you mean videos showing you how to do it

frozen knoll
#

Like, "how does a 'for' loop work"? Then look up video or on-line text.

#

Video or reading, one of the two. Whichever you learn best with.

maiden kelp
#

k

celest wasp
#

hey paul craven that website mentions some project folders and I can't find them anywhere on that site

#

am I not supposed to use them?

frozen knoll
#

You can clone or download from here:

celest wasp
#

ahhh I see

#

thanks

#

do they need to go inside the arcade template folder?

frozen knoll
#

Not really. I use that for consistency when I teach students so it is easy to find their work.

celest wasp
#

oh ok

#

thanks for sharing this, this looks like a lot of work you put in

rocky monolith
#

can someone please help me

#

i am new to code

dawn quiver
#

the answer that is already there doesn't work

fallow kite
#

what is the best method to make such a grid with pygame ?

#

Should I use a image or draw rectangles

#

I am making a battle ship game

#

@dawn quiver Could you help me ?

dawn quiver
#

maybe

#

could you explain what you are trying to achieve?

fallow kite
#

So like I said im making a battle ship game

#

and I am trying to recreate that grid

#

( with the letters and numbers around the grid)

#

with pygame

dawn quiver
#

I can answer your second question, but not the first. you should use rectangles if you want it to look as you depicted it in the picture, but images if you want to add more detail to it.

#

I can't answer the first because I don't know the best way of doing it

fallow kite
#

I see

#

but how do I turn a image ( of a grid ), and make it a actual grid

#

you know what I mean ?

#

with cords and stuff

dawn quiver
#

are you going to have mouse clicks?

fallow kite
#

@dawn quiver yes

dawn quiver
#

I can't help you with that, I haven't really learn how to do that yet

tulip basin
#

Anyone knows about turtle library in python?

#

The listen function is not working in MacOS

pliant dust
#

I am trying to set up Visual Studio Code for python and pygame, however, continue to have an error. I have installed pygame to the VS terminal, it tells me it is satisfied, and then when I try to run a program, it stops at the "import pygame" and states that there is no such module. I have tried looking online, but it seems like no one else has this issue.

potent ice
#

Check in lower left corner what python interpreter is selected

#

That should be the same as the version you used in the terminal

#

python --version

#

@rocky monolith Questions like that will almost never result in an answer. You need to be more specific.

fluid lintel
#

hello everyone anything going on

#

@the boss

#

@solar stone hello again

solar stone
#

hello @fluid lintel

fluid lintel
#

so what's up

solar stone
#

Im making a webpage

fluid lintel
#

cool with django or flask or html

fluid lintel
#

@solar stone with django , html or flask

solar stone
#

html

#

and CSS

#

and a bit of Javascript

fluid lintel
#

k

fluid lintel
#

does anyone deal with panda3d in python

coarse roost
#

anyone got any ideas on how i can further optimize my particles?

#

they're already fast but i want the freedom of using potentially up to 50k when currently it starts lagging at about 15k.

#

    for particle in particles:
        
        angle = int(abs(particle[1][0]%360))-1

        oldx = particle[0][0]
        particle[0][0] += costable[angle]*particle[1][1]
        location = [int(particle[0][0]/tile_size),int(particle[0][1]/tile_size)]
        if location[0] < len(tilemap) and location[1] < len(tilemap[0]):
            if tilemap[location[0]][location[1]][0] != 0:
                if angle >= 0 and angle <= 180:
                    particle[1][0] += 90
                else:
                    particle[1][0] -= 90

                particle[1][1] *= 0.9
                particle[0][0] = oldx

        oldy = particle[0][1]
        particle[0][1] += sintable[angle]*particle[1][1]
        location = [int(particle[0][0]/tile_size),int(particle[0][1]/tile_size)]
        if location[0] < len(tilemap) and location[1] < len(tilemap[0]):
            if tilemap[location[0]][location[1]][0] != 0:
                particle[1][0] = -particle[1][0]
                particle[1][1] *= 0.9
                particle[0][1] = oldy

        particle[2] -= 1
            
        pygame.draw.circle(screen, particle[3], (int(particle[0][0]),int(particle[0][1])), int(particle[2]/10))
        if particle[2] <= 0:
            particles.remove(particle)

#

particle is [[x,y],[angle,velocity],lifespan,colour]

#

just realized my wall collisions are wrong xD floor is fine though

frozen knoll
#

Using opengl instead of raster graphics via pygame can allow the GPU to help emmensly

coarse roost
#

does pygame not utilize the gpu already? i've got SLI 970's so opengl will definitely help 😁

#

oh yeah and while im here, is there a better way to store a tilemap than a 2d list?

frozen knoll
#

The best way to do particles is to write custom shaders I believe. That's a lot of learning though. I don't know if pygame 2.0 uses much of the gpu? Pyglet does, and has opengl bindings. Arcade uses the GPU and hopefully soon will support custom shaders. Or use moderngl or pyglet and write your own.

#

Shadertoy and related tutorials is one way to learn to write your own shaders.

pearl raft
#

Hello Guys, does anyone who already used NEAT knows how to save a specific generation after a run?

#

anyone got any ideas on how i can further optimize my particles?
@coarse roost i know thats not what you want, but i always use a "skip frame".
When you cant draw all the particles in the expected time - 0.016s (60fps), you just skip the next frame drawing. That way your program recovery the loss time in the last frame.
You will lose some fps but the tick will be intacted.

elder forum
#

if you want anything more than a quick prototype dont use pygame if you want any performance @coarse roost

#

it takes alot more to learn a graphics api like opengl but its orders of magnitude more performant

merry echo
#

That's pretty impressive already! Like others have said, opengl really is the way to go if you want speed. Though you could do a few optimizations with your code.
Instead of computing the velocity everytime like you do here py particle[0][0] += costable[angle]*particle[1][1] you could only do it whenever you change the angle.
And if your tile_size is a power of 2, you could use bit-shifting instead when computing the grid location.
I don't know how large is your max particle size, but a compromise would be to have your particles as pixels instead, and change the alpha according to their life span. This would allow you to use pygame's PixelArray class and could help a bit with the performance.

#

Also when you hit a tile, you could just multiply the velocity by -1 instead of changing the angle. This all in all should reduce the amount of divisions and multiplications you're doing.

hearty adder
#

i started learning pygame!

#

if anyone knows any good sources or tutorials, do provide a link

#

im trying to make a side scroller, sort of endless runner, but im more looking for a general pygame tutorial

#

for now im following tech with tim's pygame tutorial series, but it seems a little slow to me

#

if anyone has some good youtube or other platform links for pygame dev, ping me

#

thanks guys!

fluid lintel
#

what's up

pliant dust
#

@hearty adder kidscancode has a helpful tutorial series, while long, I have found it helpful for learning the concepts and how certain commands work in pygame.

fluid lintel
#

hmm

pliant dust
#

class Pow(pygame.sprite.Sprite):
def init(self, center):
pygame.sprite.Sprite.init(self)
self.type = random.choice(['shield', 'gun'])
self.image = powerup_images[self.type]
self.image.set_colorkey(WHITE)
self.rect = self.image.get_rect()
self.rect.center = center
self.speedy = 3

#

so i'm not sure why, but the image will not clear out the white space when it is drawn

#

(WHITE is a defined variable for the RGB color)

hearty adder
#

@hearty adder kidscancode has a helpful tutorial series, while long, I have found it helpful for learning the concepts and how certain commands work in pygame.
@pliant dust thanks!

merry echo
#

Shouldn't you be using __init__()? and super().__init__() for the inherited class

pliant dust
#

I honestly don't know, I followed the tutorial, it worked, and then it didn't. All other sprites work with that set up.

fierce wraith
#

super() Just gets you the parent class, so it's the same thing as pygame.sprite.Sprite

grim jasper
#

Not necessarily

#

If you did a subclass of MyPow(Pow, MySprite) then super() would go to MySprite instead

#

It probably doesn't matter here but it is generally preferred to use super() over hardcoding types

merry echo
#

Why does python do that? You'd assume that Pow ends first since it's called first right? Is it because they subclass the same class, which would be object?

grim jasper
#

It allows for easy dependency injection which is a benefit but I think the "real" reason is that it's to solve the famous diamond problem of multiple inheritance

unique narwhal
#

someone got any recommendations on how to make an installer?

#

or how to use an installer

#

for a graphic game with images and pygame

potent zinc
#

wdym installer @unique narwhal

unique narwhal
#

Idk how to explain it really much

#

lets say I create a game

#

and I want it to work in every computer

#

you have to install the app with an installer

potent zinc
#

Pygame can make it so that you can download an executable (.exe) from your game

#

If you wanna know more about it, ask the expert himself @foggy python

unique narwhal
#

oh really?

potent zinc
#

ye

unique narwhal
#

i dm'ed the expert

iron galleon
unique narwhal
#

mmhm

#

I joined his server then

#

lets hope he can help me

potent zinc
#

thanks @iron galleon . I see that the link removal got implemented ;p

celest wasp
#

has anyone done paul cravens tutorial? I have a question

#

it's about this section on making an adapting viewport, I'll add only the relevant code for the question:

self.view_bottom = 0
VIEWPORT_MARGIN = 40

def update(self, delta_time):
  self.physics_engine.update()
  changed = False

  left_boundary = self.view_left + VIEWPORT_MARGIN
  if self.player_sprite.left < left_boundary:
    self.view_left -= left_boundary - self.player_sprite.left
changed = True```

There's more of these if statements for the different directions, but I left it out, then there's this:

```self.view_left = int(self.view_left)
self.view_bottom = int(self.view_bottom)

if changed:
  arcade.set_viewport(self.view_left,
                      SCREEN_WIDTH + self.view_left - 1,
                      self.view_bottom,
                      SCREEN_HEIGHT + self.view_bottom - 1)```
#

can someone help me understand how the left_boundary section works? it wasn't really clear how he came up with the math

celest wasp
#

so far from what I can read it's saying if the left side of the player is less than the left_boundary size, then .....the part after that I don't get

potent ice
#

Viewport stuff can be a bit tricky. I always recommend drawing that down on paper

#

There is a high possibility arcade 2.4 will also have a camera that makes this simpler to manage

tough river
#

I was wondering if you can change an objects color based on what's the color of the background below it in pygame?

potent ice
#

Not sure how that is done in pygame. Can you just read the pixel or something?

#

or keep some more sparse structure in python to make that easier to deal with?

#

Depends on the finer details

frozen knoll
#

@celest wasp Imagine you've got a window that is 800 pixels wide. To start with, you might have a viewport then, 0-799

#

If you scroll to the left 100 pixels, you'd have 100-899.

#

"Margin" is how close to the edge you need to be, before you start scrolling.

#

If your character was at 300, then you'd be 200 pixels from the edge. 300-100 = 200.

#

If your character was at 150, then you'd be 50 pixels from the edge.

#

If the "margin" was 100 pixels, then 50 is too close, and you'd need to scroll to the left 50 more pixels to maintain that 100 margin.

celest wasp
#

right

#

I think what I don't understand is the view_left

#

what is that variable for

frozen knoll
#

That's the left-edge.

#

So if you were scrolled 100 pixels to the right, left would equal 100.

#

left and bottom together make the coordinate of the lower left corner of the screen.

celest wasp
#

ahhhh ok i get it now

#

thank you!

idle imp
#
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit(0)

        if pygame.mouse.get_pressed()[0] == 1:
            print(pygame.mouse.get_pos())

    pygame.display.update()

How do I limit the mouse.get_pressed() to only execute on click, and not allow to hold the mouse button?

dreamy swan
#

You can set a variable to true when it is down then check that that variable is false before allowing the second click

pliant dust
#

If the mouse works with the KEYDOWN event, ( or something similar) that would work to only allow one click.

dawn quiver
#

While I was making a game engine for my game I ran into this issue:

Traceback (most recent call last):
  File "main.py", line 148, in <module>
    x,ct = trect.move(bmovement, tile_rects)
  File "/home/user/Pygame/Throw-Away-Joke/data/engine.py", line 92, in move
    collisions = self.obj.move(movement,platforms,ramps)
  File "/home/user/Pygame/Throw-Away-Joke/data/engine.py", line 34, in move
    xcollisions = collision_test(self.rect,platforms)
  File "/home/user/Pygame/Throw-Away-Joke/data/engine.py", line 17, in collision_test
    if obj.colliderect(object_1):
AttributeError: 'thrown_obj' object has no attribute 'colliderect'

Does anyone know why this is happening? If you need the code, I can post it

pliant dust
#

At a guess, without looking into it too much, and not being familiar with the colliderect command, the “thrown-obj” is not having a rectangle generated for it and therefore, cannot be used for the command. Idk if that is what is happening though.

worn harbor
#

How to make a binder?

quaint fog
#

Is it possible to use python in the unity engine

merry echo
#

Yes, you could probably do that with IronPython, though you'd still need some C# code before you could get it running

quaint fog
#

ok

#

well id rather do it the simple way and learn c# because that is one of the languages you can use with unity

wet elk
#

Can i make a basic model of solar system with pygame?

#

Or should i prefer opengl?

fierce wraith
#

depends on how accurate you want to be

#

if a couple (approx. 5) circles following gravity in 2d is enough pygame should do the trick 🙂

potent ice
#

yup. Kind of depends if you need 2D or 3D and how detailed you need the solar system to be

fervent rose
potent ice
#

Distributed under Attribution 4.0 International license:
You may use, adapt, and share these textures for any purpose, even commercially.

fierce wraith
#

but that ones made by Akarys himself!

potent ice
#

ahh lol. Sorry 😄

fierce wraith
#

not actually a real planet texture though

#

just a cool pic of a planet

fervent rose
#

That's actually a planet texture 😄

#

That's mercury iirc

#

But I had some fun with nodes so it doesn't looks like mercury anymore haha

fierce wraith
#

really?

#

i thought its just that pic lol

cunning glade
#

So I'm working on a pygame project -- what could I expect to be my limitations

potent ice
#

Kind of hard to answer without knowing anything about your project

cunning glade
#

so my idea is to create a game where it's kind of like asteroids, like the ship moves around but the aliens are static at the top, and if you shoot it, it duplicates though weaker

potent ice
#

pygame can handle a lot of sprites per frame

#

Probably a few thousand easily at least. I'm guessing sprite groups is the way to go

#

They also provide simple collision testing

upbeat goblet
#

Is anyone here familiar with renpy?

stray hornet
dawn quiver
#

The thing is that those are oranges.

dreamy swan
#

@upbeat goblet Whatcha need?

#

Dm me

merry echo
#

Was that planet painted?

#

Pretty cool! 😄

fervent rose
#

That's a 3d render

#

Thanks!

drowsy warren
#

hey guys i wanna learn python from scratch where do i start from , can someone help me ?

frozen knoll
drowsy warren
#

@frozen knoll thank you dude

solid obsidian
#

on minmax search you dont calculate the value at each step correcT?

dawn quiver
#

is this the place to discuss help with game code?

fierce wraith
#

Yes

distant granite
#

so, i wanna load a picture with pygame.image.load() however the image is in another folder, not in the script folder.
the folders looks like that:

main folder:
  assets:
    picture.png
  scripts:
    script_to_load_pic.py
#

how to load picture.png from script_to_load_pic.py?

frank fieldBOT
#

@harsh trout Per Rule 6, your invite link has been removed. If you believe this was a mistake, please let staff know!

Our server rules can be found here: https://pythondiscord.com/pages/rules

merry echo
#

I think you'd go up a level from your working directory, like cd .. in terminal

#

That would be os.chdir('..') in py

#

Then you could finally use assets/picture.png as the image path

potent ice
#

@distant granite The best way might be to use the __file__ attribute in the module to create a path to your assets directory

distant granite
#

thanks for help :D

potent ice
#

Can use os.path or pathlib.Path. I would recommend the latter

#

For example```python
from pathlib import Path
resource_dir = Path(file).parent.resolve() / 'resources'

#

resolve just makes sure the path is absolute

distant granite
#

oh, ok

#

but what if the script to load pictures was imported to the main script?

#

it would make a difference?

potent ice
#

nope. __file__ will always be the module's location

#

Importing it does not change that

distant granite
#

oh

dawn quiver
#

Guys is it essential to use pygamr.time?

pliant dust
#

Yes and no. It more or less keeps the entire program running at a consistent frame rate/speed.

frozen knoll
#

Otherwise you just peg a CPU at 100% too, as you do nothing but loop and loop and loop with no break.

smoky coyote
#

It's crazy to see free-to-play games make more money than premium games now ahahaha

undone mason
#

Time to make legend of delza on mobile then

acoustic cape
#

hey guys im new to programming in python and was just beginning to experiment with the pygame module but everytime i try to run a sample projects or code from

#

shit i wasnt done typing

#

oops

#

everytime i try to run the code the terminal executes as if it was the beginning of the program but the graphics window python icon just bounces around in the dock and I cant get the freakin window to open

#

i couldnt find anybody w/ this same issue on reddit etc so if u know how to help please lmk!!

#

im in vsc and using a mac

#

installed the latest version of python, pip, and pygame

wide plover
#

hey ! I make a game on pygame with wall composed of squares. But do you know how to associate a rect to each square easily?

fervent rose
#

You could have a square dataclass, which stores coordinates, a reference to the rectangle and what-not, and store them into a 2d list

wide plover
#

i already have a list which stores every coorinates of the walls, but the characters of the game don't move square by square

jovial fable
#

Can you be more precise with what you want to do?

#

Having a 2D list of object with texture/position in the list/coordinates on screen seems a good option to me

wide plover
#

i make a tower defense and I'm actually coding the behaviour of an ennemy. The level is composed of squares, which are blue if it's the ground where it can moves and red if it's a wall. The level is generated of a list where "m" is a wall and "0" is the ground. And I want collision for each wall

jovial fable
#

I suppose that pygame have already colision detection, then you can probably calculate the position of the item in your list and check if its m or 0

#

for example if you have 20x20 squares, you detect a collision at 0, 26, it's probably (0, 1) in your list

#

if you can build objects, it's even easier, make a list of objects with coordinates and if they block or not, when you detect that you collide with such object, you would just check their property

wide plover
#

OK thanks

pearl patrol
#

hi, does anyone know how to store/edit data without using external modules or text files?

normal mica
#

oh if youre asking this u can ask general

#

if youre asking about the game itself ask ehre

pearl patrol
#

oh ya right

dreamy timber
#

Hi, python noob here.
Are there any ways I can determine which framework to use for my game without slogging through opinions?

near wedge
#

@dreamy timber I am assuming you've already decided to use Python?

#

@dreamy timber Copying a previous reply of mine to a similar question: That will depend on your goals. At the very least you'll want to decide between 2d and 3d, and then, from there, figure out how much you expect the engine to handle for you. In general, I would likely go for Arcade for higher-level 2D and Panda3D (or the higher-level Ursina, which is built on top of Panda3D) for 3D. If you want to get more in the guts of graphics rendering, then maybe something like pyglet or moderngl would be better.

potent ice
#

@dreamy timber Depends what kind of game you are making I guess..

#

I usually just recommend Arcade to newbies. What you learn there will transfer to other libraries anyway

dawn quiver
#

Hi guys, why does the word "None" appears in front of my input for each of the 3 players for the following code ?

import random


print ('''Hi guys, few of few will have to guess the correct number between 0 to 10. ''')

number_to_guess = (random.randint(1, 10))


player1 = int (input(print (''' Hi Player1 please have a guess: ''')))
player2 = int (input(print (''' Hi Player2 please have a guess: ''')))
player3 = int (input(print (''' Hi Player3 please have a guess: ''')))


print (''' Now we will see who among you have guessed the right number... ''')


if number_to_guess == player1:
    print (''' Bravo Player1. ''')
elif number_to_guess == player2:
    print (''' Bravo Player2. ''')
elif number_to_guess == player3:
    print (''' Bravo Player3. ''')
else:
    print (''' Sorry. None of you found the right number...
The right number was actually %s'''  %(number_to_guess))


potent ice
#

@dawn quiver Because print returns None. Don't use print inside input. Just provide the string.

dawn quiver
#

@potent ice Thanks a lot pal. Indeed. Found it meanwhile. 🙂