#game-development

1 messages · Page 76 of 1

low shadow
#

just assign one standard max velocity in the x and y axis respectively
then find out the angle the mouse is pointing from the thing that is shooting the bullet
then take sin and cos of that angle and multiply that with max velocity across y and x respectively

#

then update your bullets x and y points with the velocity
edit: spelling mistake

mystic lodge
#

ok thx

low shadow
# mystic lodge ok thx

if u dont get it even after that check tech with tim's vid
its on projectiles
ig even dafluffypotato made one

mystic lodge
#

oh thx

hushed bluff
#

yo

#

hello

#

??

bleak aspen
#

yo can someone help me

#

open the project and run the game you just use arrow keys to move its a zombie and when it touches a brain it and your score goes up by 1
my teacher for homework said that i have to add a nother character
that is in the sprites folde r as you can see if you go into the sprites folder
then session 3
there are zombies
and there are robots
he told me to add the robots into the game and make them move with w a s d
so basically i can control both characters
also open challenge.py
and run that one
that one is the one for how
its basicall t a done version of the game without the robot
and i have to add the robot
and make it move with w a s d keys
in the exact same way the zombie does
except with w a s d
also i use arcade library

glad bramble
#

How to use python?

tranquil girder
#

You write it

magic gazelle
#

How to do most basic game on py?

potent ice
#

@magic gazelle depends what kind of game. Text based? graphics?

magic gazelle
#

no just text in IDLE

potent ice
#

Can start with something very simple. use input() to read text input from the user and react to that

#

bonus if you find a way to make your project a bit more organised using functions

low shadow
#

try making a simple hangman game using some reference u can find online

#

or just copy it and understand what each statement does

#

and make something new on your own

potent ice
#

That also works. Focus on understanding how every part of the program is working.

low shadow
#

otherwise its pointless to build the game

potent ice
#

Definitely. I see way too many newbie programmers skipping important steps in the learning process and get completely stuck when they try to make something bigger. It's so important to understand the details!

dawn quiver
#

how to make a game multiplayer game using discord bots (discord.py)

vale bay
#

damonki

potent ice
#

@dawn quiver That is a very open ended question. It really depends what you are making. Probably in all instances you will have to store the game state and the players in an object somewhere. It's not really that different from making any other bot with discord.py.

frank fieldBOT
fringe heath
#

im new to pygame

#

wondering why i get this error

#

i put py clock.tick(27)
but for some reason it says
AttributeError: 'builtin_function_or_method' object has no attribute 'tick'
anyone know what i can do?

mystic lodge
#

i put py clock.tick(27)
but for some reason it says
AttributeError: 'builtin_function_or_method' object has no attribute 'tick'
anyone know what i can do?
@fringe heath
can i see all the code?

thick wasp
#

so im woring on learning classes and i kinda wnat to rewrite the movemnts of my charcter using classes

#

any got an idea hwo to do that?

wet folio
safe halo
#

just came to stop by

low shadow
slim sky
#

The output is just blank (no error)

signal bronze
#

Hello everyone, I'm working on a project that requires GPU acceleration so I'm trying to use PyOpenCL but I'm having issues with indexing a numpy array from the kernel

#

Does anybody know what the problem might be, the np_array is a result from opencv2

main abyss
#

is ursina engine good for pythpn 3d game development

void wagon
#

hello everyone present here

dawn quiver
#

lol

blissful palm
#
print("plus minus multiplication or divide?")
print("Now if you wanna make a story, type 'Story'")
option = str(input())

if option == "plus":
    num1 = int(input("First Number: "))
    num2 = int(input("Second number: "))
    print("Results: ", num1 + num2)
    print("Thank you for playing my game!")

if option == "minus":
    num1 = int(input("First Number: "))
    num2 = int(input("Second Number: "))
    print("Results: ", num1 - num2)
    print("Thank you for playing my game!")

if option == "multiplication":
    num1 = int(input("First Number: "))
    num2 = int(input("Second Number: "))
    print("Results: ", num1 * num2)
    print("Thank you for playing my game!")

if option == "divide":
    num1 = int(input("First Number: "))
    num2 = int(input("Second Number: "))
    print("Results: ", num1 / num2)
    print("Thank you for playing my game!")

if option == "Story":
    print("There once was an old man that")
    word1 = str(input("Say 1 word: "))
    print("There once was an old man that " + word1, "when he touched a")
    word2 = str(input("Say 1 word: "))
    print("There once was an old man that " + word1, "when he touched a " + word2)
    print("Thank you for playing my game!")

very simple calculator i made

drowsy copper
#

can i please get somehelp in manganese? i m trying to make a snake game

clear cloak
#

hey just watched some yt tutorials and the documentation for pygame but was wondering if there's another way such as an app to learn that library

low shadow
clear cloak
#

alright thank you tho

karmic void
#

you guys have any idea how to fix this? ```
programIcon = pygame.image.load('./Sandyicon.png')
FileNotFoundError: No such file or directory.

mystic burrow
#

What module would be best if i wanted to make a 2d board game?

frank fieldBOT
karmic void
#

@mystic burrow you could use pygame

winged oasis
winged oasis
mystic burrow
#
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("First game")```
I'm making my first pygame program. When i run this, it opens the window for only a second and then closes it and the program stops running. Is this intentional?
I also get ```pygame 2.0.1 (SDL 2.0.14, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html``` every time i run the program.
potent ice
#

You need to make a main loop for the window to stay open

#

There is a way to remove the initial message

#

