#game-development
1 messages · Page 69 of 1
kinda did it
that's circling around (.2843, -.0660)
so not quite the origin but close enough
@last moon this is something that I made while I was still learning the basics I think it would be helpful.
maybe not
but here it is https://repl.it/@Hi123876/rectangle#main.py
that's pretty neat
im pretty sure turtles have a speed cap tho
let me try to make something else, cause i want to do it seing u do it
"very fast" being the quickest without it being instant
ye
modulos are wacky with this
well i am gonna try to make something and i need ideas
for i in range(1, 200)
enemy.left(45 + i%4)
enemy.backward(100 - i//2) ```
the %
higher the divisor, the more intricate?
ohh
btw it doesn't need to be the exact origin becuase
remember there is going to be a hitbox
i hope i didn't was the time for that lol
ya sorry I'm kind of getting distracted
no no
I'll get you your spiral enventually
your already going out of your way to help lol
I'm already extemely thankful because you've spent like the past 2-3 hours trying to help lol
I'm just stressed out because a 5 week assignment is compressed into 3 days lol
and I have no prior knowledge
so it was quite stressful becauase
my school region decided to have a hybrid learning enviornment where we would go to school for 2 days, and the rest would be ascynchronyse learning, and
our semsters normally had 4 courses and would last 4 months each, its not compressed to 4 semesters each containing 2 courses and each semester lasts 2 months
@last moon
so
what you want to do
you take the point for a circle
you know how to do that?
loop through each angle and x = sin(angle) * circle_radius and y = cos(angle) * circle_radius
plus that in and you get the point of a circle
and so each step you increase the radius
what if I use left/backward/etc/etc?
wdym
oh
um
lets see
start at something like 0, 0
yeah
0, 0
and then step through some amounts of rotations
increasing the angle each time by some amount
each step, increase the radius by some amount
then get x, y coords
and subtract the previous coords from that
and thats how much you move
oh so I need to iterate until the spiral hits -250, 250 and run through the range backwards
if you want to have a 2d spiral, yes
that's the plan
eh
i wouldnt reccomend setting a point as the end thing
i think it would be better to set the params, then tweak them as you like
that's what i've been trying to do
idk I need to walk throught the math for a sec
so the initial radius needs to be the sqrt(250^2+250^2)
like where the turtle starts
initial radius would be zero
ig it's x,y coords so that doesn't matter
final radius would be that amount
no it needs to be the other way around
unless I draw it backwards
which is the same thing
are you looking to set the spiral to go to a certain point?
or are you just trying to make a spiral in general?
How big should I make the hitbox for the turtle because I think that would reduce some of the issues
or not tbh idek
what i would reccomend doing is taking that last point, taking the distance from the last to first point, dividing by the amounts spirals you want, dividing by the steps per spiral, then using that as the radius increase per step @late quartz
how do you take the inverse cos/sin in py?
im getting somewhere
decided to use polar coords and convert them
a = 0
b = 1
for i in range(200, 1, -1):
phi = i
rho = a + b*phi
x = rho * math.cos(phi)
y = rho * math.sin(phi)
enemy.goto(x, y)```
just need to tweak a,b
oh wow
btw thanks once again, I'm going to call it a night, its almost 2 am and I got school tmr
alright have a good one, ping me tomorrow, I'll have it figured out hopefully by then
probably lol
I would say if its just 5-10 it would be more than enough, and we don't need it to go directly to the center because remember we are working with a hitbox
so as long as the last spiral is close enough for the two hitboxes to touch, we should be fine lol
@brave widget py first = True a = 0 b = 1.5 freq = 3 multiplier = 4 exponent = 9/10 _min, _max, _step = 250, 1, -1 for i in range(_min, _max, _step): phi = i / freq rho = a + b * phi**(exponent) * multiplier x = rho * math.cos(phi) y = rho * math.sin(phi) if first: enemy.up() enemy.goto(x, y) enemy.down() first = False enemy.goto(x,y)
so it doesn't start at -250, 250 specifically
but you can tweak the range so it's close
_min, _max, _step = 250, 1, -1
a = 0
b = 1.5
freq = 9
multiplier = 10
exponent = 9/10``` that seems to work pretty well
thx
i am gonna make a race track
lol
not a race track but like a swmming pool racing thingy
where turtles are gonna race
guys i need help with an code!
print("We're no strangers to love")
print("You know the rules and so do I")
print("A full commitment's what I'm thinking of")
print("You wouldn't get this from any other guy")
print("I just wanna tell you how I'm feeling")
print("Gotta make you understand")
print("Never gonna give you up")
print("Never gonna let you down")
print("Never gonna run around and desert you")
print("Never gonna make you cry")
print("Never gonna say goodbye")
print("Never gonna tell a lie and hurt you")```
rick_roll()
what's the issue? @dawn quiver
import pygame
pygame.init()
screen = pygame.display.set_mode((1000,800))
screen.fill ((0,0,45))
ball = pygame.image.load('circle.png')
def ball_come():
screen.blit(ball,(ballx,bally))
x = 300
y = 30
ballx = 500
bally = 400
ballspeed = 1
ballspeed_2 = 1
ai_stick_y = 400
font = pygame.font.Font('freesansbold.ttf', 50)
shape = pygame.surface.Surface((250,250))
run = True
while run :
for event in pygame.event.get() :
if event.type == pygame.QUIT:
run = False
stick_1 = pygame.draw.rect(screen, (0, 255, 0),(1000, 400,100,200),50)
stick_2 = pygame.draw.rect(screen, (0, 255, 0), (0, ai_stick_y, 50, 200),)
#go = font.render("Click up arrow to start ", True, (255, 255, 255))
#screen.blit(go, (x, y))
clock = pygame.time.Clock()
#clock.tick(100)
ballx -= 0.3
bally -= 0.3
ai_stick_y -= 1
ball_come()
pygame.display.update()```
That is my code and my problem is :
A dough like thing when try to move
just a pong game
help me
imma take a wild guess and say you're adding the blit on top of the last one
so what should i do ?
idk pygame but I'm assuming you'll have to redraw the background + paddles + new ball pos
ok
you can see it's happening to the paddles as well so you have to update those
it might be a bit easier if you stick the sprites in class instances
ok
hi game developers
hi gamers
@little eagle you want to use screen.fill() to clear the frame and then redraw the elements
hi
im having issues with pygame instalation in ubuntu 16.04
i tried every command possible
nothing works
python3 -m pip install pygame?
yes ofc
python3 -m pip install pygame?
@flat dew no module named pip
i have pip and pip3
python3.7
20.4 i think
If you are using pip install without the python, you need to use pip3. but sometimes just using pip3 installs pygame in a different version of Python that the program is not using
So, use python -m in front of pip in order to specify that you want to use the pip that is a module command in that specific Python version
Successfully installed pygame-2.0.0
You are using pip version 8.1.1, however version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
but then i type
python3 -m pygame.examples.aliens
/usr/local/bin/python3: Error while finding module specification for 'pygame.examples.aliens' (ModuleNotFoundError: No module named 'pygame')
WHat command did you use for installing pygame
I thought py was for windows, not linux
WHat command did you use for installing pygame
@flat dew i tried everything i found in forums
python3 and pip3 is correct on ubuntu
python3 pygame.examples.aliens.py```
```pip3 install pygame
python3 pygame.examples.aliens.py```
Run those?
And try
no module named pip
😦
pip -V and pip3 -V works though
the second script you say
Requirement already satisfied: pygame in ./.local/lib/python3.7/site-packages (2.0.0)
i think theres a problem with the directories
where everything is installed and stuff
but sounds odd
@glass forge it looks like you have multiple versions of Python and pip3 corresponds to a different one for you than python3
Maybe try running with python3.7 instead
Or uninstall and reinstall Python to clean up the mess
Or uninstall and reinstall Python to clean up the mess
@olive parcel this seems more neat
i have python 3.7 though
You might have more than one 3.7 for all I know
someone told me to type this
/usr/local/lib/python3.7 -m pip install pygame==1.9
You might have more than one 3.7 for all I know
@olive parcel idk , it doesnt seem
Those are different Python installations than the ones that come from the Ubuntu repositories.
That's the problem
If you type python3 you might get the system version, and if you type /usr/local/bin/python3.7 you might get the version in /usr/local
pythn -V
I would suggest deleting all Python versions in /usr/local/bin and /usr/local/lib and just using your system installation
Or just explicitly running python3.9 all the time then
python3.9 -m pip install pygame and python3.9 pygame.examples.aliens.py
If you get an error saying that there's no module called pip, do python3.9 -m ensurepip
Anyway, just pick which Python installation you want to use and stick with it
someone just told me this : PyGame 1.9 is not compatible with Python 3.8, 3.9 or 3.10 alpha
can i just delete them from the directory? i mena with right button --- delete
Probably not, how did you install them?
Or just explicitly running python3.9 all the time then
@olive parcel
Probably not, how did you install them?
@olive parcel command scripts . 3.9 downloading a zip file from pygames webiste
How did you install Python 3.9? Not from PyGame's website I assume?
Because it looks like it's broken
@olive parcel i downloaded as a zip file
mmm
perhaps i messed up something
lol
now idk
can i just unistall it?
Depends on how you installed it… if you built Python from source, which it does look like, then calling "sudo make uninstall" inside the source code directory is the best way to do it
If you no longer have the source code directory, well, then… I guess you would just need to carefully manually delete a bunch of locations within /usr/local
local/bin or local/lib ?
/home/igna/Downloads/Python-3.9.0/pybuilddir.txt
Okay, great, do cd /home/igna/Downloads/Python-3.9.0 and then sudo make uninstall
its also here : /usr/local/include/python3.9/
Yeah, that's not the one
Erm, maybe it's deinstall instead of uninstall ?
You're inside /home/igna/Downloads/Python-3.9.0/ right?
yep
~/Downloads/Python-3.9.0$ sudo make deinstall
make: *** No rule to make target 'deinstall'. Stop.
~/Downloads/Python-3.9.0$ sudo make uninstall
make: *** No rule to make target 'uninstall'. Stop.
@glass forge
sudo rm -f /usr/local/bin/python3.9
sudo rm -f /usr/local/bin/pip3.9
sudo rm -f /usr/local/bin/pip3
sudo rm -f /usr/local/bin/python3
sudo rm -rf /usr/local/include/python3.9
sudo rm -f /usr/local/lib/libpython3.9.a
sudo rm -rf /usr/local/lib/python3.9
i think its done
before
when i type python3 -V
3.9.0
now
No such file or directory
}
Okay, good. You should still have python3.7 or python3.5 or whatever else you had before
now i should install pygame?
You can certainly try
it works!
but it crashs
idk why
when i pres space bar
(shoots a missile)
and crushes
its a space invaders game
I have no idea (and please try not to hit "enter" after every three words)
No problem
@last moon Hey, sorry to ping you, I didn't know what time zone your in so I waited till the first time you responded to me yesterday
sorry to bother again
any help with this? : ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
it displays evrytime i want to run a game using pygame , from the terminal
i found this answer but idk what to put there. import os os.environ['SDL_AUDIODRIVER'] = 'dsp'
no problem what's up?
This appears ALSA lib pcm.c:7963:(snd_pcm_recover) underrun occurred
Everytime I try to run a game
That uses pygame
ah sorry idk about that I was talking to @brave widget
Ooh
Hey, I'm having an issue
so I have a bullet that is shot from my turtle
but once Input the formula for the spiral formula, it says there is an error with the bullet state
That's the original code for the bullet but the enemy doesn't move at all
Thats the one with the enemy movement added in
as the error says, bulletstate is not defined anywhere
it works for the first image tho
line 105?
you not using the global bulletstate
also find a way to not use global
you'll end up with more issues than you need
Hey guys, I need some help here please.
First of all, I don't really know in which channel I should ask for help, so I apologize if this is the wrong one.
Here is the deal:
I'm trying to merge two images with python.
I've searched the web, and came to a (sort of) little script for doing it. Here it is:
But the problem is that my IDE tells me that PIL doesn't have any "image" method.
I think that my PIL installation went a bit wrong, but how can I fix it, please ?
Image not image, it's a class
I had tried this, but same problem here:
Import, the issue is with the second picture, idk why tho
ah so PIL's __init__.py's a bit odd, it's not actually importing Image.py or any other file
just call from PIL import * or from PIL import Image
im trying to figure out if there's another way but I haven't seen a library modeled like this in a while
import PIL.features as pil that seems to work idk if anything is left out tho
getting rid of global?
no i mean it works with the first image
where I didn't input the movement for the enemy
but when I do that, it give me the error message
the same message?
wait lemme take ss of what happens
:incoming_envelope: :ok_hand: applied mute to @brave widget until 2020-11-07 00:26 (9 minutes and 58 seconds) (reason: newlines rule: sent 115 newlines in 10s).
!unmute 240210899263160320
:incoming_envelope: :ok_hand: pardoned infraction mute for @brave widget.
!paste use this for longer code
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
np 😄
what's the issue with it?
when i try shooting the bullet for the second code, it tells me that bulletstate is not defined
!traceback
Please provide a full traceback to your exception in order for us to identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / 0
ZeroDivisionError: integer division or modulo by zero
The best way to read your traceback is bottom to top.
• Identify the exception raised (e.g. ZeroDivisionError)
• Make note of the line number, and navigate there in your program.
• Try to understand why the error occurred.
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
@brave widget what's the traceback?
oh
oops
File "C:\Users\wajda\Downloads\Code.py", line 75, in fire_bullet
if bulletstate == "ready":
NameError: name 'bulletstate' is not defined
My brain hurts lol
I'm going to take a break from this and do physics lol
I can't think straight
far enough
idk I can't even figure out how to pass it as an arg now
def fire_bullet(bulletstate):
...
fire_bullet(bulletstate)```
you know when you try on smth for a long while ... and you become incapable of thinking lol
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\wajda\AppData\Local\Programs\Python\Python39\lib\tkinter_init_.py", line 1885, in call
return self.func(*args)
File "C:\Users\wajda\AppData\Local\Programs\Python\Python39\lib\turtle.py", line 687, in eventfun
fun()
TypeError: fire_bullet() missing 1 required positional argument: 'bulletstate'
i can't
lol
i'm just braindead
I'm going ot physics, I'll be back in like an hour lol
anyone know how to update the window after drawing polygons with arcade?
I can't call .draw() because it's not a sprite, and I seemingly can't crate it as a sprite without an actual texture
Is there some GL workaround or am I missing something
That should already draw the polygon, what do you mean by update?
Guys I need help with something in pygame
Guys I need help: I'm running this little program that loads images to the screen in fullscreen mode but once it loads the program it will not exit by any key combination and it's a black screen. I end up having to reset the computer to complete whatever else I was doing. Can I DM anyone to help bc my code is long???
def draw_floor():
screen.blit(floor_surface,(floor_x_position,900)) # puts two surfaces on screen and creates fluid left movement
screen.blit(floor_surface,(floor_x_position + 576,900))
pygame.init()
screen = pygame.display.set_mode((576,1024)) # create display surface
clock = pygame.time.Clock()
bg_surface = pygame.image.load("background-day.png").convert() # import first image
bg_surface = pygame.transform.scale2x(bg_surface) # takes one surface, doubles the size, and returns it
floor_surface = pygame.image.load("base.png").convert() #import image
floor_surface = pygame.transform.scale2x(floor_surface) #scale floor surface
floor_x_position = 0
while True:
for event in pygame.event.get(): # pygame looks for events happening currently such as moving your mouse or closing a window
if event.type == pygame.QUIT: # closing the game
pygame.quit() # uninitializng game
sys.exit() # shuts down game completely
screen.blit(bg_surface,(0,0)) # use blit method to put one surface on another
floor_x_position -= 1 # will make floor move to right
draw_floor()
if floor_x_position <= -576:
floor_x_position = 0
pygame.display.update # Draws it from screen from while loop
clock.tick(120) # Limit frame rate per sec ```
I'm on mac OS btw.
travel = 100
start = [0,100]
point = start
travelList = [ [1,0],[0,-1], [-1,0],[0,1] ]
i=0
while current < travel:
point+=travelList[i]
draw(point)
else:
travel*=.9
i+=1
if i>3:
i=0
if travel<1:
break
@late quartz
travel over-100 pixel turn -> travel 90 -> turn -> travel 80 -> turn
I don't know how to rotate a 2d orientation though
a list could work
[ (1,0),(0,-1), (-1,0),(0,1) ]
that should work eh
for your fibanachi thing?
I'm on mac OS btw.
@storm cradle same
hi, how do i display long text in pygame without it getting cut out? (please ping me)
hello bois
is it to do with games?
hi, how do i display long text in pygame without it getting cut out? (please ping me)
yeah @severe saffron
im trying to do screen.blit(square.png(50, 50)) and its saying that
it needs to be pygame.surface
what do I do?
quick question, not trying to be disrespectful. do you guys view python game development as like a novelty or learning instrument, or are you trying to actually make real games using python?
games are incredibly dependent on performance and i can't imagine python ever being the best tool for the job in that arena
One approach is to use Python for game logic while relying on an engine written in C++ with Python bindings (this is more or less the model of Panda3D)
Need some help with pygame 😦 Was just codeing for fun and turns out I was basically codeing Spaceinvaders. After about 1hr I noticed I hadent run the code once and when I did, basically nothing was working. I can see all of the graphics, but i could not move the "space ship"and no mobs were spawning. Heres the code if anyone can help: https://paste.pythondiscord.com/xiwufazevi.rb
so I'm working on an Anti-Cheat plugin for game developers to use, does anyone know of some good package libraries that could help? (this may sound like a stupid question)
According to me I would say first learn how to hack your game
Then work according to that
And I don't think so there might be any way to make anti cheat plugins for other games using python maybe there are but I am not sure of it
Is Pyxel malicious
hello how do I make my game have several themes that users can choose from? I’d want them to be able to select light mode or dark mode, and this will apply in the menu and the whole game itself. I’m familiar with creating separate themes in pygame but I’m not sure what the best way is so that selection of either theme can change other assets in the game
im having trouble with jump mechs and dk what the fix is im in help-copper
Is it feasible to use bpy to make games
any ideas how could I add any robot or this kuka one to pybullet?
I got that ROS files and URDF
I was struggling to get pygame installed, can anyone help?
URDF @elfin frost
oh
you should be able to open the thing using the command line I bet
any ideas how could I add any robot or this kuka one to pybullet?
@elfin frost how did you make that?
For game development in python which module is the best?
2d or 3d
hello
For game development in python which module is the best?
..
also, pygame 2.0 is out ; what are the benefits over pygame
2d or 3d
@last moon both
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:
I recommend ursina, but I'm biased :)
Hey ho, im currently working on a Space Invaders game/ Meteor Shower game and everything is basically working as it should, except shooting the laser. Instead of shooting it draws a line following the ship. Any suggestions how I can fix this?
well
i have not even started game dev
but imo the laser image should be deleted
as soon as it changes position
laser image?
@elfin frost how did you make that?
@clever turtle >???????????????????????????????????????????????
hey
is there a way to get the mask of a rectangle in pygame?
because i have a player (which is a rect) and some enemys which are circle and i want to check for collision
Nope, dont think so
Im haveing som problems with my shooting mechanism and collision detection, can someone please help me?
can you send the code? @sterile dust
anyone got any recommendations for a noob who wants to try making games using python. Whats a good framework to use?
pygame
I have a pygame related question
Hey, I'm running into this error in turtle and I have no clue what it means:
tkinter.TclError: bad screen distance "(8.815368133829546+0.22569957494980106j)"
When generating a map in my game it does not spawn underneath my character causing him to fall into the void
cool thx
upbge is super fun to code python in
@dawn quiver
this is *bge legacy selling on steam right now - https://www.youtube.com/watch?v=V2pvoWlKYvk
Hey guys,
Haunted Cemetery arena is finally done. Zombieees!!!
Links:
https://www.facebook.com/KrumGame
http://krumgame.com/
https://discord.gg/dCYF3aHT
https://www.youtube.com/watch?v=j512ObmplEo this is my own project
Wrectified Systems Demo - 3/6/2020
in 0.3.0 - eevee
and right now I am working with the other developers to support XR
audio is in :D (next is getting stereo VR speakers working !)
I am more py / front end guy
change the spawn position?
hmm y'think that'd work in a 2-d platformer?
well i think the problem is my map spawns far away from the character
@brave widget how are you getting imaginary numbers???
Hey got a question
can someone help me with the mask function in pygame
i implemented it in the code and i got no errors but i never have a collision xD
def check_ball_collision(self):
player_mask = player.get_mask()
ball_mask = pygame.mask.from_surface(self.ball_img)
b1_left_offset = (self.x_left - player.x, self.y1_left - player.y)
b2_left_offset = (self.x_left - player.x, self.y2_left - player.y)
b1_right_offset = (self.x_right - player.x, self.y1_right - player.y)
b2_right_offset = (self.x_right - player.x, self.y2_right - player.y)
b1_left_point = player_mask.overlap(ball_mask, b1_left_offset)
b2_left_point = player_mask.overlap(ball_mask, b2_left_offset)
b1_right_point = player_mask.overlap(ball_mask, b1_right_offset)
b2_right_point = player_mask.overlap(ball_mask, b2_right_offset)
if b1_left_point or b2_left_point or b1_right_point or b2_right_point:
return True
return False ```
well thats probably not really possible to understand without context
so the b1 and b2_left balls are the both balls on the left
the balls keep in there row and just move left and right
and i want to check for collision between those balls and the red rect
Probably a little too long for python general but I can try :D
@last moon both
@proper coral yes with and without pyopengl
got some tutorials ill like to reccomend
I'd suggest learning arcade
yes
if you're doing 2d
thee's alos ursina, panda, Harfang etc.
for 3d, pyglet or panda3d
it does look decent
yes
imma start with 2d first
so arcade it is?
and what if im a beginner
who only knows GUI
@dawn quiver
ping mee :))
arcade's a great place to start + you'll start learning OOP with it
yes
then move o to pygame
and some small ide recommendations are thonny (pip install thonny)
a small recommenadtion
pip3 install thonny
just in general or for game dev?
thonny? it is for everything
the debugger looks great for absolute beginners but stepping through it seems like it would get annoying for more complex stuff
git control?
no it is basic
it has micropython and esp8266 support too
no move this to a discussion which is related to this
I saw that it's the default for the pi or was
have you used it with pygame?
if you understand arcade at a decent level, it might be worth it to look at arcade.gl first
should be yep
ok
the tutorials look fairly extensive too
hello guys should i learn pygame ?
@waxen patio Yes pygame is very easy for beginners
and if yes do you have any tutorial?
@waxen patio Yes there are many good tutorials on youtube just search "Pygame Tutorials"
@floral tartan so i cant do a 2d big project with this?
I actually made a tictactoe game , its kind of long , so how do I send that?
Im currently working on a little collision system, but collision is only detected at the right and upper side of a rect, any tips on how to solve this?
if mob.x < ship.x < mob.x + mob.width:
if mob.y < ship.y < mob.y +
mob.height: mobs.remove(mob)
hp -= 10
what is mob?
basically a meteor moving down the screen
So I want to chech if the ship crashes with a meteor
I think you should send whole code,
I will actually have to see a few tutorials to understand
Hey
Can anybody help me with pygame?
@sterile dust just an idea, tell me if I'm wrong but i believe you need to create two separate collision boxes around both the ship and your mobs, so that when they intersect it is detected. You would have to outline the boxes by specifying the size and make them follow the centre point of the ship and mob. That is my my best guess at helping...
My character doesn't move when I press the keys:
import pygame
import sys
from pygame.locals import *
clock = pygame.time.Clock()
# ----- Initiates Pygame -----
pygame.init()
# ----- Size of the window -----
WINDOW_SIZE = (400, 400)
# ----- Initiates the window -----
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 32)
player_image = pygame.image.load('sprites/player/player_idle.png')
moving_left = False
moving_right = False
player_location = [50, 50]
# ----- Game loop -----
while True:
screen.blit(player_image, (50, 50))
if moving_right:
player_location[0] += 4
if moving_left:
player_location[0] -= 4
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# ----- Right Key -----
if event.type == KEYDOWN:
if event.key == K_RIGHT:
moving_right = True
if event.type == KEYUP:
if event.key == K_RIGHT:
moving_right = False
# ----- Left Key -----
if event.type == KEYDOWN:
if event.key == K_LEFT:
moving_left = True
if event.type == KEYUP:
if event.key == K_LEFT:
moving_left = False
pygame.display.update()
clock.tick(60) # Maintain 60 FPS
@dawn quiver try this (pressed_right/left is moving_left/right):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
pressed_left = True
elif event.key == pygame.K_RIGHT:
pressed_right = True
elif event.type == pygame.KEYUP: # check for key releases
if event.key == pygame.K_LEFT: # left arrow turns left
pressed_left = False
elif event.key == pygame.K_RIGHT: # right arrow turns right
pressed_right = False
so do i just have to do add pygame to the inputs?
you should have a set speed variable that you can add when the conditions are met
yes
for checking keys, at least when running pygame, yes. I believe so.
Sure he has to
not works when i add pygame to everyone
vel being player speed?
Sure
Velocity
And you dont have to use the key up events
And he doesnt even have to use the Booleans
moving_right = True etc
it is true that he can add velocity in the direction he wants when key pressed straight away. In my short experience it was easier to have them separate in case i wanted to change the key binds later.
Ok i like it more the other way...
@marsh dust Thank you, will try
good morning.
wow
arcade docs are so damn good for beginners
so well thought out
i wish other docs were like that
hello
i have a problem
when running a very simple arcade file
i get an error
RuntimeError: The current Numpy installation ('C:\\Python\\Python38\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86```
why am i getting this
and how do i solve it?
ping me 🙂
this is my code btw
import tkinter as tk
arcade.open_window(500, 500, window_title="HELLO")
arcade.set_background_color(arcade.csscolor.GRAY)
arcade.start_render()
arcade.draw_rectangle_filled(250, 150, 500, 300, arcade.csscolor.GREEN)
arcade.finish_render()
arcade.run()```
@proper coral That is a problem with numpy. If you have 1.19.4 you might want to downgrade to 1.19.3
@floral tartan so i cant do a 2d big project with this?
@waxen patio maybe but you have to be an expert at that before trying your hand at big ones
@dawn quiver you never use the player_location variable it seems
u could start w godot@rotund hearth
or using pygame or most python game engine that i think, blender
Or start by creating a simple game
In python
Ok thanks
how would I do something like this
the contiune thing doesn't work for this for some reason
also basicly cirlces is a dict filled with the object circle
I'm trying to do a contiune loop because the loop gets stuck in the for event loop
u could start w godot@rotund hearth
@dawn quiver godot isn't too friendly with beginers and even after I started learning pygame I couldn't really figure it out too well so idk
def checkClick():
mouse_pos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
for c in circles:
click = circles[c].sprite.collidepoint(mouse_pos)
if click:
circles[c].color [255,0,0]
@dawn quiver I think it might've been the order of iterating through the circles and events
try that?
wb c?
edited
no problem
From my experiences with pygame, you often want to limit how many timesyou are calling event.get() (maybe to like once an update or so)
You made that in python without pygame? Lordy I'm struggling to learn python with pygame currently… that seems so impressive to me
i just need some genuine feedback
@jade wadi This is really amazing brother!
@sweet condor @proper coral
It's not python, it's the unity3d game engine
oh
yep and it's uses C#
hi
@crisp junco thank you so much
@dawn quiver it uses Unity And C#
what can i do to improve, guys?
@sweet condor @proper coral
It's not python, it's the unity3d game engine
@fierce wraith yeah
Ping
Does aneone know whate r the graphics code editor in d coder online in androied I cant seem to find it ?
what do you mean? can you explain a bit more?
I made a game for android, ran the code in pydroid3, and it works, but my joystick is going opposite direction
import pygame
from pygame.locals import *
from math import atan2, degrees, cos, sin, radians
class Joystick:
def __init__(self, x, y, r, color, stick_color):
self.is_move = False
self.color = color
self.stick_color = stick_color
self.x = x
self.y = y
self.r = r
self.stick_r = r // 3
self.stick_x = x
self.stick_y = y
def _move_stick(self, x, y):
distance = abs(self.x - x) + abs(self.y - y)
if(distance > self.r):
distance = self.r
self.stick_x = int(self.x + distance * cos(radians(self.angle)))
self.stick_y = int(self.y + distance * sin(radians(self.angle)))
def _find_angle(self, x, y):
delta = [1, 0]
vector = [self.stick_x - x, self.stick_y - y]
self.angle = degrees(atan2(delta[0] * vector[1] - delta[1] * vector[0], delta[0] * vector[0] + delta[1] * vector[1]))
if(self.angle < 0):
self.angle += 360
def draw(self, surface):
pygame.draw.circle(surface, self.color, (self.x, self.y), self.r)
pygame.draw.circle(surface, self.stick_color, (self.stick_x, self.stick_y), self.stick_r)
def on_touch(self, event):
if(event.type == MOUSEBUTTONDOWN):
x, y = list(map(int, pygame.mouse.get_pos()))
if(abs(self.stick_x - x) + abs(self.stick_y - y) <= self.stick_r):
self.is_move = True
else:
self.is_move = False
elif(event.type == MOUSEMOTION):
if(self.is_move):
x, y = list(map(int, pygame.mouse.get_pos()))
self._find_angle(x, y)
self._move_stick(x, y)
elif(event.type == MOUSEBUTTONUP):
self.is_move = False
self.stick_x = self.x
self.stick_y = self.y
@property
def distance(self):
return abs(self.x - self.stick_x) + abs(self.y - self.stick_y)
j=Joystick(200,200,100,(25,255,255),(255,255,255))
r=pygame.display.set_mode((18,8))
while 1:
r.fill((0,0,0))
j.draw(r)
for ev in pygame.event.get():
j.on_touch(ev)
pygame.display.flip()```
hi
yes it does
guys
i have a problem
i asked this q in many places but ididnt get any help
Hi guys
I made a space invaders game using python - pygame
And it worked well in my pc
I put it to github so my friends could see and use it too
But then I realised that they were telling that the space bar button doesn't work for shooting
I tried identifying the prob but couldn't find it
Now here is the code on GitHub https://github.com/sudo-nikhil/Space-Invaders
GitHub
sudo-nikhil/Space-Invaders
If someone could please clone it and identify why only the space bar doesn't work but when i clone and run the same code on my pc, the space bar works! it would be helpful
I am a 14 year ol beginner in python so please don't judge my code quality
Please ping me if anyone finds a solution to fix
Thanks!
its fine if anyone of u dont want to help this long message might be overwelming 😭
Can I Execute .bat File in a mac?
Ok
np
@versed agate The game is working perfectly fine for me
also a useful tip: make a requirements.txt file on your root and
pip freeze > requirements.txt and it will make a list of all the libs you use in your virtual env, and then the user could just pip install -r requirements.txt
i am not using pygame or anything
@jade wadi how the fuck?
that's some
crazy shit
that'd be crazy with pygame
so without pygame
it's even crazier
That's quite simple with unity isn't it?
hey guys
I'm trying to create simple enemy AI in a 2d platformer
I just want them to simply move left to right y'know
I'm kinda stuck though even with the tutorials online
?
que evil laughter - XR locomotion achieved
Hey I need some help. (for turtle)
I have my bullets and character motion inside a main while look and I have the bullets shooting in the direction of the player. But if the character changes direction while the bullet is being shot, the bullet starts to follow the (x,y) cors for the new direction
@versed agate The game is working perfectly fine for me
@dawn quiver hi! Looks like it works for us but but I checked it with two other laptops with 4 threads and it didn't so idk
I sorta got dragging to work from the deck in solitaire woo
still buggy as it deletes the drawn cards from the deck and you can't let go of the card, but we got a base of dragging done.
it's a good thing this is just for fun.
A little quick polish + a 16k hdri :D
How do you guys structure your game.py and all your modules and classes?
I am making a game and it's going amazing but I have hit this wall where I just don't know how to organize all this mess
and don't know how to do it differently
it's a rogue-like engine, not necessarily for rogue-like, but you get the picture
I want it modular, compact, easy to read, for the sake of productivity
For the code part, I usually separate the engine, the level-related code (loading, unloading, major level gameplay), the sprite (different objects that can go in your levels), gameplay elements and UI stuff
And I put all the art related stuff in a totally different folder, and separate them too
Hey
hey which software is used to make games in python ???
Pyglet?
I wrote a terminal game engine. You can write fun little games like pong in it. https://github.com/cmcmarrow/tamcolors what do you guys think of it?
is it possible to use the pygame module without having python installed? I'm trying to make a game as portable as possible, but I can't think of a way to make the game playable on computers without python and pip
make it an exe @agile finch
how would that solve importing the pygame module?
you wouldnt need to, since its stored in an exe.........i think
oh
@agile finch I think you would like pyinstaller https://www.pyinstaller.org/
alright thank you!
@versed agate I put in a fix for you
Hi @lament hamlet , thx, I have replied to your comment
I wrote a terminal game engine. You can write fun little games like pong in it. https://github.com/cmcmarrow/tamcolors what do you guys think of it?
@lament hamlet thats amazing and i will surely chekc it out!
hey guys, I'm trying to code the enemies in my 2-D game and I want them to simply move left to right, here's the code it have so far...
#Enemy Movements
enemy_movement = [1, 0]
enemy_movement[1] += enemy_x_momentum
enemy_x_momentum += 0.2
if collisions['left']:
enemy_movement = [-1, 0]
enemy_movement[1] += enemy_x_momentum
enemy_x_momentum += 0.2
if enemy_y_momentum > 3:
enemy_y_momentum = 3
enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
if collisions['bottom']:
enemy_x_momentum = 0
air_timer = 0
else:
air_timer += 1
display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
my problem is that the enemy only moves right, but does not move back left
any ideas?
@frank spear I'm not 100% sure what's going on there but two things stand out to me:
You add 0.2 to enemy_x_momentum twice, before and in the if statement detecting left collisions
You never test for collisions on the right
I see, I changed it up so it looks like this now,
#Enemy Movements
enemy_movement = [1, 0]
enemy_movement[1] += enemy_x_momentum
enemy_x_momentum += 0.2
if collisions['right'] == True:
enemy_movement[0] *= [-1, 0]
enemy_movement[1] += enemy_x_momentum
if collisions['left'] == True:
enemy_movement[0] *= [1, 0]
enemy_movement[1] += enemy_x_momentum
if enemy_y_momentum > 3:
enemy_y_momentum = 3
enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
if collisions['bottom']:
enemy_x_momentum = 0
air_timer = 0
display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
It tests for both left and righthand collisions now
but, the enemy still only walks to the far right and stops after colliding,it doesn't walk back
any pybullet dev here? I wana have small talk about what is possible or what is not in that env 😄
it is mostly physics engine, but I want to do some static stuff
what is the best minecraft bot module? need bots to test my server.
cmd => pip install fivem
or something like C:\Users\username\AppData\Local\Programs\Python\Python37\Scripts\pip.exe install fivem
I think you need to configure it to the scripting program you're using
😦
so
I made some changes to my original enemy AI
but I still can't seem to get them to move back and forth after colliding with an object
#Enemy Movements
enemy_movement = [1, 0]
enemy_movement[1] += enemy_x_momentum
enemy_x_momentum += 0.2
enemy_rect, collisions = move(enemy_rect, enemy_movement, tile_rects)
if collisions['right']:
enemy_movement[1] = [-1, 0]
if collisions['left']:
enemy_movement[1] = [1, 0]
if enemy_y_momentum > 3:
enemy_y_momentum = 3
if collisions['bottom']:
enemy_x_momentum = 0
air_timer = 0
display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))```
there it is
any ideas?
@frank spear it's hard to tell what is happening here without more code, but you seem to be changing enemy_movement[1] from an integer into a list
and in your previous code you were using enemy_movement[0] to store your direction
it's very hard to tell what you're doing here without more code
here lemme show you
def move(rect, movement, tiles):
collision_types = {'top': False, 'bottom': False, 'right': False, 'left': False}
rect.x += movement[0]
hit_list = collision_test(rect, tiles)
for tile in hit_list:
if movement[0] > 0:
rect.right = tile.left
collision_types['right'] = True
elif movement[0] < 0:
rect.left = tile.right
collision_types['left'] = True
rect.y += movement[1]
hit_list = collision_test(rect, tiles)
for tile in hit_list:
if movement[1] > 0:
rect.bottom = tile.top
collision_types['bottom'] = True
elif movement[1] < 0:
rect.top = tile.bottom
collision_types['top'] = True
return rect, collision_types
this is the code for collisions here
I'm using this to determine the directions in which the enemy is hitting the block
enemy_rect = pygame.Rect(50, 50, enemy_image.get_width(), enemy_image.get_height())```
this here is the hitbox for the enemy, for obvious reasons
Is the enemy at (50, 50) all the time?
and the first code I gave you tests which sides of the block the enemy is hitting and is supposed to have them turn around
well no but I'll change it to a randint after i get it to work so it spawns randomly
But for now the enemy doesn't ever MOVE right?
it moves...but only to the far right then it stops once it hits a block
You seem to be switching your x and y values in the first code
which would cause x movement to be zero
if I'm looking at this correctly
movement and enemy_movement both have a direction and momentum, are structured the same?
So what is the problem with your code right now?
his player is supposed to switch directions when they collide to the right
the enemy is supposed to move from left to right when it collides with the blocks
In your first code you are using enemy_movement to calculate enemy_rect, then blitting the image based on the new rect?
except when you change enemy_movement, enemy_rect had already been calculated prior to that
maybe this is the problem
enemy_rect is not going to save the changes made to enemy_movement until you recalculate enemy_rect
if collisions['right']:
enemy_movement[1] = [-1, 0]
if collisions['left']:
enemy_movement[1] = [1, 0]
if enemy_y_momentum > 3:
enemy_y_momentum = 3
if collisions['bottom']:
enemy_x_momentum = 0
air_timer = 0```
are these ifs supposed to effect enemy_rect?
they are supposed to check for possible colllisions
display.blit(enemy_image,(enemy_rect.x - scroll[0], enemy_rect.y - scroll[1]))
except as soon as you do this, none of those ifs changed anything
because you only changed enemy_movement and enemy_momentum
post more code
ok
your code is just really wierd
I do a lot of grid stuff but this is wierd
no offense
it's ok
okay so here's some more code
enemy_y_momentum = 0
enemy_x_momentum = 0
enemy2_y_momentum = 0
enemy2_x_momentum = 0
air_timer = 0
true_scroll = [0,0]
player_rect = pygame.Rect(50, 50, player_image.get_width(), player_image.get_height())
enemy_rect = pygame.Rect(50, 50, enemy_image.get_width(), enemy_image.get_height())```
that set up the hitboxes
and the variables for momentum
so wait is this not a tile-based grid?
well It's a 2-d platformer, are you asking to see how I made the map?
nvm
ok so first, I'm not sure why Rect is getting 3 arguments, it's supposed to be x,y,x,y or (x,y),(x,y)
unless get_width is returning width and height?
player_image.get_height gets the height
those two numbers spawn the actaul character and enemy
sorry, I didn't see the 2nd line of that, nemvermind
no problem
I think I am the wrong person to help, sorry
That's okay thank you anyways
you'll figure it out. Things like this are part of programming life 🙂
The help channels are good too
anyone have experience making android games with python, using recent technology?
I want to know if anyone has found a good way since it is still a new thing
something without many limitations and only knowledge of python needed
something I can release as a professional app
native UI and/or cross platform is a plus
game dev/gpu capabilities are a plus but not necessary
by "good way" I mean advice from somebody who has tried different libraries and actually finished a game
I need to get this game out ASAP
I once used Kivy and compiled an android app using linux. It is not suitable for professional work
It might be better now, but it's still not native. If it works good with pygame now I might try it again
but honestly I would rather use something else
and how is the new pygame for that matter?
i am using pygame and,
I want to include some game physics in my game......
are there any good libraries for the same??
pymunk is widely used unless you are making simple physics yourself
nah, i don't have that much time to make physics myself
i have simulated gravity tho
https://www.pygame.org/docs/ref/rect.html
How can i overload the constructors like it's done in pygame? I tried to search in pygame source but Rect is implemented in C
import pygame
class PhysicObj(object):
def __init__(self, x, y, w, h):
self.rect = pygame.Rect(x, y, w, h)
def __init__(self, pos, size):
self.rect = pygame.Rect(pos, size)
def move(self, movement, platforms):
pass
p = PhysicObj(10, 20, 30, 40)
p = PhysicObj((10, 20), (20, 30))
``` e.g this doesn't work
Traceback (most recent call last):
File "physic.py", line 14, in <module>
p = PhysicObj(10, 20, 30, 40)
TypeError: init() takes 3 positional arguments but 5 were given
they probably check the parameter types, you can't do overloading
do everybody use just pygame because i dont have pygame.
I make games by importing the turtle module does anybody else do like that?
I make games by the turtle module*
@sharp hornet imo turtle is not good for gamedev
atleast i used it to learn for and while loops years back 😅
@sand granite overloading is not typically the go-to.
you can setup a (self, *args, **kwargs) method
PhysicObj(pos=(10,20), size=(20,30))
PhysicObj(10, 20, 20, 30)
to access pos or size
kwargs["pos"], kwargs["size"],
kwargs.get("pos") to check if pos was a given keyword argument
kwargs,get("size") to check if size was a given keyword argument
or, to futher extend your method.
try doing this
p = PhysicObj(10, 20, 30, 40)
p = PhysicObj(*(10,20), *(20,30))
@idle sandal it gave me a cmd with text was that what it was suppose to do?
yes
okay yeah
thanks for help
Im currently making a memory game, does anyone know how to make printed text disappear
ok so i open pygame window in pycharm and it opens up for a second then closes, i just strated pyggame
x = 50
y = 50
width = 40
height = 60
vel = 5
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.quit()
``` why is 'win' not a correct param im following a tutorial
you haven't started the window
or inited anything actually
so before any mechanics, you need pygame.init() to start the window
and window/win/surface/whatever you want to call it = pygame.display.set_mode(arguments)
Im currently making a memory game, does anyone know how to make printed text disappear
@lusty vector
Re fill that surface
where can I download pygame for windows?
👍
@dawn quiver Yes I know but i am not able to install pygame its showing error when i try to install package thats why I make the turtle programs.But its also good i used it to make a game “Snake Game”
hey ^^ , can i ask u guys somethings ? when i run my file .exe it open the microsoft store , can i fix it ?
i cant test game TT
I wish I knew, but alas, I have not accended unto the level of game development yet
is that even python?
install it from https://www.python.org/
i have installed py
the right version?
newest version
is that the version the game is running tho?
yeah
it might be a dependency issue idk
the only time I've gotten that is when I don't have py installed
it's sending you to the ms py page right?
wait me for a second
i found something be changed in my computer
that make the exe change its target
i need to handle it first
maybe its the problems
idk what you mean by that but maybe
yeah , i got that new when my fire wall called me
can anyone help me with a little piece of my code over DMs? it's not complicated but im lost
How can I create an input box in pygame? Just like entry in Tkinter
@unique narwhal that can be difficult but still we can make it
I actually found a source code
Of actually?
np :)
I'm getting an error,
pygame.Rect.move_ip () should return a rect but for me it returns None
block-breaker-game $ python .\main.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
[328, 721]
Traceback (most recent call last):
File ".\main.py", line 79, in <module>
if circle_rec.topleft == ball_pos.topleft:
AttributeError: 'NoneType' object has no attribute 'topleft'
This is the error I'm getting
Hey @dawn quiver!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@dawn quiver Can you post your code at the pastebin or something?
I can't copy it.
I'm new to that so idk
I will try though
@dawn quiver here you go, any help will be appreciated
@dawn quiver Why are you using move_ip? In PyGame Doc Same as the Rect.move() method, but operates in place., that means, returns nothing.
Ohh
Thank you, I'll try it
@dawn quiver that did nothing
Also, even if you change to Rect.move it won't work either.
Of course.
Why?
ball_pos is a list, so it doesn't has topleft attribute.
So, we should provide topleft?
You should learn how the PyGame coordinates works, you are mixing x and y coordinates with top, left, bottom, right and its variations
I know them
Its variations means topleft, topright, etc
Yeha I know @dawn quiver
But for move_ip, should we provide topleft as the parameter?
@dawn quiver
@dawn quiver The top right coordinate of a Surface is (width, 0). If you want to move to the center of the surface, for example, then you have to move in the negative x direction, but in the positive y direction rather than the negative y direction.
@dawn quiver I am actually trying to make a breakout type of game
you could/should move ball into a class
So the circle rec is the ball
And it moves to random poses
That's why move_ip
you could/should move
ballinto a class
@last moon actually I want to do it without classes
Else I would have used classes only
why not?
It's like a challenge to myself
what are you trying to do with the main loop?
grogus is right tho, pygame.gfxdraw.filled_circle(win, circle_rec.left, circle_rec.top, 20, CYAN) should be
pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN) and etc
grogus is right tho,
pygame.gfxdraw.filled_circle(win, circle_rec.left, circle_rec.top, 20, CYAN)should be
pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN)and etc
@last moon oh
In the main loop actually, I check for events and move the paddle
And also
Move the ball continuously to a random pos
if right and player_rect.right < 1364:
player_rect.right += speed
elif left and player_rect.left > 2:
player_rect.left -= speed```
I'm fairly sure that's not how you move it either
you're grabbing the right/left edges of the circle
not the x pos
Ohhhh
if event.type == KEYDOWN:
if event.key == K_q:
terminate()
if event.key == K_RIGHT or event.key == K_d:
right = True
elif event.key == K_LEFT or event.key == K_a:
left = True
``` you can also get rid of the redundant `False`'s here
Hey guys.
I have a question.
if player_location[1] > WINDOW_SIZE[1]-player_image.get_height():
player_y_momentum = -player_y_momentum
else:
player_y_momentum += 0.3
player_location[1] += player_y_momentum
```
what do the [0] and [1] mean after player_location?
I am following a tutorial but don't understand.
Alright
Thanks
Anybody know how to pause in arcade?
Like how I could make a pause function? (Ping me please)
hi can someone help me with a part of a code? it is a check so that I do not step on a list of lists, for a naval battle the game ((I am learning Python and I think an senior would find it quickly)) sorry if it isn't the channel
Hey @dawn quiver!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey guys ! I am trying to do a tricky thing with PIL:
I need to make a square image become round
In a photo edition software, I would usually do a round selection on a square, and remove everything that is out of it
How can I do that with PIL, please ?
Here is an example:
(The first image is the result I want to get, the second one is the image where I start from)
is there a more efficient way to detect 2-D pixel collisions?
@dawn quiver
@lament hamlet is there a name to it?
@dawn quiver not that I know of. But its O(N*2) which is way better than O(N^2).
You can rewrite it to be O(N)
@dawn quiver
I would read something like this -> https://stackabuse.com/big-o-notation-and-algorithm-analysis-with-python-examples/ its is called Big O it gives you an idea on how fast something is
There are multiple ways to solve a problem using a computer program. For
instance, there are several ways to sort items in an array. You can use merge
sort [https://en.wikipedia.org/wiki/Merge_sort], bubble sort
[https://en.wikipedia.org/wiki/Bubble_sort], insertion sort
[http...
thanks
Thanks @last moon , the issue AttributeError: 'NoneType' object has no attribute 'topleft' was resolved, but I got another problem
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File ".\main.py", line 97, in <module>
draw()
File ".\main.py", line 51, in draw
pygame.gfxdraw.filled_circle(win, circle_rec.x, circle_rec.y, 20, CYAN)
OverflowError: signed short integer is greater than maximum
I did what you suggested
here is the code
im assuming that means either circle_rec.x or circle_rec.y is too large
I don't see any handling for vertical movement
I don't see any handling for vertical movement
@last moon like what do you mean
Should add exception for that?
if right and player_rect.right < 1364:
player_rect.x += speed
elif left and player_rect.left > 2:
player_rect.x -= speed```
you have handling for the horizontal
not the vertical
ok then you don't have any handling
the ball isn't going to collide with the window, it's going to keep going
OverflowError: signed short integer is greater than maximum
I'm assuming this is because yourcircle_recis trying to be drawn outside the window
Hey guys I would like to ask about how to delay a function for 2seconds (its like a skill cooldown)
@willow mirage i would do that by masking off the rest of the image using a mask like this.
Pillow has a great function called putalpha that will set the mask as the alpha value for the image.
mask = Image.open('mask.png').convert('L')
im = Image.open('image.png')
mask = mask.resize((im.size), Image.ANTIALIAS)
im.putalpha(mask)
im.save("out.png")
here is the full script after playing with it a bit:
from PIL import Image
mask = Image.open("mask.png")
mask = mask.split()[-1]
im = Image.open("image.png")
mask = mask.resize((im.size), Image.ANTIALIAS)
im.putalpha(mask)
im.save("out.png")
a higher res mask
produces this output
Thanks a lot Leterax ! I will try to do as you said ! Have a great day 😄
Why i cant import Clock from kivy.clock ?
ImportError: cannot import name 'Сlock' from 'kivy.clock'
python 3.9.0
np Azuoo 😉 let me know if you run into any problems or need some more help!
hi there, im currently working on a game through the coding engine "renpy", and i'm stuck - let's say i have a list of words, and i want to choose random words and put them in a choice menu. is there a way to do it without making a pre-set menu?
also, i wanna guarantee there will always be one word that already appeared and one that did not.
mmm
Hey, lately I've been working on a little game which his main idea is images falling from the sky,
and you have to catch them with moving right and left.
I am struggeling now to get the objects to fall from the sky each xxx seconds, without getting the code lagging with threads. Can anyone suggest an idea to implement this?
pygame library ↑
@ for answer
array of current images which you add one to if the current time is such that it's been long enough?
@unique narwhal
@unique narwhal add a counter variable that updates every tick or so. And then every Z ticks, create a new image?
This shouldn't be too laggy especially if your game is running at a set fps
im am trying to recreate this game and was wondering what would be the most efficient way to make the buttons in tkinter?
This week on Heat Vision Breakdown, host Patrick Shanley gets an inside look at 'Call of Duty: Modern Warfare' with interviews from the team behind the new game.
#CoD #InfinityWard #HeatVisionBreakdown
Subscribe for Roundtables, Box Office Reports, & More! ►► http://bit.ly/...
Cool video I figured somebody would appreciate. Doesn’t have that many views, but it is official Behind the scenes of the most recent modern warfare Activision studio. Absolutely amazing how these guys bring real life into a 3-D virtual environment.
im am trying to recreate this game and was wondering what would be the most efficient way to make the buttons in tkinter?
http://kolor.moro.es/
@unique narwhal the python scheduling library would be great for thus
It's called sched
@fierce wraith Would that also work in tkinter?
@somber creek you could 'easily' do it in tkinter or pyqt/pyside2
how could I easily do it in tkinter?
I said 'easily' but you need an update function
looks like tkinter.Frame.after is used for that if you use OOP
create buttons wt colours and handle the logic based on which button is pressed
after pressing, update the frame with new colours
ok but how would I make the round buttons?
ikd I'm not familiar with tkinter
just do that but with circles
Ive already made circles and then tried to to put buttons behind the circle but that did not work
the buttons should be attached to the circles otherwise you'll have to update the screen + define which colour is behind which button
but you can load an image onto the button which im assuming will be easier
might have to play around with randomization tho because you won't be able to change the colour unless you reload the image
so you can move the button instead
and the button will be directly correlated with that colour
Ive also been able to put circles onto the button
but the problem is I get errors when trying to do multiple even when assigning variables?
@last moon
oh nvm i figured out that I can use a canvas to upload multiple images, but if I wanted to access only 1 of the image i would have to put canvas.image name right?
no clue
ok but thanks anyways
So if pygames is used to make 2D games what’s a good one to make 3D games? @ me if answer me 😀
There's Panda3D. Haven't used it though. So I cannot tell you enough about it.
@waxen nebula forgot to do this
panda is pretty good from what I've seen
pyglet's another great option, gets into c programming a bit too
you can use pyglet\OpenGL through arcade too, so having some pre-built features with access to the libraries
Wow thanks all look into both thanks 🙏🏻