#game-development
1 messages ยท Page 86 of 1
It supports every programming language but that version is not officially out yet.
oh it does?
When it's out you can simply download the python support someone added from the asset library (directly in the godot editor): https://github.com/touilleMan/godot-python
someone told me about blender
I know how to use blender
but I don't know how to create a game in it
@glad oak you could check out Ursina
I check that but that's not what I want
Then you should be a lot more specific
There used to be a game engine for blender
This is now a separate project : https://upbge.org/
@glad oak I assumed you were looking for something related to python since you are asking the question on a python server. If none of these fits what you are looking for you need to be more specific.
ya I heard that
but accually I want to make a python server for my unity game
because of python libararies like tensorflow
Can you recommend pygame course(video or text format, both are fine)?
Hey @meager fable!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
https://paste.pythondiscord.com/marowegici.py
does anyone know why nothing is displayed when the OPENGL flag is included in display? (line4)
?
Hey!
Anyone here who is willing to contribute to this open source module? https://www.reddit.com/r/Python/comments/my47xe/pyunity_a_python_implementation_of_the_unityengine/
Checked it out and it looks really good, I'm not a really good coder so I can't help out much but I'm definitely going to follow its progress. you should try posting this in other coding discord servers as well, might grab someone's attention
Yea. I am posting in many servers. We also have a discord server, if u wanna join (pls tell me if this is known as self advertising I'mma delete it)
I'm good, appreciate the offer though! not sure if its classed as advertising might wanna check with the mods
Yup. That's why I included the bracket
Update on my lottery game: Finally got the start button to work and i added a gradual decrease of speed until it finally stops
Now i have to add like
some christmass like light stuff
like a blinking feature
i will work on that tmrw tho
gn!
@sinful lodge You might look at http://programarcadegames.com for pygame. Or you might like Arcade, which is at https://arcade.academy and https://learn.arcade.academy
Looking for a dedicated individual to help me complete my game
LMFAO
how do i implement the a* search algorithm for search finding in pygame, because its not tile based
Make your game tile based I'd say ๐
hello..?
hello
can we make a game with optional mods in pygame?
like a specific file extension that can open and load a mod in my game?
Pygame doesn't have anything like that so, you should make ot from scratch.
Ohh alright
imo arcade is a better library
Does anyone know what is the main programming language used to create a DNS?
Is it beginner friendly?
It's about the same as pygame
๐ oke
@tawny crystal always has been
[RequireComponent(typeof(PlayerMotor))]
public class PlayerMovement : MonoBehaviour
{
private PlayerMotor motor;
public float speed = 5f;
void Start()
{
motor = GetComponent<PlayerMotor>();
}
void Update()
{
float _xMov = Input.GetAxis("Horizontal");
float _zMov = Input.GetAxis("Vertical");
Vector3 _movHorizontal = transform.right * _xMov;
Vector3 _movVertical = transform.forward * _zMov ;
Vector3 _velocity = (_movHorizontal + _movVertical).normalized * speed;
motor.Move(_velocity);
; }
}```
I can't understand what's the error in here
I am using Unity and C#
Hi guys ,I found this on the internet ,I think this is from cyberpunk, planning to create a game like this a freerunner infinite racer,anyone interested?
hey can anyone help me out with a programming issue I'm having? I posted my question here: https://stackoverflow.com/questions/67757967/getting-an-winerror-10057-in-my-python-multiplayer-game-using-pygame?noredirect=1#comment119766277_67757967
hey everyone
i've a prblm
i'd like that if we let press on the "d" (this is the button to moove on the right), the personnage in my game forward continuously. My problem is that i need to spam d to forward and it's annoying.
mention me if u have the answer
Use tkinter or pygame
It's a library for developing 2d games with python. But you could also use it to create a GUI.
Quick Noob Question Alert:
Essentially, I want to randomly generate a set of four ability scores.
I have written a function that does this.
When I set the variable
mystats = generateStats()
every time I run this, mystats is overwritten with the newly generated stats.
is there a better way of making that rolled set persistent?
Ex: would savedStats = mystats.copy()
make a copy of the stats that were rolled and ensure it isn't overwritten? Or will it still be overwritten every time?
Or...is it better to export those stats...to a file perhaps, that can be read later to grab said stats when needed?
I considered, an alternative of a lambda that runs only when called...I think thats how they work....
https://github.com/The1Divider/chess if someone minds taking a look at this, im hitting the max recursion depth after trying to move a pawn and I can't seem to figure out why (altho im not suprised it's a bit of a mess atm)
Hey guys I wanted to ask a general question so sorry if the scope is kinda broad. I am trying to make a simple platformer with a friend and have some python knowledge under my belt and have been using pygame to create my idea. I have been using tutorials which I feel kinda guilty about since I feel like im "cheating" or something and feel like I should be able to figure it out myself even though ive never done this before. I dont want to make tutorials my crutch and be self dependent but dont know how to go about it? Also to make games is it better to simply throw myself into a new language such as C# with Unity or use python so that way I can use it for all types of projects such as web scraping and other things. I just feel unsure and thought someone whos done this before me would have advice. If you have read this far thanks for the time and sorry itsvery long! ๐
The best way I've found is to watch a few tutorials when you're first entering a subject and then if you have a more specific question you look it up; avoiding tutorials is fine as well
Yeah that sounds good too, for me with this platformer I found a series but I never know how heavily to rely on it because sometimes I feel like im not learning but rather like just grabbing pieces of it. I think trying to do more independent stuff might be smart like you said a few tutorials and then specific questions later. Like for a platformer look up like tilemaps and movement or what basic videos would you think?
Coding with Russ is a channel that i watched, it helped me understand the basics easier but as i said a lot of this stuff its just soooooo much better to learn individually; but tutorials for general knowledge and new topics yeah
I'm working on a snow-themed game, I want to add spider-man style swinging with some elasticity but I'm not sure what to search for math wise. If anybody has a good module / guide I'd appreciate it.
for learning individually you mean like on your own or like individual piece by piece of a project? but yeah new topics fs
i've tried using kivy before to make a lightweight graphical project
but after compiling it, the resulting program took a lot of space
is this specific to kivy only? should i try a different framework?
or is it because of how python runs things
how do i make an entity spawn only if its chosen, and it would be chosen at random from a list
@dawn jolt If you want to make a GUI application that has a modern GUI I would recommend PyQt5 because of its style that can be changed using CSS, if you want to make a simple GUI application I would recommend Tkinter if you want a simpler version of Tkinter you can use PySimpleGUI, let's just say PySimpleGUI is a simplified Tkinter
PySimpleGUI docs : https://pysimplegui.readthedocs.io/en/latest/
None
can i use it for game development?
specifically where i need to compile it
for that I don't really know, because I usually create a GUI in games using pygame itself.
in the pysimplegui repository they gave an example of making pong games using pysimplegui
how do i check line of sight between two points in pygame?
hey guys i try to import a file with this :
import os
os.system ('/home/pi/classes.py')
and I have this error : /home/pi/classes.py: 1: /home/pi/classes.py: Syntax error: "(" unexpected
someone knows why ?
I don't understand, do u want to know the coordonnees ?
this is python server not C#
joke please i swear
It's a Game Dev channel so I can take help with Game dev no matter which lang I am using
does anyone know if its possible to embed a pygame window into another gui framework eg tkinter?
without using virtualbox and google colab, does anyone know how to convert kivy into an APK?
Jesse is better
actually no this is a python discord which means EVERYTHING (except ot) revolves around python
!ot for other off topic things
Off-topic channels
There are three off-topic channels:
โข #ot0-psvmโs-eternal-disapproval
โข #ot1-perplexing-regexing
โข #ot2-never-nesterโs-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
such as unity questions
i've never really tried to compile kivy to an apk, but i've never heard of using virtualbox and google colab
there's a tool kinda like pyinstaller for compiling kivy to apk
Any beginner down to work on a pygame project with me
I am a complete noob in tutorial hell and want to get out but I feel it would be easier to do so with the help of another
Even if it's only to brain storm ideas off one another
Maybe py and python use different python versions?
just run the script with python and see if it works
maybe?```
py --version
python --version
No worries. pip can also be a source of confusion so it's also safer to run it through the same python command python -m pip install <package>
yup
will do
so I'm looking at this sorting algorithm visualizer that I found on github
It gives a white screen instead of what it's supposed to do
is it better to use rectangle or sprite for gui in pygame?
Ok friend
@dawn jolt could you please tell me what this tool is?
oh wait you're not using linux?
you've probably looked at buildozer right?
yes
buildozer only works on linux unfortunately...
oh no its fine.
Guys how do i add a 'glow' to my sprites in pygame ๐ค
ive seen youtubers do it for their games in unity
am working on a new game ๐
its going to be a maze game
the lighter shade of tiles are indistrcutable
and the darker shade are breakable by shooting
:D
am going to make it such that the map moves with the player
so like
instead of players position increasing
i will just append more tiles to the map while deleting few
so for example if he moves to the right
world_data.remove(left column)
world_data.append(new_right_column)
O.o
wow
But jesse crying is not nearly as entertaining
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:
you can make an invisible line, and see if it collides with something
i already found a better solution: pygame.sprite.Rect.clipline
just blit the line based on where the user is facing
oh i see
so
can u
uh
help me
.
you didn't include any of the assets in the website, so i can't run your game
i just wanted u to spot any obvious errors
i mean
i can give the assets and all
but do u really want to run it
i can't really spot any errors from just looking at the code
maybe instead of repeatably rotating the same image, try just rerotating the same image
maybe that will fix any loss in precision?
so you already aren't doing that
ok
i don't think i can help you because i am short on time rn
I can help
Is java scripting ok in this discord.
guys i set up Pycharm but i don't know anything about python and i want to make a multiplayer 3d game so i heared about ursina engine but don't know how to set up it so now any help lol thx for reading !
Learn basic Python before you attempt to create a 3D game.
I just got the mission game book thru humble bundle, and I'm in the beginning where you set up the background and stuff. For some reason, even when I use the exact code as written in the book, my pygame window has a chunk of blackspace that cuts off the picture(s). Anyone worked with this book and know what I am talking about?
Escape game*, misremembered the name
Due to the way pygame renders things (via surfaces), the rotation function resizes the surface causing a shifting center. When it blits the image the center is rounded and since it's constantly changing it wobbles a bit. Fixing this stuff is annoying and pygame is really weird so I would recommend just using arcade instead.
i actually just ended up making it a feature lmao
by adding the same wobble as idle animation haha
but the idle wobble is up and down
Arcade does not have this issue because it renders with opengl which does not do this whole surface thing with resizing while rotating, in general it will save you headaches by switching to it (also, speed). @dawn quiver
or i could just use opengl
lmao
I am trying to make a 'game' sort of a thing for a Machine Learning project of mine. I want a python module that can handle physics, collisions, IK, hinges, sprits, and forces (especially IK). What modules can I use?
Hi, Really difficult question.
I am looking for 3 files all over the internet but I cannot find them. Is there anyone who can help me? The files are:
CrystalReports11_rdc_license.msm
CrystalReports11_rdc_reportengine.msm
CrystalReports11_rdc_runtime.msm
Hello, I'm trying to recreate flappy bird
using pygame but when the pipes move they appear very laggy
as they reload in their new position
Is there any way to fix this?
yes :P
ok
i need help
iss cool you can go first
i use a udemy course for the python part and brilliant for my animation
in game dev obviously
i see
hmm
yes python isnt in any games ive seen so this is rare...
i would take a udemy course
they have courses for all aspects of a game
but ususally only some parts are used for a game
because like it is only python is rare
yes
its 189 usd but well worth it in my opinion
think it was 24 during last week
but it updated
ah
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
?
maybe theres course info in the tools/refrences
hmm
@dawn quiver See https://learn.arcade.academy and https://arcade.academy
thanks mate
yoo i finally got a moving background and all to work!
# Player
key = pygame.key.get_pressed()
if key[pygame.K_UP]:
idle = False
world_data.insert(0, [1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1])
world_data.pop()
print(world_data)
๐
Should I use Pygame or arcade?
Are you fairly new to python?
.. and what are you hoping to make?
Yeah I am.
2D game
Alrighty
Hi i rly need help with my game. I Have made a Menu and a Game but the button that says start I need it to start the game. Same with the exit button I need that to close down the game.
More context needed. Like what are you using to draw your game and buttons?
I'm trying to make a Defender game (classic arcade game), and struggling with the wrapping
I have a surface than I'm scrolling through with a viewport and I want it to wrap smoothly from right to left or left to right. But that transition from one end to the other is not smooth
So I think I need to copy my surface and have two of them in a row
So at the end of the first surface is the start of the same surface and the jump back to the actual start will be smooth
I really don't even need the second surface to be a complete copy of the first, only the first SCREEN_WIDTH pixels of it
Same on both ends, I suppose. A copy of SCREEN_WIDTH pixels from the right placed on the left and from the left placed on the right
Pretty new to this kind of thing, coding a viewport and using multiple surfaces
Any experienced MOD, with super coding skills? DM me immediately
Hi, I just fixed a error in my very basic code. I was hoping anyone could explain why the error occured.
I got a "video is not initialized" error, and the fix to that was to move "pygame.quit()" from the while loop into the if statement (in the same loop).
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.
Dont mind me, I just realized how stupid I am ๐
put pygame.quit outside the while RUN
What would you have said if he said no and 2d game?
Infinite circular scrolling and player movement pretty well worked out, I'm learning! https://pasteall.org/d4Qr
Next, I gotta dig into pygame sprites
How to add sprites to lists and use the collisions
Pretty hacky way to do the minimap but it works. Just triple it, all three side by side, then scroll it using the offset and use two black rects to cover the parts outside of the minimap
Actually, the same kind of trick is used for the main screen to get it to wrap nicely too
Scale the actual playing field, 9720x512 pixels, to 480x88, put three of them side by side, and scroll it properly = minimap
No drawing blips or translating or converting, just scale the entire surface
I'm not pleased with the mismatched aspect ratios of main player screen and minimap, but from what I could tell, that was pretty close to the original
You'll have a lot more options. pygame, acrade, pyglet, cocos, wasabi2d .. and the list goes on
Even ursina/panda3d
The reason I recommend arcade to beginners is that it's a project created for learning and has a lot of official examples and tutorials including a book
I am trying to do something stupid.
I am doing this to get the keys
keys = pygame.key.get_pressed()
ball.update(keys)
So how do i type hint in the definition of update method?
where can i ask questions i am a beginner
look in the help channel if it is about a specific thing
look in to #โ๏ฝhow-to-get-help
and can i ask if creating games need gpu??
if you read it you'll get an better idea what can be asked
which is almost everything
it depends
bc i can not buy a gpu it"'s expensive
what games are you making?
if you are makings game with python. you won't need it most of the time
ohhhhh
it depends more on the game
i am working on a big big idea bro i think i'll go viral bc of it
i am a creative person but now i just started learning python language and how to use it in spyder ide
can you program well?
if not just get started, right now.
i use to work on small basic\
yes, solidify your basics, learn a new language. then you'll get a grip of programming
then start with your project
It won't mean anything if you don't start though.
so just keep going
check out
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
thx man but can i ask one more question about which course or where did you train or study python
ahhhhhhhhhhhhhhhhhhhhhhhhhh
thx buddddyyy
which ide you use?
you don't need to buy courses though, youtube is great, the internet is endless, guys here help out
IDE doesn't matter
i use neovim, not an IDE just a text editor
sure it is, but how long is your code going to be to need a tools which are tightly integrated, which are made for large code bases
python is an interpreter, neovim is a text editor
games need a lot of large codes
yes.
I am not saying that IDE's aren't for small code bases, but they get in the way
and character designerfor games and these stuff which software i use?
what type of game are you thinking?
3d, 2d, board game
Fusion360, Blender
FUSION360???
just ducked them
Yes, Fusion360
Isn't it for engineering models?
Models of any kind
dad, those games look like they are 2DD
yeah i think so
Okay, i didn't expect that out of fusion360
you can use gimp
my pc is under construction so i am using now window 7 it works on it?
sure any thing which works
omg thx everybody
just don't forget to start programming.
Character design for games will usually mean 3d characters even if used in a 2d game
and @past star please don't use sypder
i am hopping into youtube to check a bald man teaching python
those games looked like sprite art ones
what should i use remind me
this summer i'll end up gettting a job even if i am 15 ill work harder to full the bg
bag*
Like I'm making a 2d game now, and have made others, where I used 3d models (for proper lighting) and rendered them to sprite sheets
how mant games have you created
Hmm, maybe a couple dozen
what isdozen?
Dozen = 12
So maybe 20-30 games
have you uploaded a game n playstore?
are they online somewhere i can take a look?
Nah, just some Python games for the past few years
Some I made in Blender
Blender used to have a game engine built in
And was pretty good engine

Still is but it's no longer a builtin, it's an addon
have you created one?
i have made maybe one or two, i am not as much of game maker
Most of my games are simple, like Tic Tac Toe, some more complicated like Cribbage (a board game with cards), some are shooters like Asteroids, some are pong-ish like Arkanoid. Now working on another classic arcade game, Defender
Some are very complex, like Rubik's cube animator/solver
Blender doesn't have a learning curve, it has a learning mountain
But it's unmatched in 3D modeling
like this?
Like there are other modelers out there, they cost an arm and a leg, and they're really not any better than Blender
but guys i can't start coding if i didn't get morenowledge so i don't think a 6 hours course will help
don't think
just go with a youtube video you like about a topic
like search for "make a game in python"
then they will mention something you don't know about
like functions, then search for "functions in python"
then keep going like this
if stuck ask here
i mean look here #โ๏ฝhow-to-get-help
Defender progress so far, you'll need pygame installed, use the arrow keys to for movement: https://pasteall.org/fNEe
umm guys if i am coding and i wanna see if it worked or check the game without upload it and reinstallet
Game mechanics pretty much done, now to add sprites and collisions and firing bullets and enemy types and humans to rescue and ground and...a lot
What do you mean?
The enemy behaviors are scaring me, coding AI behaviors is tough
it's like i just put a new item in the game i wanna see if the item is actually in the game that i am coding
You can just run the game
You code on a computer that can run the things you make
As i said, you need to start. Questions will form, answers will come
thx a lot you're good guys
The AI behaviors here: https://youtu.be/gss3lxeqCok?t=424
โบ Defender (Red Label) 1980 Williams.
Subscribe:
http://www.youtube.com/subscription_center?add_user=MamePlayer
Visit my channel:
http://www.youtube.com/user/MamePlayer
Browse my videos:
http://www.youtube.com/user/MamePlayer/videos
Browse my playlist:
http://www.youtube.com/user/MamePlayer/playlists
My videos are made with the use of SaveS...
You doing this in python?
Yes
Got the mechanics worked out for how things move
It should be fairly easy-ish to complete
Just take it one bit at a time
Mine probably won't be exactly like that, but a reasonable facsimile
ayo bro
sublime
needs pythonto be installed
or what
i needto know better about these little stuuf
stuuf*
I haven't used Sublime but perhaps it's like those I have used. It might ask you during the installation to point it at your Python installation so knows what interpreter to use
So yeah, I'd install Python first
i installed python
Good
thx buddy
And you should, during that installation, be sure to enable the python to path thing
There's a tickbox for that in the Python installer
That way your whole system points at your python installation when it encounters a python program
should i use the newest python version?
Yes, unless you have some specific reason to use an old version, always install the latest
I don't think it's totally necessary to download the latest every time there is a release, but you always want to be within a few months of the latest version
window 7 require the 3.8
That might be an issue for you, yeah
Windows 7 is a problem, it's not even fully supported anymore, end of life
Windows 7 is that specific reason I mentioned there
Or one of them
Just use the latest you can use.
And never use python 2
Added player blip to the minimap, progress!
so like
every time i feel like quitting my game
i end up reading a game dev chat
and feel like doing it again
;/
ima properly stop now
You can do it
bro do not stop what you have been strated
Did you check out my progress so far? I like it!
you can do it
What doesn't kill you makes you stronger, especially when it comes to tough codes
the future is wating for you
you need to full the bag
money is the best thing existed
without money you cannot do anything lol
what game should make to train
Asteroids
tic tak toe
That's another good one, depends on level. Tic tac toe for beginner-ish level, Asteroids for intermediate-ish level
is tic tac toe easy?
Asteroids is good because rocks don't need AI
or theres alot of typing?
i made a game wghere you have to avoid cars
but it was mostly word for word from the tutorial and by the end i ctrl c ctrl v the entire code cuz it didint work
eeeeeh
Nono, thats not the problem, im saying im bored of it lol
the game im working on isnt very fun
That's ok, having the interest to even copy and paste should motivate you to try learning from it and in that regard, it's ok to copy and paste, just make sure to learn from it!
k
im just
gonna revise my web automation
start ML
and continue my web dev
i find those more fun
thats
not good
theres no point
Tic tac toe can be done with a UI in less than 150 lines
and dont say you made it
because its not your code and theirs nothing original about it
you need to read the docs, or pick up an article, or use tutorials only for certain concepts
theres no point if you watch the tutorial for the entire game
well how am i supposed learn pygame if i didnt know anything about it
first understand how the fuck something works before making a car game
understand how a jump works
watch a video on it
then try doing it
or just think for 2 min
That's exactly how but just make note of that when you tell people that you made a game
chill dude
"Hm.. so now that i have a window open... how would something move on it?"
Then you will learn to blit an image to the screen with google
I usually credit those I get ideas from
then you will use ur brains to move the image on command with keypress
and slowly
you will make your way to bigger projects
im just gonna stick to discord.py or other stuff
well
thats your choice
Like you learn how to do something by seeing how it's done. The learning part comes when you can actually do it yourself and understand the concept and can do it without looking up how it's done
I still have to look up a lot of how it's done, because people have worked out these things and I don't yet know them, like methods of a module. I have to look up everything with pygame methods at least a couple of times
Because I don't know it yet
But I know the concepts since I've been making games for a long time
Wanna see my tic tac toe code?
It's one of those games that's a lot easier than many would think. All 'innings' are the same...one player places an X, the other player places the opposite of X. After each turn, check for win in rows, columns, diagonals, or a tie, repeat
And it's a good intro project for OOP and using a class
Making each of the grid squares into objects with attributes and methods, like how to draw themselves and what to draw
The entire class for grid squares (Spots) in my tic tac toe...```py
class Spot:
def init(self, x, y):
'''
Spot objects will be drawn to the screen at the cartesian coordinates of self.x and self.y.
Reads global constants to determine size and where to draw self relative to self.x and self.y
'''
self.x = x
self.y = y
self.value = None # used to determine whether self is an X or an O or nothing
def show(self):
if self.value == None:
pygame.draw.rect(screen, WHITE, [self.x*wr, self.y*hr, wr, hr])
pygame.draw.rect(screen, BLACK, [self.x*wr, self.y*hr, wr, hr], 2)
elif self.value:
pygame.draw.line(screen, RED, [self.x*wr+20, self.y*hr+20], [self.x*wr + wr-20, self.y*hr + hr-20], int(width/30))
pygame.draw.line(screen, RED, [self.x*wr+20, self.y*hr + hr-20], [self.x*wr + wr-20, self.y*hr+20], int(width/30))
else:
pygame.draw.circle(screen, BLUE, [self.x*wr+wr/2, self.y*hr+hr/2], hr/2-20, int(width/30))
let me chgeck you tictactoe
So I use the Spot object's .value attribute to determine if the square is empty (None), or an X (True) or an O (False)
And note when I check for wins. Not once in that code do I check if something is an X or an O, all I care about is if they form a row/column/or diagonal of equal values
One side-note, and the row/column or diagonal doesn't have a None in it
Equal but not None
the code is notbuilding
Not building?
they tell me this
What?
[WinError 2] The system cannot find the file specified
[cmd: ['py', '-u', '']]
[dir: C:\Program Files\Sublime Text]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0]
[Finished
That's weird
There's nothing VSC specific about it and it loads nothing
Beyond imprting pygame and sys
But I just copied and pasted it into VSC and it is messed up, let me try the other paste site...
!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.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.
i ll use another ide
Yeah, that's weird. I'm getting some unwanted characters from both sites, pasteall and hastebin
โ
โ
Yeah, it's an escape character
Never saw that happen before either so not sure why there are escapes on every empty line in VSC when copied from one of the pastes sites
Ok, so that might be happening to all the codes I've been posting
On those sites
And I don't know why
Well, they're easy to remove by selecting one of the bad lines (double click it) then select all occurences and backspace them
But still don't know why they happen
Until I do know, I'll stop using them
the most minimalistic jump code incase anyone interested:
count = 0
i = 0
LIST = runRight
while run:
clock.tick(fps)
count += 1
# Key inputs
key = pygame.key.get_pressed()
if key[pygame.K_RIGHT]:
x += 3
LIST = runRight
if (count % 30 == 0) and (i < len(LIST)):
i += 1
if i == len(LIST):
i = 0
if key[pygame.K_LEFT]:
x -= 3
LIST = runLeft
if (count % 30 == 0) and (i < len(LIST)):
i += 1
if i == len(LIST):
i = 0
if key[pygame.K_UP] and touched_ground:
jump = True
if jump and (dy >= -10):
dy -= 1
else:
jump = False
touched_ground = False
if y <= HEIGHT-150:
dy += 0.5
else:
if touched_ground == False:
dy = 0
touched_ground = True
y += dy
screen.fill((25, 25, 25))
screen.blit(LIST[i], (x, y))
hey everyone, this is my code :
from tkinter import *
fenetre = Tk()
fenetre.title("Leave ?")
fenetre.geometry("220x80")
texte1 = Label (fenetre, text = "Are you sure to leave ?")
texte1.pack()
bouton1 = Button (fenetre, text = "Yes")
bouton1.pack()
bouton2 = Button (fenetre, text = "No")
bouton2.pack()
fenetre.mainloop()
i want that when we press Yes I leave and when i press no, nothing happends
pls help me ๐
https://youtu.be/C-FV4NOFjnU
Snow themed game I'm working on, I was hoping to make the game snowier but it starts to lag having that many entities loaded, I was wondering if anyone knew of a blender rendering trick to prerender a bunch of entities in a 3D space for use in a game
A demo of a game I am developing called snowfall, written in the ursina engine using python. https://www.ursinaengine.org/
bro it's insane
it's a motor for video games on python
bro u are incredible juste wow
Ahh, I don't want to rewrite it in a 5th engine heh I already did it in pygame in 2D and got the snow rendering in 3D OpenGL
(OpenGL demo below)
I played with a few others too but Ursina was really user friendly
i just know the bases of python, is it easy to learn ?
https://youtu.be/uUc370bLUJo
Pygame
Yeah python is one of the easiest languages to learn in my opinion.
i'm not bad in pygame tooo
is it ur creation ?
The game is, I haven't written any engines myself. That one is written in pygame but pygame is pretty slow
wow i watched the teaser of Ursina, it looks good
It's an awesome engine
I'd recommend it for any beginner wanting to make a 3d game
It has preset control schemes for fps, racing, and other genres
A bunch of included models and textures
And it's pretty fast for being python
okay
can i just ask u ur help
i have a problem with classes
look :
for the moment, i just write the script for the mooves of mario, here, my classes :
class mario :
def __init__ (self) :
self.Mario_jump_left = mario_saut_gauche (fenetre, Mario__saut__gauche,y,x)
self.Mario_jump_right = mario_saut_droite (fenetre, Mario__saut__droit,y,x)
self.Mario_normal_right = mario_normal (fenetre, Mario__normal__droite,y,x)
self.Mario_normal_right = mario_normal (fenetre, Mario__normal__gauche,y,x)
and when i start the script, the events don't work (the d key for go to right, the q key to go to left and the key z to jump)
so i decided to just forget the classes and i just done the functions without classes
and it works
but i just want to know why when i use the classes, the game does not work (tell me if i did error in the class)
I know taht classes are really important so i really want to know what's my error
Can you post the full code on github? I can't see the issue here
yes but i'm french so the functions are in french ๐
i will send u the code with the classes
Hey everyone, im a Computer Science student and I am looking into entering game development when I graduate. I know this is a python server but which languages do you guys recommend to start learning for making games?
Ill give it a try thanks man
Don't forget Arcade as an option. Lots of examples: https://arcade.academy
hi
I'd never heard of arcade
That's super cool
I love the cave generation example that's cool, I'm gonna write a blender plugin that does that to make 3D mazes
I saw that pygame 2 is out, should i try that instead?
For game development? Might look at https://learn.arcade.academy to step you through it.
hey guys i made a .exe game file check it out please
Hey @formal fable!
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.
Feel free to ask in #community-meta if you think this is a mistake.
ok
i think you could use if statements
You shouldn't post executables anywhere, not just here.
I would say
Does anyone know how to use pyopengl?
What is the best python game engine?
what is it?
If your talking about what pyopengl is, itโs an OpenGL wrapper for python. In the case of your question, I think organelle is the easiest to get started with but pyglet is also pretty good
what is an open gl?
sorry i'm a beginner ๐
what is better pygame or python arcade library?
wich game engine is the best for python?
ok thanks
start with learning python, THEN do what you want
also, godot has a completely different langauge built in so you'll have to learn that as well
@midnight heart if you are starting out, you might want to look at https://learn.arcade.academy
ok thank you
but can i program in python with pygame on godot?
or with arcade librery
Nope
You don't need to
Learn what is needed for making a game with pygame.
Then, if restricted by it, venture for godot
ok thank U
๐
I have shooting, I have scrolling, I have enemies (1000 of them for testing), I have particle explosions, no lags
Twinkling starfield BG
Getting there
Going to need a lot more content, too
Enemy types, enemy behaviors
Level setups and endings
Already feels like playing the original game though, just zipping around blasting those dummy badguys
They won't be dummies for long
They gonna start shooting back, too
All enemy types added, and their art: https://pasteall.org/media/e/9/e91d23a76422214814dfa5cfee1516f4.png
what's it
i have a problem here. can someone help me?
What is the problem?
when i open it. thz game crashes after 5 secs
Is there an error message?
Hey @obsidian nexus!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
No idea, sorry
I got perlin noise proceduraly generated terrain working
Nice
pog!
are you having a while loop inside your game besides the main loop
hi
hi
can i get help for godot here?
You might try the godot discord to get godot help.
if anyone's interested in a very different kind of game dev - hello, MUDs! https://www.patreon.com/posts/52198824
is there any good tutorial for pygame ?
or
is there any good tutorial for making games with python ?, i don't care what is the library i just want to learn making games but i don't find any good tutorial
Here's two:
For Arcade: https://learn.arcade.academy
For Pygame: http://programarcadegames.com
If you already know how to program, you can just look at example code.
Hope that helps.
getting this error
PS D:\Projects\Coding Projects\Python\Game> python pgame.py
Traceback (most recent call last):
File "D:\Projects\Coding Projects\Python\Game\pgame.py", line 7, in <module>
x=window.width//2, y=window.height//2,
TypeError: unsupported operand type(s) for //: 'property' and 'int'
for this code
import pyglet as pg
window = pg.window.Window
label = pg.text.Label('Hello, world',
font_name='Times New Roman',
font_size=36,
x=window.width//2, y=window.height//2,
anchor_x='center', anchor_y='center')
@window.event
def on_draw():
window.clear()
label.draw()
pg.app.run()
window is just a class, not an object
cuz you didn't create one
window = pg.window.Window <-- There is the problem
()

Hello freinds,
i was trying pygame for game devopment,
so i installed it in my mac and it installed perfectly,
but when i tried to make a pygame window with an image,
this happened,
why the heck is this distorted
pls help
How about in here...see the ground in this image? I'm really struggling to come up with a procedure to add random 'hills' to it
Maybe I pick a random pixel of that ground and elevate it some random height then pull those up next to it until it forms a hill
Oh that's really hard to work out since I don't want to make hills where there is already a hill
Hah, I kinda did it...
With this ```py
ground_group = pygame.sprite.Group()
x = 0
y = 1
while x < 9720:
g = GroundPixel(x, 580.0 + y)
ground_group.add(g)
x += 3
r = random.randint(0, 100)
if r == 0:
new_y = y
height = random.randint(0, 150) + 20
for j in range(height):
if j < height / 2:
new_y += 2
else:
new_y -= 2
g = GroundPixel(x, 580.0 - new_y)
ground_group.add(g)
x += 3
else:
y = -y
It's not quite the same alg as the original's ground maker but close
The original could do nested hills
How do I start to code a py.game
Well, I can share with you my version of tic tac toe, written in pygame, maaybe you can work through some of that
Really simple game, the setup is pretty straight forward as most pygames start the same way: https://pasteall.org/2khe
After that, you look for Tech with Tim on youtube, he has a vast collection on PyGame
I started this video, and he made a window
Im trying to press the arrow in pycharm to open the window and it wont work
Is there an error message?
No
`import pygame, time
pygame.init()
window = pygame.display.set_mode((600,300))
myfont = pygame.font.SysFont("Arial", 60)
label = myfont.render("Hello Cole" , 1, (255,255,0))
window.blit(label, (100,100))
pygame.display.update()
time.sleep(5)
pygame.quit()`
@limber veldt thats all it is
and it wont let me play it
Do I maybe have to add a configuration
That looks really fun to play, were you aiming for a retro look? If so you did an amazing job.
wait
are u saying that the pygame window aint opening?
u need to use pygame.event.get()
Hello! I'm looking at this piece of code
gl.glTexImage2D( gl.GL_TEXTURE_2D, 0, gl.GL_RGBA32F,
self._data.shape[1], self._data.shape[0], 0,
gl.GL_RGBA, gl.GL_FLOAT, self._data )
self._data is a numpy 3d array(created with np.zeros). how do opengl convert it to void* on the go? does it just take [i][j][k]?
this is a python thing, if I'd done the same thing in another language it would either crash or wouldnt compile
are n-dimensional arrays in python contiguous?
Yes (and I'm not sure what non-contigious implementation you have in mind - I thought contiguous was the normal way to implement n-dim arrays)
For a description of how they work, see Anatomy of an Array here:
https://www.labri.fr/perso/nrougier/from-python-to-numpy/
(and in general it's a very nice guide to numpy)
@proper peak normally in c/java etc. an n dim array is an array of arrays. That was ehat I thought, but numpy handles it differently.
not in c
?
a 2d array in cc int** arr = malloc(5 * sizeof(int*)); for(int i = 0; i < 5; i++) { arr[i] = malloc(5 * sizeof(int)); }
a 2d array = an array of pointers = a pointer to pointers
that's an array of arrays
if you don't do that, it would be contiguous
like int arr[3][3][2];
Hmmm, honestly I never used multi dimensional fixed size arrays. Thank you :)
@limber veldt have you tried perlin noise?
It's pretty good for procedurally generating terrain
Hey thanks, it's getting there and yeah, retro...the original was made in 1981
Thanks for the suggestion but no, it's just 2d line for my 'ground'
If I were to do a procedural 3d ground, I'd probably whip up a noise texture to use as a displacement map
Hello, I have just started pygame and made a window opener. What do I do next, because I want to make a starter game.
Tic tac toe is a good starter project, I think
It'll get you working on breaking down the logic and program flow
Asteroids or some kind of block breaking game also good starter project but maybe not good firstt projects
And, if you can, do the tic tac toe without looking for someone else's code for it
We all know how the game works already
Well, maybe what you do is make one square with a border around it then make eight more the same way, arange them on the screen and viola, grid
Another important part is getting mouse clicks or keyboard presses
And where mouse clicked, even more important
Because if we know where the click happened, we can do some pretty basic maths to know where on the board was clicked
And which grid square
If just starting with Python too, I'd suggest a functional code but if you know any python at all already, it might be time to dive into object oriented programming, OOL
Tell ya this, tic tac toe or any kind of grid game or game in general really benefits from being object oriented
Think of classes as object factories, once you know how to use them, they're very powerful
Stuff like this probably not even possible without classes: https://imgur.com/gallery/2uqVNjA
In that code, all those grid squares are separate objects. Each has a color at the start, and has attributes for which walls are True (yes, wall there) and whcih walls are False
And just a bunch of logic to generate and solve a random maze as fast as I could make it happen
The purpose of that project though was not to practice maze solving but to learn path finding algs, very applicable to games
is it ursina or pandas3d? although ursina is based on pandas, but i dont know if they use the same debug window
4 dimensional game
@heady pine Ursina, I really love working with this engine
This is what I'm making with it currently
Hah, look at that, completely recreated the enemy explosion
On the right, the enemy remains so we can see what it looked like before the explosion but look at those particles, same shape and size and velocities
Colors vary, but no biggie
That is badass
The original game uses a couple of different velocity patterns for the explosions, I plan to recreate them all but awesome that I got the test case working
looks awesome! ๐
Nice :)
And I worked it into a nice, clean bit of code for the particle generatorpy loc = [mutant.rect.x, mutant.rect.y] loc_y = loc[1] vel = [0, 0] rect_y_start = 0 vel_x = -8 vel_y = -8 for j in range(4): vel[0] = vel_x vel[1] = vel_y rect_x = 0 rect_y = rect_y_start loc_x = loc[0] for i in range(4): particle = Particle([vel[0], vel[1]], enemy_mutant, [loc_x, loc_y], [rect_x, rect_y, 5, 5]) vel[0] += 4 loc_x += 6 rect_x += 6 vel_y += 4 rect_y_start += 6
That makes all 16 particles
I always have to write all those particle assignments one by one before I can see the pattern and construct a couple of loops from it
Or anything like that
Next question...can I make them go in reverse to spawn an enemy
Yes, Just have to grab each of the particle positions after a certain amount of time then use those positions to recreate all of the particles with inverted velocities
So the particles have an age, when it reaches a certain value, the particle dies. When it dies, I print out the position and the velocity. Since there are 16 of them, I get a list of all of their positions and velocities
So now I just have to code a couple more loops with different values and determine how I'm going to kill them....I could just do the same and kill them after the same age
Since I'm using a constant FPS, that will work
Hello, is there any way to schedule aperiodic events in pygame? I want to have a sprite that essentially just has an onclick function that only runs when I click it
It seems like the current solution to this is to simply poll in the for event in pygame.event.get(), then if you get a MOUSEBUTTONUP event, check for collisions with the sprites of interest
But this seems really ugly to me
_
Is there no construct for asynchronous/aperiodic event handling such as click events? Something essentially like
btn1 = AClickableSprite() # A user-defined class that implements necessary "clickable" traits
pygame.events.AddAperiodicEvent(
condition=lambda: pygame.events.on_click() and btn1.wasClicked(),
response=btn1.clicked()
)
If this exists, that would be awesome. If it doesn't, maybe I'll write an issue
"scheduling" can be a complex thing, because since timing is involved, which process is going to be around to care?
I dare you to whip up a solution or hack in an existing scheduling system ๐
Well yes, yes I can
@next estuary I Want to get help and work with you in ursina engine I like your game's video
Please
This is
For any new game developers(or experienced), I stumbled upon this really well done video of a senior-dev refactoring a aspiring dev's console based Yahtzee game. It's worth a look. https://www.youtube.com/watch?v=l7E3y4te7sA
Learn how to practically apply design patterns and principles by watching this full code refactoring of a Python project submitted by one of the subscribers. I start with a thorough analysis of the code, discuss its strengths and weaknesses, and then refactor the code to (hopefully :) ) improve it.
The code I worked on in this episode is availa...
What do you guys prefer among visual studio and pycharm?
I prefer pycharm but I use sublime
make a multiplayer battle royale
Can we use Pytmx with PIL?
Nah I don't make shooters or anything where the goal is to kill someone
hey i need a game dev to work with me on a game
import pygame as pg
from pygame.math import Vector2
import math
pg.init()
screen = pg.display.set_mode((640, 480))
my_rect = pg.Surface((20, 20))
my_rect.fill((255, 0, 0))
clock = pg.time.Clock()
BG_COLOR = pg.Color('gray12')
point = Vector2(320, 240)
mouse_pos = Vector2(0, 0)
radius, angle = (mouse_pos - point).as_polar()
i = 320
j = 200
speed = 3
done = False
while not done:
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
mouse_pos = pg.mouse.get_pos()
loc = Vector2(i, j)
radius, angle = (mouse_pos - loc).as_polar()
x = radius * math.cos(math.radians(angle)) + 320
y = radius * math.sin(math.radians(angle)) + 240
vec = Vector2(x, y) - point
v = vec.normalize()
i += v.x * speed
j += v.y * speed
screen.fill(BG_COLOR)
screen.blit(my_rect, [i, j])
pg.draw.line(screen, (0, 100, 255), point, mouse_pos)
pg.display.set_caption(f'radius: {radius:.2f} angle: {angle:.2f}')
pg.display.flip()
clock.tick(60)```
That's a nice little piece of code
Enemy shooting at player in 2d? You'll need something like that
Gotta be a better way to do it though
And there is a better way
Much nicer, no need for angle```py
import pygame
from pygame.math import Vector2
import math
pygame.init()
screen = pygame.display.set_mode((640, 480))
my_rect = pygame.Surface((20, 20))
my_rect.fill((255, 0, 0))
clock = pygame.time.Clock()
BG_COLOR = pygame.Color('gray12')
point = Vector2(320, 240)
mouse_pos = Vector2(0, 0)
x = 320
y = 200
speed = 3
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
mouse_pos = pygame.mouse.get_pos()
loc = pygame.math.Vector2(x, y)
if mouse_pos != loc:
new_loc = (mouse_pos - loc).normalize() * speed
else:
new_loc = (mouse_pos - pygame.math.Vector2(x - 5, y - 5))
x += new_loc.x
y += new_loc.y
screen.fill(BG_COLOR)
screen.blit(my_rect, [x, y])
pygame.draw.line(screen, (0, 100, 255), point, mouse_pos)
pygame.display.flip()
clock.tick(60)```
I now have mutants who can chase the player along a wobbly path (making them harder to shoot)
Two enemy behaviors kind of done. The only thing they lack is shooting at the player and, given what I have now, that shouldn't be too hard to implement with a Bullet class
The lander behavior is gonna be the hardest. They have a few modes. First is like search mode, where they fly left or right toward the nearest human on the ground and once they get there, the descend to the human, pick it up then ascend toward the top of the screen. If they get there with the human, they turn into mutants
@sst can you help me with https://github.com/InZane84/WADdle-Plot-CLI/issues/1
And they're tough af
My math seriously sucks
Constraining to window is fairly straight forward
Can you explain concept?
Lemme look at your post a sec...
Ok
So I don't quite understand the question
How are you creating points?
Do the points move once they're created?
No, they are static.
So the raw points are in the range of -65k - 65k and I need to compute a translation offset for each vertex.
To plot them within a 640x480 window...
Then I need to scale the map so that it is within the window...
And the points each have an x and a y coordinate in that range?
Yes
Ok
Right?
Basically, yes
65k - -65k = 130k
Yeah, I'm with you
So just divide 130k by 640 for each point
Let me work through that a sec...kinda buried in my own code at the moment
Nah
What about min and max? To get a rect of all the points?
I don't know how to proceed lol
So, (640/130000) * X, and (480/130000) * Y
And that translates the point to screen space?
Yes
Should I use float?
new_x = (640/130000) * point.x and new_y = (480/130000) * point.y
That depends, you might want to cast to floats, do the math then cast back to ints
I see.
The math will be floats
If they're not moving, I don't see any reason to really, but I don't know every usecase
Eventually I do want to add zooming and panning.
If you give a screen location as a float, it'll be turned into an int anyway
What are you using to draw your plot?
Then I want to move away from Turtle and over to arcade because of pyglet>opengl
I'm using the Tkinter Turtle module.
I've been working through a lot of that lately with pygame
Like transforming and translating surfaces
But I need Tkinter for widgets and a hardware accelerated surface so that's two event loops? How can that work? Threads?
Interesting...
I'm no pro with pygame, but I'm learning, no pro with anything really as a hobbyist : )
Cool, but I was implying I would help you with the game first. Anyway, let me see if I can fix this since you have given me some insight..
just wondering
Oh yeah, and since your range is starting in the negative, you'll have to offset that, just add 65000 to all of your point.x and point.y to bring it from a range of -65k through 65k to a range of 0 through 130k
Before doing your scaling math
Might just be able to abs() the result otherwise but I haven't worked that out
Nah
But that should be good
Just add the 65k to each one
That's a pretty massive scale, less than .005 per value in range
hmmm
I'm into now and I have fallen into "Indentation Hell" ๐ฆ
and infuriating situation that happens in VS Code
what is causing this? tabs? spaces? whiteline? i mean what
there is no syntax error, something has happened to indentation.
So plot() is a method, that entire block would be indented one more level
To be inside the class to which it belongs
And just break that if statement and conditions into the proper three lines it should be
That's the problem
Paste that line here for me, and the else: line too
I can't wait to do the enemy pods in this game. When they die, they spawn a few swarmers that come straight at the player hard and fast
That should be fairly easy to code the swarmer individual behavior but they kind of act as a group
I've figured it out. Code is in an inconsistent state and has mixed tabs and spaces for some odd reason
that sounds cool. you have art assets?
might be stupid but can i thing coded in pygame be made into an app?
just wondering
yeh
An Applicatiion is compiled code that runs within a runtime environment
You should hit up Google for that. I haven't even tried to develop Python apps on mobile. I do know there is Kotlin + Android Studio
on iOS you would probably use Swift?
mobile is a different space?
@limber veldt thanks to you I'm on the right path. I just need to figure out now how to stay centered while scaling...but I have the points staying within the window!!!
yup
In pygame, I would select a rect from the screen surface and scale it up to screen size then place it at 0,0 on the screen
so the screen surface has a different coordinate system from the screen size of say 640x480?
No, same thing
The surface is the size of the screen
But things can be outside of it, they just won't show on the screen
on this though 0,0 is top left so I need to Heighth / 2 and Width /2 to get center
I see how to do it now, I believe
So a rect of size 100 x 100 will be [width / 2 - 50, height / 2 - 50, 100, 100] to define the x and y of the upper left corner of the rect and the x size to be 100, y size to be 100
I'm not sure what kind of rectangle definition you need though
A rect centered in screen, I should say
width / 2 - 50 why -50?
I think that's generally how we define a rect though, that or just give the upper left point and the lower right point
T0 be centered in screen and 100 pixels wide, we have to take 50 from the left and 50 from the right of center
https://pythonhosted.org/planar/index.html this is the 2d geometry library I'm using
50 pixels left of center is center - 50
50 pixels right of center is center + 50
Right?
lol
https://pythonhosted.org/planar/bbox.html specifically this right now to try and get the rect of the world points
yup i got you
I have my enemy baiters flying to the player then doing a stretched diamond flight pattern around the player
Never really trying to hit the player, just fly around him
Eventually, they gonna fire bullets too
lol
This is great
๐ sounds neat
learn bro
@limber veldt are you here?
could someone help me with translating some points to screen space?
does anybody know why when i am editing an animation sequence and save that and restarting the engine the animation stays as the last one?
(unreal engine 4)
ping at help please
So it looks like, at least from my watching of the videos, that some maybe even all Defender enemies have multiple behaviors like roam, search, attack, chase
And all of them well defined
Well, maybe not so well defined in a couple of them
Their transitions are so subtle sometimes, not so subtle other times
Sup man?
I wish I had the original game and could enable god mode just to watch the enemy flight patterns
I've done a lot of google digging, seems nobody has already analyzed these behaviors for me : P
Even found the source code but by the time I figure out exactly what that's doing...
The source is in 6809 assembly, not totally foreign to me, I use to know it but that's been decades
Color computer days, Coco3 was the shit
Part of the problem is with the term. Put the word "Defender" in a google search and you get a lot of tower defense hits
Anyone good enough please feel free to extract the enemy pod behaviors from this: https://github.com/AaronBottegal/Defender-Source-Code/blob/master/SourceCode.txt for me in either english or pyhon, thanks : )
Like I still remember the mnemonics
JSR = jump sub routine< --- meant to say jump there
LDB = load B register
STA = store A register
Some of them I have a hard time recalling but...meh, it's been 30 years
is some one here familiar with pygame and can help me with a code for collision detection i have put my questions in a help channel atleast 5 times, i have tried to figure it ourt my self for weeks so if anyone can hekp i would really appreciate it
What kind of collision detection do you need? Simple rectangle/bounding box?
sprites
Make your objects into pygame.sprite.Sprites and add them to a pygame.sprite.Group, done that already?
I'm just now learning some of this stuff for pygame, too
i am pretty sure i have done that my error is that they are iterable
https://replit.com/@815398/dinoD#main.py well this is a link to my code if you would like to take a look
So in your draw_screen() function, you're doing something like: ```py
enemy_group.update()
enemy_group.draw(screen)
Sorry, lemme fix that...
this is the first time i have made a game like this so
That indent, I dunno why...
yeah i am pretty sure i do that
So then in my main loop I have just one line for collisions py hits = pygame.sprite.groupcollide(bullet_group, enemy_group, True, True)
Your player class draw() method is probably not even necessary. You can draw the group as I did up there
None of my objects have a draw() method, group.draw(screen) just calls pygame to blit them to the destination
i tried what you have and now it says that my object has no attribute to sprites
this is my player
Hard to read, but I try....
@nocturne nova that website is freaking cool! replit...
Ok, so your sprite needs a couple of things...
yeah it is really easy to use and you have tons of languages
The formatting here is going to mess up the long-ish lines, but...```py
class EnemyMutant(pygame.sprite.Sprite):
def init(self, x, y):
super().init()
self.image = pygame.Surface((25, 24), pygame.SRCALPHA) # going to eventually be an enemy mutant, but a blank surface so far
self.rect = self.image.get_rect(center = (x, y)) # get the rect of that surface
But sprites need the image or surface or whatever is being drawn as self.image
And they need the rect of that image
And, most importantly, have to inherit from the parent class, hence the super().__init__()
Well, have to init the parent class, I should say
Excellent
Oh yeah, it is there, like I said though, that's hard to read for me here
As I look very closely, yeah..
i am quite confused could i take a look at your code or like a github that you recomnend that could help
what was your error again?
Ahh, so is asteroid not another pygame.sprite.Group()?
sorry i dont know how to show it like this
So you have```py
asteroid = Asteroids()
asteroid_group.add(asteroid)
asteroid = Asteroids() only this
You'd need to add that asteroid to a group of them for them to be iterable...I think
Iterate the group, of course, not the asteroid itself
alright i am going to that right now
layer = DINO('player', 200, 325, 1.5, 5)
asteroid = Asteroids()
asteroid_group.add(asteroid)
player_group.add(player)
asteroid_group = pygame.sprite.Group()
asteroid = Asteroids()
asteroid_group.add(asteroid)
Then that hit detection line can iterate that group
ohg thanks i was about to say that i get an error like that
And if there are problems along that route, fix the objects because that's how I'm using it and it's working
: )
Looks like a fun project you're working on
what do you mean fic the objects?
thank you
asteroid = Asteroids()
asteroid_group = pygame.sprite.Group()
asteroid_group.add(asteroid)
player = DINO('player', 200, 325, 1.5, 5)
player_group = pygame.sprite.Group()
player_group.add(player)
What I mean is that I got them working the way I described but to fit into that kind of group, a sprite group, an object has to have certain things...it looks like all yours do from what I've seen so you should be good to go
sorry to bother you again but hat is my code and it says that DINO (player) has no attribute to sprites
Hey @nocturne nova!
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:
Can you show the code around the line that's giving the error?
this the error
Because it's true, there is no self.sprites = assignment in the __init__()
ok so what does the self.sprites need to equal to
Change to player_group and asteroid_group, not player and asteroid
We add them to groups so we can use them in the hit detection, so we can't use the objects themselves, but the group containing them
No
Not like that
Delete that line
ok
This line, make it this: py hits = pygame.sprite.groupcollide(player_group, asteroid_group, True, True)
oh
ok so there is no error now how do i make the if....: line so i can tell it do something
Do the objects disappear from the screen when collided?