If you want to remove it```python
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'

#

I never bothered myself

low shadow
#

the program gets over

#

the message you get from the python shell is the default note that you get whenever u run the pygame library

potent ice
#

Already answered these questions 😉

low shadow
#

oh sorry i didnt read

#

lol

potent ice
#

No one died 😄

karmic void
#

its fine

#

fixed it

low shadow
#

nice

radiant echo
#

can someone help me

radiant echo
#

Can anyone help with my pygame? I need help for my game

potent ice
#

@radiant echo You just ask the question. The best thing is to spend some time formulating it and prepare some related code snippet. One post with the questions is enough

radiant echo
#

I need to make my targets clickable and have a "+1" show up when they are clicked
https://repl.it/@Koleo/NiftyFortunateHertz-3#main.py
repl.it
NiftyFortunateHertz-3
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Python 2.7, Ruby, Roy, Python, Node.js, Deno (beta), Go, C++, C, C#, F#, ...

here is my code, you may need to run it a few times until you see the "play game" part

lean falcon
#

Hi

#
import sys

import pygame

def check_events(ship):
    """respond to keypresses and mouse events."""
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            check_keydown_events(event, ship)
        elif event.type == pygame.KEYUP:
            check_keyup_events(event, ship)

def check_keydown_events(event, ship):
    """respond to keypresses."""

    if event.key == pygame.K_RIGHT:
                ship.moving_right = True
    elif event.key == pygame.K_LEFT:
                ship.moving_left = True


def check_keyup_events(event, ship):
    """respond to key releases."""

    if event.key == pygame.K_RIGHT:
                ship.moving_right = False
    elif event.key == pygame.K_LEFT:
                ship.moving_left = False
                # Move the ship to the right.
                ship.rect.centerx += 1

def update_screen(ai_settings, screen, ship):
    """update images on screen and flip to the new screen"""
    #redraw the screen during each pass through the loop.
    screen.fill(ai_settings.bg_color)
    ship.blitme()

    #make the most recently drawn screen visible.
    pygame.display.flip()
#

What in my code is making my sprites movements so terrible?

#

I'll press left arrow and nothing happens, I hold it down, nothing.

#

I spam it, sometimes it moves to the left

#

or gets stuck moving to the left

#

sometimes pressing left makes it go right

#

and vice versa

dawn quiver
#

@lean falcon you're only moving the ship right one pixel when the left key is released (so once)

#

the indentation is inconsistent as well, that's a big no-no in python

lean falcon
#

and that would cause the program not be able to move properly tho?

#

I hold left arrow and nothing happens, I spam it then stop and it non stop slides to the right

#

sometimes nothing happens

severe saffron
#

@lean falcon i don't really see how you would expect this to do anything else

#

the only time you move the ship is when the user has released the left arrow key

#

you ignore your ship.moving_left and moving_right variables completely

queen peak
#

Hey

severe saffron
#

howdy

brittle nacelle
#

is python any good when it comes to making games ?

arctic fjord
#

kinda , ive been making python games for over 30 years and it sucks tbh

#

pretty much only game u can create is snake

#

but u can add snakes if u want

#

thats pretty fun

#

i once created snake with over 300 snakes

#

had to use 3 monitors

#

@earnest micaratoras

#

<@&267629731250176001>

silver stratus
#

!tempban 148778907074691072 7d do not insult other users.

frank fieldBOT
#

:incoming_envelope: :ok_hand: applied ban to @modern totem until 2021-02-08 12:58 (6 days and 23 hours).

potent ice
#

@arctic fjord You can definitely make more advanced things than snake. What tools are you using?

radiant echo
#

how do I make images disappear when clicked in pygame

potent ice
#

Break down the problem into smaller parts.

#

You probably need to look at the mouse position when clicked and figure out if the mouse is selecting one of the clickable objects.

#

Then you remove that object for the next frame you draw

#

This is not too complicated with rectangles at least

#

Sprites have collidepoint that can help

severe saffron
#

i feel like we should have some kind of guide for that kind of problem solving, cause a lot of answers to those sorts of questions are kind of explaining the same things, and while it's very valuable it feels like something which a lot of people miss out on

#

i guess it's 'asking the specific question you want an answer to' or the bit of the problem you're stuck on

#

although often it's really useful for the person to get an overview of an approach to solving their problem

potent ice
#

That also kind of depends on the library you are using.

wet folio
potent ice
#

Looks like there is a missing frame in there?

wet folio
#

Seems like

#

I have no idea of the reason tho ahah

potent ice
#

Add some prints?

wet folio
#

Let me check everything before writing something stupid here

potent ice
#

In most cases it's something stupid 😄

wet folio
#

Yeah but I keep asking myself

#

I've added a player animation

#

The code is basically the same of the guard except for the images

#

Why isn't the player animation buggy ahah

potent ice
#

Just start from the bottom looking at the images, how you load them and how they are used in the code. Do some prints if needed. It's almost always something stupid.

wet folio
#

Okay thanks, I'll try

wet folio
#

Fixed it, it was a stupid mistake ahah

#

One too many else statement

wet folio
#

Lmfao that's sick af

sleek seal
#

how do you make a game in python.

#

pygame?

dawn quiver
#

by making a game o guess

sleek seal
#

wow i didnt know that

#

...

dawn quiver
#

never mention

sleek seal
#

anyone know?

lunar venture
#

read the channel's topic

sleek seal
#

ok

sleek seal
#

oh wait

#

...

lunar venture
#

wack

the last thing in this channel's pinned messages has a youtube tutorial Pygame 2019

sleek seal
potent ice
#

Made a custom physics engine or maybe using pymunk

sleek seal
#

k

#

can you make something like that in pygame?

#

with pygame*

potent ice
#

Yes. The gif above is most certainly using pygame

sleek seal
#

hmmmmm

#

how do you make a gif.

potent ice
sleek seal
#

cool

#

imma look at that

potent ice
#

SceenToGif is used a lot in Windows

#

There are lots of other options out there depending on OS

sleek seal
potent ice
#

Nope

sleek seal
#

where do i get it then.

potent ice
sleek seal
#

which one tho

#

portabale or the other thing

#

installer*

potent ice
#

I have no idea. I don't use it myself. Just know that it's very popular

sleek seal
#

k.

#

which one do you think tho and is it safe?

#

like is it gonna give me a virus

foggy python
sleek seal
#

what is pymunk tho

#

and which one should i pick in screen to gif

foggy python
#

it's a python wrapper for the chipmunk physics library

#

I use gifcam for recording gifs

sleek seal
#

o

#

where do i get chipmunk.

foggy python
#

if you're using python, you just need pymunk

sleek seal
#

and where do i get that.

#

also im sorry if im asking to much

foggy python
#

pip install pymunk

sleek seal
#

and if im using pycharm?

foggy python
#

dunno how pycharm works, but if you're using it, you should know how to install libraries

sleek seal
#

ok

#

ok installed the libary

#

also why is the python icon pink.

foggy python
#

probably valentines day

sleek seal
#

ahhh yes

#

ok

lunar venture
#

if you are using a virtual environment in PyCharm then I have no clue, pip install pymunk should install it for everywhere, so it will be also available in PyCharm (unless venv)

potent ice
#

Doesn't pycharm also detect packages based on existing imports?

sleek seal
#

it just gives you an error

potent ice
#

No idea. I just use pipenv or set up venv manually. Less frustration for me personally 😉

scenic plank
#

Why is the server icon pink?

potent ice
#

It's the luve month

scenic plank
#

oh right

lunar venture
#

or uninstalled modules.

#

unless maybe there's a venv or a dependencies thing, idk, didn't explore this IDE really

potent ice
#

hmm. It used to in the past. At least it asked you.. but that was 3 years go

lunar venture
#

it should error ImportError if a module is not installed

potent ice
#

I am 100% sure it used to ask you about installing the missing dependency if you clicked the error

#

(might only be for "known packages")

lunar venture
#

sounds too kind to be true

mystic lodge
#

@foggy python are you the real DaFluffyPotato

potent ice
#

@mystic lodge you can probably assume that from the roles

foggy python
#

yes

#

my youtube is linked to my discord

#

I can't do that unless I have access to the channel

mystic lodge
#

oh ok lol

sleek seal
#

@foggy python what editor do you use?

#

text editor?

#

.

#

Da fluffy potatoe

potent ice
#

@sleek seal You get those answers by watching the videos

#

I think he's using Atom. The choice of editor doesn't really matter that much. It's subjective.

sleek seal
#

okkkkkkkkkkkkkkk

foggy python
#

I use IDLE for single files and Atom when working on larger projects

trail wave
#

vsc is good

#

plugins are easy to use and help a lot

river temple
#

I might be the lowest level personnel here. I don't even know how to install pygame it keeps setting me back when I try to pip install it and I've tried everything, can I get some help it doesn't have to be right now

potent ice
#

What happens when you install it? How exactly are you installing it and where?

spark mesa
#

can I make 3d games using python?

potent ice
spark mesa
potent ice
#

Depends if you want the high level or low level method of doing it

#

Panda3D and/or Ursina might be a good start

#

If you are interested in rendering with gpu in general (low level) you can also use pyopengl, pyglet or moderngl

#

(But that is a bit more hardcore)

spark mesa
#

thankyouu

#

i will try it

crisp junco
last moon
#

also the build tools

sharp cedar
#

how do game engines deal with frame rate with accordance to time? for example when moving a character, it would certainly travel farther if the frame rate is higher right?

potent ice
#

You keep track of time passed

#

I usually have a timer giving me time (seconds elapsed since the game started) and a frame_time being the delta time since last frame.

#

Some game libraries have this built in

last moon
#

Is time not constant?

tranquil girder
#

it's usually capped at the monitor's refresh rate, but it can lag

sharp cedar
tranquil girder
#

and then it's slower

potent ice
#

You can probably get away with just measuring the time since you started processing the last frame

#

For the delta time that is

dawn quiver
#

ya t'il des FR

main abyss
#

is ursina engine good

crisp junco
main abyss
#

so shouls i use it

mystic lodge
#

i tried using ursina engine but in my opinion i like pyopengl more because its more basic but way more complicated and there is also way more documentation on it

river temple
river temple
eternal prawn
#

@river temple can you show the output of py -0 in terminal

river temple
#

Installed pythons found by py launcher for Windows -3.9-64 * -3.7-64

eternal prawn
river temple
#

How do I fix that

eternal prawn
river temple
#

Should their be as space in between

eternal prawn
#

copy them as it as

river temple
#

'python-3.7' is not recognize as an internal or external command, operable program or batch file

eternal prawn
river temple
#

It worked😀

eternal prawn
#

:)

#

gl

river temple
#

Thank you

#

Do you know of any code editor I could use?

eternal prawn
river temple
#

Visual studio Code?

eternal prawn
#

Yes

dawn quiver
#

I use thst as well

fierce aspen
#

wait i got a question

#

i thought most people use C# for game development

#

how do you guys use python for game development

main abyss
#

python is a high level language that dose not mean you can't make games you just can not make that are upto the level of games made by c++ and c# but yeah you can

potent ice
#

@main abyss That really depends on the game. Python can be surprisingly competent.

#

You just need to use the right tools for the job

distant thorn
#

is there a discord server for pygame

low shadow
low shadow
main abyss
#

and whwnever i try to do setup in sublime it does not run it

potent ice
distant thorn
#

Thx

frank depot
#

What is a good graphics API? As I would like to get into game development and am confident in my knowledge enough to try make a simple game

#

or yk framework

severe saffron
#

pygame is good for starting

#

in python

river temple
# eternal prawn :\)

Thanks again I just finish a tutorial on using pygame an it was great,most complex game I've ever made😀

proper yoke
#

how to make a game launcherr

#

pleaseee

vital relic
#

im having trouble installing arcade

#

it throws an error while preparing wheel metadata

#

but still proceeds to say successfully installed

rapid solar
#

hello I am new to Python I have been following youtube tutorials on how to code some stuff like a hangman game is there any tips for me to improve am I doing something right by writing someone elses code and If I did it wrong please do criticise I am open to it and looking to improve and also pls do give tips

mystic basalt
#

if you dont you should atleast get the basics of it

dawn quiver
#

My python file has resources (png, wav) in a folder, I need to open the whole folder to run the .py correctly. But what I want is, it should run directly without opening the whole folder. Any solutions for this
(this is a game)

dawn quiver
#

does anyone know how to fix this problem. I am trying to make my game executable

#

'pyinstaller' is not recognized as an internal or external command, operable program or batch file.

potent ice
#

Either you did not install it or you have multiple pythons installed and you installed it in the wrong one

#

pip list or python -m pip list

#

some systems also have python, python3, pip and pip3

#

python --version

pulsar field
#

Is pygame worth it?

fervent rose
#

no

low shadow
wise vine
#

I'm rotating a tank image and at the tip of the tank image, I want to know the x and y coordinates there so that I may shoot something.

#

Does anyone know how I may do this?

wise vine
#

Serious games need an engine or another language.

#

I'll show you the code I have right now though.

#
#SIMPLE TANK GAME
import pygame, sys
from pygame.locals import * 

pygame.init()
WINDOW_DIMENSIONS = (400, 400)
FPS = 30
fpsClock = pygame.time.Clock()
DISPLAYSURF = pygame.display.set_mode(WINDOW_DIMENSIONS, 0, 32)
WHITE = (255, 255, 255)

tankImg = pygame.image.load('tank.png')
tankx, tanky = 100, 100
angle = 0
while True:
    angle -= 6
    DISPLAYSURF.fill(WHITE)
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.quit()
    img_copy = pygame.transform.rotate(tankImg, angle)
    DISPLAYSURF.blit(img_copy, (tankx - int(img_copy.get_width() / 2), tanky - int(img_copy.get_height() / 2)))
    pygame.display.update()
    fpsClock.tick(FPS)```
