#game-development
1 messages · Page 76 of 1
ok thx
if u dont get it even after that check tech with tim's vid
its on projectiles
ig even dafluffypotato made one
oh thx
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
How to use python?
You write it
How to do most basic game on py?
@magic gazelle depends what kind of game. Text based? graphics?
no just text in IDLE
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
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
That also works. Focus on understanding how every part of the program is working.
yea
otherwise its pointless to build the game
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!
how to make a game multiplayer game using discord bots (discord.py)
damonki
@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.
Hey @unique kernel!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
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?
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?
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?
Try writing
'click =pygame.time.Clock()'
outside your main loop first
just came to stop by
as he says the website you can't access even after clicking on advanced
yeah. U have to set the clock first and make the object first. Then u can call the 'tick' method
that's why it is giving u that error.
The output is just blank (no error)
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
is ursina engine good for pythpn 3d game development
hello everyone present here
lol
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
can i please get somehelp in manganese? i m trying to make a snake game
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
i dont think there is any app to learn from. just read what each command does and try messing around
If you do want some good channels tho, check out
- Dafluffypotato
2.TechWithTim
They use pygame library in their projects
alright thank you tho
you guys have any idea how to fix this? ```
programIcon = pygame.image.load('./Sandyicon.png')
FileNotFoundError: No such file or directory.
What module would be best if i wanted to make a 2d board game?
Hey @winged oasis!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@mystic burrow you could use pygame
simple number game for beginners............
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.
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
it closes because you didnt put a loop
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
Already answered these questions 😉
No one died 😄
give the full path
nice
can someone help me
Can anyone help with my pygame? I need help for my game
@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
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
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#, ...
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
@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
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
becuz of a boolean
@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
Hey
howdy
is python any good when it comes to making games ?
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>
!tempban 148778907074691072 7d do not insult other users.
:incoming_envelope: :ok_hand: applied ban to @modern totem until 2021-02-08 12:58 (6 days and 23 hours).
@arctic fjord You can definitely make more advanced things than snake. What tools are you using?
how do I make images disappear when clicked in pygame
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
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
That also kind of depends on the library you are using.
Have you guys ever gotten animation glitches like this?
Looks like there is a missing frame in there?
Add some prints?
Let me check everything before writing something stupid here
In most cases it's something stupid 😄
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
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.
Okay thanks, I'll try
Lmfao that's sick af
by making a game o guess
never mention
anyone know?
read the channel's topic
ok
wack
the last thing in this channel's pinned messages has a youtube tutorial Pygame 2019
what did he use to make a game like that?
Made a custom physics engine or maybe using pymunk
Yes. The gif above is most certainly using pygame
@foggy python has a youtube channel with lots of useful tips : https://www.youtube.com/channel/UCYNrBrBOgTfHswcz2DdZQFA
I make games and tutorials with/for Python/Pygame! :D
Website here: http://dafluffypotato.com
SceenToGif is used a lot in Windows
There are lots of other options out there depending on OS
does it come with the windows?
Nope
where do i get it then.
I have no idea. I don't use it myself. Just know that it's very popular
it's pygame + pymunk
it's a python wrapper for the chipmunk physics library
I use gifcam for recording gifs
if you're using python, you just need pymunk
and if im using pycharm?
dunno how pycharm works, but if you're using it, you should know how to install libraries
probably valentines day
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)
Doesn't pycharm also detect packages based on existing imports?
it just gives you an error
No idea. I just use pipenv or set up venv manually. Less frustration for me personally 😉
Why is the server icon pink?
It's the luve month
oh right
it doesn't install missing imports
or uninstalled modules.
unless maybe there's a venv or a dependencies thing, idk, didn't explore this IDE really
hmm. It used to in the past. At least it asked you.. but that was 3 years go
it should error ImportError if a module is not installed
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")
sounds too kind to be true
@foggy python are you the real DaFluffyPotato
@mystic lodge you can probably assume that from the roles
yes
my youtube is linked to my discord
I can't do that unless I have access to the channel
oh ok lol
@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.
okkkkkkkkkkkkkkk
I use IDLE for single files and Atom when working on larger projects
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
What happens when you install it? How exactly are you installing it and where?
can I make 3d games using python?
yes
how?
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)
try using python -m pip install pygame
If that doesn't work make sure if you've installed pip correctly
also the build tools
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?
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
Is time not constant?
it's usually capped at the monitor's refresh rate, but it can lag
I’ve seen this on unity and godot how does it work mathematically
and then it's slower
You can probably get away with just measuring the time since you started processing the last frame
For the delta time that is
ya t'il des FR
is ursina engine good
yeah
so shouls i use it
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
It shows that it is installed but when I go into python idle an type import pygame it give me an error. I pip installed pygame from CMD
I'll try
Requirement already satisfied
@river temple can you show the output of py -0 in terminal
Installed pythons found by py launcher for Windows -3.9-64 * -3.7-64
you have multiple python installed
How do I fix that
try python-3.7 -m pip install pygame or python-3.9 -m pip install pygame or Uninstall One of them
Should their be as space in between
'python-3.7' is not recognize as an internal or external command, operable program or batch file
replace python with py and have a space between py and version
Like this py -3.x
It worked😀
Code editor doesn't matter at all, Pycharm is good if you are just working with python, else I Prefer VsCode
Visual studio Code?
Yes
I use thst as well
wait i got a question
i thought most people use C# for game development
how do you guys use python for game development
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
@main abyss That really depends on the game. Python can be surprisingly competent.
You just need to use the right tools for the job
is there a discord server for pygame
depends on the types of games
u can make games that are not graphically and computationally expensive
use sublime
or vs code
vs code is usually better for big programs that require multiple files and shit
sublime is much more simple
and whwnever i try to do setup in sublime it does not run it
@distant thorn Pygame discord (the most active one) : https://discord.gg/h8ujJGCcq3
Thx
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
Oh thanks
Thanks again I just finish a tutorial on using pygame an it was great,most complex game I've ever made😀
im having trouble installing arcade
it throws an error while preparing wheel metadata
but still proceeds to say successfully installed
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
umm do you even know how to program in python?
if you dont you should atleast get the basics of it
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)
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.
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
Is pygame worth it?
no
if u wanna make games, i wouldn't really suggest python
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?
If you want to make full fledged games, don't use Python. PyGame is mostly for people who are screwing around or just learning.
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)```
how much maths have you done in school
or university or whatever
you can use some fairly simple trig to do this
Whatever it is, I know it.
I'm in University for engineering atm. I know trig.
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
Why not?
for pygame where do you guys usually get your sound files from?
any channel for discussing game dev in pythons's pygame library
i make my own with sfxr
yeah I also use audacity
Aight I'll check that out, thanks
let me explain the diffrence between sfxr and audacity
yeah right
no in audacity you can record sound and then customize it
btw what kinda game do you make
I am working on a platformer my avatar is actually my game character
it's a very basic one where you just dodge some bullets
doing it for fun more than anything else really
its fine you start from basic then learn advance that's how I am learning
that's the plan
well,would anyone like to see my artwork for game
go ahead
just a min
this one is player spritesheet(a single image consist of several images used for animation)
its rock
this one is tree
its a tile set
there are not many of these as my game is in initial stage of development
btw,would you like to join my channel
not atm, thank you
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?
Use Sin and Cos functions
It’s simple trigonometry
||peanuts||
Should be a python library for simplex noise, but you can also replicate this in pure python ("good enough" version)
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
this is my code for loading a background image
background = pygame.image.load("D:\vghw\Main\back.jpeg")
but I'm getting this error
The path should be a string
wait
"D:\vghw\Main\back.jpeg"
yeah it is a string
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
sorry that was an old code that I pasted
Just use forward slashes
The \ character has a special meaning in strings
It "escapes" the next character
oh right right I forgot
D:\\vghw\\Main\\back.jpeg or D:/vghw/Mainb/ack.jpeg
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
Does the image even exist?
it does I can show you a screenshot
Are u using a computer?
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
as you can see the type is jpeg
any idea how I do that?
from pathlib import Path
print(Path("D:\\vghw\\Main\\back.jpeg").exists())
See if you get a True or False there
I can do this in shell right?
yeah
You can also just right click the image file and see the full name there (properties)
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
Configure explorer to not hide extensions. Should be an option somewhere, but I am not on windows now 🙂
Ok I'll search that up
but now everything in my game moves really slowly
very slow
should be easy. 3 clicks 🙂
both player and enemies
Share some code
I'll share the full code
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:
Use https://paste.pythondiscord.com/ like suggested there
Try to increase enemyNX_change and enemyNY_change
hi to find files just move them into the folder in which the file is located
oh lol I never thought it would be that simple
that worked
tho I am a bit confused why they suddenly slowed down after adding a background
That is also a good idea, but nothing wrong with hard coding absolute paths to begin with
Probably because your framerate was insane before you did that
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'
wouldn't it be a good idea to add a clock object?
It definitely would
I will do that later on right now I'm working on sound effects
I think you need capital S in sound
ah stupid mistakes
that worked thanks
I am making a lot of minor mistakes because it is my first time working with pygame
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
ah good thing it's not just me haha
Well I'm a beginner too ahah
well I don't see any rule against pinging staff sooooo
@potent ice
Need your help ahah
Helps to look up things in the official docs :https://www.pygame.org/docs/ 🙂
Does anyone know how to make animations for your character while moving or standing still?
And implement it?
😑
Load the animation images into a list and whenever you move the character you cycle through your list
That was for Doom
We don't really know what library @dawn quiver is using. There are tons of game libraries for python
the beginning of my lunarlander clone 🙂
oh looks like the preview messes up the lines, looks fine if you go into fullscreen
Thanks!
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
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()
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
can anyone help me with putting my pygame project on the web?
is there a way to do it?
Can someone help me how to collide objects in pygame? because im making a platformer game
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^
dm me
i know
hey are you using pygame
No turtle
then no
we use pygame and other library here\
yah
@dawn quiver
is kivy used for game dev
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
just increase the y value of player
this way you dont even have to disable anything
no, but yeah it can be used for gui in game
but I want to show him dropping down and out of the screen instead of magically disappearing
ok4
If I increase the Y value the boundary function stops him from dropping out
hey, first of all you shoukld add a clock object else you will have problem with speed and making your game framerate independent
I will google how to do that
make a value for gravity such as 0.6 or something play with these value and you will get a value which is good for you drop down effect
this is the code: clock = pygame.time.Clock()
just put that at the beginning of the code or in my main loop
use this code in beginning
in while loop write: clock.tick(60) so, here 60 is the frame rate you can also play with this value
ok I put it in
just a quick advice 60 is great for frame rate and most game's run on 60 fps
I think I will increase because the game is still very slow
also, higher fps will provide higher speed
did you use clock.tick(60) in your main loop
try to set it to 120
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
also,in youtube search how to make your game frame rate independent in pygame, a youtuber called DaFluffyPotato will appear you can watch him
ok
would you like to show me your code as, it can be because of your code
also make sure you are not using so many loops for no purpose
I forgot the name of the website
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:
ok here it is
let me check
I think i am sure its your CODE! yeah,its your code
yes it is mine
so,the problem is your approach to write code
wydm?
I mean just try to use OOP in your code it will make coding way easier and efficient
is there anything I can do about my game lagging?
yeah you can split your code into various files(dont split them into so many as it takes time to find file) this will make it more clleaner to read
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.
Ok thank you I will try that
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
Hey @worldly flare!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
👍
https://paste.pythondiscord.com/ocewacimul.lua this is my code just try to understand the approach
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
what is boundary function doing?
def boundaries():
if playerY <= 0:
playerY = 0
elif playerY >= 536:
playerY = 536
boundaries = True
this is the boundary function
you can make a bool for this blocking = true
I want it to stop
why dont you just make boundaries = false
if playerY <= 0 and boundaries == true:
playerY = 0
I want it to stop when lives reach 0
here is added another condition for your if statement
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
let me write a code for you
that would be very nice of you
https://paste.pythondiscord.com/fuweditezu.yaml here when boundaries is false and the player life == 0 then the boundaries will not work
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
now the boundaries are not working from the start
the player can go out of the screen
its because the players value is not zero before it dies
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
Please can someone help
I cant install pygame i dont know why
I follow every step but it doesnt work
kinda slower than the other languages
It struggles when you have many objects in the game
C is better at handling that kinda stuff
@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?
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
Thanks
you're missing a : in the line for event in pygame.event.get()
it should be for event in pygame.event.get():
try to post the error along side your question , it just makes our job easy
hi, does running loops for getting events put more burden on cpu?
elaborate
Every game do have a main game loop
i had this problem with everything i made with pygame. making simple objects using verlet's integration and points would also give me similar problems
i have the same problem while making platformer games with gigantic maps. It works well with small maps tho
when the no.of objects increases, it happens
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 🙂
You should not blit all map objects on the screen, just blit the visible part
i made a map editing program that displays the entire map. I then used windows magnifier tool cause the tiles are small
so by my program, i had to blit the entire map
its still slower than c++ tho
edit: i referenced wrong message
Maybe the new sdl2 stuff in pygame2 can help you there. The alternative is to use some of the gpu based game libraries.
makes sense, also there is something like tile editor software take a look into that
yea those are way better, but i havent gotten there yet. will check it out tho : )
will look into it
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
key = pygame.keys.get_pressed()
Unindent above line out of for loop
is kivy good for gui development for games?
you can but
but what?
you have to optimize your code when build for android
otherwise it can work on pc vey well
you mean to get it out of the loop?
yes
every line after running = False
?
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()
im sry im very begginer
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
Wrectified UPBGE 0.3.0 BETA - works in newest branch by youle to fix collection spawn instance
Please support me on patreon and like / share subscibe
https://www.patreon.com/user?u=571333
https://drive.google.com/file/d/1UdfcCi67mgFUgHR4zvDUW8VrVHoCr6MX/view?usp=sharing
upbge build - https://ufile.io/u34hdyxi
Build / File / patron in video description
is it allowed to ask for help here regarding turtle? or .pygame only
I sure hope so. Pygame is not the only python game library.
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
Is there a good game development tutorial for Pygame that is recommended?
🙂
hey how can i display someting in pygame with tkinter in my pygame window
I recommend DaFluffyPotato he make good tuts in youtube
Is it even possible? and what's actually the point in doing so?
oh I think tkinter is better than pygame for gui
I dont think you can display it with tkinter in pygame window
they will be 2 seperate windows...
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
k i found how to move the tkinter window. I dont use it much, but i did find a stack overflow code that i cleaned up
hmm i dont know how to paste code here
https://paste.pythondiscord.com/ulemakipod.properties
this is the original code
whats the prob?
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 😉
thanks man for your effort
Np man
Was kinda fun tbh
Didn't know u could do that and use it like that
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
I would say it lacks contrast
I can't differentiate between objects that much
Mh looks good to me ahha
Zomb_8 - core mechanics finished - PRe-polish
nice
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?
For particle effects I recommend using shadera.
The Arcade library is pretty friendly if you want to dive into opengl graphics.
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?
@dawn quiver You can give arcade a try. It's a bit more high level.
It's definitely more focused on game logic
Thanks! I checked him out and he's pretty cool!
anyone got some time on their hands and could look over my code?
Don't ask to ask. Just post it and hope that someone will reply 😉
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
@potent ice is arcade a good game engine for python?
is it more complex than pygame?
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 Use our code pasting service instead : https://paste.pythondiscord.com/
pls someone help me im desperate ive been trying to figure this out for 2 days now
What exactly are do you need help with?
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
How advanced is this supposed to be?
Ok, so the bot is just supposed to pick a random free cell?
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
So it should only place the 3rd symbol if that makes a win?
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 🙂
what font is that?
[
(0, 1, 2), # top row
(3, 4, 5), # middle row
(6, 7, 8), # last row
]
like this?
@wise vine im using IDLE
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.
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
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
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
it's the listcomp that checks that
if v == ""
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
It means exactly what it states. It cannot choose(..) from an empty list, so you need to check for that
Sure. It can be depending on your code
Paste the relevant code snippet
use !codeblock if you can
!codeblock
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.
oh okie
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
random.choice(free_positions)
u mean this?
!e ```python
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
random.choice(free_positions)
@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
!e ```python
import random
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
random.choice(free_positions)
@potent ice :warning: Your eval job has completed with return code 0.
[No output]
Crap it's late here too it seems
!e ```python
import random
pjaser = ["", "", "", "", "", "", "", "", ""]
free_positions = [i for i, v in enumerate(pjaser) if v == ""]
print(random.choice(free_positions))
@potent ice :white_check_mark: Your eval job has completed with return code 0.
4
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
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
okay! 🙂
so my current issue would be that there isnt a list for the bot to choose from
paste the code again here : https://paste.pythondiscord.com/
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)
@potent ice :white_check_mark: Your eval job has completed with return code 0.
001 | False
002 | False
@potent ice :white_check_mark: Your eval job has completed with return code 0.
001 | False
002 | True
That is better
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]))```
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
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
BGMC 34 ZOMB_8 - with audio + dev commentary
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
@cold storm looking good 🙂
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
I did not want to comment on the shadows and the rounded corners 😄
basically you are seeing about 2.5 hours of coding
and about 4 minutes of scene setup
Yup. That's what I thought. Good results in that amount of time
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.
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
@gleaming zealot No problem. Don't compensate people for helping here.
@cold storm Looks clean. Pathfinding mesh, collision etc. Makes perfect sense.
I am taking a look at it. The need for opengl might be a limitation but maybe its optional if you actually dont draw sprites
it is very nice, gg 🙂
(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?
Seems like you're not calling the main()
btw is this your full code?
What's an easy to use 3D game ide that uses Python?
godot engine
when i run it its not working
after importing pygame, it tells Line is not defined
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)```
in def main(): put a line global DISPLAYSURF , that would just use the global DISPLAYSURF variable otherwise the function will create it's own local variable
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)
You can read more about the global term here https://stackoverflow.com/questions/13881395/in-python-what-is-a-global-statement
https://paste.pythondiscord.com/anuwuduwew.properties
It should restart if I press SPACE and it does but the bird just falls down very quickly
Could you please share the dependencies(pics)?
I did
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]))```
Thank you
BUt it still doesn't do aonything
@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
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?^
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)
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)```
Well at least for the box the ai placed
It's turtle. You just keep adding to the canvas
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
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
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
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
You need a formula like the one you already have (in reverse) : #game-development message
Do someone here have good platform tutorial
Ive been trying to figure this crap out for 1 hr now with no success 😞
@gleaming zealot What did you try?
Trying to understand, but i can’t seem to figure it out
Where are you stuck exactly?
Literally where we left off
and why are you stuck? What is the question?
@gleaming zealot https://paste.pythondiscord.com/oqubekuzel.apache
I’m not sure on what to do to solve the issues I have
What about that?
Yup exactly
Okay 1 sec
-
my issue is that i both have to start for myself and for the bot before the bot starts picking random locations
-
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)
So you did solve the first problem we worked on?
The version I posted works fine except that the user picks the first position
Is there a good server for Python Arcade?
because it is showing promise and I will most likely need help... lots of help.
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
@gleaming zealot I already posted a solution #game-development message
i got u man
i fixed it
there was a lot of random stuff in the middle
i dont really understnad why u used a numpy lib
So it was my shitty code. Got it.
yup
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
u there?
Yes, I am.
tell how to paste the code here
in that formatting in which u pasted it
with the box and code inside it
I need to go soon.
so ill paste it without that
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()
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
check out dafluffypotato and tech with tim
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
thanks @low shadow
share all the images needed
i need
'Untitled1.png'
'floor.png'
'pipes.png'
np
@low shadow Thanks for cleaning up my code, chief.
np man
thanks for teaching me how to paste code : )
Is Arcade or Pygame better for an intermediate programmer
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
ok
how famous is arcade compared to pygame?
It is pretty popular but there are not many tuts
;-;
correction: not as many
There are lots of great tutorials in the official docs
pygame is definitely 10 x more popular because it has been around for so long
yeah
What you learn by using pygame or arcade translates well betwen the libraries anyway
so it doesn't really matter which I choose?
Arcade was made because pygame had shortcomings as a teaching tool
oh
It's used a lot for teaching python by making games in schools
So which one do you think is better for someone who doesn't understand much more than functions and classes?
thats good
i thought i had to go through some extra stuff for arcade
extra stuff? 🙂
ig arcade is good, but idk
code on the graphics card is always faster and games require lot of calc
i assumed there might be some problems converting from cpu to gpu based programs
Nah. It's fairly high level. You work with Sprites mainly
Also built in collision detection and stuff like that
My brain is melting from an information overflow.
tmx map loading
that is actually kinda cool
welp
tmx map
There is a library for pygame as well
like tmx?
woah it has waay more features than those inbuilt in pygame
It supports pygame, pyglet and sdl2
but starting from scratch is still better cause u understand the logic and mechanics
kinda depends if u wanna make a game or learn how a game works
Tiled map editor : https://www.mapeditor.org/
the same as telling using an engine to make a game or making an engine and a game
Well. Its not that high level. It gets you started faster
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
can pygame use tmx?
Damn this chat is to advanced for me 😔
wait tmx is just a format right?
i am not too sure what it is
lol
Super easy to learn and gets you started with a game world in no time
