#game-development
1 messages · Page 103 of 1
ohh i learned more python more for virtual intelligence and build on website
and to gain faster experience with have building programs
That look smart
@runic granite I love your profile.
True, but I almost don't download any program on my computer, only the ones I need
thnx,I like you pfp is cool
I play roblox LOL
I played it too but when I became addicted I put a point
so i stopped playing
Yeah me too
I am not stop play but play less
cooll
So I can focus on python 🙂
me, same, I have deleted almost all my social media apps (I still have only Instagram)
sure
hohoho
import random
while True:
y = 0
z = input('Called ben?1 YES / 2 NO: ')
if z == '2':
continue
while y<10:
number = random.randint(1,4)
x = input('Ask question here: ')
if number == 1:
print('Yes')
y = y+1
elif number == 3:
print('No')
y = y+1
elif number == 4:
print('Hohoho')
y = y+1
elif number == 2:
print('Uhhh')
y = y+1
print('Ben hang phone on you.')
to pay more attention to programming
That cool
Basic program
Use What I learned
cooll
how long have you been working on 'Python?
Can you show me a few of program that you made?
3 days : /
No CAP
I learned from codecamp
when i go to my pc i will send it for you, because i'm on the toilet now🤣
LOL
I don't use them anymore, because I think they don't give everything
For me they give a lot because they explain well
They said CPU is dumb but It is fast
I don't think so, because I followed C# there and I notice that they didn't give everything like oop
I mean in python
For me
nice, that's what many people say to me
But there is more way to learn ex. from internet
community
That's right, I also use a website to learn
Yes sir
@runic granite
this is what my friends think I do:
reality:
ohh , lol😅 ,I didn't tell my friends I was programming
Really
same
only my virtual friends know
They thing we can remember all command.
But In real life we copy and paste(Only part that don't know how to deal with it)
@runic granite I gtg
It is about 10 PM here
I also from time to time, but if you continue to program then you will also remember, I notice that with me
ohh, are u from india ?
sleep well ,Ping me when you're there tomorrow and I'll send you my code
OK I will spam :)
JK
Nah, I don't see that as spam
lol,
btw good night
You too
in india it was 8:34 then
can i participate in someone's game project?
Hey @severe flame!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
I would love that to
Hey @severe flame!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
u can participate in my bullethell project if u want (pygame)
What is it about?
Mainly just added/improved telegraphs - made projectiles fade out in some attacks
Added one new attack and also reworked another
Music: Made by DM DOKURO
https://www.youtube.com/watch?v=KJHNdl3R8GM&t=0s
https://www.youtube.com/watch?v=e3t_dbLaw-M&list=PLbrAnF1cQ0SCKw3yfO2SzJ1g5DaxXOYkv&index=36&t=0s
hm? dont get it
Uh
It's just a bullethell with literally nothing else
And I'm not using/making any sprites since I'm lazy af
snek
Turn your phone into a wireless game controller for Call of Duty game.
All the setup and source code available at GitHub repo (Give a star if you like).
GitHub Repo : https://github.com/YashIndane/Call-of-Duty-
My Linkedin Profile : https://www.linkedin.com/in/yash-indane-aa6534179/
Source code
Hey @restive parrot!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
I made puzzle game there is only one question if you want script DM me
You can use the code uploader linked in #welcome
you uploaded this video so many times
in this channel
nvm
how is your pc surviving?
are you using optimization?
i see
the player speed
is slow
Hey guys.
may I ask. Difficult to explain but I'll do my best.
What is the concept called when In a open world game like WoW for instance. Only what is in the radius of the character is visible but not the whole map.
to reduce resource consumption.
Consider this. Star being the character, yellow being what the character can see at the time. Then the Grey as the rest of the map, but inactive because there's no need to view it at the time.
Clipping, in the context of computer graphics, is a method to selectively enable or disable rendering operations within a defined region of interest. Mathematically, clipping can be described using the terminology of constructive geometry. A rendering algorithm only draws pixels in the intersection between the clip region and the scene model....
Thank you @keen beacon !!!!!
There’s also level of detail tactics
Where you basically have higher and lower resolutions versions of textures/models and render lower quality things that are further away and switch to higher quality assets for closer things
Which library is used for game development sorry for bad English*
Arcade, pygame, ursina, pyglet, etc.
I worked on a tutorial for shaders if anyone is interested: https://api.arcade.academy/en/development/tutorials/shader_toy/index.html
Any reason for me to switch from pygame to a better 2d lib?
if you have already decided that other lib is "better" then why not?
Well i havent had issues with pygame, and it seems to meet my current needs for it. Ive just heard theres better ones out there and wondered if i should consider switching
do you have any progress on your current project in pygame? if yes then dont switch, you can use the other lib when u start a new proj
You might want to see if the speed or features make it worthwhile. If you spend a lot of time coding a feature that is built into another library, that's time wasted. Or spend time optimizing a slow program when another is fast up front.
heyy
I've just started learning pygame and I had one doubt regarding screen.blit()
this is from a tutorial I'm currently watching on how to code flappy bird in pygame (and they're making like the floor move towards left-
and it says that there are two floors next to each other moving left at the same speed)
I've understood what they wanna do
BUT MY QUESTION IS-
doesn't screen.blit() just redraw the floor? like how are there two floors simultaneously?
no it doesn't, that's why you have to clear the screen manually
you code draws the same floor surface at two different positions
got it, thanks!
but I haven't had to clear the screen manually yet- does update() automatically do it for me?
Hello, i am working on my first game ever with python using pygame => basic game to write what program typed and i have problem that text to write is not on same line as the entered text by user. How can i fixed that? I tried to find to set something like "line height" but without any success 😦
If your floor_x_pos is constant you have been drawing the same floor on top of the old one, it was not clearing the screen
Wow the game looks really cool so far. Hope you continue working on it 🙂 also what is the color scheme you are using in your editor?
Or, if you are drawing to a surface and then drawing that surface to the main screen then it's drawing that surface on top of the old one. Effectively clearing the screen in an indirect way (that might also not clear the entire main screen depending on if the surface is the size of it or not) by drawing a big background, you can think of it as using a background image as a clearing tool. Either way, it's recommended to just always clear the screen.
i am using PyCharm by JetBrains and Hiberbee Dark Theme =>Java and Python looks sick with it
is there a geometrydash coded in python, with the same physics as in the original game?
Sadly i dont think sublime has that scheme ill have to search for a similar one
Oh i put there wrong screen, this is the problem (red text not on same place as green text => red means both texts are not the same)
Fullscreen it if you cant see it clearly
This could be extended to 3 dimensions against cubes. It may be a cheaper alternative to more general raycasting algorithms
It uses a form of vector projection and point slope form to calculate ranges(yellow lines). If the rectangle is within these ranges then the ray hit
Someone notice me 🥲
Lol i notice and ray tracing is cool
wow nice! I would have use masks for collision though xd
cool collision check
HI, I am trying to code a chess game based on a youtube ||video|| which is 2 years old. Here is a python function whose task is to draw the bhess board.
def drawBoard(Screen):
#this function draws the squares on the board
"""The top left quare on the chess board is always light colored."""
colors = [pygame.Color(255,255,255),pygame.Color(127, 127, 127)] #defining the coloured used to fill up the squares on the board
for rows in range(dimension):
for cols in range (dimension):
#choose the colour based on the rule.
"""if row+col %2 == 0 square is light coloured otherwise dark coloured."""
#color = colors[((rows+cols)%2)] this I think causes errors
if ((rows+cols)%2==0):
ind=0
else:
ind=1
color = colors[ind]
#drawing the square on the board after selecting it's colour
pygame.draw.rect(Screen, color, pygame.rect(rows*sq_size,cols*sq_size,sq_size,sq_size))```
but the last line is not working maybe due to some syntax changes of pygame. The error is as follows :
``` File "/home/shiv/projects/Cheng/CHESS_ENGINE-Cheng-/chessMain.py", line 55, in drawGameSate
drawBoard(Screen) #function to draw the board
File "/home/shiv/projects/Cheng/CHESS_ENGINE-Cheng-/chessMain.py", line 76, in drawBoard
pygame.draw.rect(Screen, color, pygame.rect(rows*sq_size,cols*sq_size,sq_size,sq_size))
TypeError: 'module' object is not callable```
can anyone help me in figuring out the solution.
have you used masks collision for animated objects?
Isn't that slower speed wise tho?
Oh wait nvm
idk i want to know how to do it
I didn't realize message u were replying to
oh
do you know how can i collide animated object bcz my character is colliding to that object but not touching the img
idk I just use circle collision, line/psuedo rect collision for my game
;_;
(my game has hundreds of projectiles and already nears being too slow for 60 fps so I can't use masks)
,_,
should i use masks i am making platformer game
I guess
but there is no tutorial for using masks with animated objects
isn't animation just swapping between images so couldn't you just do collision based on the current image chosen?
You need pygame.Rect not pygame.rect.
Where did u learn pygame btw
me?
Yes
many resources
#bot-commands
so how it going
i changed the last line to pygame.Rect(rows*sq_size,cols*sq_size,sq_size,sq_size) still the screen is blank please help me guys
here is the youtube video I used for making the project
This is the first video in creating a chess engine in python using pygame. Enjoy!
Here's a link to the pictures:
https://drive.google.com/drive/folders/1qH7IQj5lj7o3MQIb5TAZhsDr_5f9p8aq?usp=sharing
Does anyone have any idea on how would I go about making the tank shoot along the blue line?
how would I apply the physics in game?
hello does anyone know how to make the "camera" follow the player on pygame?
finally got sprite explosion to work behind player when they kill a enemy
Hey is it typical for game windows to be scalable? I'm trying to make mine scalable but i'm running into a lot of issues with my UI textures breaking when scaled too small
ok for this you should render all the objects on the screen witht heir positions relative to the player's
you can follow this tutorial perhaps: https://www.youtube.com/watch?v=5q7tmIlXROg
The implementation of a camera is actually an illusion. Instead of moving a "camera", you just move everything on screen.
The project can be downloaded here: https://dafluffypotato.com/static/platformer_project.zip
A larger platformer example project: https://cmlsc.itch.io/super-potato-bruh
If you were confused by the tile physics in the last...
I think you may want to consider a bigger game engine like Unity or Unreal, pygame is also good but I don't find as efficient as bigger game engines, maybe for small projects but for games that are scalable you should consider a proper game engine (my opinion)
Honestly, I'd love to do it in Unity but I'm terrified that my knowledge of coding will not be enough
I barely have a grasp on python at this point haha
Don't worry, at first it may look confusing but trust me, you want regret learning it
Maybe try Godot
It is also using python as far as I know
Or something similir
Good luck
hello im doing a test and it worked but thats weird
to display seconds 0 to 1 min in the surface
it keep saying me not responding
but when i print in the console the seconds its working
@young pine If you can help me and btw sorry for the ping
time.sleep() pauses whole program so it wont respond you should use pygame ticks instead
mainticks = pygame.time.get_ticks()
while i < 60:
...
now = pygame.time.get_ticks()
if now - mainticks == 500:
second += 1
mainticks = now
i += 1
...``` ig this works @ember carbon
hi
self.manager = arcade.gui.UIManager(window=parent_window)
self.manager.enable()
self.v_box = arcade.gui.UIBoxLayout()
manage_building_button = arcade.gui.UIFlatButton(text="Manage Buildings", width=200, x=100, y=100)
self.v_box.add(manage_building_button)
manage_building_button.on_click = self._on_click_manage_building
self.manager.add(
arcade.gui.UIAnchorWidget(
child=self.v_box)
)
I have this code for a button in arcade but the button isn't placing at x=100 and y=100, it is always placing at (443, 326) no matter whatever value i give
Figured it out need to add align_x in anchor widget
how do you load a png image to a sprite in pygame so that the transparent background doesn't turn black?
here's how I load the image:
class Piece(pg.sprite.Sprite):
def __init__(self, pos):
pg.sprite.Sprite.__init__(self, self.containers)
data = starter_locations[pos]
self.image = load_image(f"Pieces\{data}.png")
...
def load_image(file):
"""loads an image, prepares it for play"""
try:
surface = pg.image.load(file)
except pg.error:
raise SystemExit('Could not load image "%s" %s' % (file, pg.get_error()))
return surface.convert_alpha()
but the background will still be black, even with convert_alpha()
You make chess?
you gotta start somewhere
I've made a tictactoe discord bot before 😄
k but how do you load that image :C
yeah
I made clicker
And I can't make points
When the button is pressed
I will try to send the program code sometime
when you create surface instance, you need add flag alpha i guess:
pygame.display.set_mode((1280, 720), pygame.SRCALPHA)
let's check
this is the screen or?
screen = pg.display.set_mode(SCREENRECT.size, pg.SRCALPHA) didn't change anything
idk how you name variable for creating main surface = window, but if it is, then yes
uh, that's kinda weird there but you can take a look at it if you want to
def main():
pg.init()
screen = pg.display.set_mode(SCREENRECT.size, pg.SRCALPHA)
pg.display.set_icon(load_image("Pieces\\bq.png"))
pg.display.set_caption("Chess")
board = load_image("Board.png")
background = pg.Surface(SCREENRECT.size)
for x in range(0, SCREENRECT.width, board.get_width()):
background.blit(board, (x, 0))
screen.blit(background, (0, 0))
pg.display.flip()
pieces = pg.sprite.Group()
all = pg.sprite.RenderUpdates()
clock = pg.time.Clock()
Piece.containers = pieces, all
for pos in starter_locations:
Piece(pos)
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
sys.exit()
all.clear(screen, background)
all.update()
screen.fill((0, 0, 0))
dirty = all.draw(screen)
pg.display.update(dirty)
clock.tick(40)
for x in range(0, SCREENRECT.width, board.get_width()):
background.blit(board, (x, 0))
```just realised I don't need this part
i dont see any problem with this, it should be transparent
Anyways cool idea to make chess
if they really have alpha channel, then not, check if they dont contain black background
don't think so, seems fine
idk mby, i have no problem with alpha channel so idk
set_colorkey neither
@hasty arch got it after commenting out screen.fill((0, 0, 0)) in my main
just so you know it works now 🙂
good job!
do y'all prefer python over unity?
Today I learned this exists:
https://github.com/coding-horror/basic-computer-games
An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-h...
That is a huge number of contributors, and I like browsing the code therein 
how to fix this?
Hey @hasty ruin!
It looks like you tried to attach file type(s) that we do not allow (.exe). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
can someone explain the formula of slope calculation
why is the (y2 - y1)/(x2-x1) the slope calculation
uhm, fix what exactly
rise over run. read up about graphs in math
this
Block Breaking Game-
you mean the hitbox is too big?
yes :DDDDD
i think a way would be to add another rect for collision, or crop the image
i did resize the img it didnt work
i mean crop it, crop the invisible parts
how exactly can i do that?
OHHH GOT THANKSSS
!paste
I get this error https://paste.pythondiscord.com/uyirinokuw
when doing this
error_label = arcade.gui.UILabel(width=250, text="message".upper(), multiline=True, text_color=(255, 0, 0), font_size=12)
and apparently this error doesn't pops up when using UITextArea with the same arguments
I love this
using arcade lib. can i in any way bind primitives/set of primitives such as rectangle to a sprite, so i'd be able to deal with it like an object (without using an actual image)?
i see there is arcade.SpriteSolidColor, that might be useful
hey can somone help me
i have a pygame question maybe someone can help me with
maybe if you ask it someone can help you with it
@empty wraith There's a circle and a solid color sprite available.
For advanced draw-on-a-sprite work, you can use code like this minimap example:
The minimap is a sprite, and you can draw whatever on it.
Glad you like it!
increase = 1
score_list = 0
hands_list = []
mouth_list = []
class ClickButton():
def init(self, image, x_pos, y_pos, text_input):
self.image = image
self.x_pos = x_pos
self.y_pos = y_pos
self.rect = self.image.get_rect(center=(self.x_pos, self.y_pos))
self.text_input = text_input
self.text = main_font.render(self.text_input, True, "white")
self.text_rect = self.text.get_rect(center=(self.x_pos, self.y_pos))
def update(self):
screen.blit(self.image, self.rect)
screen.blit(self.text, self.text_rect)
def checkForInput(self, position):
if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, self.rect.bottom):
score_list += increase
UnboundLocalError: local variable 'score_list' referenced before assignment
does anyone know why i get this error
this is pygame btw
could you upload the entire file? just drag&drop it in here
?code
oh im not swag ic
?tag code
This is not a Modmail thread.
!code
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.
wrong prefix 😉
use less memory or allocate more
Might be a simpler example: https://github.com/pythonarcade/arcade/blob/development/arcade/experimental/atlas_render_into.py
anyone help with this?
its arcade
When using global variables in a function or method you need to expose it with global varname. Python expects score_list to be a local variable in that function
screen.blit(left_wall , (left_wall.x , left_wall.y))
is showing the error screen has no attribute blit . why is that ?
what's minesweeper's mine generating algorithm?
Random placed, but not until you have clicked once and not immediately around the first click.
Might be unsolvable without randomly guessing.
You can write a generation algorithm that makes sure it's always solvable.
place any random pos besides the position the player clicked
then scan each grid and indicate the number on the grid
mark zukerburg, please delete metaverse. plz.
ohk then can i buy google and twitter?
File "c:\Users\saksh\Desktop\pygame\game1\main.py", line 29, in <module>
player.add(Player('sidewall.png' , 0 ,0 , 100 , 100 , 'left_Wall'))
File "C:\Users\saksh\AppData\Local\Programs\Python\Python310\lib\site-packages\pygame\sprite.py", line 454, in add
sprite.add_internal(self)
AttributeError: 'Player' object has no attribute 'add_internal'```
why is there an error in pygame file?
because most likely Player is not a subclass of Sprite
so i have to do somthing like class Player(p.sprite.Sprite)?
yeah
how do i make an object move continuously while i keep pressing the button instead of pressing it again and again?
When you press the button, set a bool to True and back to False when you release it
Then every frame, move of that bool is True
if i wanted to animate ( sprite ? ) a needle gauge or a custome gauge , is there a limit to how many animation frames i can use ?
If I was doing a guage like that, I'd probably have two sprites, one for the needle, one for everything else.
Also, kind of depends on the library you are using.
does anyone know a way to add a value to a variable every second?
Hey, I coded a hangman today in python but when I open it in cmd prompt it immediately closes…might any one know why?
Very new with Python, so don’t have much idea what to expect with it
Hi try to use the time module
arcade. is there a way to disable logging, like for exampe suppress the Attempting to add texture log message, which is of a fairly high INFO level
So you changed the global log level then?
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
logger = logging.getLogger()
i have this specifically, and i import logger wherever i need
when i said disable logging i meant only disable logging for arcade, was hoping there's an option to do that
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
arcade_logger = logging.getLogger("arcade")
arcade_logger.setLevel(logging.WARN)
It's a python logging thing, not an arcade thing
logging.basicConfig changes the global/default log level of everything
oh, but logger can have its own level right?
yes. Just like the above code
i somehow got confused and thought logger/arcade_logger in this case would change the global level
oh man, what a silly mistake
Also a good idea to name your loggers logger = logging.getLogger() will just return the default one
thanks
logging.getLogger(__name__) is great
what would be the purpose for naming? putting the name of the logger into the output?
(with corresponding format)
The logger name hierarchy is analogous to the Python package hierarchy, and identical to it if you organise your loggers on a per-module basis using the recommended construction
logging.getLogger(__name__). That’s because in a module,__name__is the module’s name in the Python package namespace.
i mean, what would be the practical use for it. i've been using just one logger object and importing it in things, i guess with extensive logging and a lot of different modules i could use multiple logger objects and name them so i could instantly tell where potential warning etc come from
We have lots of loggers in arcade. Typically per module. loggers could be arcade, arcade.sprite, arcade.spritelist, arcade.texture_atlas etc.
This will set the level for all of them ```py
arcade_logger = logging.getLogger("arcade")
arcade_logger.setLevel(logging.WARN)
That's the advantage of just using __name__ (name of the module)
If you need to kill some time (after pyweek 😄 ) https://docs.python.org/3/library/logging.html
thanks for your help. i have been using logging for quite some time, just apparently not to its full potential (also made this dumb oversight today) 🙂
Loggers can be a mess sometimes. Not blaming you 😄
after messing around with it a bit more, i now understand the source of my confusion better, basically if you leave the name empty it will indeed set the global logging level when you setLevel to it (because you get the root logger). i just forgot how crucial this detail is after several months of not doing python 🥴
also since i'm here, is there an easy way to check for "collision" of the mouse cursor and Sprites, in other words, an easy way to detect when i'm hovering over a specific sprite
from what i've seen so far there's no easy way, and i'd need to loop over all sprites and see if mouse cursor position belongs to an area/hitbox of each individual sprite. Do it in on_mouse_motion, most likely.
See collision methods at the top of this page : https://api.arcade.academy/en/latest/api/sprite_list.html
For example : get_sprites_at_exact_point
If you have spatial hashing enabled in the spritelist it will be an O(1) operation. Otherwise it will loop all the sprites (O(N))
i assume for static sprites i want that spatial hashing enabled
well, not assume, i've read that it's not as good for dynamic ones
..or maybe it's only applicable to sprite-sprite collisions
You definitely want spatial hashing for static sprites
You could have 1M sprites and still have fast collision detection with spatial hashing
would spatial hashing improve performance if all sprites are dynamic?
It depends. It's a tradeoff. Every time you rotate or move a sprite it needs to update the spatial hash
You will have much slower movement, but fast collision detection
(against the list of moving sprites)
If it's like 50 sprites it might not be worth it
There are plans to cythonize spatial hash and a few other things for 2.7
day night cycles based on real time in discord bot game, still not happy with artwork
granular sunrise/sunset and background change based on time. Anyone want to give feedback on art?
doing a rework of the market stall now
I like this! Well done.
Trying to implement jumping. Right now, i have it working so the player rises during the ascension time and falls during the dissent. However, it looks very linear. Is there a way i could make it so as the player approaches the peak, they go slower, and do the inverse on the fall down?
Multiply the yvel (y based velocity) by 0.9
that way it consistently reduces
idk what ur code looks like, im assuming u have a y axis velocity or something
if something doesnt work well, try replicating it using an asynchronous visual coding language
i.e. scratch, its super fast and easy to fix small bugs with ur physics engines and stuff
I have player.y += Entity.jump_power * (1 if rising else -1) essentially inside the game loop
i assume rising is a binary variable where it detects if ur going up? or not?
True or false, ye
It isnt actually that, just used that as a placeholder to explain
lemme check smthng really quickly
Sorry, i was typing it all up and i forgot to include a gravity script
💀
i gotta sleep now, sorry
Alr, no worries 👍
lagtrain (curses)
Is it okay if I ask something about pygame in this channel?
Sure, but probably other places with more eyes
Probably way more pygame people on pygame discord to be honest
Watch our Elden Ring review. Elden Ring is a massive iteration on what FromSoftware began with the Souls series, bringing its relentlessly challenging combat to an incredible open world that gives us the freedom to choose our own path.
Elden Ring Reviewed by Mitchell Saltzman on PC. Also available on PlayStation and Xbox.
#IGN #Gaming #Elden...
aaaannnnnddddd
how am i supposed to render a red cube in python?
Hey @junior lintel!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey guys , How can I make the logic of tic tac toe like if X is marked it will be the turn of O and etc
btw I'm trying to do this game by myself , so if u find something weird on the code just ignore
create player objects, loop over them with itertools.cycle
i want to make a function and i want it to check for a yes or no and turn that into a 1 or 0
"yes" or "no" as user input?
def is_yes():
return input().lower() == 'yes'
if really want 1 or 0 instead of a bool, can just convert it to int
can someone help me with some pygame stuff
i want to create a button
i searched a lot of toturials
didn't find anything simple
you can not , because the module is installed on the server not on your local machine
so i shouldnt code on a website
or i could code on repl.it and then copy it all to my machine
yes and you should have pygame installed on your machine
alright thank u dude
Hello wondering if someone knew how to rotate a drawing is there a command for it or would I have to rotate the surface its on?
Drawing would be pygame.draw.circle() or polygon etc no images imported
ig there is one pygame.transform.rotate(Surface, degrees)
Ok but this would also rotate the drawing?
yes it will rotate drawing but rotated drawing will not be saved
i mean png will not be changed it will be changed in pygame window
Its not an image its the built in draw function
Drawing many shapes on screen and trying to rotate them all at once
if its a surface which you can draw on screen it can be rotated
How to make a snake game on python?
Could either make surfaces and fill them or make surfaces and add shapes, also check for collisions of course
Should watch a yt video
Ok tysm!!!
What did i do wrong in this code? its not giving any error, but it wont run when i try to have the sound effect:
BULLET_HIT_SOUND = pygame.mixer.Sound('Assets/Grenade+1.mp3')
BULLET_FIRE_SOUND = pygame.mixer.Sound('Assets/Gun+Silencer.mp3')```
import pygame
pygame.init()
WIDTH, HEIGHT, = 700, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Pong")
FPS = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
PADDLE_WIDTH, PADDLE_HEIGHT = 20, 100
class Paddle:
COLOR = WHITE
VEL = 4
def __init__(self, x,y, width, height):
self.x = x
self.y = y
self.width = width
self.height = height
def draw(self, win):
pygame.draw.rect(win, self.COLOR, (self.x, self.y, self.width, self.height))
def move(self, up=True):
if up:
self.y -= self.VEL
else:
self.y += self.VEL
def draw(win, paddles):
win.fill(BLACK)
for paddle in paddles:
paddle.draw(win)
pygame.display.update()
def handle_paddle_movement(keys, left_paddle, right_paddle):
if keys[pygame.K_w]:
left_paddle.move(up=True)
if keys[pygame.K_s]:
left_paddle.move(up=False)
if keys[pygame.K_o]:
right_paddle.move(up=True) #Pay attention to here, it was K_UP, K_DOWN, but, then I had to spam the arrows up, and down for right paddle to move. I changed it to K_O, K_l all of a sudden it fixed my problem?
if keys[pygame.K_l]:
right_paddle.move(up=False)
def main():
run = True
clock = pygame.time.Clock()
left_paddle = Paddle(10, HEIGHT//2 - PADDLE_HEIGHT//2, PADDLE_WIDTH, PADDLE_HEIGHT)
right_paddle = Paddle(WIDTH - 11 - PADDLE_WIDTH, HEIGHT//2 - PADDLE_HEIGHT//2, PADDLE_WIDTH, PADDLE_HEIGHT)
while run:
clock.tick(FPS)
draw(WIN, [left_paddle, right_paddle])
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
break
keys = pygame.key.get_pressed()
handle_paddle_movement(keys, left_paddle, right_paddle)
pygame.quit()
if __name__ == '__main__':
main() ```
did you initialize the mixer?
this is the error i get:
File "main.py", line 18, in <module>
BULLET_HIT_SOUND = pygame.mixer.Sound('Assets/Grenade+1.mp3')
FileNotFoundError: No file 'Assets/Grenade+1.mp3' found in working directory '/home/runner/Test-spel'.```
it clearly states that file isn't found
you probably passed wrong path or wrong name of file
lol
kek
thanks for the help still man
i hate doing my own art. how do i even do a mushroom cloud
Use a reference image.
e.g.
😤
Notice the bottom is lumpy clouds of smoke, and the top emits a lot of light (so shading is different than a normal object). Also it has a bunch of darker spots / texture.
(nor is the top a perfect mushroom shape, try breaking the contour a bit)
If it's a still image you can add some shock waves or something
Honestly, I tough it was just an overgrown mushroom
*The explosion should also be shading the rest of the objects in the scene as a back light.
Due to the dust there may be some nice visible rays of light / volumetric lighting.
You can see how in the reference image it glows around the mushroom as well.
Near the top and bottom it's so bright that it's basically pure white.
Then it becomes more lumpy and darker:
alright thanks, ill give it another shot in a minute, just so tired of drawing tho
slowly getting there
the bottom should be more orangey imo? looking better tho
Arcade 2.6.13 is out:
https://api.arcade.academy/en/latest/development/release_notes.html
Guys, can anyone help me in building a TCG, sort of like MtG Forge? How do I code in the card effects?
Programming Tutor is an educational platform that provides 1:1 coaching for those who want to learn... adabor 10, 1207 Dhaka, Dhaka Division, Bangladesh
As far as I can think, it would involve things like moving a card from one point to another, tapping/untapping/ removing summoning sickness, battle/combat, tap ability, etc.
বাঃ, ১:১ কোচিং টা বেশ কাজে দেয়। ঢাকা তে?
are you familiar with vector math?
One thing that may be a source of problem is your while loop is blocking the application from processing window events. What are you trying to achieve conceptually? Do you want a timer that counts up/down to a minute?
yeah I figured that out
it's working now
the thing is in the X direction it would move to a distance of = velocityX * time
in Y it would be Y = ut + 1/2at^2
well what id do is constantly add to your y velocity component. This simulates gravity. Then give an initial push by adding a vector in the direction you want to shoot.
It should give an arc
oh
right i forgot you need to decrease your horizontal velocity as well
velocity.x *= .5 should slow it down
Can someone
tell I need to start
my
pygame
I am very week
in it
and if I write code in pygame
and use in kivy
who wants to contribute, its open source, any pulls are welcomed. The todos are labelled below https://github.com/Wizock/sorter_visualiser
'''py
Hey @sage ermine!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @sage ermine!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
😤 finally done
is there any way to get a pygame.Surface from a pygame.Rect?
FYI: Arcade 2.6.13 is out with some important bug fixes reported during pyweek : https://api.arcade.academy/en/latest/development/release_notes.html
This also includes a new feature: Headless rendering on linux server.
!paste
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.pythondiscord.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.
Cave generation
That was just a shot of it compiling and running. it actually takes 14 milliseconds.
Though im not sure how good that is
recruiting is not allowed here unless you have mods approved iirc 😬
might want to get one at @light nest
🚀
exept its not recruting
mods know more than I do ¯\_(ツ)_/¯
btw vaxeral is in the server
<@&831776746206265384>
def draw_window(sydän):
WIN.fill(MUSTA)
WIN.blit(TAUSTA,(0,0))
WIN.blit
pygame.draw.rect(WIN, KELTAINEN, (400, 100, 400, 400), 6)
WIN.blit(SYDÄN, (sydän.x, sydän.y))
pygame.display.update() ```
this is my window so far and I want that the hearth is inside of rectangle(it already is) and it cant go trhu the walls but other objects can that i make later
hmm what should i make a blackjack npc look like
i wish i had made the perspective of the drawings anything but head on, i could draw a tabletop and cards and it would have made so many things easier
Hello can someone help me with making snake game in python and with pygame?
Hey guys very nooby question, i've just started coding. Im about 2 days in and i'm getting stuck with an issue. Can i recall 2 functions in a elif statement? i've had alittle look around google but i cant find anything i can really use to help me
or can i call a function, and then recall to a variable after the function has finished?
Could be better to grab a help channel for this since it's a generic python question. Also try to provide some lines of code showing what you you are talking about. #❓|how-to-get-help
Thanks mate, through my own problem solving i think its an issue with my function which is why its not being called properly. i'm going to do abit more diggin before i start bothering people lol!
i've made a game using pygame and i wonder how i could make it publicly available? Im not trying to earn money or anything. i just want it to be publicly available without forcing the user to downloading the game files
@feral plaza you can copy paste
huh?
what do you even mean by that?
You said that you want to publice your code. so you can copy paste and drop it in the chat or somewhere else
i didnt say that.
i said i want my game to be public not my code...
Did you have made a lot of games in Python?
not too many honestly i've just made a few and none of them have been public in any way
I don't think copy pasting it is what they want. Players would have to 1. Be on this server, 2. install python, 3. install pygame and any other modules it uses, 4. launch the game through a terminal interface.
There are packaging tools you can use, such as pyinstaller, but there are lots of other ones too. When I released a game on itch.io, I just uploaded python.exe, the modules I used and game code + assets, so that's possible too.
Maybe follow this: https://www.youtube.com/watch?v=lTxaran0Cig, since he's actually released commercial games
Alright Thank u this was helpful. But is there Any way i can make it public without forcing the user to download anything
No, that's literally impossible. If you mean make it run in the browser, that's still downloading. I don't think pygame has an export to web option either
Alright Thank u
I can confirm that bush looks like a bush.
How to fox it?
bush confirmed thank
I didn't ask the right question, why is it not compiling?
me running a small game using repl.its cpu
pyinstaller is a python module
you execute it by passing it to python
python -m pyinstaller -F test.py
how do we use python for game dev
Would you recommend a nice Python editor
Hey all, I'm using Lua, but any answers in other languages would be appricaited, as I understand that this is more of a programming concept than anything else probably.
How would you call a function ULT_Ped.setWeapon like this:
controllerWeapon.all(pedestriansMenu_weapon, ULT_Ped.setWeapon)
pedestriansMenu_weapon - is a variable something unrelated
And but pass in the value from inside the controllerWeapon.all method?
-- controller
function controllerWeapon.all(parent, func)
for index = 1, #data do
local ult_category = data[index]
local ult_categoryName = ult_category.name
local ult_weapons = ult_category.children
local ult_categoryParent = menu.add_feature(ult_categoryName, "parent", parent, nil).id
for j = 1, #ult_weapons do
ult_weapon = ult_weapons[j]
menu.add_feature(ult_weapon.name, "action", ult_categoryParent, function(feat)
-- ULT_Ped.setWeapon(ult_weapon.hash)
func(ult_weapon.hash) -- Thissssssssss
end)
end
end
end
Feels like needs a callback? or a global state umm
The function is what's dynamic. Although there are only a few options that it can have so maybe having a switch could be better such as (parent, option) if option is 1, give weapon to npc, if option is 2, give weapon to player, is option sis 3 ec... and maybe have like up to 5 options 🤷♂️
But can't guarantee this would be the same with other stuff since this is just weapon controller
Man, thank you so much, I didn't expect such a comprehensive answer.
think you tagged wrong person : p
Why do you think that?
You're not very nice, are you - please don't write anything if you're here to insult/mock whatever you call that people. Were not here to have 'fight's over nonsense. Take that elsewhere - this discord/channel is not the place for that.
I think you misunderstood me, I asked a question, and I thought you answered that question, so if you didn't answer that question, I'm sorry, I misunderstood.
And since there are not enough software resources in my country, I need foreign resources, I'm in Turkey, and there are almost no software resources in Turkey, and the resources that will force me financially, so I don't even know your language.
I'm glad I could explain myself.
Hi guys, I'm a little new to pygame, I'm trying to create a Button to display unto the screen, but for some reason when I call my Button's draw method, I don't see it on the screen.
This is my code
class Button:
def __init__(self, surf: Surface, text: str, coords: Tuple[int], size: Tuple[int], bg='black'):
self.x, self.y = coords
self.width, self.height = size
self.text = text
self.font = pygame.font.Font('assets/fonts/playfair_italic.ttf', 30)
# Make a rectangle for the button
self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
self.surface = surf
self.bg = bg
self.clicked = False
def draw(self, border=False):
# Draw the button
self.textBox = self.font.render(self.text, True, (0, 0, 255), self.bg)
self.size = self.textBox.get_size()
pygame.draw.rect(self.surface, (0, 0, 0), self.rect)
# Draw the border
if border:
pygame.draw.rect(self.surface, (255, 255, 255), self.rect, 1)
self.surface.blit(self.textBox, (self.x + self.width / 2 - self.font.size(self.text)[0] / 2, self.y + self.height / 2 - self.font.size(self.text)[1] / 2))
Hey @keen valve!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
this started off as trying to draw a cat and now idk where im going with it
how tf do legs work
what does pip list show?
hey guys im searching if some one know how to create, open and write plain text archives to save simple data as arrays
Hey @icy valve!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
im using pickle but it saves the data in binary files and i tink i cant edit whit git if i want to retur to a older version of the IA
You might be looking for json files : https://docs.python.org/3/library/json.html
from what i've read it means i can configurated pickle to save in an simple .txt?
@ripe marsh Dude, what's the name of the program you're using?
Call pygame.display.flip() outside of the draw function after you call it, or call pygame.display.update(self.rect) inside the draw
Thank you very much 🙏, I used the second option and it works 😭
hey legends
im super slow and idk how to return this function and use 'guess' and 'answer' can someone help?
def update_history(history: tuple[tuple[str, str], ...], guess: str,
answer: str) -> tuple[tuple[str, str], ...]:
ConEmu
💀
I game developer
I make game
About Vlad and Alexey
In Russia
Name CyberVkid228
noise generated caves(black)
hello guys i want some help about how to make an very specific part por a python game
i want to encrypt just part of the source code of some characters because there are the dialogs of every character and i dont want the pepole spolier them self
Hi. Can anyone help me with an idea how calulate value which will help change position Y from text? If needed i can drop whole code. Im trying to do it in ursina engine (which is build on panda3d)
https://pastebin.com/H48T1jsb
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What stops people from decrypting these messages?
well nothing but at least they will not blame if they get spoiled of the story
i want to encrypt the code whit out lose funtionality in the whole program
Maybe just base64 encode the text somewhere. That at least requires a little bit of effort
It can work if you have a server and a client and the server sends keys on demand to decrypt some text
It's not unusual for games to do this. For example encrypting items data on the client
if this could be virtually imposible to unencrypt by no dev pepole could be the best tbecause i want the characters dont be trated as tings i want they fell real but if they can see all the dialogs then the magic is gone
it could work but its a game all the code is inside the machine of the player
lets called a semi open source game writed in python
the players can make all the changes they want in the code but they cant see the scource code of the characters ill made
i tried making the code inside of a image whit steghide
but it has to be so hard to work propelly than the code to make that works was 20 times biger than the character code
The weakness is that only one person needs to figure this out and then it's all open
You could do weird stuff like getting a sha256 of some file and use that as key to encrypt things?
To be honest I don't thing that would be any safer than just base64 encoding the text
Unless you are doing some heavy code obfuscation when building the game
For example with Nutika
if they spoil it it's their fault, a normal user wouldn't dig into the source files
Nothing wrong with just scrambling data, but I wouldn't put that much energy into it. 99.9% of the users won't know how to unscramble it.
@potent ice @sinful lodge And I down want anybody get the information for another's
It's like the case of FNAF or pops playtime if I want to keep the story in secret it's for keep the players aware of his actions not only for the spoilers
If someone doesn't care about the spoilers but he want to solve the mystery it brokers the experience for the rest of players I want the game be played as it has to be
And also as I don't know how to make an executable game all I can made it's a .py format
i think if you want it to be fully "hack-proof" you'd have to have some sort of a web server to verify the user's actions and return the secret data
anything that you can unscramble client-side should be able to be unscrambled by the clien t as well
it could be but i cant aford a web server or making my wabe only bia accesible whit web serving
and what hapends if the player loses his internet conection?
which is why i'm saying this is a strange problem, anything you wanna keep 100% secret shouldn't be stored client-side
but you could always encrypt the data
the alternatibe is maybe i can encrypt all the source code to make all inaccesible
because all the game are like 1000 lines of code in only one python script
i don't think it's possible to encrypt source code, again if you wanna run it then you'll have to decrypt the source code, which means that it isn't 100% secure
and is full based in text whit no libraries
you cant just compile the python code and then run it like an normal .exe?
or like an binary file of c++?
i'm pretty sure if you store raw strings in there they can be decrypted (in exe files)
if you absolutely must keep the stuff secret from the user, afaik you can only store it on a web server/some backend
you can always host that web server/backend on replit
damit so there is also not 100% unecryption proof?
nope
if something can be encrypted it's going to be possible to decrypt it, HASHING is different though, but it wouldn't work for what you're asking
well i tink maybe i have to forgot the mystery in my game and focus in the adictive gameplay instead
you wanna try the game?
Hey @icy valve!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
is there anyway to ask questions in pygame and then let the user type in their answer?
You can use: https://github.com/Nearoo/pygame-text-input
is tkinter good for making a game window or is there another lib i should use
Game libraries provide their own window usually. Mixing those with the tkinter is not that straight forward.
If can do some crazy stuff of course if you dig into things on the OS level manually setting the window or widget framebuffer, but that's a pretty complicated affair.
this looks like both a gui and a cli at the same time
is there a cleaner way to get a top 5 list split by guilds, i start with a structure which is {guild id: {#1 player id: score, #2 player id: score}} then whenever someones score (generated) changes i use this code:
if player.guild not in guild_gen_rank:
guild_gen_rank[player.guild] = {player.id: player.generated}
else:
temp_ggr = guild_gen_rank[player.guild].items()
for count, tup in enumerate(temp_ggr):
_, generated = tup
if player.generated > generated:
temp_ggr.insert(count, (player.id, player.generated))
guild_gen_rank[player.guild] = dict(temp_ggr[:5])
break```
How do I get global ports into a python socket? To be able to connect from another computer
HARFANG® High Level is a set of simple functions that allow you to code faster, and to achieve results without needing to become familiar with the deeper notions of complex programming tools.
Get familiar with the basics, and stay focused on your needs.
With a small example, you will be ready to use HarfangHighLevel in your project.
With this...
anyone know how to use collision detection for maze generated using DFS? Need to identify and establish walls, so player cant go through them
what is the best framework for beginners to start
You'll get a lot of opinions on that.
I'll recommend Arcade. Pygame is popular too.
@void ivy See: https://api.arcade.academy/en/latest/examples/index.html#platformers under 'procedural generation' it does a maze with DFS an collision.
@frozen knoll thanks
cool, are these harfang tutorials?
The first one 😅
We have a dozen more to come
awesome
Do you think it would help ?
(Sorry for the naive question)
Ah yeah :)))
I see you former nickname now 🙂
I had in mind you had a preference for text tutorials though
These tutorials are made by Thomas, one of your team mates who implemented a short API to make Harfang more easy to use
yeah, the api at the moment provides a lot of info, just that i don't know how they can be put together
anybody here familiar with renpy ?
opinions on ursina?
anyone know if kivy works on 3ds?
It can definitely do 3D. It's using opengl es. However, I don't know if there's any higher level support for it, but you can definitely crank out some shaders doing that. If I know the Kivy community right there's at least something.
i meant like the 3ds cosnole
There is rotating monkey head example : https://kivy.org/doc/stable/examples/gen__3Drendering__main__py.html
You will have to be a lot more specific
Ok, so can I use Kivy to create a game for the Nintendo 3DS?
idk how to be more specific
According to kivy.org
Kivy runs on Linux, Windows, OS X, Android, iOS, and Raspberry Pi. You can run the same code on all supported platforms.
mhm.. but it also says this:
With Kivy, you can create apps that run on:
Any other touch-enabled professional/homebrew devices supporting TUIO (Tangible User Interface Objects).
is there not a 3rd party lib or something to make kivy work on 3ds?
I would imagine the Nintendo 3DS platform is very different unless it's based on some android version. I have no idea. Can always jump into Kivy discord.
got a link?
Hi, Do you have any libraries to recommend, when it comes to 3d development?
Panda3D (and/or Ursina).
Using Panda3D directly can get you all the way down to low level. Unless you want to use OpenGL / DirectX / etc directly (kind of no point (unless you really know what you are doing / or for education), you will end up just making a copy of Panda3D at that point).
It's a full 3D/2D game engine. It can do whatever.
It's also mature.
Definitely look at Panda3D. That's a nice next step after urina anyway since ursina is using panda3d
You can pick apart ursina to expore how it's working
It's better than spending 5 years making your own game engine/renderer that would probably be worse than panda3d
Going down to GL / Vulkan can work if you have very simple needs.
It's not even that it's better or worse, it's just that consider now wanting to work with others. What do you do? They have to learn a whole new thing if using your custom engine.
Same reason everyone uses Unity or Unreal now. You can be on the same page.
*Also Panda3D being tested on projects already, while your custom engine is an unknown as to whether or not it will work out in practice.
**Still there are times when a custom engine is not a bad idea. But that's a bit hard to explain (when and when not). So for beginners it does not really make sense unless you want to learn how game engines work in depth / maybe you want to contribute to something like Panda3D or work on Unity, etc.
ofc its not, making an exploit is only legal when the opposing party which said exploit damages thier property consent to the development and usage of said exploit, seeing as i know the individual that employed you to make this cheat probably has malicious intent behind this "cheat" i highly recommend you not attempt this because its highly unethical and probably highly illegal.
you're absolutely a marvel, i stay in disbelief at the depth of your games seeing its made in pygame.
highly reccomend ursiana, its under-doccumented but its a fully functioning 3d programming library for python
thanks
i also saw your tutorials on youtube, your advice being " understand the problem and figure out ways it works and try to conceptualise them" because i've seen many individuals talk about "how limited pygame is" but your advice totally breaks down those conceptions of limitations just because pygame is a simple direct layer of graphics. the "particle" video is a must watch for all developers aspiring for 2d pixel art game developers.
ok tysm for your reaction
lol, i cant sent any messages anymore to the job offerer
hey guys i have a question. how reliable is traslate a python proyect into a unity vr project?
im making a prototype of the mecanics and world in a 2d vision but the game works in 3d
im just playing whit the code and evertings looks good so i have to finish the bots and then move my 3d matematical model to unity which i never touched before
please don't discuss this here, it breaks our rules on posting job advertisements and malicious projects
ooh sorry
@sullen wagon do you mean me or aeternus?
not you
i wanted to be sure i didnt do any illegal, and i thought the job offer would make clear if it was illegal or not
@dawn quiver are you working on a project? about what?
nothing atm
comoon im searhin for coders friend to learn about
im breaking my shell to meet pepole
Hey guys i need some help. Im creating a text based game. i've given the player 4 options on "Classes" and im looking how to recall which option the player has chosen to move forward with the story. I know this is abit vague so here is the code im talking about
slowprint(f"So you have chosen the Berskerer is that right?: \n", 0.5)
bb = input(f"Yes/No: ")
elif choose_class == '2':
slowprint(f"So you have chosen the Sniper is that right?: \n", 0.5)
sn = input(f"Yes/No: ")
elif choose_class == '3':
slowprint(f"So you have chosen the Scientist is that right?: \n", 0.5)
s = input(f"Yes/No: ")
elif choose_class == '4':
slowprint(f"So you have chosen the Animal handeler is that right?: \n")
ah = input(f"Yes/No: ") ```
like how do i get the players choice from the variable so i can recall their choice later. sorry if this is the wrong channel
@ocean lichen i tink its the correct chanell
well like i can see in your code it still very raw
you have to do 1 of 2 tings
Yeah it is xD i've only been coding for a couple of week and this is my first solo attempt
1 make a universal and imutable tree of elections and events(which is very extensive and long and very low reliable)
lol what?
or 2 make modificators whic will keep the story going and mark the important choices for the future
dont use elif, just use if
So if i change my elif to if how would i recall the players choice? after the fact
for example i made a lets call it "bitcoin simulator" and its only 1000 lines of code
is that your full code?
that its not very complex but not very simple too
yea less than 1000 is the full game in 1 archive
complex code != better code
but for a next time (if it comes that far) how do i know if its illegal or not?
complex code == harder to read code
of course be complex its not the solution its make the code escalable
scalable is the word i was wanting to use
my game its like a tetris all based in text but i later will ad some story and more mecanics
no, im abit ashamed of my code as sal said its very raw. by here is it regardless lol ill give you a paste bin:
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its extrememly elementary, i dont think they need to impliment a design pattern xD
i get your point and you're not incorrect
also wdym how to recall the play's input
ive done the best i can xD but yeah i've got a lot of stuff to learn
if you got the players input then its there, it doesnt expire
whit variable = input("give me you election player")
so their is choice 1 - 2 - 3 - 4 for the classes how would i be able to recall what the player has chosen to refer to it later, rather then making my if statements huge
i think you can understand if something seems wrong
what do you mean
you literally asked for input from the player
why cant you use that
just use the variable again
choose_class = input(f"Choose: ")
using elif nest the next elif inside the last if one
you asked for the input
i think im maybe confusing myself and you guys
yeah you used elif, meaning you terminate the posibility of other ifs,
whats the error
because you've defined the player's input as a variable and have worked with it thoroughly within the main loop
class start(): should be def start():
their isnt an error, the code runs ok, so what you saying is the choose_class var will register the players choose and i'd only need to refer to choose_class as i continue?
yes
i get you
their is a second question if you have time, it will help me tidy up my code abit.
chose_class variable is put into memory, it stays defined as long as the game is running
your "classes" should use a dictionary
are all the attributes the same but just different values?
you've just defined them with different names because of nameerror right?
you can use a "python class" for the play classes
a class is something difficult to understand but if you know what a class is, you should make a class called "Atributes" and then inherit from it into the berserker class
and etc
but only if you understand what it will do
it depends of tha law of your country and some times it could be in a very grey scale but as i dont know what is the project about i can made a basic resolution
otherwise a dictionary will do fine to store the attributes
Ill look into that, the next question that i have is. if you look at my paste in you can see i've reused the same set of "player options (refer to the end of my code) how could i recall the options of 1 - 2 - 3 - 4 - 5 after the player has select option '5' so after seeing the stats of the classes they can then choose one.
okay
for the 5th time
choose_class is defined as a variable, you can refer to it anytime ,anywhere after its been defined
if you want to "redefined" choose_class
you can redefine it
by simly
choose_class = input()
oh
wait i think i understand what you mean
so how could i recall that choose_class var to rerun the options. after they have selected option 5 and seen the stats? print(choose_class())?
a player can say "1, 2 3 or 4" multiple times?
and depending on what they press, something is effected?
no its not xD its just a choice
ill try and be as detailed as i can here. one second
wait, if this is an rpg game, i think you're going at it, the right way but there's things you can improve
The player has come to choosing a class and is presented with 5 options. The player has chosen option 5 to see the stats of each class. how after seeing the stats can i then rerun the options for the player to then choose which class they want. without repasting the whole code again. can i rerun the code
using if statements that many times isnt good
should i maybe use a class function and define the player options to return to it?
you should have a main game loop in which there's not much visible code and most of the functionliaty is handled by functions that are called upon user input
if that makes sense. i know my code talk is abit gibberish
Yeah
class Student:
def __init__(self, name, age):
self.name = name
self.age = age
def show_details(self):
print(self.name, self.age)
rick = Student("rick", 16)
rick.show_details()
>>> "rick, 16"
you can do the same for a player
I think i can see where i've gone wrong, i've made this so much complicated then it needs to be. which is probably why im confusing myself
all that code can be avoided by one class xD
you can make a player have attributes
those attributes effect other objects
class player_class:
speed = 0
attack = 0
health_points = 0
rs = 0
ms = 0
charisma = 0
ah = 0
class Breserker(player_class):
def __init__(self, name):
self.name = name
def set_attributes(self):
speed = 8
attack = 3
health_points = 8
rs = 1
ms = 8
charisma = 8
ah = 2
getting_gold = Breserker("GettingGold")
print(getting_gold.speed)
that can seem like complex code but its making objects on inital values, therefore you can have scoped definition of attributes
and in order to make more and more kinds of classes of players you can "inherit" that player_class and adjust the attributes
def __init__(self, , name, str, agi, hp):
self.name = name
self.str = str
self.age = agi
self.hp = hp
def show_details(self):
print(self.name, self.str self.agi, self.hp)
warrior = Student("Warrior", "str: 8", "agi: 4", "hp: 9")
warrior.show_details()
>>> "Warrior, str: 8, agi: 4, hp: 9" ```
something like this? i would create a class for each "Class" and then def the attributed underneath to recall later?
Classes is kinda bad name but yeah its a good start
yeah im with you. ill rename it specs or something 😄 and thanks for the help thats alot clearer now
mine is more complex, yours is better for you, mine is used for a bigger game design but yours is good because you can understand what you write
no i understand what yours does and how to use it, i can read and maniplute codes pretty well. but writing them from memory is abit of an issue at the min lol
that's why mine has a player_class which defines attributes and allows for inital values for a class so that if theres a new player, if you get to the stage where you have multiple save files, you can easily start a new game with a player class
glad you know oop
im gonna stay online, try to impliment the oop
also get a github, makes it easy for others to easily work on your code with you
i've made one, ill have to learn how to post to it xD maybe should of started with that to make things abit easier. Cheers bud appreciate your time.
hiya
so uhh
whats a good guide for pygame?
i cant find a decent on
e
ive tried going into the docs and make just a simple rectangle that moves left and right using the arrow keys but the docs are confusing a bit
I think the Pygame Community discord have gathered a lot of resources.
can anyone help me with this one?
please make it simple it doesnt matter if it doesnt work.
import random
xmen_array = []
random_xmen_array = []
print("Welcome to the x-man battle simulator")
for i in range(2):
random_xmen = random.choice(xmen_array)
random_xmen_array.append(random_xmen)
print(random_xmen_array[0] + " is battling " + random_xmen_array[1])
Idk
but is this what your looking for???
ngl D.O.G. track very good
made my game 10x more fun
Music by DM Dokuru: https://www.youtube.com/watch?v=wjOj_6cMGEY
https://www.youtube.com/watch?v=3UtURionlvU
https://www.youtube.com/watch?v=-Syn1mJVt7U
booooooleeet hell
i legit made those 6 attacks
using the same attack function
and just some minor number changes and maybe like 1 line of code addition on avg per attack
C:\Python\Pygame\Ms. Martin Game>py main.py
Traceback (most recent call last):
File "C:\Python\Pygame\Ms. Martin Game\main.py", line 1, in <module>
import pygame, time, random, sys, numpy
ModuleNotFoundError: No module named 'pygame'
anybody else tends to get these errors by chance?
the module is installed bt
very cool, was the 3d effect with the triangle attack intentional?
Nah LOL
are you sure you downloaded proper version? I mean sometimes happens that you download 32bit instead 64bit pygame and so...
i have the correct version
I figured it out btw
it's because i have both python 3.10 and 3.9 installed simultaneously
yeah i had pretty similar problem with tkinter few months ago
What courses, pages, and videos do you recommend for ursina?
https://replit.com/@G1NGERN1NJA/BlackJack#main.py
I got bored so i made black jack
what is the biggest python flaw for game development?
Looks good!
well, python doesnt need to be compilated externaly - that does mean its sort of compilated when you run the program and that significantly slows the program compared to compiled languages as C++, C# etc.
i already knew that, but, is that it?
yep, its pretty big problem for bigger games, python is useles for making some sort of professional games, but for small games made by one person it should be completely fine
The line there might be a little more blurry, but it's at least somewhat true
i mean maybe for games which have like 0 stress on computer than maybe it has some use
Anyone here interested in sharing their game concept? Bounce ideas around?
I mashed up Robotron 2084 with Conway's Game Of Life @scenic dome
@round obsidian: Do you shoot gliders at enemies?
Oh wow it really feels like a retro gaming! (Except for the fact that no 80's atari rig could do that.
Do the enemies interact with the conway also?
my game concept is jsab except no music sync
wow thats soo cool
Hey @void ivy!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
what does : AttributeError: partially initialized module 'arcade' has no attribute 'Window' (most likely due to a circular
import) mean?
Share the entire stack trace?
Or share something here : https://paste.pythondiscord.com/
Did you by any chance make a file called arcade.py?
i dont think i did, I'll share the code if u want to have a look at it
I'm waiting
what do i do after i have pasted it?
You press the save icon and paste the url here
The error message you got is confusing though
What sort of game engines is there for python these days?
My go to is ursina
Of course its only on windows and linux XD
at least is't windows exclusive...
3D: Panda3D (low level), Ursina (high level)
2D: PyGame (low level), Arcade (high level)
what all modules are good to use if i wanna create a simple game(2D)
started working on a simple game engine for ascii graphics, opinions?
I'm toying with that as a possibility, they already do to a limited extent.
I haven't had time to work on it recently as life got very busy.
Arcade or pygame I would guess #game-development message
yo im making an SOS game sorta like tic tac toe using tkinter, does anyone know how to make a dynamic game board using user input?
make the board be returned by a function
use the board values be arguments so that everytime the board is created, the values are different and dependant on the values being passed as args
like this
def board(1,2,3,4,5,6,7,8,9):
print(f"|{1}|{2}|{3}")
print(f"------")
print(f"{4}|{5}|{6}")
print(f"------")
print(f"{7}|{8}|{9}")
then when you call it, the values will be dependant on your value states
like if the player selected 1, 2, or 5
That's cool
pygame is the best, SDL2 is a C (c language) library for graphics and visual software. Pygame is a native wrapper for SDL2. I personally belive that SDL2 and pygame are the best that 2d development has to offer
I was following tech with tim's paint app in pygame. How do I save a screenshot of only the grid area?
yall seen the new epic games app
realityscan
its so cool
basically you take pictures of objects and you can upload it to your game as a 3d model
pygame, or turtle is not bad
i donnu i hope it works for other stuff
but tbh that thing should've existed long time ago
the only reason i dont make games is the lack of models and assets
It has existed for a long time. There's lots of photogrammetry applications out there. But yeah, it's cool. Hard to make things that doesn't exist though
Ya i tried turtle earlier
usually, what is the best way to handle multiple levels in game? do you make a an "abstract" class, and when you need to load a particular level, create an object
How would you go to level two? Here's a simple example where you collect all the coins, then you get another group of them: https://api.arcade.academy/en/latest/examples/sprite_collect_coins_diff_levels.html#example-sprite-collect-coins-diff-levels
But depending on your game logic, that can all be different.
true, i'm making a 1943 clone, so my levels need a custom background, some randomly generated decoration like island for pacific themed levels, cloud cover, style of enemies stuff like that
it's a bit of a mess, but i'm working on it @frozen knoll
hello
Hey, can anyone help me?
I am making a 3d engine which is going on pretty well so far.
Currently I am trying to implement sphere and box collision. Can anyone help me how to do it? I can quite figure it out.
My implementation so far:
# Recieves a cube (c), sphere center point (c_center) and a sphere radius (s_radius)
def check_collision(c, s_center, s_radius):
center_distances = c.center - s_center
distances = c.dimensions + s_radius
if (-distances[1] < center_distances[1] < distances[1]) and \
(-distances[0] < center_distances[0] < distances[0]) and \
(-distances[2] < center_distances[2] < distances[2]):
return True
return False
I'm trying to create a basic space invaders game in Python, and I have ran into this error using pygame
Basically, I try to run it but there is an error trying to load the files from github.
My IDE is replit, and I need to know a fix to this problem.
lmao
my little game-server)
Hi, not even a beginner at game dev but in the unreal engine 5 keynote, I saw Epic mention python in their tutorial forum
quick google searches showed you can use python for scripting but not in real time
I have very little clue what that means, if anyone could tell me what this is about. cause it seems interesting
being able to use python in Unreal without messing with C++, if its true
I'm guessing python is more used on the tools and asset pipeline side. This is very common with productions dealing with lots of assets. Games, animation, film etc etc
yeah, the docs has no mention of "real time scripting" that ppl on reddit have mentioned
it does mention something about importing a module called unreal that can be used to link with blueprints just like how C++ does
can multithreading be useful for handle multiple enemies actions in a game?
I created a terminal based Pokemon like game. https://github.com/lxgr-linux/pokete
Hey I am new to python discord saw YouTube video what are the competitions that take place and how will I get to know.?
major competitions are Ludum Dare and Alakajam. You can find their dates on their websites. Other competitions like PyWeek also have the dates on its website. You can find other competitions on https://itch.io/ too
this is awesome
Thanks a lot
For that purpose I actually build my own terminal gameengine https://github.com/lxgr-linux/scrap_engine
oh thats neat
Thanks a lot
Hey @keen valve!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey @keen valve!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
would python really be great for a heavy story-driven platformer or a multi-path QTE action? if not, what language?
hello there, how can i save some variable data into my pygame project? DM me in private chat if u can teach me! 😄
@north bridge :white_check_mark: Your eval job has completed with return code 0.
Hello World
!e
for i in range(1,5):
print(i)```
@north bridge :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | 3
004 | 4
for K in range(1,9):
print(K)
!e x = 5
@sour cobalt :warning: Your eval job has completed with return code 0.
[No output]
That looks sick, libraries used?
Another sick project, libraries?
just wandering when pygame is better, and when pyglet
If you are fine with limiting the platform your game can run on because you need a gpu then pyglet and arcade are more than fine. These are able to draw a lot more graphics per frame. On the other hand... pygame runs almost anywhere.
You can do a lot with these libraries if you know how to write efficient code.
Thx a lot
My sister just started developing games And I want to help her
if you can guys Give me some tips to help her get started
Youtube pygame tutorials work for me, this one is very clear imo - https://youtu.be/FfWpgLFMI7w
Learn how to use Pygame to code games with Python. In this full tutorial course, you will learn Pygame by building a space invaders game. The course will help you understand the main game development concepts like moving characters, shooting bullets, and more.
💻 Code: https://github.com/attreyabhatt/Space-Invaders-Pygame
🎥 Course created by bu...
Hi can someone explain me why it's still saying that pygame "could not be resolved" even if I download it ?
thank you
so much
Only pygame (and some other basic libraries like random and math etc.)
@ornate blade
Take a look in the console, you'll see that the 2 in 2 cards is yellow
I'm super proud of it
I can tell. The code looks like some real effort was put in.