severe saffron
#

how much maths have you done in school

#

or university or whatever

#

you can use some fairly simple trig to do this

wise vine
#

I'm in University for engineering atm. I know trig.

severe saffron
#

well then it's just

#

trig

#

idk what to tell you lol

#

take the position of the gun barrel and rotate it around the origin

wise vine
#

Rotation matrix?

#

Gotcha.

severe saffron
#

uh

#

well more like just right angled triangles

dawn quiver
#

for pygame where do you guys usually get your sound files from?

worldly flare
#

any channel for discussing game dev in pythons's pygame library

worldly flare
worldly flare
dawn quiver
#

Aight I'll check that out, thanks

worldly flare
dawn quiver
#

sfxr you make your music right

#

and audacity has music made by other people

worldly flare
worldly flare
dawn quiver
#

ohh

#

that sounds very cool

worldly flare
#

btw what kinda game do you make

#

I am working on a platformer my avatar is actually my game character

dawn quiver
#

doing it for fun more than anything else really

worldly flare
dawn quiver
#

that's the plan

worldly flare
#

well,would anyone like to see my artwork for game

dawn quiver
#

go ahead

worldly flare
#

just a min

#

there are not many of these as my game is in initial stage of development

worldly flare
dawn quiver
#

not atm, thank you

worldly flare
#

any sneek-peak of your game

#

btw, I am having a question any help will be appreciated: how can i generate 2d procedural terrain in pygame using perlin or simplex noise or something else?

pulsar field
#

It’s simple trigonometry

slim sky
#

||peanuts||

potent ice
#

Or just come up with something chaotic yourself. As long as you have a low turnaround testing different values you can combine several layers and masks

dawn quiver
#

this is my code for loading a background image

background = pygame.image.load("D:\vghw\Main\back.jpeg")
#

but I'm getting this error

potent ice
#

The path should be a string

dawn quiver
#

wait

potent ice
#

"D:\vghw\Main\back.jpeg"

dawn quiver
#

yeah it is a string

potent ice
#

After you edited the message, yes 😄

#

working now?

dawn quiver
#

but the error im getting is

Traceback (most recent call last):
  File "D:\vghw\Main\Downrider.py", line 14, in <module>
    background = pygame.image.load("D:\vghw\Main\back.jpeg")
pygame.error: Couldn't open D:ghw\Mainack.jpeg
dawn quiver
potent ice
#

Just use forward slashes

#

The \ character has a special meaning in strings

#

It "escapes" the next character

dawn quiver
#

oh right right I forgot

potent ice
#

D:\\vghw\\Main\\back.jpeg or D:/vghw/Mainb/ack.jpeg

dawn quiver
#

ok I will try

#

still can't open

#
  File "D:\vghw\Main\Downrider.py", line 14, in <module>
    background = pygame.image.load("D:\\vghw\\Main\\back.jpeg")
