#game-development
1 messages ยท Page 80 of 1
If they squeeze Vulkan out then someone will have to make some kind of cross platform open source lib that wraps both, or it will be a nightmare to port stuff.
(At which point they might as well allow Vulkan to be a thing)
There is a reason many python game / media libraries are using GL 2.1 / 3.3 still
Can still do a lot with tranforms and geometry shaders.
.. and still support 8 year old hardware
Can even do simple SAT collision detection on gpu with that instead of making C/C++ module
Also it's not a complete waste to learn the GL pipeline and simple GLSL shaders. There is quite a bit of overlap with vulkan
But definitely use a higher level GL wrapper. Writing everything that is needed to get that up and running is.. not fun
So may pitfalls and weirdness it's not even funny
You mean creating the opengl context? Yeah that is a nightmare specific to the OS (all of them are terrible).
I also find it funny that the opengl headers are just on some random website rather than shipped with the OS.
(Or packed with an IDE like visual studio)
"SDK"
Yup. Got to parse the registry : https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml
I had to make this to generate bindings for pyglet and moderngl : https://github.com/moderngl/opengl-registry
Core context only, so it's not that bad
I hope no one is starting from scratch doing that for their own projects.
That xml file is what generates the header files
There are higher level libraries (for example pyglet and moderngl) that provides higher level abstractions for a buffer, program, texture etc. That's what I mean.
Playing with things on a higher level just learning simple shaders and the pipeline
It's not going to cut it for more fancy projects, but it's ok as a learning tool
Is it possible to play a GIF file in pygame window?
I want it to play in the background of the main menu screen
doors stuck
DOORS STUCK
DOOORS STUCK
HELLP
HELLLPP
PLSSS
PLSSSSSS
DOORSSS STUUCCKK
HEEELP
HEEEEEEEEEEEEEEELPPPP
PLEEEEEEEAAASSSSSSSSSSEEEEEEE
6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.
help with what? to open the door?
ITZ STUCK!!
send help
(breaks door and opens)
I AM ALIVE!!!
I HAVE RETURNED!!!
yussss
s
yusssss
Classic 1.6 clip from a long time ago, still makes me smile to this day.
directors channel: http://www.youtube.com/user/KinetiK001
His description:
Me having fun in ESEA.
No, I'm not a Goron.
EDIT: First off thanks for all the views and positive comments! Never expected this vid to get this popular, I just recorded it and put it o...
hes talking about this
quick question
is there a way to make the program wait a few second before ruinning the next line in pygame??
Do you need anything to happen while itโs waiting?
yes
I need a object to moev
fak u'
hi everyone
i started some days ago learning python,i tried to build a snake game but the keybinding dont works
can anyone help me?
you might want to take a look at asyncio.sleep(), it'll allow you to freeze the part you want while still drawing/updating the objects, or you could set up flags and count how many second have gone by:
# start of event
if # condition to start event:
flag = False
start = time.time()
if time.time() - start == n_of_seconds:
flag = True
else:
# event```
smthing like that
asyncio.sleep() would let you separate your logic a bit more tho
please use one of the off-topic channels
Can anyone make me a snakes a ladders game using python turtle I'm willing to pay money?
Pm me if interested
Is anyone familiar with PyGameZero? I have a question about 3D graphics in a book I'm reading (Mission Python) that I can't seem to wrap my head around.
No but I might be able to help?
!Rule 6
6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.
start of event
if # condition to start event:
flag = False
start = time.time()
if time.time() - start == n_of_seconds:
flag = True
else:
# event
<@&267629731250176001> Got some unrelated spam from ๐ฑ๐๐๐๐๐ ๐ฏ๐๐๐๐๐๐๐
it didn't work
Hello, could you send a message over @light nest
@viscid venture
- make sure the start variable only get set to time.time() once and not every frame
- use < instead of ==
- do the delayed stuff after you set the flag, not in the else part
idk i do latest
the volume must be between 0.0 and 1.0, @dawn quiver
at 0.0 it's completely silent, so a negative value would be impossible
aaaaaa thnx didn't know that never tryed 0.0
Always read the documentation. It will save you years of your life in the long run ๐
ok thnx
Anyone have an easyish game to make in pygame for me?
@finite badger if your experience is just for learning a good first game is a simple maze game rendering a map of x*y with blocks you cannot pas thru and letting the user just move up down left right to get from enter to exit
hello i got a problem with pygame and i think this is the right channel to ask sory if its not newbie ๐ ,
so the problem is i wrote this code and it prints the position in bunch of numbers like 1023, but i wanted to attach the position to a slider to keep a track of the music. But can't get it to work. The silder value is 0-100 and so the mixer.music.get_pos() needs to give a value under 0-100. Can i get help please ty
ping me if anyone knows
Hmm. I'll try it thanks
Hi, it may help if you post your entire source tree it is impossible for us to know what mixer.music.get_pos is doing currently since that code is not in your screen capture
oh well this is the full code
If it is https://www.pygame.org/docs/ref/music.html#pygame.mixer.music.get_pos it may be that you are using the wrong method
i want to get the current playing position but not in 2323, i want in 1:05 like that
If that is the case you will need to just do the math
pygame.mixer.music.get_pos()
get the music play time
get_pos() -> time
This gets the number of milliseconds that the music has been playing for. The returned time only represents how long the music has been playing; it does not take into account any starting position offsets.
so if you want that you should convert it to min/sec and then display it
weird in my location it is working
so for your printing that you want to show mm:ss is that like just to print it or do you need to also pass it elsewhere later?
Use an archive site.
oh actually this is what i'm building. the slider will show the current playing time
its a music player i'm trying to make
the slider value is 0-100
ah so you have some work todo then because it is not simply convert to mm:ss you also need to know % of total right that 0-100 is like percent of the song length?
yes
well will take time ig
can datetime module do that
convert ms to something else
probably
sadly i think no since this thing you are calling is just giving you a number back
Hello, I'm a newcomer to the entire Python community, and I also want some help. I was taking notes on how to make a version of Pong, inspired by this usual video, When I got to work on the Paddles, then ran my module. This would happen, only just one. What's the actual problem here? https://www.youtube.com/watch?v=C6jJg9Zan7w&t=10s
A Pong clone game tutorial for beginners using Python 3.
โญ๏ธCourse contents โญ๏ธ
โจ๏ธ (00:00) Part I: Introduction and the basic window setup
Code: http://christianthompson.com/sites/default/files/Pong/Pong1.py
โจ๏ธ (03:32) Part II: Add game objects to the screen (Paddles and Ball)
Code: http://christianthompson.com/sites/default/files/Pong/Pong...
and if i use get_pos()/1000 the output is
2.83
2.858
2.898
2.93
2.954
2.984
3.128
3.161
3.188
3.219
3.245
3.26
3.283
3.317
3.451
3.474
3.507
3.53
3.549
3.565
3.597
3.646
3.771
3.787
3.81
3.843
3.891
3.926
3.969
4.014
4.07
4.098
4.13
4.146
4.169
4.186
4.227
4.424
4.45
4.468
[Finished in 9.5s]
i think your next step at least for now would be to get this get_value you are writing to return you two things first is the mm:ss you wish to see but then also a second which is % of total song length. Percent of total song length looks easy if you did
percent_total = pygame.mixer.music.get_pos() / pygame.mixer.sound.get_length()
https://stackoverflow.com/questions/6936393/find-the-length-of-a-song-with-pygame
that should tell you as a percentage how far though a song you are, although it should be a 0.95 rather than 95 so you may need to do it *100
ah ok ty i will try
to get it into minutes and seconds that should be some simple math to get seconds it would just be pygame.mixer.music.get_pos()/1000 and then you could do some more math to get minutes/seconds remaining from that
cool good luck
i hope that website becomes unnlocked soon it is just the pygame docs you will need those
ah ye i duno why but the site is locked since 1 year in here
where are you located? perhaps it is a region thing
india
oh weird usually India is not bad I'm in the US but work with 2 guys in India and we usually are ok but the one guy in australia its all issue
yea i should probably do my actual day job some ๐
keep asking questions man that was a good one
Oh, hey man. I was looking for some help on how to fix Paddle B
i may be away for a few but you mean to say that you were only able to make one padle move but the other did not?
No, the other paddle just did not appear.
oh hmmm do you have your source code somewhere? github/pastebin? i have to run for a few now but I can check it once i finish with this work stuff
Python.
` import pygame, sys
class Dino(pygame.sprite.Sprite):
def init(self, posX, posY):
super().init()
self.run_animation = True
self.sprites = []
self.sprites.append(pygame.image.load('DinoStart.png'))
self.sprites.append(pygame.image.load('DinoRun1 (1).png'))
self.sprites.append(pygame.image.load('DinoRun2.png'))
self.current_sprite = 0
self.image = self.sprites[self.current_sprite]
self.rect = self.image.get_rect()
self.rect.center = [posX, posY]
def update(self, speed):
self.current_sprite += speed
if int(self.current_sprite) >= len(self.sprites):
self.sprites = 0
self.image = self.sprites[int(self.current_sprite)]`
The error Iโm getting is TyperError: โintโ object is not subscriptable
If int(self.current_sprite) line looks like the problem
The issue is the last line and the self.sprites = 0 line.
Hey @grand valve sorry for the delay just got back from work. In your code take a look at two things #1 in your initialization bit in the first screenshot look at the goto calls. unless i am reading this wrong you are putting them in the same x,y position you will want to change "where" they draw so they are seperate the #2 thing is i don't see you binding anything to paddle B so u can move it
Okay.
when sharing your code if you are not yet comfortable with github you can always send people text on the internet using https://pastebin.com
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.
!Rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
Hi
cool
hey anyone there
!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.
Hi all!
If I would take my first baby steps in game development with Python, which tools do I need?
I already got ATOM.io with a few python extensions, but which "engine" is recommended?
There are plenty, check godot
if you want an engine with an editor godot is the way to go its uses a python like language called GDscript if you are looking for some kind of a framework there are plenty of them some are pygame, ursina, pyglet and pyopengl
Which of the frameworks would you recommend? I have no means to evaluate them.
I recommend looking at some of the examples and maybe try some of them to see which one you like the best
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.
i wanted some tips to improve my code
python is slothing da frick outta me
the screen after the connect four match is done is not responding
it seems like whenever i hit interrupt shortcut, its always stuck at line 45 (blitting the cell)
and it seems like its slothing on blitting the images
i will try to scale the images down to 32 x 32
thats the preferred size for loads and images
seems no either
any python game development frameworks recommended
is there any good python game framework
Pygame
what is the most efficient way to store, load and overwrite game data in pygame? any modules? there is pickle but it's maybe not the best way
or should i use pythons built in open with a specific data file?
maybe use OS module
how exactly would this work? os is a large module
https://www.guru99.com/reading-and-writing-files-in-python.html Maybe actually just check this tutorial
In Python, there is no need for importing external library for file handling. Learn how to create, open, append, read, Read line by line, and Write,
if you don't know how to make files
yeah i saw someone doing it like this, but i'm scared it might not be handy with large data, or maybe too slow
also i'd like to convert the game from python to exe later on, but i'm not sure how exactly it works and it would then also need to be able to save data while not being a python program anymore
Need to create an executable from Python script using pyinstaller? If so, I'll show you the full steps in Windows to accomplish this goal.
yeah but will it still read and write the code in the text file or will there be compatibility issues?
Maybe try testing to see if it works but I think it should
Hi, Im programming a mini mathematics dice rolling game
its only a couple lines but I want it to be able to count the median of the sums
if someone dms i would be ecstatic
has anyone here used dr racket to create games?
Does anyone have a good pyxel tutorial?
The framework
can anyone help me with this? ;-;
Is this a school question?
Maybe try this? https://m.youtube.com/watch?v=m7msykl-P9I
Check out my new video about the making of my spaceship game in python with the pyxel module. This is a timelapse video with some NCS music going on in the background. There are 1000 coupons for discount in the link below. Check out on udemy if you want to know how to create such a game.
Github: https://github.com/r3ap3rpy/pyxel-project/blob/ma...
import pygame
pygame.init()
pygame.mixer.init()
from plane import plane
screen = pygame.display.set_mode((800, 600))
pygame.display.flip()
pygame.display.set_caption("ppy_test")
icon = pygame.image.load('kerstboom.JPG')
pygame.display.set_icon(icon)
img = pygame.image.load('plane.png')
pygame.mixer.music.load('relaxed music (3 hours).mp3')
pygame.mixer.music.play()
pygame.mixer.music.set_volume(0.2)
running = True
while running:
screen.fill((34, 45, 129))
screen.blit(img, (335, 480))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT:
plane.moving_right = True
elif event.key == pygame.K_LEFT:
plane.moving_left = True
elif event.key == pygame.KEY_UP:
plane.moving_up = True
elif event.key == pygame.K_DOWN:
plane.moving_down = True
elif event.type == pygame.KEYUP:
if event.key == pygame.K_RIGHT:
plane.moving_right = False
elif event.key == pygame.K_LEFT:
plane.moving_left = False
elif event.key == pygame.K_UP:
plane.moving_up = False
elif event.key == pygame.K_DOWN:
plane.moving_down = False
pygame.display.update()
why are the keys not working?
my image is not moving
Hi iโm looking for developers to develop a game on roblox based off the netflix series โThe Orderโ if you donโt know what it is, it is:
When Belgrave University student Jack Morton joins a fabled secret society, the Hermetic Order of the Blue Rose, he is thrust into a world of magic, monsters and intrigue. Out to avenge his mother's death, he uncovers dark family secrets and lands in an underground battle being waged between werewolves and practitioners of dark magic. Assisting Jack in the fight is Alyssa, a tour guide at Belgrave and fellow member of the Order, which is led by Jack's estranged father.
Please dm me if you can help
Arenโt roblox games done in lua?
yes
But hello i have arrived for a question
I am trying to import a sprite for my python game and its supposed to 2d but i cant figure out how to actually get the sprite in the game. Am not using a game engine am using visual studio code. Ive been trying to search it up on how to actually code that (putting the sprite in the code/game)
What graphics / game library?
and by "not using a game engine", how are you planning to draw the sprite?
tkinter maybe?
Game / graphics libraries will give you better and easier access to efficient draw operations for (for example) sprites.
Unless you just want to display textured surfaces in tkinter (slow, but works) ..
i already have the sprite
Meaning what? You have an image or some sort?
a png of my character
Yes, so you probably need some graphics library to draw it
oh, i dont think i have that
python doesn't really know how to do that by default
ah
Unless if you are using the tkinter gui library, but that is pretty slow compared to other solutions
and probably more difficult
oh ok do i download tkinter? because this is my first time hearing about tkinter
It's already installed with python.. BUT I think that is the most difficult and slow path for you
oh you see i downloaded the python addon for visual studio code is that the same or is it different
The addon just helps vscode to interact with python better
ok lemme download python on my laptop
oh wiat i already have it on my laptop
so i have it my laptop and vscode
should i download tkinter?
Since you are so fresh to this I would suggest a free book using arcade : https://learn.arcade.academy/chapters/02_setup/setup.html
ok thank you
Go through the chapters. You will get to sprites pretty fast
ok thank you
You don't need to install pycharm as they suggest though
you just need to open a terminal and install it with pip install --user arcade
ok
What you learn playing around with that book will translate well to other libraries later on.
alright thank you
You can drop the "Version Control Systems" part for now
ok
I'm trying to write code like intended in this video https://www.youtube.com/watch?v=jO6qQDNa2UY but already catching error "module pygame has no quit member"
In this Pygame for beginners video, we'll be making a game in about 90 minutes. I'm going to cover a lot of stuff about Pygame in this video, including sound effects, images, moving objects, collision, most of the fundamental things you need to make a basic game. We'll be making a simple 2 player game to showcase how everything works in Pygame i...
oh yeah i had that problem i kind just had remvoed pygame and if that doesnt work i just complelety removed the quit code
if event.type:
SystemExit()
main = False
thats my code
why it's happening, something changed in pygame since january?
not sure
this tutorial is already outdated?
ive never heard of that video
from a quick look it seems like it's been an issue for a while
while running:
if event.type == pygame.QUIT:
running = False
pygame.quit()```
that might work?
I wrote exactly like that and it's not working
You don't have to call pygame.quit() is that is causing issues
or did you do something weird like calling your python script pygame.py?
no
Have you called pygame.init() yet?
what's the point of having the function then?
what
What are you using as the IDE?
vscode
Ah
I should use different, right
I remembered having some problems in PyCharm, but not VSCode
I'm trying to do like him, his code is working while mine gives error
pygame.quit() : Uninitialize all pygame modules that have previously been initialized. When the Python interpreter shuts down, this method is called regardless, so your program should not need it
seems I should look for other tutorials
It's from Jan 2021. I doubt it is outdated
can you run the code or does it stop the window from opening?
might be a linting issue
or vscode setup issue if this is what you are using
if it is vsc being funky and the code works, this should solve the error from being shown https://stackoverflow.com/a/52600893
or you have several python versions installed?
probably vscode
um einarf i didnt get what that website said
Terminal -> New Terminal
ok
python --version
python -m pip list
i downloaded what you said
More specific?
i have python version 3.9.2
i did this
and?
it downloaded arcade -2.5.5
yes
but i only had downloaded something i didnt type any code
i had wanted to know how to like import the png
welp i gotta go ill be back later
It will show you in the sprite section of the book
But I don't think you should skip ahead like that.
Impatience is the biggest enemy of learning
anyone have any resources on rendering tile maps, I don't have enough braincells to figure out why my math is wrong
Render where?
Just simple array based time maps? tmx files? pygame?
array based ones
Would depend on the graphics/game library you are using I guess. .
arcade
oh. I guess you'll just build a sprite list. I think there are some examples building random maps etc
I sort of had a half-working camera but I realised both the player and the cam were moving together + I had an issue with negative indices and all that fun stuff
so I've now got a signal bus that updates both the player sprite + the camera to move (in opposite directions) and locks that dictate which one should actually move
Some of the simple examples are just adding walls with for loops like this : https://github.com/pythonarcade/arcade/blob/8b98302490b06e79ad470bfba74a89df43406cf0/arcade/examples/sprite_rooms.py#L53-L70
yeah camera with viewport makes everything move (gpu moves it all fast)
^ The important thing to know about cameras, is that there is no camera, everything else moves (in the opposite direction of the camera to give the illusion of camera movement).
ya that's not what im looking to do
i feel like we've had this conversion lol
Ok. I misunderstood then ๐
I want the 'camera' to move when the border of the map isn't visible and the player to be the one moving when it is
so the player will stay in the centre of the screen as long as the borders aren't being drawn
array based ones "tilemap" assumed to just be some pyton array you crated with integers saying what sprite it should contain
well that's the plan but I don't want the whole thing on screen at once
What does this have to do with tile maps? You are asking for a camera that follows the player, but not out of bounds.
We do cull the sprites for you so the spritelist can be huge
100k+ tiles easily. If it gets a lot higher you might want to chunk it up in regions
I have to be able to choose which tiles to draw + where (if there's a offset (if only part of a tile should be drawn))
I'm assuming that arcade does culling for you.
It does the culling for you, yes
Sprites / tiles outside of the viewport will not be rendered. We weed them out in the pipline (geo shaders).
im not actually sure if that simplifies anything but that's nice to know
It means that you just act like everything is drawn from your pov, but it's not so it's fast.
If you want a camera centered on the player, but not centered on them when they reach the edge of the map (the player just moves around in the view at that point), then you can just clip the camera position based on the map bounds and camera half size.
(The camera is always in bounds)
ok but the camera's not actually an object right? it's just what the viewport is rendering?
yup
so I need to choose what to render if the border isn't in view, and if it is the player gets moved instead
(for x and y ofc)
that's where im getting lost
There is an experimental camera in arcade.experimental.camera, but it doesn't have scroll limits added yet (on the list) : https://github.com/pythonarcade/arcade/blob/development/arcade/experimental/camera.py
I should probably try to get that working for 2.6 release
Can add some other things to the camera while at it, like smoothing where the camera drags behind (acceleration).
yup ๐
Other interpolation things, like a current position and target position and it just moves to it smoothly (can also add for zoom and rotation, allows for some nice animations like starting out with a large view of a map and then zooming in to the player (cinematic)).
Black bars for cinematics would be convenient.
Already does black bars. Just need to make aspect_ratio settable. Not a bad idea
(But with interpolation too, black bars that very slowly come in are used a lot)
Interpolating all the things is a very easy way to make your game look way better.
Definitly
That's also fun to make. I'm normally deeper in the arcade library fixing other stuff. Got few horrible things to fix before the fun starts
Such as proper texture atlases and text rendering
Btw something you could add which many game libs don't is dev GUI stuff (via DearIMGUI), for making in-game tools / in-game editors.
Any IMGUI will do, but dearimgui will have a lot of work done for you if you are doing any c++ stuff.
Already did in a separate project I contributed to. I made a imgui renderer for arcade : https://github.com/kfields/arcade-imgui
hmm, so i was wondering about pyimgui, does it just expect some opengl context to work?
like you pick a backend or something
Yeah you pick a class for rendering and one for events
Yea so do you plan on having any kind of in-game editor (since python has run-time reflection for all objects).
For arcade?
Not at this time. We would need more contributors to pull that off
idr does arcade have a game object / scene system?
Not really, no.
Ah, ok, such an in-game editor would make more sense with a unified game object system so you can view and poke at any object in the game.
Normally for something like this in c++ one needs to add a reflection system for game objects, but since it's python you get that for free and can even dynamically add properties.
Could work with a simple scene system and a way to poke around runtime at least
Usually this system is also combined with code hot-loading so one can edit code while running the game and push a gui button in game to reload all game object logic.
I think python has built in module reload
It can go something like this with the in-game gui: freeze game clock -> inspect object -> edit properties and/or game logic code -> reload
I rarely see this is hobby / smaller engines, but it's not too hard to add.
It could work as a separate project. arcade-editor or something
When in game it's even better as one can freeze and inspect when bugs happen (can also buffer last couple of frames for rewind).
Most people have just been using Esper with arcade : https://github.com/benmoran56/esper
Yep. That is definitely nice.
Not sure one needs a full blown ECS, but that can work.
It's sort of different way of thinking than the typical OOP.
As it comes from data-oriented design.
Now I just need a machine that can make a few copies of myself
Same
The inspector in-game is like running a debugger, but at a higher resolution / more specific to games.
And allows for fast iterations with reloading
If it's a debugger and a editor that doesn't save state I definitely see the usefulness
import pygame
pygame.init()
window = pygame.display.set_mode((800,600))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.quit():
running = False
i am getting an error
Traceback (most recent call last):
File "/Users/arnavdaultani/Desktop/game/main.py", line 6, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
i don't udnerstand this error
pygame.quit() <- this
what about it?
you probably mean pygame.QUIT
oh
2021-03-12 09:31:05.353 Python[2551:49040] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/bn/s3cydgv91tn9dplynv3jytg80000gn/T/org.python.python.savedState
Traceback (most recent call last):
File "/Users/arnavdaultani/Desktop/game/main.py", line 7, in <module>
if event.type == pygame.QUIT():
TypeError: 'int' object is not callable
@potent ice
get rid of the ()
It's a constant, not a function
Yeah, and it can even rewind a few frames back if you get a bug you can quickly hit pause and step back to see the state change. The buffering can be turned off when not needed to save memory, but many games already double buffer their state (and even more in the case of multiplayer).
(being able to change the framerate / slow down helps too in that debugging case to catch it in time)
Making so that it saves state if you edit stuff is a whole other thing that can be done, but is not needed. It's mostly just to give insight in what is happening.
oh ok
can someone help me
import pygame
pygame.init()
bg = "bg.jpeg"
window = pygame.display.set_mode((800,600))
running = True
background = pygame.image.load('bg.jpeg')
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
window.blit(background,(0,0))
no error but i am no able to see the image as background
๐ฆ
:
@real solar pygame.display.flip()
pygame.display.flip(): Update the full display Surface to the screen
This is covered in the pygame intro, first page : https://www.pygame.org/docs/tut/PygameIntro.html
i got it
@potent ice but i needed some more help
there is only as section
of the picture
i want the whole thing to come
I don't really know how it looks right now. Is it covering the upper left area?
mhm
@real solar why don't you share a screenshot?
not this, I was taking about the game screen
How big is the picture vs your window?
im not sure
Exactly that's causing the problem
It doesn't fit in your window. It's a huge picture
how do i resize it for my window
pygame.transform.scale()
It's a 3840 x 2160 image. oh wow
pygame.transform.scale() takes two args pygame.transform.scale(img_name ,(new_width,new_height)
self.x_start: int = (self.pos.x - SCREEN_WIDTH) // TILE_SIZE
self.x_stop: int = (self.pos.x + SCREEN_WIDTH) // TILE_SIZE
self.y_start: int = (self.pos.y - SCREEN_HEIGHT) // TILE_SIZE
self.y_stop: int = (self.pos.y + SCREEN_HEIGHT) // TILE_SIZE
>>> -4 12 -5 -12```
I don't know what's happening but this is what I meant by my math being wacky
`x_start`/`y_start` shouldn't be negative + the stops are too low (I think it should be ~(6, 14, 5, 14) but I'm not 100% on that either)
actually no nvm the pos should be replaced with half the map size, but even then it's about 2 tiles too wide/tall
import pygame
import pygame_gui
pygame.init()
bg = "bg.jpeg"
window = pygame.display.set_mode((1000,800))
running = True
background = pygame.image.load('bg.jpeg')
hello_button = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((350, 275), (100, 50)),
while running:
pygame.display.flip()
background_scaled = pygame.transform.scale(background,(1000,800))
window.blit(background_scaled,(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for event in pygame.event.get():
if event.type == pygame.USEREVENT:
if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == hello_button:
print('Test button pressed')
while running:
^
SyntaxError: invalid syntax
You have a trailing comma after you create hello_button
Instead of a comma there needs to be another closing )
i see
i fixed one thing but
import pygame
import pygame_gui
pygame.init()
bg = "bg.jpeg"
window = pygame.display.set_mode((1000,800))
running = True
background = pygame.image.load('bg.jpeg')
hello_button = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((350, 275), (100, 50)) , text='Start' , manager='')
while running:
pygame.display.flip()
background_scaled = pygame.transform.scale(background,(1000,800))
window.blit(background_scaled,(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for event in pygame.event.get():
if event.type == pygame.USEREVENT:
if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == hello_button:
print('Test button pressed')
@ancient marsh what does it mean by manager
It seems to be something specific to pygame_gui, I recommend you check the official documentation.
Personally I've never used it, so I can't help you with that.
Can I make editor in pygame
Apparently you'll need to pass a manager instance you create beforehand:
Make sure to reread the documentation if you get stuck, I have never used pygame_gui so I sadly can't help you with that.
okay
@ancient marsh if youre stil here i had a question
You just ask the question. No need to ping people.
Better to reply to a message than direct ping.
im working on GTA 5 mod menus, if anyone is interested then contact me.
wait when i finish my python project will the entire game be in my terminal
and should i have all my code in one file or multiple files
hey anyone there
Probably, but that question doesn't really make sense. Almost no one is staring at this chat 24/7 ๐
If you have a question you can just ask. You may get a response some time in the future.
Halllllllooo
anyone care to help me with some Panda3D terrain stuff?
I am making a Pong game with PyGame, and the ball keeps going off screen, then bouncing back. Almost as if the edge is off the screen. (This is only for the top and bottom for some reason.) That is one of my problems, another one I have is the PyGame window pops up in fullscreen, and there is no 'X' to close it. Can anyone help??
My code:
Check if the size youve set your window to actually is within the size of your physical screen
Try making it a 100x200 window and see
Ok, let me try
yea maybe the resolution is bad
nice, must feel great ๐
very ngl
Are you using the Clear Code tutorial @finite badger
Yeah
Thought so it looked like it
Yup
Halllllo
Anyone has a good step-by-step tutorial?
For pygame? Pls?
Anyone know about the ursina engine?
ClearCode
What is your question?
Hi, I'm using pygame zero and I don't understand how to detect key lifts
I looked at the documentation and I don't understand when they said that the key parameter is an integer
In replit, how would one make battleships the game, just for now I need to know how to populate my grid with "ships"
@warm badge are you trying to use pygame?
This is my grid
def grid():
x in range (1, 11):
for y in range (1, 11):
print ("๐ฆ", end=' ')
()
grid()
Yeah basically
I just need to be able to add different sized ships onto it and idk how cos I'm special
I only started learning python this year
BTW, don't tell anyone that it is for school
some people get mad
Oh why
They say things like "Do it yourself!!" etc.
Bruh kind mean lol
Yeah... Just don't say that and most people will be fine
But I get it, I don't really want someone to do it for me, I just wanna understand it cos man's got his GCSEs coming up
But yeah noted, so thanks
But I mean how would I be able to append to an individual square of the grid
What u mean
@warm badge You can also try claiming a help channel
Kk thanks
np
Help pls
A cursory look at the documentation suggests this is done with on_key_up
@olive parcel yeah, but it says "An integer indicating the key that was released" and I don't understand what it means by "an integer"
@blissful depot an integer is a whole number, it is probably a constant matching the key code
ie. you can compare it against keys.BACKSPACE or whichever other key
oh
@olive parcel So I would write
def on_key_up(keys.BACKSPACE):
so on, so forth
What is the mod parameter?
You may want to learn python's basics before going into game development.
@blissful depot no, just give the argument a name like key and compare it against those constants
I concur re. learning basic Python first.
how would that look like?
Learn python's basics and you will know the answer to that question and many more.
what part of the basics?
variables?
if/else statements?
data types?
@normal silo
In this specific case, functions and enums.
But also just how to make some small programs that combine multiple ideas.
thanks @normal silo
Do some practice problems, there are several ones online for beginners.
enumerations, right?
Yes, this website seems fine, I have not checked the problems, but just from the titles it seems like the right level: https://edabit.com/challenges/python3
Oh
I understand functions
just not what an enumeration is
I can do pretty much all of the challenges
I just don't understand enumerations. I understand functions very well
You also probably lacking general programming hints / ways programmers typically do things knowledge. For example: if you see an all capitalized variable name it's probably a constant and if there are several of them that belong to some group it's probably an enum.
I understand constants and how you would name them CONSTANT = 500
I just don't get the enums
If you read the pygame docs for keyboard input and scroll down you will see a bunch of constants for various keys (hinting that there is an enum, or just a loose collection of constants that act like an enum).
hmmm
From the docs, you need to able to understand what something like this is saying.
Do you know what a queue is?
in english, yes
Let's move this to a help channel.
For those reading, the issue was being able to read documentation / piece it together (and data structures).
oh boy data structures are everywhere
does anyone know
why the robot does not move up or down
when I press up and down keys
<@&267629731250176001>
<@&267628507062992896>
@dense hare
@modest plover Please refrain from pinging random staff
This doesn't seem related to Python too. Asking in off-topic would be better.
thank you
can someone send the pygames file to me pls
what do you think on pygame vs the raylib binding in python or maybe jsut c++ raylib?
How would someone go about coding in freecell?
I understand how I'd code the tableaus and rules for cells and card movement, but my main question is
How are seeds determined?
Like, would someone have to code in every possible arragement and give it a seed?
which python game engine is good?
import pygame
import pygame_widgets as pw
pygame.init()
bg = "bg.jpeg"
BLACK = (0, 0, 0)
window = pygame.display.set_mode((1000,600))
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
font = pygame.font.SysFont(None, 24)
img = font.render('hello', True, BLACK)
rect = img.get_rect()
window.blit(img, (20, 20))
while running:
pygame.display.flip()
background_scaled = pygame.transform.scale(background,(1000,600))
light_gray = (135,206,235)
window.fill(light_gray)
pygame.draw.rect(img, BLACK, rect, 1)
#window.blit(background_scaled,(0,0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
i can't see the text :c
you should render it
font.render(text, antialiasing(1 or 0), color tuple)
and then blit
got it
how can i use a font that i downloaded from the internet in my pygame game
it's a .otf file :c
Can always try to load it using Font but I have no idea what formats they support. The docs mention truetype and freetype
Hey guys I need help with a pygame project Iโm doing
cool
@blissful depot fwiw, an enumeration is basically just a collection of different, related, constants.
This is quite hard to answer as it strongly depends on how does your game work. If you have something really simple, the just instead of moving your character move everything else. If your game gets complex, you should keep your own position of every object, and in some frame then render all objects that can be seen in that frame but positioned relatively to the player/camera position.
A game by Jerome Sentex (Wizital)
Source code : https://github.com/harfang3d/game-winter-z
Reimplented in Python with HARFANG 3D.
Guys!
first message in here noice
Kind of rude but nm
it's fine
How?
Tech With Tim pygame tutorials are so amazing
Class inheritance is like black magic but mmm it feels good to use this dark power ```py
class MenuArea(Rect, Group):
"""
An object that can be be used to group sprites together and position them
within a rectangle on the menu. The rectangle is initiated with a size
parameter, which should be a tuple containing width and height values.
"""
def init(self, size, *sprites):
Rect.init(self, 0, 0, *size)
Group.init(self, *sprites)
sololearn teaches oop awfuly, but very good at explaining everything else. I have to learn oop again
I have the book Python Crash Course, I have never even made anything like this before, that book really unlocked something in my brain as far as OOP goes. Biig pycoder toolkit gains
do you guys know about the ursina engine
Yes, it's based on Panda3D. If you search in this channel you will find discussions about it ๐
can someone help me i need help making my charecter follow the player
@real solar what library?
@real solar i mean i can try my best but i dont really know pygame
okay cool
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
img = font.render('Score : ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
x = 0
y = 400
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[K_w] and y >= 0:
y -= 7
if keys[K_a] and x >= 0:
x -= 7
if keys[K_s] and y <= 390:
y += 7
if keys[K_d] and x <= 580:
x += 7
window.fill(light_gray)
window.blit(bob, (x, y))
window.blit(img, (20, 20))
pygame.display.flip()
:c
my charecter = bob
wait what is the difference between character and player
How to disable keyboard in pygame when I press mouse?
wdym @pine forge
whats the difference between the two
probably a dumb question
i mean
take a look at this
i don't understand :c
if you want attach camera to the player "make world move around you"
how? move everything as the player moves
yes, player stay, world move
how/
lmao its embarrassing that i just google search xdd https://stackoverflow.com/questions/22218174/disabling-mouse-events-pygame
hope it helps at least
I tried set_blocked, seems I do things wrong
ill try to run it by myself
oh
mhm
but ill try
cool!
ill give you the pics ๐
Hey @real solar!
It looks like you tried to attach file type(s) that we do not allow (.ttf). 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.
:c
i will try to run it
I fixed it
cool
yeah was about to do that
mhm
okay cool
yes
i do
Im in game development bshehegdhdgdg
yes
hi!
so @vivid crag you gave me the code yesterday but can you make it so the jump which is 'w' is jump and not bob turning into jesus
i tried a lot of shit nothing worked :c
Oh, some jump code? Lemme get some rq
ty
i do :c
f
okay cool
but i have a fundamental question
is camera a thing in pygame?
or is it just an illusion
so its just moving the environemnt?
ya know when your in a car
and you think
am i moving or is the other persona moving
you shouldnt really move the player but only the backgrouond items
it's like that
yeah i know
not yet
there is just a solid bg
xd
if keys[pygame.K_SPACE]:
isJump = True
if not(isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
go assign isJump to true and jumpCount to 10 outside the while loop
?
@real solar here ye go, put this somehwere
turn it to K_w if u want
how i can fix it
NameError: name 'isJump' is not defined
try removing the .py?
did you try to install a .py file
@real solar maybe make a function that moves all bg objects
probably a dumb idea
put this above the while:
isJump = False
jumpCount = 10
i peed
ah yes
prays to our god Peculiarination
im a god now
yes
@vivid crag is there a way to calcualate
the distance bob moves in one directions
so let's say i have a count var
right and i need to store the distance big bobby moves towards the right
so u want to count how much former-jesus moves in one direction?
yes
only right not left because then user will be like
a and d key go brrrrrrr
ez score
if keys[pygame.K_d]:
#weird movement code
count += 4
and just do the same thing but u deduct the number when pressing a
i did something
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
x = 0
y = 400
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
if keys[K_d] and x <= 580:
x += 7
count = count + 1
window.fill(light_gray)
window.blit(bob, (x, y))
window.blit(img, (20, 20))
pygame.display.flip()
count += 1 does the same thing but sure
u deduct 1 from count when pressing a
ah
the score counter just
stays at 0
:c
do i need to
render the font
at the end
:c
yes it works
very weird tho
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
x = 0
y = 400
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
if keys[K_d] and x <= 580:
x += 7
count = count + 1
window.fill(light_gray)
window.blit(bob, (x, y))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
window.blit(img, (20, 20))
pygame.display.flip()
this
it increaser the font so quick
o whoa u did the same thing
yay
it increaese the score very quick tho
I can make setting menu and adjust pygame's fps thing right?
you can
yea
just alter the FPS var
also
FPS=60 and clock= pygame.time.Clock() then clock.tick(FPS)
:c
nice score = kool
yes
now time to figure out while i break the fuck out of my code on how to move the camera
ah well get to that later
now
time to try something
is there a way to delete bob
like
bob.kill
add some if statement
i did
above ur while: dead = False
if health == 0:
replace this: window.blit(bob, (x, y))
with this
if health != 0:
window.blit(bob,(x,y))
that way, it only draws former-jesus when his health isnt 0
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
health = 100
x = 0
y = 400
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
dead = False
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
count -= 1
if keys[K_d] and x <= 580:
x += 7
count += 1
window.fill(light_gray)
if health != 0:
window.blit(bob, (x, y))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
window.blit(img, (20, 20))
pygame.display.flip()
????
yes
nice
now i make enemy
how does one detect colission
wait lemme make
bad bob
bob's evil bro
what it
show code
ooo yay
i didn't get it
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
bad_bob = pygame.image.load('data/pictures/bad.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
health = 100
x = 0
y = 400
x2 = 0
y2 = 500
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
dead = False
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
count -= 1
if keys[K_d] and x <= 580:
x += 7
count += 1
window.fill(light_gray)
if health != 0:
window.blit(bob, (x, y))
window.blit(bad_bob , (x2 , y2))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
window.blit(img, (20, 20))
pygame.display.flip()
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
bad_bob = pygame.image.load('data/pictures/bad.png').convert_alpha()
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
health = 100
x = 0
y = 400
x2 = 0
y2 = 500
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
dead = False
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
count -= 1
if keys[K_d] and x <= 580:
x += 7
count += 1
window.fill(light_gray)
if health != 0:
window.blit(bob, (x, y))
window.blit(bad_bob , (x2 , y2))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
window.blit(img, (20, 20))
pygame.display.flip()
@real solar try dis
uhh
i did thid
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
bad_bob = pygame.image.load('data/pictures/bad.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
health = 100
x = 0
y = 400
x2 = 0
y2 = -1
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
dead = False
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
count -= 1
if keys[K_d] and x <= 580:
x += 7
count += 1
window.fill(light_gray)
if health != 0:
window.blit(bob, (x, y))
window.blit(bad_bob , (x2 , y2))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
window.blit(img, (20, 20))
pygame.display.flip()
did tath worc
yes
import pygame
import pygame.freetype
import pygame_widgets as pw
from pygame.locals import *
import time
import math
import sys
import random
def player(window, x, y):
window.blit(bob, (x, y))
#K_w = pygame.key.key_code("w")
#K_w = pygame.key.key_code("a")
#K_w = pygame.key.key_code("s")
#K_w = pygame.key.key_code("d")
pygame.init()
FPS = 60
BLACK = (250, 250, 250)
window = pygame.display.set_mode((1000, 600))
bob = pygame.image.load('data/pictures/bob.png')
bad_bob = pygame.image.load('data/pictures/bad.png')
running = True
background = pygame.image.load('data/pictures/bg.jpeg')
background_scaled = pygame.transform.scale(background, (1000, 600))
light_gray = (135, 206, 235) # (250,250,250)
font = pygame.font.Font("data/fonts/EvilEmpire-4BBVK.ttf", 95)
count = 0
health = 100
x = 0
y = 400
x2 = 550
y2 = 400
clock = pygame.time.Clock()
isJump = False
jumpCount = 10
dead = False
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
isJump = True
if not (isJump): # Checks is user is not jumping
if keys[pygame.K_SPACE]:
isJump = True
else:
if jumpCount >= -10:
y -= (jumpCount * abs(jumpCount)) * 0.5
jumpCount -= 1
else: # This will execute if our jump is finished
jumpCount = 10
isJump = False
if keys[K_a] and x >= 0:
x -= 7
count -= 1
if keys[K_d] and x <= 580:
x += 7
count += 1
window.fill(light_gray)
if health != 0:
window.blit(bob, (x, y))
window.blit(bad_bob , (x2 , y2))
img = font.render(f'Score : {count} ', True, BLACK)
rect = img.get_rect()
pygame.draw.rect(img, BLACK, rect, 1)
window.blit(img, (20, 20))
pygame.display.flip()
this worked
also
how can i make bob not go throught bad_bob
he can go through him rn
also i made bad_bob a rat
ok so
you what
if keys[K_a] and x >= 0 and x <= x2 and x >= 1000-x2:
x -= 7
count -= 1
if keys[K_d] and x <= 580 and x >= x2 and x <= 1000-x2:
x += 7
count += 1
o wait i flipped the thingers
thingers
if keys[K_a] and x >= 0 and x >= x2 and x <= 1000-x2:
x -= 7
count -= 1
if keys[K_d] and x <= 580 and x <= x2 and x >= 1000-x2:
x += 7
count += 1
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.
yeah!
yesss
also @vivid crag WANT TO BECOME PARTENRS IN THIS GASME
WE WILL CALL IT BOB'S WORLD
OR SOMETHING
IDK
I KNOW SOMEONE WHO WILL MAKE ACTUALLY ART
AND NOT A FUCKING RAT.PNG IMAGE I GOT FROM GOOGLE
FUCK MY CAP'S LOCK IS STUCL AGAIN
now for hitboxes
yeah!
just change the weird comment to wutevr u want
sure
ok
what i was trying to tell you over the noise in the other channel is that this is a lot more complicated a problem than you initially thought.
if you are trying to do an approach of just blindly intersecting arbitrarily shaped polygons that are rendered to tiles, that's partly the same as rendering polygons to a bitmap
and then doing a logical AND over two bitmaps
does that make sense?
uhh
i use photoshop
lemme do a really quick easy diagram
so you have two layers with shapes in white, each set to 50% opacity, right? on a black background
partially overlap them
the area that is 100% white is the collision
i can draw that if you want
hold on
but i think you can imagine it pretty easy
opening photoshop
oh no
ahh yes
?
k
the problem is that when you're trying to let the user do arbitrary polygons, you have to decide how to draw the white area of each
does that make sense so far?
yes
now, there are multiple approaches you can take to this
wait my game engine doesnt work like that
well then why are there tiles
you give it an ascii drawing thing, it will draw it
each tile is a character space on screen, right?
yes
ok back up because i think we have a misunderstanding of purpose right now
