#game-development
1 messages ยท Page 25 of 1
with wut
i want gmail login on device to test my application
how to make scrpt for game
i want t hack the diep io game
i need a java script
tere pan nu lun
give me a hck script
fck hck
control two tanks
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
:incoming_envelope: :ok_hand: applied timeout to @worn lake until <t:1714586499:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
y would u even ask for a java script in a python discord
How do you go down a folder in pygame when trying to load an image? for example the folder you wanna access is not within current working directory but 1 level below it
Cuz I forgot
Im trying to make a prototype of a platformer with a rectangle as the charecter but the jumping is way too jittery if someone could help that would be great
here is the link to the github page: https://github.com/Laughattack7339/all_things_gravity/tree/main
Just the folder name and the image name separated by a forward slash and in quotes if you want to use a string as the path
Or pathlib or os.path.join(), just the folder name and the image name
I figured it out. I meant going back a level like this: "../graphics/character.png"
Ahh cool
But thx for helping. It made me remember this actually
Also do you know how to do the same thing but for imports? Like importing from a lower level
Outside of cwd
I learned some os.path.join() from a Clear Code tutorial, it's really nice for these paths actually
I needa see this tutorial
You mean to import from lower folders?
Yeah
Just list the folders separated by .
How
from folder.file import class
What if the folder that you're importing is one level lower than the code
Will it still work?
It should, give it a try
I had to use os.path.join thingy first cuz it didnt work on its own. But thx man!
np
wdym by jittery?
I ran the code but don't understand the problem
Cuz it works
It's repeatedly reading many keypresses when you hit space and thus jumping as fast as the framerate
I made a couple of small changes, just suggestions, but this gives a little better jump https://paste.pythondiscord.com/M4SA
Oh no wonder I didn't have the problem. I used mouse press to jump cuz I ran it on my tablet (touch screen) ๐
Basically, I only capped the framerate at 60 per second and used the event loop to read the space key being pressed down instead of get_pressed() which reads keys being held down
So no matter how fast you press and release a key, get_pressed() will read a press for every frame and at 60 frames per second, that's a lot of jumping = True essentially
Hmm, I'm not sure how to read touchscreens with pygame
Guys, I'm having a funny error while raycasting some rays...
For touch you have can use the regular mouse inputs but it only takes 1 touch at a time when you do this. And what I mean is you can't use multiple fingers with mouse inputs since you can only click a mouse once. The better alternative is to use finger events like finger down/up or finger motions. There is no finger get pressed() command outside of the event loop it seems tho. (But atleast you can get multiple fingers)
Works great, but IDK WHAT
This is also funny
Sometimes just... it cast perfect...
But idk I'm tired, some help
Idk what ray casting is and I've never done it before but like where is de code
I heard pygame is based on sdl2
it uses sdl2 under the hood
If sdl3 exposes new features that an ambitious coder wants to implement, maaaybe they'll fork it, I hope
I hope too
Can I write you on yours DM's?
To bring you the code
what algorithm r u using
just send the relevant sections of code ere so at least someone can help
Hii guys someone know is better to use PyGame or Unity for creating video games
??
well, pygame won't pull the rug out from you and put you in debt :p
:p
i mean unity is like the holy grail of game development, looking past their reputation and piss poor financial decisions
its versatile enuf that u can make any game, 2d, 3d, platformer, first person shooter wutever
I was meaned for starting creating gamees
i mean i started and would recommend starting in pygame
but u gotta realise that its not a "game engine"
at least to the level of unity
many of the features that normally u can just click and drag into ur game, u need to make from scratch
physics being a notable example
on the flipside that means u have direct access to handling or changing code or memory as u see fit
I agree that pygame and unity are very different kinds of thing, though because of unity's shit i'd recommend godot instead of it.
true ye
godot has pretty pythonic syntax asw right
the switchover shouldnt be too bad compared to c#
You can start making games without any libraries (in your terminal).
You are going to have to be more specific about the type of game for a better answer.
i would assume he means actual graphical games if he specified pygame or unity
Still very non-specific.
true enough
I was meaned like 2D nothing Soo complexed
do yk basic python
What kind of 2D game?
Hmm interesting suggest thank u,I will try like that!!
Yees
OOP?
Like zombs.io Io games
๐
bruh thats practically impossible in a terminal
What is the target platform? PC, mobile, console, web?
Like for web games
pygame/raylib/panda3d
Do you want a GUI editor or just straight code / you make your own GUI tools?
Maybe GUI editor
Game Maker or Godot. If no GUI, then Pygame (since you know Python, it's 2D (usually), simple, and it can target web).
Godot is free, and has a language similar to Python.
Well I want to use PyGame for 2D games for start
You can start and end on Pygame for your target game.
But it's just code, unless you make your own GUI tools (which is not that bad really (game specific tools are faster in the end)).
Okay ty a lot for your information!!
You can make those tools with Pygame itself (and/or have them integrated into the game (so game/editor are one thing, you just switch modes)).
Interesting
Like the guy said, just share your code in chat so that everyone can see and have a "try" at it. I don't even know what you're doing so I doubt I could help on my own
Anyone had any issues with 2D games and shooting a projectile where it seems to snap to specific angle rather than have full 360 degrees of rotation?
thats usually due to having a small window resolution i think
or ur angles are in integers rather than flots
most likely the second
looks rly polished good stuff
No problem, those little projects are great teachers, keep it up
Hi, i want to ask
is there any tutorial for how to make game mmorpg server using python twisted?
very much working ray caster in python ๐
I don't think there's an entire tutorial for one
There's tutorials for parts of it tho, an rpg game and networking separately for example
Any book or link for it?
There's PyMMO?
Probably the most robust multiplayer handler I've seen
Oh u should probably look into thr port forwarding stuff in the pins of #networks if u want to use it outside of ur LAN
Assuming ur not buying ur own server from a hosting site that is
That's rly cool
Can I ask what the difference between the green and red lines are
green lines represent hitting a horizontal point of a wall in the grid and red ones represent the vertical point
Oh makes sense
then u pick the shortest one, and if u cast like 60 of them u can project them with rectangles and create a basic 3d scene
to put it in another way, green lines have some complicated shit for the X offset, and to check the next row for walls it just adds 100 because thats the wall offset
i mean grid
ah OK makes sense
oh that yea
Cool stuff
but in my version the rays sometimes dissapear for some reason at certain angles
as seen in the screenshot
need help on how to use a rect from a class, i dont understand how to use the rect from a class and detect collision with my mouse
losing my mind i'm not oogly goo
Well to access the rect of your class instance, instead of squares.rect, use square.rect within the event loop.
For detecting collision with the mouse, you can use the collidepoint method of the rect object.
And try this code :
if event.type == pygame.MOUSEBUTTONDOWN:
if square.rect.collidepoint(mouse_pos):
print("Collision detected with mouse!")
Just to be sure for work will be printed in console "Collision detected with mouse! " Just to test if work
thank you very much, i'm studying and having the hardest time trying it on my own
No problem I hope u will make really good game ! ๐
Character creation yay
Woow looks really cool
tyy
i got a player and shop class able to work with each other after some time
i havent implemented it but i plan on maybe having like a sequence of inputs to get there like for example:
Main Actions:
1 Explore
2 Inventory
3 Quit
then if player pick explore itll have another options
Explore:
1 Town
2 Beach
3 Forest
then if player chooses town another options appear such as
Town:
1 Shop
2 Quest Board
3 Armory
then ect ect untill the player gets to the shop then the shop options would have more options
Shop:
1 buy
2 sell
i dont know if that answers your question but thats how i understanded it xD
O ok
Gl hardcoding all of that logic lol
Oh ig a state machine would work
Sounds good either way
I saw this and thought my game I'm planning on is going to destroy me at the inventory part, so guys if you have free time to spare for my shit please help me out
https://discord.com/channels/267624335836053506/1236066171816644771
i just use a dictionary or a list for the inventory which is like:
inventory = {} <-- dictionary or dict
inventory = [] <-- list
I know dicts are very useful for game data, I just don't know if there's a better way than nesting dics 3-4 layers...that's what my little head can come up with now
https://paste.pythondiscord.com/PHQQ
here is an inventory example i used for my inventory system, hope it helps!
โจOโจ
Thanks for the code!
I'm just unsure if this is the best approch to store a apple with a ton of attributes
like how many seeds, weight, calories... and even the seeds have attributes! like how much cyanide a seed posses!
sounds like a fun challenge, ill be right back to give some result
might not be the pretiest result but its something xD
im still a beginner coder after all
im beginner too
so any code is beautiful to me, except the anti-loop cult on r/programminghorror
I am so hyped now lol
back again, here is the results of me adding simple attributes such as weight and calories
did i do the correct thing you were asking for lol
https://paste.pythondiscord.com/5LFQ
here is the updated code!
np! you can ask me anytime and ill try helping with the best of my current abilities
thank you!
working sell function y e y
got some simple controls finished time to sleep =w=
I smell the aroma of someone cooking a fun game
its just ganna be a little text rpg game and your goal is to just get the highest stat ig
That is fun enough
like
very little coding
most games are basically the same
true
if you don't look at the graphics and stuff
and the lore
All RPG are similar lol
after i gained enough experience points from finishing this project im ganna work on another one and its ganna be another rpg text based game with story
wait but spaghetti code RPG is not the same lol
If you don't look at the lore of Undertale
It will be much more horrifying
undertale coding is readable by aliens
when I see ppl saying Undertale makes them sick
but its a sucessfull game
I'm thinking like
Oh ho ho
you haven't seen the worst part of it
have you seen the yandare simulator i think which has like if statemens for everything
Yes, truly coded by a yandere
indeed
not just any Yandere
but the specific one that's HI on shrooms every midnight while coding
my code currently is barely readable by anyone else i think
If that shit came out like in 2023
No one can convince me that game is not developed by asking OpenAI 100 questions a day
I think it's ok?
but I haven't seen enough though lol
that reminds me of a video where they "made games for a year" but really just used mr gpt
lol my classmates use GPT for coding so much that they have to seek my help to identify that GPT added an extra : after a for statement(or maybe they messed something up pasting or fucking with the variables)
while thier PyCharm compiler literally says
statement expected before ':' on line xx column 20
i guess thats what happen when you rely on gpt too much
I thought I never have to deal with ; after I left C...
now you have to deal with ':'
But his brother : came to revenge me through my classmates
do you have like programming related stuff as your subject?
I was so grateful that I don't have to press shift for ;
but python use : so much now I'm not grateful anymore lol
Nah
just physics
ah i see
a bunch of for's
for loops?
yeah
much funner when I see the code of my roommate...
he over came the problem that he didn't know he can and should use a new array after plotting one plot...
Ill leave the rest of the imagination of how he overcame that to you guys...
I'm afraid to talk about it
bb
U have 1000 lines of codes...
Well im bigger bc I'm on phone ๐ฅฒ
I love library's but I hate compiler on phone can't give u suggest and can't finish instantly like when u write
That's Soo bad ๐
Oh I just use a little bit to give me exercise for practice something ๐คฃ
wait the entire game in a single file?
im not sure if that specific file is just massive but its good practice to split ur classes and stuff into their own modules
Im aware of that, its just for this project im just making something held by duct tape and hope but for my next projects i will absolutely use different files for different purposes
Ive already got plans making a module for an rpg text based game so it isnt as clutter as my current one lol
Do be like that sometimes
hello im new to python so i made a choose your adventure game
the end is a bit buggy but other than that its all good! please try it out and give me some feedback.
Ohh well I will try it to make it when I got PC
Btw good luck to make more bigger game :))
ty, good luck on your future projects too
here is a little suggestion
maybe have it like this so its a little readable
oh i use pycharm
print("A very epic and long dialogue that took me years to type and because its so cool")
print("[Choice 1] [Choice 2]")
input(">>>")
print("\nAnother very epic and long dialogue that took me years to type and because its so cool")
print("[Choice 1] [Choice 2]")
input(">>>")
there
using \n creates a new line so you can have that white space in between dialogues
you're talking to me?
i mean... i dont believe anyone else is here lol
oh i realised that i replied to the wrong person xD
yea
alright
if you wanna be extra fancy with it you can even have colors lol
so instead of writing nAnother very epic and long dialogue that took me years to type and because its so cool ill write what i have to write right?
how?
thanks by the way
you have to add "\n"
its like this \nHello Hi""
what does that do?
creates space?
ill keep that in mind when creating another one
it creates a new line, similar to when you press enter
this is withought that, no space it between dialogues
oh alright
here are some colored text
you may use colorama or you could make your own variable for it
alright thanks
gl on your coding journey
Ooooo
for what is even using for colorama ??? I for first time see that librsry
coloroma is a pretty cool module that lets you color text in terminal
here are the main things i use:
- change the font color
- change the backround of the text
but then i got bored then made my own simpler version
Soo I see for 1 game it's having like 20+ modules ideas that I can import inside ...
im making my own like rpg pack module and have features such as:
- Player and Enemy interactions
- Player and Shop interactions
- A combat system
- Fancy Dialogue stuff
probobly more
Well I want to create something like that but I'm not sure how much is that possible to I create on mobile...
wait you use python on mobile?
Yeees
It's pretty hard to write code on Pydroid 3
But I think is possible to make a game like a flappy bird
oh thats pretty cool, never knew you could use python on mobile devices
might try it so i can have things to do when im bored in school
got a working physics bridge made. any suggestions to improve it design wise
sry for the laggy recording, its much smoother in game
thats pretty cool!
for suggestions though maybe you could have railings?
like one of those rope railings
oo thx ye ill try that
Obviously bro, I started coding on mobile first and then shifted to pc
this types of railings maybe
its not that obvious bruh theres a much smaller proportion of mobile programmers
mainly cuz of how hard it is
sounds good alr i'll try figure out how to rig that
Yeah, it's was 5 years ago ๐
ah ok
has anyone of you heard of microstudio?
its a gameengine similar to gamemakerstudio but with python lua and js
Hi,
can anyone help in building the computer player logic for dot and boxes game(designed purely in Reactjs),
I want to implement Deep Q learning in reinforcement learning in javascript( or in python if it is possible to colab with my react project)
what app did you use man? thanks
u dont actually make a player instance anywhere
im assuming this section isnt running
in states.py
im not rly sure what tmxData is so i can't help u there but just check if a "Player" layer is actually in it
probably pydroid
keras is prolly ur best bet https://keras.io/getting_started/
linking the moves played in the front end of ur game to a simulated "environment" in python
and making + training a keras DQL agent inside the environment
also u sure u want to even use DQL, tic tac toe is a completely solved game theres far easier algorithms than a literal neural network
is this for a specific deep learning job
self.tmxData = load_pygame('Game assets\\Maps\\0.tmx')
its the map made in tiled
in this section
if "Player" in Layers:
print("exists")
for obj in self.tmxData.get_layer_by_name('Player'):
if obj.name == "0":
print(obj.name, "this is the object")
self.player = ...
Dude, paste your code up here next time...
It's tiring having to pause/rewind while I'm trying to read your code
Pydroid
wow looks awfully similar to what @foggy python made
had he released the source code for that game?
tictac toe has less number of possible states, but dot and boxes has huge number of possible states that cannot be handled by brute force algos(Minimax or monte carlo), hence I need to use DQL( reinforcement lerning)
No, personal project, just for learning purpose
nope
this entire project is trying to recreate what hes made
but with my own implementation
ah ok
definitely look into keras then
even down to the art...?
and the shaders?
ye
for the art i basically had to stop clips of his videos by frame
and just recreate it in ms paint or pixel art editors
shaders technically arent shaders cuz i have no idea how to use moderngl
@grave inlet
wait never mind lmao
i have to download colorama
dw
i downloaded it using python packages
i gotta learn how to use it now though
Ah, alright then.
im trying to find the type of slash you use for /n ๐ do i have to change my keyboard?
Have you checked below the backspace
yea
yea i have that under my backspace
for some reason it does lean in the direction it is supposed to
instead of \ its /
yea
oh ๐
yea
wait how did you use \
oh
hmhm
hold shift i guess?
did that
ive no clue how to solve that problem
if finding a backslash is this hard just change your keyboard yeah
Or copy paste backslash everytime you need it if you dont wanna change ig
Oooo interesting keyboard
thanks
here are some things i used in colorama
import colorama
red = colorama.Fore.RED
print(red+"Hello")
Thats for changing the color of text to red
red_bg = colorama.Back.RED
print(red_bg+"Hello")
To change backround of text to red
helpful thanks
Npp, just ask if you need help. Ill try to help with the best of my current abilities
remember to also colorama.Fore.RESET so the rest of your terminal isnt red
Oh yeah that too or if you want the next prints to be back to normal
the happiness when things work
a system that makes weapon and rarity combine
damnnn
im going to learn thiss
i have to use weapons in my next one
Weapon can probably be a dataclass
alright thanks
ooh, what are dataclass?
!docs dataclasses.dataclass
@dataclasses.dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)```
This function is a [decorator](https://docs.python.org/3/glossary.html#term-decorator) that is used to add generated [special methods](https://docs.python.org/3/glossary.html#term-special-method) to classes, as described below.
The `@dataclass` decorator examines the class to find `field`s. A `field` is defined as a class variable that has a [type annotation](https://docs.python.org/3/glossary.html#term-variable-annotation). With two exceptions described below, nothing in `@dataclass` examines the type specified in the variable annotation.
The order of the fields in all of the generated methods is the order in which they appear in the class definition.
a decorator that takes a class with the fields specified in a certain way, and automatically generates an __init__, __str__, repr, eq, and some other dunders like that
alright, ill look into it and see what i can learn, thanks.
(or coming from another direction, a dataclass is a class primarily made to just store some data. Most classes people write are dataclasses.)
i keep getting this error:
Traceback (most recent call last):
File "c:\Users\yanic\OneDrive\Desktop\Kingdom's Fate REAL\Game files\games.py", line 140, in <module>
games.loop()
File "c:\Users\yanic\OneDrive\Desktop\Kingdom's Fate REAL\Game files\games.py", line 129, in loop
self.states[-1].draw(self.screen)
File "c:\Users\yanic\OneDrive\Desktop\Kingdom's Fate REAL\Game files\state.py", line 89, in draw
self.camera.draw(screen, self.draw_sprites)
TypeError: draw() takes 2 positional arguments but 3 were given```
are all your files saved?
It was an indentation ๐ญ
how would one go about making a pygbag game into a multiplayer HTML5 game? as in a multiplayer turn based game
I'd start by adding something like a requests.get("some server that I have") to the pygame code and testing whether my server gets these requests when I run the game (because it might be that the way pygbag packages games disallows that).
If this works, then, well, implement multiplayer whatever way you want.
yeah, I'mm unsure if pygbag would support because it html5 nature, websockets I guess
thanks sorry
looking for a thread to pull
I was thinking of websockets too. I figure if you can make a basic GET request you can probably make a websocket connection too, but you could test specifically a websocket connection to be sure.
are dataclasses any better performance wise
So it didn't override the super().draw() method which indeed takes two args and is why that particular error message
not really, about the same. doing slots=True to make it a slotted class gets you some small performance gains.
thanks man
doesnt "normal" class need like pickle or somethin to save
u can pickle classes??
ive always just saved the attributes as json and reinitalised it
depends on what you mean by "need". saving a dataclass instance as json works the same way as saving a normal one - you convert it to a dict first. dataclasses just have a handy method for that.
yeah i used it to save my inventory filled with classes
cool
personally I never use pickle because I tend to write my data structures in such a way they can be easily dumped to JSON, and JSON is human-readable and not a massive security (and correctness) risk
wdym by correctness risk
pickling a class instance pickles the class, too. Meaning if you use pickle to store saves, and you load a save from the old version of the game, it'll be an instance of the old version of this class. Good luck figuring out why you are still getting bugs you fixed several versions ago ๐
ah makes sense ye
thats usefull to know
is there ever an instance pickling is more efficient or better to use over json
json just seems leagues easier and better
picking is faster, funnily enough. not by a lot, and only when using the builtin json and not a faster library.
not sure why
oh
my suggestion for saves is "zipped json". non-zipped is fine too if your saves are small. (Looking at you Egosoft - if your saves are 500MB of XML, use compression! ๐ฉ)
thx for the info ๐ ill look into that next time i need to save stuff
I've made a game using pygame and I have a file classes.py with all my classes.
How can I generate a class diagram automatically?? Is there any way??
I have a pickle save method but it's just saving what is basically a class with a dict of data
Things like sprite position, rotation, room
whats a class diagram?
And the load reads that and re-instances according to those attributes
can you send me a DM? so I can show you an example of a class diagram
Pycharm Professional can show the class diagram for a class. Otherwise, there's some tools like pyreverse.
okay thanks
i dont think pycharm can make that
i dont think anything can, its the kinda thing you're better off making yourself
especially if this is for education
Yo guys, i need to make a car racing game(2d) with python but i never used pygame. Do you guys have sources that i can use so i can build a game like that. I only have a week to make it:(
uhh
do u have any experience at all with python
also how complex does it need to be
I almost learned every basic
at this rate your only chance is to youtube pygame tutorials
why are you working to such a tight deadline?
The school has given me only a week
Do you have to make it so conplicated?
Its a simple 2d game it does not look to complicated
It looks a little bit like this
I think techWithTim made one a few years ago
hmm
Wasn't really a game, just an experiment
is similar
I was inspired by one of Coding Train's tutorials, so I did it in python
They have brakes, acceleration, and rudimentary collision detection
Where can i find the tutorials
It's not in python, but I can look for it
It's a looong way from this tutorial to my experiment, but this is where I learned how to do the projections https://www.youtube.com/watch?v=DHPfoqiE4yQ
This video covers the dot product and scalar projection with p5.js and vectors, concepts that Iโll need for finding the distance between a point and a line which will lead to the path following steering behavior in the next video! Code: https://thecodingtrain.com/tracks/the-nature-of-code-2/noc/5-autonomous-agents/6-scalar-projection
p5.js Web ...
That entire Nature of Code series is great, even though not in python, the logic (and his whiteboards) is great
Probably not really beginner python projects though, since they're in java or js
thought id have a bit of a fun with this so its definitely not a beginner project per say, nor finished for that matter but i made this quickly
theres no camera boundaries or offsets but works as a proof of concept of whats possible?
still would recommend the path following racer sst suggested for ur schl project
cant tell if the video is just glitching out for me but that looks pretty cool
i should really try using a framework instead of just good ol cmd
ill comment the code then dump it here if anyone interested
if u want to but ur style is very niche and cool
thanks! I only chose my style of doing text adventure stuff because its probobly the easiest for me and it makes me think less of the graphics and stuff
This looks great, the camera is a good idea
I had to update gpu driver to get OBS working for me, seems one of the latest drivers broke something, the updated driver fixed it
man i should try recreating the turn based battle system in final fantasy 1
That'd be a fun project, Clear Code's latest tutorial has a battle system
a tutorial would be nice but i think i can handle doing it on my own so i can find out my limits in problem solving
Yeah, you're already doing really good
https://github.com/theShim/racing_thing realised i couldnt send zips so dumped it into github
Contribute to theShim/racing_thing development by creating an account on GitHub.
thats fair, i think im the opposite. im not really creative, story wise or feature wise so i try to make it look as polished as possible
oh ok ill look into that
thx, and i think the camera is definitely a do-able feature to add for that guy's school project
I usually use tutorials just for discovery, adding tools to my toolbox, so to speak, that I can apply to my own projects. Sometimes I actually do the code of the tut but I'm really just after the tools
Yea it looks good. I will give it a try.
good luck, pop any questions u have along the way here
Aight
u use it the same as any of the other colour codes i swear
alright
this is how its going
im going to change the choices tho
im testing stuff out
i think u can change the background colour asw, might make the black text more visible
what is asw
the black text is visible tho
i will chage the background color
as well
alright
ye but more visible, especially on black terminals
oh alr
alright thanks
put it off for a while but finished that bridge with the idea u guys gave me
its not very detailed or textured since i have to do it with math rather than sprites but works enuf i think
I dont know why but if you use the bg too much it kinda just glitches out and cover the whole terminal
Also thats pretty cool!
I was trying to find png images, but it seems like all of them are fake png. Are there any tips or things i should do for png images? I tried to do the google filter transparent thing but it seems didnt work, at least in my case.
there should be some websites online that do it
otherwise i fill the background with black or something
then in my code i set the colourkey to black
img = pygame.image.load("image_location.png").convert_alpha() #image with background that should be transparent in black
img.set_colorkey((0, 0, 0))
thanks
oh ok
here, it just glitches out whenever i print out too much of it
even in command promt
its like a certain point where it glitches out
alr
my code is going well
im going to make the story line later
but how to make italics?
and the type writer effect
print("\033[3m'Sentence In Here'\033[0m")
the random giberish in the left side is what makes it italic and the right side is what resets it
but what you have to change is just the 'Sentence In Here' and you should be good
alright thanks
oh thats really weird is it just a normal while loop
my guess is using the end="\r" parameter in print functions and keeping a timer for the current letter ur on
tho idk how Christian implemented it
text = "This is a sentence."
t = 0
speed = 0.001
while t < len(text)+1:
print(text[:int(t)], end="\r")
t += speed
print()
this works but i dont think it's that robust
alright
yeah
for i in range (0,50):
print(" ")
this is a class that makes a type writer effect, the way to use it is
EnhanceDialogue(text="Your Sentence",
color=EnhanceDialogue.green, # The EnhancedDialogue.green is kinda like my own colorama.fore.
speed=0.02, # Controll the speed with this variable.
rainbow=True # Just a silly addition .
)
a little far off
yeah, i dont really know how to make a buffer/delay
ive pretty much stopped using sleep cuz i work in pygame
which would pause the entire update loop
alrightt
oh
where do i put this?
at the start?
you could put it in a separate file and use the import
but yes
you could also do that
so you kinda just import the file by using the file name
create another file in the same directory
ok
hmhm
it says unresolved reference
for enhanced directory
screenshot?
here is an example
alright
oh he doesnt have enchanced dialogue
i have to download?
well get the code from this
but just the class
oh sry
replace what u have inside this file
with the class code from the link Christian sent
ohh thankss
im importing the text_keyboard.py by using import since its in the same folder as the code im currently using
yepp
ye
yes
also you might need to remove the example from the enhancedialogue file at the bottom
alright
have u pip installed it
uh use
pip install pygame-ce
its the latest version basically
i sometimes use py -m pip install pygame-ce
i had almost the same issue as you lol it was because of my venv
ohh ye
i have to download the file tho right?
yep
i used those files
to create diffeent projects
alright
which one
the one christian sent me?
i have no idea about this but ig check your venv?
cuz thats what happened to me
uh
this one
alright
in ur main.py
after u import os
put this line
os.chdir(os.path.dirname(os.path.abspath(__file__)))
i didnt import os tho
oh import os then
im so confused ur file layout is very complicated
this is kinda the simple version of importing for future reference
idk how pycharm rlly works
damn
i might switch if i can have anime girls in it though ||joking||
swear u can in vs code
can do what
have some sort of anime related extension
there has to be at least one
programmers are clinically insane
imma check on yt
why yes there is
crazy
im sane
insane*
print("I'm sane.")
lol
ill take your entire stock
forgot the apostrophe so you are indeed insane
no its not edited i dont know what you mean
paranoid?
this is not gaslighting
this is a masterpiece is what it is
i just use animeFace and Doki Theme lol
anime face is to track how many error i have to deal with
is that the bokuben thing on the top right
oo thats cool
i mean have to import pygame for the typewriter
wait you need to use it for pygame?
demnn
what do you mean?
no
now im confuse
ohh
do you need like a typewriter effect for pygame?
now that i can provide
yep im just the terminal guy lmao
i dont need it for pygame i need pygame for typewriter lol
choose your adventure game
are you using a physical typewriter ๐
yes

i want to create a type writer effect in my choose your adventure game
yes
terminal
oh
the code i provided is a typewriter effect but i could make it simpler so it legit is just the type writer effect if you want
yeee
aight
why did he need pygame then
ohh ok
yeaa
lol i was wondering where u went
i think i kinda zoned out, did u end up getting what u wanted lol
Fun stuff
not yet
christian is writing the code rn ig?
i mean
Well writing isnt really the best way to put it
ye
Even vs code just crashed
bruh what happened
No clue
damn
Restarting it
dats crazy
ill give a shot at editing the code in the meantime
is it in the pastebin link u sent
simplify it in terms of
alright
commenting it or optimising it or?
Removing unnecessary stuff such as the rainbow function, color function, and only leaving the type writer function since its the only thing he needs
understood
oh i think that was it
import time
class EnhanceDialogue:
def __init__(self,text:str,speed=0.1) -> None:
self.text = text
self.speed = speed
self.print_input()
def print_input(self):
for char in self.text:
print(char,end='',sep='',flush= True)
time.sleep(self.speed)
EnhanceDialogue(text="Your Sentence",
speed=0.02, # Controll the speed with this variable
)
eh mine's pretty close i cut it down to this
import time
def __init__(self, text: str, color=red, speed=0.1, ):
self.text = text
self.color = color
self.speed = speed
๐
Uh
That doesnt really give a typewriter effect i dont think
Nor does it print anything
yea i know now
i just said it was close
Well maybe like a couple letters you coulda gotten jt
Also i think thid is it
So you see when you import it you have to use it like
Example if the file name imported is
Cool_Dialogue.py
import Cool_Dialogue
Cool_Dialogue.EnhanceDialogue("Cool Messege")
imo i would use from just to save myself typing it so many times
alright thanks
what do u mean?
from Cool_Dialogue import EnhanceDialogue
EnhanceDiaologue("Cool Message")
EnhanceDiaologue("Another Cool Message")
compared to
Yeah that one too works and easier
ah that is easier
Unless you have like a big module
what about print and input?
Doesnt need one
ye its in the class already
Yeah already implemented for you
Is that the original module?
its cuz Enhanced Diaologue basically just prints stuff with the typewriter effect
so when u do
Also you could just put the name inside of a {name} like {fore.cyan} so you dont have multiple string
name = EnchantedDiaologue(...)
name doesnt have any text in it
alright
Oh wait you tried to use it as an input
what about the color part?
There is a built in function (if youre using an original) that lets you pick a color
.
Use EnhanceDialogue("text here",Fore.CYAN)
but what bout the your sentence?
Try
its shwoing at the start
alr
fore.cyan in that bracket?
hes gonna get the same error i think
or {}
No need
Well making it was kinda hard
hmhm
im predicting TypeError
what you told me to do?
she means did it work
what work
The color
Guy btw lol
My brain just defaults to guy when i see a anime girl pfp
entirely fair enough on this app
Print(fore.cyan)
EnhanceDialogue("some funny")
i should do this?
yes
yes
screenshot of code pls
acc
send the code directly here
just the top bit where u changed it to enhnaced dialogue
alr wait
which code?
import colorama
from colorama import Fore, Back, Style
colorama.init(autoreset= True)
from scratch_8 import EnhanceDialogue
print(Fore.CYAN)
EnhanceDialogue("some funny")
EnhanceDialogue(Fore.RED + Style.BRIGHT + "LUCID DREAMS!\n")
name = EnhanceDialogue(f"{Fore.MAGENTA}What is your name?\n>>>")
EnhanceDialogue(f"{Fore.CYAN}Good luck " + name + "!\n")
alr
import colorama
from colorama import Fore, Back, Style
colorama.init(autoreset= True)
from scratch_8 import EnhanceDialogue
print(Fore.CYAN)
EnhanceDialogue("some funny")
EnhanceDialogue(Fore.RED + Style.BRIGHT + "LUCID DREAMS!\n")
EnhanceDialogue(f"{Fore.MAGENTA}What is your name?")
name = input("\n>>> ")
EnhanceDialogue(f"{Fore.CYAN}Good luck {name}!\n")
ok im back
alright
im ganna type some codes
11 25
pm for me
can i just send yall the code i made
and u can add type writer effect to it?
๐
maybe this is kinda what he is trying to do
ohh
import time
import colorama
class EnhanceDialogue:
def __init__(self,text:str,speed=0.1) -> None:
self.text = text
self.speed = speed
self.print_input()
def print_input(self):
for char in self.text:
print(char,end='',sep='',flush= True)
time.sleep(self.speed)
print(colorama.Fore.BLUE)
EnhanceDialogue("Whats your name?")
name = input(f"\n{colorama.Fore.WHITE}>>> ")
print(colorama.Fore.BLUE)
EnhanceDialogue(f"{name}? You have a nice name.")
anyways ima sleep 3 am is crazy
ye u need it gn
np ill get to work
ill send it tmr
ping me if the chat gets clogged
alright
๐ ๐ฃ๏ธ
hey there, looking to start a new project based on a drag racing game. I'd like to use this proof of concept: https://www.reddit.com/r/pygame/comments/1277t1x/had_an_idea_for_a_game_involving_drag_racing_with/ . But, I'm not sure where to start with all the physics. I understand physics well, but how can I create an accurate model to work out speed in MPH from RPM, gear, HP, torque, grip etc...? Any ideas? Thanks.
how realistic do u want it
also what perspective
like those arcade games or old topdown mario kart
or a pseudo 3d thing like the proof of concept thing i sent a few days ago
as close as i can get it, somewhat like 'AngeTheGreat' engine simulator
but rather than simulating the engine, taking those values and making it into a drag racing game.
Also the perspective will be similar to 'pixel car racer'
appreciate the reply @pine smelt means a lot
no worries
oh thats very doable
graphics wise it helps that its pretty much completely flat
the physics hm
ok well ig first step is decomposition as with most things
ya, the physics is the main part of the game
ye
specifically what would physics entail then
first obvious is gravity and friction
then based off the AngeTheGreat sim u mentioned
ye
i wont lie i dont know much about cars in general but
i think first off is just making a physics based body
probably a rigid body than soft
then adding wheel objects attached to it that experiences its own forces
quick q, do you think it's possible in pygame
then beginning to link up all of these values in a way that the entire body's math takes it all into account by itself
ye defo
will be harder than say using unity and c++
i didnt really wanna use a sep engine
but POSSIBLE yes
just pygame and vsc
fair enuf ye
u might need to sacrifice complete realism at some point due to how intensive calculations can be in python
but its definitely worth a shot
yea
idek where to start with the physics calculations.
i mean, i have one useful one
for cars in general, not physics
Torque = (HP x 5252) / RPM
but then again, I need to be able to find out much more from this
well, I guess i could work out general force using F = Torque x gear ratio / tire radius
then use this to find acceleration due to f = ma
im just processing my thoughts lmao
do you know how u normally apply acceleration and stuff in pygame
i mean pretty much but when applying it to code its euler-cromar integration
velocity += acceleration * deltatime
position += velocity * deltatime
dt great
ye
tho
for games thats usually just
the time taken between each frame
its more for "framerate independence", having the game run at the same speed even at different fps's
how would i even integrate dt into pygame
with this basically
when u apply any force as a vector
just multiply it by that deltatime
i meant finding dt due to framerate
obviously the game will not run at the same speed at different fps's if a constant is used
ig u could have ur FPS as a var
1/fps = dt i guess
Sry I was busy
That's very inconsistent
The time between each frame can vary very slightly
I usually just
It's very simplistic but have a temporary var of the time last frame
And finding the difference to the current time
Then updating the last frame time every time
makes sense
I'm trying to make collision happen between the player and a block above them and i want the block to be directly above the player but it is going to the middle instead of where the player is @ me if you can help
here is the github link: https://github.com/Laughattack7339/all_things_gravity
Your images are huge, open them in an image editor and crop them to include only the image instead of all that alpha
^ this ye
I can crop them for you...
There we go
also sry my slight ocd couldnt take ur code presentation
import pygame
pygame.init()
import time
width, height = 1000, 600
screen = pygame.display.set_mode ((width, height))
running = True
clock = pygame.time.Clock()
background = pygame.image.load('testing_back.png').convert_alpha()
question_block = pygame.image.load("question_block.png").convert_alpha()
question_rect = question_block.get_rect(midbottom=(442, 369))
player_image = pygame.image.load("robo_cycle.png").convert_alpha()
player_image.set_colorkey((0, 0, 0))
player_rect = player_image.get_rect(midbottom=(442, 492))
jumping = False
jump_key_pressed = False
gravity = 1
jump_height = 20
velocity = jump_height
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and not jumping:
jumping = True
print(player_rect.bottom)
print(jumping)
screen.blit(background, (0, 0))
if jumping:
player_rect.y -= velocity
velocity -= gravity
if velocity < -jump_height:
velocity = jump_height
jumping = False
screen.blit(question_block, question_rect)
screen.blit(player_image, player_rect)
pygame.display.flip()
clock.tick(60)
pygame.quit()
also use .convert_alpha() EVERY time u load an image, thats what was causing the major lag
I've had projects where the difference was a lot, so yeah