pygame.error: Couldn't open D:\vghw\Main\back.jpeg
potent ice
#

Does the image even exist?

dawn quiver
#

it does I can show you a screenshot

dawn quiver
#

yes

#

see

#

back is the image I want to use

potent ice
#

are you sure the file has a .jpeg extensions and not .jpg or anything else

#

I would turn off "hide file extensions for known file types" in explorer

dawn quiver
dawn quiver
potent ice
#
from pathlib import Path
print(Path("D:\\vghw\\Main\\back.jpeg").exists())
#

See if you get a True or False there

dawn quiver
#

I can do this in shell right?

potent ice
#

yeah

#

You can also just right click the image file and see the full name there (properties)

dawn quiver
#

yess that worked

#

it was .jpg

#

not .jpeg

#

omg I was stuck for so long

#

thank you so much dude

#

I'm dumb I thought that if it had type as jpeg it'd be .jpeg

potent ice
#

Configure explorer to not hide extensions. Should be an option somewhere, but I am not on windows now 🙂

dawn quiver
#

Ok I'll search that up

#

but now everything in my game moves really slowly

#

very slow

potent ice
#

should be easy. 3 clicks 🙂

dawn quiver
#

both player and enemies

potent ice
#

Share some code

dawn quiver
#

I'll share the full code

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

potent ice
dawn quiver
#

this is the full code

#

now the enemies move really slow

#

and the players

wet folio
#

Try to increase enemyNX_change and enemyNY_change

worldly flare
dawn quiver
#

that worked

#

tho I am a bit confused why they suddenly slowed down after adding a background

potent ice
#

That is also a good idea, but nothing wrong with hard coding absolute paths to begin with

potent ice
dawn quiver
#

oh I see

#

also I am now getting another error

Traceback (most recent call last):
  File "D:\vghw\Main\Downrider.py", line 234, in <module>
    explosion_Sound = mixer.sound('explosion.wav')
AttributeError: module 'pygame.mixer' has no attribute 'sound'
wet folio
#

wouldn't it be a good idea to add a clock object?

potent ice
#

It definitely would

dawn quiver
#

I will do that later on right now I'm working on sound effects

wet folio
#

I think you need capital S in sound

dawn quiver
#

ah stupid mistakes

#

that worked thanks

#

I am making a lot of minor mistakes because it is my first time working with pygame

wet folio
#

Makes sense ahah

#

I've been trying to fix an animation bug for 2 days

#

then I found out that I just had to remove an else statement

dawn quiver
#

ah good thing it's not just me haha

wet folio
#

Well I'm a beginner too ahah

#

well I don't see any rule against pinging staff sooooo

#

@potent ice

#

Need your help ahah

potent ice
dawn quiver
#

Does anyone know how to make animations for your character while moving or standing still?

#

And implement it?

wet folio
potent ice
#

That was for Doom

#

We don't really know what library @dawn quiver is using. There are tons of game libraries for python

fierce wraith
#

oh looks like the preview messes up the lines, looks fine if you go into fullscreen

dawn quiver
#

lol awsome

#

9/10

severe saffron
#

looks nice!

#

also looks like its a bit squashed

#

in the preview

fierce wraith
#

Thanks!

atomic flame
#

I guess you're bad in math or smth

#

21 - 9 = 12

#

He can't be 13

severe saffron
#

they're asking to check if they're under 13

#

because if so they can't have a discord account and will be banned from the server

atomic flame
#

really?

#

I didn't know

dawn quiver
#

why my code don't want to work

#
import pygame
from pygame.locals import *

pygame.init()

# SCREEN
screen_width = 1000
screen_height = 1000

screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('TEKEN KINESKA VERZIJA')



#load images
sun_img = pygame.image.load('images/sky.png')



#running and quiting game
run = True
while run:

    # PICTURES
    screen.blit(sun_img, (0, 0))

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

    pygame.display.update()

pygame.quit()
severe saffron
#

what is the error you get

#

it's impossible for us to help you if you just post a random program and say it doesn't work

surreal furnace
#

@dawn quiver whats ur error

#

What does it say

#

And what part of it isnt working

mystic lodge
#

can anyone help me with putting my pygame project on the web?

#

is there a way to do it?

dawn quiver
#

I find a bug

#

thanks for replying

#

and trying to help me 🙂

unreal river
#

Can someone help me how to collide objects in pygame? because im making a platformer game

gleaming zealot
#

Anyone that can help w making tic tac toe?, it has to be turtle based and 1 with bot and 1 with AI payment wont be an issue. ive already started with it. (made the board, x and o, onscreenclick compatible) all that is bot&AI bot + a few prints for wins and loss etc
dm if u can

#

advantage if ur from sweden^

modern marsh
#

any game engine that uses python

#

as its language

#

ping me or dm me if u know pls

gleaming zealot
#

No turtle

modern marsh
#

then no

#

we use pygame and other library here\

#

yah

#

@dawn quiver

#

is kivy used for game dev

dawn quiver
#

Guys so I'm using pygame to make a game

#

and when the lives drops down to 0, I want the player to drop out of the screen

#

but the boundaries prevent it from doing that

#

so how do I make it drop down

#

I don't wanna disable the boundaries while someone is playing either

worldly flare
worldly flare
worldly flare
dawn quiver
#

but I want to show him dropping down and out of the screen instead of magically disappearing

dawn quiver
#

If I increase the Y value the boundary function stops him from dropping out

worldly flare
dawn quiver
#

I will google how to do that

worldly flare
worldly flare
dawn quiver
worldly flare
worldly flare
dawn quiver
#

ok I put it in

worldly flare
dawn quiver
#

I think I will increase because the game is still very slow

worldly flare
#

did you use clock.tick(60) in your main loop

dawn quiver
#

I used it

#

but it is very slow now

worldly flare
dawn quiver
#

well not that slow but kind of slow

#

I'll try to experiment with something bw 60 and 120

#

the game is lagging a lot

#

no matter what value

worldly flare
dawn quiver
#

ok

worldly flare
worldly flare
dawn quiver
#

I forgot the name of the website

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

dawn quiver
#

ok here it is

worldly flare
#

let me check

worldly flare
dawn quiver
#

yes it is mine

worldly flare
#

so,the problem is your approach to write code

dawn quiver
#

wydm?

worldly flare
# dawn quiver wydm?

I mean just try to use OOP in your code it will make coding way easier and efficient

dawn quiver
#

is there anything I can do about my game lagging?

worldly flare
#

and to eliminate lag you have to use OOP in yoour code to learn it watch the tutorial series by the youtuber i suggested he is really good at explaining stuff.

dawn quiver
#

Ok thank you I will try that

worldly flare
#

and also you are using lot of unnecessary stuff in main loop which can be done outside the loop

#

this will decrease the game speed

#

as the game have to do many things in single frame and doing so many things will definitely make your game slow

frank fieldBOT
worldly flare
dawn quiver
#

right now the problem is that he doesn't go out of the screen

#

when the game is over

#
if lives_value == 0:
    playerX == 2000
    enemy1Y == 2000
    enemy2Y == 2000
    enemy3Y == 2000
    enemy4Y == 2000
    enemy5Y == 2000
#

the boundary function stops them for doing it

#

I need some way to stop the boundary function when game is over i.e lives are 0

worldly flare
#

what is boundary function doing?

dawn quiver
#
    def boundaries():
        if playerY <= 0:
            playerY = 0
        elif playerY >= 536:
            playerY = 536
    boundaries = True
#

this is the boundary function

worldly flare
#

you can make a bool for this blocking = true

dawn quiver
#

I want it to stop

worldly flare
#

if blocking == true:

#

boundary()

worldly flare
#

if playerY <= 0 and boundaries == true:
playerY = 0

dawn quiver
#

I want it to stop when lives reach 0

worldly flare
#

here is added another condition for your if statement

dawn quiver
#
    def boundaries():
        if playerY <= 0:
            playerY = 0
        elif playerY >= 536:
            playerY = 536
    blocking = True
    if blocking == True:
        boundaries()
#

how is this?

#

I added what you said

worldly flare
dawn quiver
#

that would be very nice of you

worldly flare
#

is it fine or you want someting else you can just type the condition in if statement adn if the condition is true then boundaries will work else they will not

dawn quiver
#

now the boundaries are not working from the start

#

the player can go out of the screen

worldly flare
wet folio
#

I basically have to create multiple instances of an object and blit them on the screen, anyone who has any idea of how to do it?

#

I also have to modify the x and y value of the object so I can't just create a list and append the image and the tuple with coordinates

dawn quiver
#

Please can someone help

#

I cant install pygame i dont know why

#

I follow every step but it doesnt work

potent ice
#

What did you do?

#

How did you determine it doesn't work?

low shadow
# potent ice Why not?

kinda slower than the other languages
It struggles when you have many objects in the game
C is better at handling that kinda stuff

potent ice
#

@low shadow You can create games with great performance and lots of objects on the screen using python. Pick the right tools for the job. Also you can combine C/C++ with python to optimize specific parts. With what game library did you have this problem?

worldly flare
#

I prefer using SDL2 it has all the functionalities and is a great (atleast faster than pygame) in terms of performance

#

even i switched from pygame to sdl2

crisp junco
#

try to post the error along side your question , it just makes our job easy

worldly flare
#

hi, does running loops for getting events put more burden on cpu?

eternal prawn
#

Every game do have a main game loop

low shadow
potent ice
#

If you are talking about the pygame events it's pretty normal to loop and process all of them before next frame

#

@low shadow Then it's a limitation with pygame and not python 🙂

eternal prawn
low shadow
low shadow
potent ice
#

Maybe the new sdl2 stuff in pygame2 can help you there. The alternative is to use some of the gpu based game libraries.

eternal prawn
#

makes sense, also there is something like tile editor software take a look into that

low shadow
clear cloak
#
import pygame
pygame.init()

BLACK = (  0,   0,   0)
WHITE = (255, 255, 255)
BLUE =  (  0,   0, 255)
GREEN = (  0, 255,   0)
RED =   (255,   0,   0)

x = 50
y = 50
width = 40
height = 60
vel = 30

screen = pygame.display.set_mode((800,550))

pygame.display.set_caption("first program")

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

        key = pygame.key.get_pressed()
        if key[pygame.K_LEFT] and x > vel:
            x -= vel
        if key[pygame.K_RIGHT] and x < 800 - width - vel:
            x += vel
        if key[pygame.K_DOWN]:
            y += vel
        if key[pygame.K_UP]:
            y -= vel
        screen.fill(BLACK)        
        pygame.draw.rect(screen, BLUE, (x, y, width, height))
        pygame.display.update()
            
                 
pygame.quit()
#

i tried to play a bit with the delay but i dont understand how this works
when i press a button prolonged the rectangle moves a bit and it takes time to move again
how can i make it move constantly while that button is keep being pressed

eternal prawn
worldly flare
#

is kivy good for gui development for games?

cosmic badge
#

you can but

worldly flare
cosmic badge
#

you have to optimize your code when build for android

#

otherwise it can work on pc vey well

clear cloak
eternal prawn
#

every line after running = False

clear cloak
#

oh

#

its not even moving like this

eternal prawn
#

?

clear cloak
#
screen = pygame.display.set_mode((800,550))

pygame.display.set_caption("first program")
key = pygame.key.get_pressed()
if key[pygame.K_LEFT] and x > vel:
    x -= vel
if key[pygame.K_RIGHT] and x < 800 - width - vel:
    x += vel
if key[pygame.K_DOWN]:
    y += vel
if key[pygame.K_UP]:
    y -= vel
screen.fill(BLACK)        
pygame.draw.rect(screen, BLUE, (x, y, width, height))
pygame.display.update()

running = True
     
while running:

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


            
pygame.quit()        
eternal prawn
#

show whole

#

code

#

bruh

#

not like that

clear cloak
#

im sry im very begginer

eternal prawn
#
screen = pygame.display.set_mode((800,550))

pygame.display.set_caption("first program")


running = True
     
while running:

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

    key = pygame.key.get_pressed()
    if key[pygame.K_LEFT] and x > vel:
        x -= vel
    if key[pygame.K_RIGHT] and x < 800 - width - vel:
        x += vel
    if key[pygame.K_DOWN]:
        y += vel
    if key[pygame.K_UP]:
        y -= vel
    screen.fill(BLACK)        
    pygame.draw.rect(screen, BLUE, (x, y, width, height))
    pygame.display.update()
            
pygame.quit()         
#

am on mobile sorry for bad indentation :c

#

but yes do something like above

clear cloak
#

it worked

#

thank you tho

cold storm
#

Build / File / patron in video description

gleaming zealot
#

is it allowed to ask for help here regarding turtle? or .pygame only

dawn quiver
#

I sure hope so. Pygame is not the only python game library.

gleaming zealot
#

alrighty thanks!

#

i need help with a python code where im working on a tic tac toe game, Im trying to simply create a bot that places the piece randomly and one AI which knows where to block and where to place (nothing to hard). Ive currently made the board, x and o along with making it onscreenclick compatible. So i need someone to help me out and guide me to the right path! this is all made through turtle btw

#

so if anyone is willing to help please @ me

blissful depot
#

Is there a good game development tutorial for Pygame that is recommended?

frozen knoll
modern marsh
#

🙂

worldly flare
#

hey how can i display someting in pygame with tkinter in my pygame window

worldly flare
wet folio
worldly flare
wet folio
#

You're right hahah

#

According to internet it's possible

low shadow
#

and you could take the input from tkinter and pass it through pygame

#

or you might be able to change tkinter's location on screen to match pygame's window location
i dont really know if there is a command for that tho

low shadow
#

hmm i dont know how to paste code here

dawn quiver
#

Can someone help me loop my game

#

if you need the full code msg me

low shadow
potent ice
#

You definitely can

#

A lot of people using pygame make retro style games. It's really nice or that.

#

Making pixel art is also easier for most people

#

It doesn't have to be perfect and some of the "errors" in the sprite texture can also add some charm to the game 😉

low shadow
#

Np man
Was kinda fun tbh
Didn't know u could do that and use it like that

worldly flare
#

i am a bit confused about using this sprite in my game any suggestions

#

I will use this sprite to make lots of animation with different fighting and walking animations

low shadow
#

I would say it lacks contrast
I can't differentiate between objects that much

wet folio
#

Mh looks good to me ahha

cold storm
low shadow
cold storm
#

just noted that my sound was not recording 😦

#

😄

zenith parcel
#

I want to make a 2D game with lots of self-made "eye candy", including self-designed particle effects and shapes fading in and out of opacity and randomly moving light sources and all that craziness.
I've been using Pygame for the past twelve years, and I've remained entirely out-of-touch with recent developments in new Python libraries that are available. While Pygame is a fantastically easy-to-use library, it doesn't seem to be super friendly when it comes to "dynamic graphics" (...for lack of a better term) and can also be very slow when individual-pixel-access is involved.

My question is, is there a better tool for the job? What options do I have as alternatives?

frozen knoll
#

For particle effects I recommend using shadera.

#

The Arcade library is pretty friendly if you want to dive into opengl graphics.

dawn quiver
#

What would be a lightweight game engine for python that focuses more on game logic rather than graphics. It could be for text based games or minimal 2d graphics but ideally an active / modern project that has some community. Is there such a thing?

potent ice
#

@dawn quiver You can give arcade a try. It's a bit more high level.

#

It's definitely more focused on game logic

blissful depot
gleaming zealot
#

anyone got some time on their hands and could look over my code?

potent ice
#

Don't ask to ask. Just post it and hope that someone will reply 😉

gleaming zealot
#

oh okay my bad xD this is the code

#

so my question is, how am i able to create a "bot" that places pieces randomly

#

for example Im X and the bot is O, i place a piece down and the bot after me

mystic lodge
#

@potent ice is arcade a good game engine for python?

#

is it more complex than pygame?

potent ice
#

It's much simpler and has lots of docs and tutorials

#

It probably has more limitations though

#

Every library have pros and cons

gleaming zealot
#

pls someone help me im desperate ive been trying to figure this out for 2 days now

potent ice
#

What exactly are do you need help with?

gleaming zealot
#

So im trying to make a bot i guess that places randomly pieces, so lets say you are a player and the bot being the opponent

potent ice
#

How advanced is this supposed to be?

gleaming zealot
#

oh not advanced at all

#

just random pieces

potent ice
#

Ok, so the bot is just supposed to pick a random free cell?

gleaming zealot
#

well how do i put it in words, i guess it should choose random free cells but also know that 3 in a row makes you win

#

the bot should be able to win

#

but not too advanced

potent ice
#

So it should only place the 3rd symbol if that makes a win?

gleaming zealot
#

exactly

#

there is 6 possibilities of winning right?

#

nvm its more

potent ice
#

I guess the mus() function can respond (after the player symbol is added)

#

Should be 8 in total including diagonals

#

You could prepare a list of indices for each of them

#
[
    (0, 1, 2),  # top row
    (3, 4, 5),  # middle row
    ...
]
#

Those are the indices in pjaser

#

Also a bonus with english varaible names and comments 🙂

wise vine
#

what font is that?

gleaming zealot
#

[
(0, 1, 2), # top row
(3, 4, 5), # middle row
(6, 7, 8), # last row
]

#

like this?

#

@wise vine im using IDLE

potent ice
#

yeah just an idea so you can just loop that. need 8 of them

#

For each entry throw them in a new list with 3 elements. Then you can simply use count() ```python

["X", "X", ""].count("X")
2

#

Might be smarter ways, but this is at least simple

#

You can test this logic in a separate script as well.

gleaming zealot
#

so i guess if (spelbord [i] == "") the bot places a piece where i being i = 0; i < 9

#

bruh im not even sure on what im typing

#

im so lost

potent ice
#

Start simple and find the free positions and make the bot just pick a random one

#
>>> board = ["X", "", ""]     
>>> free_positions = [i for i, v in enumerate(board) if v == ""] 
>>> free_positions
[1, 2]
#
>>> import random
>>> random.choice(free_positions)
1
#

Maybe this can give you some ideas

#

Looks up enumerate, list comprehension and the random module and understand what it is

gleaming zealot
#

looked it up

#

so enumerate tells the program the empty spots in Board

#

how would the program know when its empty or full though

#

also is it the index or element in this case

proper peak
#

if v == ""

gleaming zealot
#

oh thats so obv

#

its 4 am here sorry xD

#

alright let me try it out

#

do i stick the code under mus()?

#

nvm i do

#

this is what i get

#

oh wait a sec

#

nvm

#

im sorry for being a pain in the ass, i would gladly send you over money if yall need me to

#

@potent ice u there? sorry for pinging

potent ice
#

It means exactly what it states. It cannot choose(..) from an empty list, so you need to check for that

gleaming zealot
#

pjaser = ["", "", "", "", "", "", "", "", ""]

#

this list correct?

potent ice
#

Sure. It can be depending on your code

#

Paste the relevant code snippet

#

use !codeblock if you can

#

!codeblock

frank fieldBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

gleaming zealot
#

oh okie

#

    free_positions = [i for i, v in enumerate(pjaser) if v == ""]
    random.choice(free_positions)
#

u mean this?

potent ice
#

!e ```python
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
random.choice(free_positions)

frank fieldBOT
#

@potent ice :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | NameError: name 'random' is not defined
potent ice
#

!e ```python
import random
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
random.choice(free_positions)

frank fieldBOT
#

@potent ice :warning: Your eval job has completed with return code 0.

[No output]
potent ice
#

Crap it's late here too it seems

gleaming zealot
#

my brain functionality is on 5,68%

#

its depending on u currently xD

potent ice
#

!e ```python
import random
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
print(random.choice(free_positions))

frank fieldBOT
#

@potent ice :white_check_mark: Your eval job has completed with return code 0.

4
potent ice
#

works

#

Might be more productive to sleep 🙂

#

There is a tomorrow

gleaming zealot
#

im literally not able to sleep

#

the code is haunting me

#

so what ive been reading off is that i need to make a list of 1st row second and third

#

and when playing the game the code fills that list up

#

so for example if im placing a piece of X in the bottom left corner

#

[
("", "", ""), # top row
("", "", ""), # middle row
("X", "", ""), # last row
]

#

and the enumerate goes on from that list and choses a free random place where the bot places the piece

potent ice
#

nono. ignore that list for now. We're simplifying the scope by having the bot just pick a random free position

#

One step at a time 😉

#

Isolate one problem at a time and solve only that problem

gleaming zealot
#

okay! 🙂

#

so my current issue would be that there isnt a list for the bot to choose from

potent ice
#
    free_positions = [i for i, v in enumerate(pjaser) if v == ""]
    if free_positions:
        ai_position = random.choice(free_positions)
        print("Picked position", ai_position)
    else:
        print("No free positions")
#

printing stuff is always a good idea to see what is happening

#

if free_positions will be false if the list is empty

#

Once you understand the code better you can remove the prints

#

(or keep them.. personal preference)

#

You can also check if len(free_positions) > 0 or if len(free_positions) == 0

#

It's just that the truthiness of an empty list itself is False

#

!e ```python
print([] is False)
print([1, 2, 3] is True)

frank fieldBOT
#

@potent ice :white_check_mark: Your eval job has completed with return code 0.

001 | False
002 | False
potent ice
#

gah. ignore lol. It's late!

#

!e ```python
print(bool([]))
print(bool([1, 2, 3]))

frank fieldBOT
#

@potent ice :white_check_mark: Your eval job has completed with return code 0.

001 | False
002 | True
potent ice
#

That is better

gleaming zealot
#

Alrighty

#

so this is what ive came up with

#
    if free_positions:
        ai_position = random.choice(free_positions)
        print("Picked position", ai_position)
    else:
        print("No free positions")
    if len(free_positions) == 0:
        print(bool([]))
        print(bool([1, 2, 3]))```
potent ice
#

The last if is pointless here 😉

#

All you need to do is to figure out how to place the computer's symbol based on ai_position

gleaming zealot
#

oh okay! 🙂

potent ice
#
    free_positions = [i for i, v in enumerate(pjaser) if v == ""]
    if free_positions:
        ai_position = random.choice(free_positions)
        print("Picked position", ai_position)
        # Place the comptuers symbol
        pjaser[ai_position] = "X"  # Or is it "O"?
        # We might also need to draw it?
    else:
        print("No free positions")
#

You already know how to determine box from an x and y position, so now you need to do it in reverse

#

Could also make those into functions to make things a bit cleaner

cold storm
gleaming zealot
#

so in this case i determine where i want the bot to place the random pieces along with where, and also who and what position the bot starts on via the cords of box

potent ice
#

@cold storm looking good 🙂

cold storm
#

I did not have much time to work on GFX so this is mostly just mechanics

#

there is 2 days left on the jam kinda

#

but I probably won't have more time

potent ice
#

I did not want to comment on the shadows and the rounded corners 😄

cold storm
#

basically you are seeing about 2.5 hours of coding

#

and about 4 minutes of scene setup

potent ice
#

Yup. That's what I thought. Good results in that amount of time

frank fieldBOT
#

Hey @cold storm!

It looks like you tried to attach file type(s) that we do not allow (.blend). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .webm, .webp, .flac, .afdesign, .m4a, .csv.

Feel free to ask in #community-meta if you think this is a mistake.

cold storm
#

upbge 0.3.0

gleaming zealot
#

einarf thank you very much for ur help hopefully you have a good night sleep, if you need compensation for the help just throw away a dm and ill gladly send over some money! ill i guess work on this tomorrow and hopefully finish it somehow even though im lost asf

potent ice
#

@gleaming zealot No problem. Don't compensate people for helping here.

#

@cold storm Looks clean. Pathfinding mesh, collision etc. Makes perfect sense.

dawn quiver
dawn quiver
wise vine
#
(WIDTH, HEIGHT) = (800, 600)
line_len = 400
DISPLAYSURF = None
fpsClock = pygame.time.Clock()
FPS=30

LINECOLOR = (255, 0, 0)
BGCOLOR = (0, 0, 0)



animation_test = Line(100,1,100,400,LINECOLOR)

def draw_animation():
    for time in np.arange(0, 1, 0.1):
        animation_test.draw(DISPLAYSURF)

def draw_lines():
    for line in lines:
        pygame.draw.line(DISPLAYSURF, LINECOLOR, line[0], line[1])

def main():
    pygame.init()
    DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
    DISPLAYSURF.fill(BGCOLOR)
    draw_animation()
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()
        DISPLAYSURF.fill(BGCOLOR)
        pygame.display.update()
        fpsClock.tick(FPS)
        ```
#

My window just keeps on closing. Does anyone know why?

crisp junco
#

Seems like you're not calling the main()

crisp junco
safe briar
#

What's an easy to use 3D game ide that uses Python?

low shadow
low shadow
wise vine
# crisp junco btw is this your full code?

I'm assuming ```py
#! /usr/bin/env python

import pygame, sys
from pygame.locals import *
import numpy as np

class Line:
x1:int
x2:int
y1:int
y2:int
color:Color

def __init__(self, x1, y1, x2, y2, color):
    self.x1 = x1
    self.y1 = y1
    self.x2 = x2
    self.y2 = y2
    self.color = color    

def linear_interpolation(self, v0, v1, t):
    return (1-t)*v0+t*v1

def draw(self, surface, percentage=1):
    nx = self.linear_interpolation(self.x1,self.x2,percentage)
    ny = self.linear_interpolation(self.y1,self.y2,percentage)
    pygame.draw.line(surface, self.color, (self.x1, self.y1), (nx, ny))

(WIDTH, HEIGHT) = (800, 600)
line_len = 400
DISPLAYSURF = None
fpsClock = pygame.time.Clock()
FPS=30

LINECOLOR = (255, 0, 0)
BGCOLOR = (0, 0, 0)

animation_test = Line(100,1,100,400,LINECOLOR)

def draw_animation():
for time in np.arange(0, 1, 0.1):
animation_test.draw(DISPLAYSURF)

def main():
pygame.init()
DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
DISPLAYSURF.fill(BGCOLOR)
draw_animation()
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
DISPLAYSURF.fill(BGCOLOR)
pygame.display.update()
fpsClock.tick(FPS)```

crisp junco
#
def main():
    global DISPLAYSURF #You need to add this
    pygame.init()
    DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
    DISPLAYSURF.fill(BGCOLOR)
    draw_animation()
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()
        DISPLAYSURF.fill(BGCOLOR)
        pygame.display.update()
        fpsClock.tick(FPS)
waxen mantle
crisp junco
waxen mantle
#

bird

waxen mantle
gleaming zealot
#

if Omvant == "X":
        Omvant = "O"
    pjaser2(pjaser)
    free_positions = [i for i, v in enumerate(pjaser) if v == ""]
    if free_positions:
        ai_position = random.choice(free_positions)
        print("Picked position", ai_position)
        pjaser[ai_position] = "X"
    else:
        print("No free positions")
        len(free_positions) == 0
        print(bool([]))
        print(bool([1, 2, 3]))```
gleaming zealot
#

Yes

#

Turtle

#

Damn it okay thanks anyways 🙂

wise vine
#

BUt it still doesn't do aonything

potent ice
#

@gleaming zealot The only thing you need to do is drawing the symbol the AI is placing

#
pjaser[ai_position] = "X"
# -> Draw the X here
#

And of curse make sure that the player only places O symbols

gleaming zealot
#

okay so should i paste this under that code you sent

#
pjaser[ai_position] = "X":
      def Cross(x,y):
      up()
      goto(x+20, y-20)
      setheading(-45)
      down()
      forward(226)
      up()
      goto(x+180, y-20)
      setheading(-135)
      down()
      forward(226)
      up()```
#

like this?^

potent ice
#

just call the Cross(x, y) function

#

The job is to figure out what x and y is based on the ai_position

#

You already calculate box (It's also an array position) from the x and y position of the mouse

#

so you should be able to do that in reverse

#
pjaser[ai_position] = "X"
# Draw the X symbol, but we need to figure out what x and y is!
Cross(x, y)
gleaming zealot
#

so cross(x, y) cords of each box

#
pjaser[ai_position] = "X"
# Draw the X symbol, but we need to figure out what x and y is!
Cross(x, y)```
potent ice
#

Well at least for the box the ai placed

#

It's turtle. You just keep adding to the canvas

gleaming zealot
#

so this is for the Bot starting position which is in the middle, so i need the cords x , y for the middle box correct

potent ice
#

You are moving ahead too fast

#

ai_position can be 0, 1, 2, 3, 4, 5, 6, 7 or 8

#

Those represents all the positions on the board

#

If need to make a function or code snippet calculating where turtle is supposed to draw it

#

This is an x and y posiiton

#

You already convert a click position to an array position ```python
def mus(x,y):
global Omvant, pjaser
radda = (x+300) // 200
rad = (-y+300) // 200
box = radda + rad*3
box = int(box)
pjaser[box] = Omvant

#

ai_position would be the same as box here. You need to do the reverse figuring out x and y based on the box value.

#

Just try something and print the values

gleaming zealot
#

alright so let me get this straight, ai_position[0, 1, 2, 3, 4, 5, 6, 7, 8], im supposed to turn these numbers into cords for the turtle to print out, in mus() i did it from cords to numbers in the grid, and here i have to do from numbers to cords

potent ice
#

Just the one position it picked

#

for example ... 7!

#

The ai picked position 7 and you have to plot that to the screen with turtle

dawn quiver
#

Do someone here have good platform tutorial

potent ice
#

Platformer game?

gleaming zealot
#

Ive been trying to figure this crap out for 1 hr now with no success 😞

potent ice
#

@gleaming zealot What did you try?

gleaming zealot
#

Trying to understand, but i can’t seem to figure it out

potent ice
#

Where are you stuck exactly?

gleaming zealot
#

Literally where we left off

potent ice
#

and why are you stuck? What is the question?

gleaming zealot
#

I’m not sure on what to do to solve the issues I have

potent ice
#

What about that?

gleaming zealot
#

Yup exactly

#

Okay 1 sec

#
  1. my issue is that i both have to start for myself and for the bot before the bot starts picking random locations

  2. also i would love for the bot to start in the middle position with X, where im O

3.Also i can place both X and O on the same position (overlining it)

potent ice
#

So you did solve the first problem we worked on?

#

The version I posted works fine except that the user picks the first position

blissful depot
#

Is there a good server for Python Arcade?

#

because it is showing promise and I will most likely need help... lots of help.

gleaming zealot
#

thats how it is currently

#

einar if you could help me make 1 position placing for the bot ill try doing the rest

#

like if you show the code for 1 piece so that i understand ill try later on to do it for the rest

potent ice
low shadow
#

i fixed it

#

there was a lot of random stuff in the middle

#

i dont really understnad why u used a numpy lib

wise vine
#

So it was my shitty code. Got it.

low shadow
#

and u declared variables but didnt assign shit
so u wasted some lines ther

#

ill paste it here, but i dont know how to get that formatting u put

#

like that huge green box and the code inside that

#

just tell me how u did that and ill paste it

low shadow
wise vine
#

Yes, I am.

low shadow
#

tell how to paste the code here

#

in that formatting in which u pasted it

#

with the box and code inside it

low shadow
#

import pygame

class Line:
def init(self, x1, y1, x2, y2, color):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.color = color

def linear_interpolation(self, v0, v1, t):
    return (1-t)*v0+t*v1

def draw(self, surface, percentage=1):
    nx = self.linear_interpolation(self.x1,self.x2,percentage)
    ny = self.linear_interpolation(self.y1,self.y2,percentage)
    pygame.draw.line(surface, self.color, (self.x1, self.y1), (nx, ny))

(WIDTH, HEIGHT) = (800, 600)
fpsClock = pygame.time.Clock()
FPS=30
LINECOLOR = (255, 0, 0)
BGCOLOR = (0, 100, 0)
animation_test = Line(100,20,50,400,LINECOLOR)

def draw_animation(DISPLAYSURF):
for i in range(10):
animation_test.draw(DISPLAYSURF)

def main():
pygame.init()
DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
DISPLAYSURF.fill(BGCOLOR)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
    draw_animation(DISPLAYSURF)
            
    pygame.display.update()
    fpsClock.tick(FPS)

main()

wise vine
low shadow
wise vine
#

That's how you paste the code

#

In Discord

low shadow
#

oh

#

It didnt work

#
import pygame

class Line:
    def __init__(self, x1, y1, x2, y2, color):
        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2
        self.color = color    

    def linear_interpolation(self, v0, v1, t):
        return (1-t)*v0+t*v1

    def draw(self, surface, percentage=1):
        nx = self.linear_interpolation(self.x1,self.x2,percentage)
        ny = self.linear_interpolation(self.y1,self.y2,percentage)
        pygame.draw.line(surface, self.color, (self.x1, self.y1), (nx, ny))


(WIDTH, HEIGHT) = (800, 600)
fpsClock = pygame.time.Clock()
FPS=30
LINECOLOR = (255, 0, 0)
BGCOLOR = (0, 100, 0)
animation_test = Line(100,20,50,400,LINECOLOR)


def draw_animation(DISPLAYSURF):
    for i in range(10):
        animation_test.draw(DISPLAYSURF) 


def main():
    pygame.init()
    DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
    DISPLAYSURF.fill(BGCOLOR)
    
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
        draw_animation(DISPLAYSURF)
                
        pygame.display.update()
        fpsClock.tick(FPS)


main()
#

k nice i got it

low shadow
#

dafluffypotato has the best platformer tutorials according to me
but tech with tim has more vids that go more into mechanics of how things work - kinda like spoon feeding you the code

dawn quiver
#

thanks @low shadow

low shadow
#

i need

'Untitled1.png'
'floor.png'
'pipes.png'
low shadow
wise vine
#

@low shadow Thanks for cleaning up my code, chief.

low shadow
blissful depot
#

Is Arcade or Pygame better for an intermediate programmer

potent ice
#

It really depends what you want to make

#

pygame is a bit more flexible, but low level. Arcade is higher level

#

A difference is also that Arcade use the gpu and are mainly limited to run on win, linux and mac

#

While pygame is possible to run in more environments

#

Arcade is much more powerful related to how much you can draw per frame

#

It's all about tradeoffs

blissful depot
#

ok

low shadow
blissful depot
blissful depot
potent ice
#

There are lots of great tutorials in the official docs

blissful depot
#

yeah

#

but not from people like TWT

#

...yet

potent ice
#

pygame is definitely 10 x more popular because it has been around for so long

blissful depot
#

yeah

low shadow
#

yes pygame is the most popular lib for python gui based stuff
after tkinter

#

ig

potent ice
#

What you learn by using pygame or arcade translates well betwen the libraries anyway

blissful depot
potent ice
#

Arcade was made because pygame had shortcomings as a teaching tool

blissful depot
#

oh

potent ice
#

It's used a lot for teaching python by making games in schools

blissful depot
#

So which one do you think is better for someone who doesn't understand much more than functions and classes?

low shadow
potent ice
#

extra stuff? 🙂

low shadow
low shadow
potent ice
#

Nah. It's fairly high level. You work with Sprites mainly

#

Also built in collision detection and stuff like that

blissful depot
#

My brain is melting from an information overflow.

potent ice
#

tmx map loading

blissful depot
#

tmx??

#

oh boy

#

I am confused now

#

completely lost

low shadow
low shadow
potent ice
#

tmx map

blissful depot
#

oh wow

#

that is...wow

#

never seen anything like that

potent ice
#

There is a library for pygame as well

blissful depot
#

like tmx?

potent ice
#

yeah

low shadow
potent ice
#

It supports pygame, pyglet and sdl2

low shadow
#

but starting from scratch is still better cause u understand the logic and mechanics

blissful depot
#

So Arcade is higher level and therefore easier to learn?

#

🤔

potent ice
#

Yeah I would think so. Also has great docs

#

But remember the tradeoffs.

low shadow
#

kinda depends if u wanna make a game or learn how a game works

potent ice
low shadow
potent ice
#

Well. Its not that high level. It gets you started faster

blissful depot
#

oh

#

huh

potent ice
#

pygame and pyglet are like graphics/media libraries while arcade is a bit closer to a game engine

#

You still need to do the work though

blissful depot
#

can pygame use tmx?

potent ice
#

yes I liked the library (pytmx)

honest linden
#

Damn this chat is to advanced for me 😔

low shadow
#

wait tmx is just a format right?
i am not too sure what it is

potent ice
#

It's a format yes

blissful depot
potent ice
#

Super easy to learn and gets you started with a game world in no time