http://pastebin.com/8qwZKnPG
just copy/paste and run the code.
Notes!
-
this game is unbeatable
-
changing the difficulty only changes the fps of the game
-
do not use disco mode if you cant do flashing lights
i know the code is VERY sloppy and poorly organized but id rather get the game done quick then spend hours making the code readable.
https://pastebin.com/XUjH54Na
(I've been told Pastebin is the way to go for sharing code, so yeah. Just wanted to show what i made!)
Here is the source. Just copy it and paste it into a text file, save it and name it whatever.py.
This requires Python and Pygame, obviously.
Also, it would be nice to have this documented. I would, but I don't quite understand it all. I'm still learning myself.
Thanks! Enjoy!
EDIT: thanks for the links!
I'm trying to learn Python by taking some codes for games like Snake. I want to copy and paste the code into Python, change some things up a bit in order to learn how everything works, and then begin making my own sets of code. But everytime I copy and paste more than one line of code into, Python launches Snake, and stops responding and I'm forced to cloe it. Is there anyway around this?
Here is a link to a video showing what happens: https://youtu.be/LsoJG4LHY4A
I really need a short, clear Pygame tutorial. Watched Clear Code, but his explanations feel too long and I forget details. Any recommendations? UPDATE: Found a good tutorial on flappy bird, and used that knowdge to make pong by myself!
Hello everyone! I've been toying with python and pygame for a few years, very casually, using my own programs and some of my friends' from high school for reference and ideas. I'm realizing that aside from small snippets of code to help me through issues, I don't really have any examples of whole programs from which to draw inspiration about coding practices and techniques, and especially anything involving more than one module. I was wondering if anyone would be willing to share some specific or generic examples of projects you have or things that get coded/imported into many of your projects.
Along those lines, an idea which was recently posited to me was having a display engine of sorts, that gets imported into another module and has all of its data passed to it. The idea being that the engine never has to change, but it can be used in a wide variety of applications. I tried to come up with something to fit the bill, but what I eventually ended up with is a neatly wrapped "engine" which makes a window and displays passed in information, but only information which has been passed before initialization. This seems minimally useful to something which constantly needs to update. I would imagine that somebody has implemented something similar to what I'm trying to do, and I figured that while I'm looking for examples, I might as well try to find as many different examples as I can. That goes for any coding examples or programs or neat pieces y'all can think up. I enjoy figuring out how code works and how I can adapt it to my own purposes, and living in the echo chamber of my own files doesn't really further my understanding at all.
Thanks!
-Jimbo
Along those lines, an idea which was recently posited to me was having a display engine of sorts, that gets imported into another module and has all of its data passed to it.
That sounds like Pygame ;)
I would go further and create a "template" structure that already does the things that pygame doesn't, basic functionality that every game needs e.g. loading and converting all the assets from the respective folders, collision and physics functions, bare UI elements that can be customized, processing gamepad inputs, etc.
I do this in almost all my projects now. Here is my sample project that I use: https://github.com/MattR0se/Template-game
And here is a game I am working on that uses this structure:
https://github.com/MattR0se/DungeonCrusaderV03
I may recommend googling source code for this. If you want to build a space invader game, look up 'space invader source code examples' for example, they are actually pretty easy to find, along with fantastic tutorials on YouTube that will step you through it. I'd honestly recommend google and YouTube for most things regarding python help for source code examples, and tutorials. Google may sound generic, but honestly that's mostly all you need to link you to the best reddit or YouTube channel reference.
I have been working in pygame for a while now but I realized that I do not know how the modules actually work. Like I learned what pygame.init()does. Before I didn't know and I would just paste it in my code because it is in the pygame example now I have a better understanding of it.
I want to have a better understanding of the modules in pygame.
Right now I am trying to loop the screen.
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = FalseI understand what the code is saying, but when I try to code it myself I do know what to code or where to start. All I know is it need it to loop and be able to exit the loop.
I guess my main question is how do I read through the pygame docs to better understand pygame?
Right now I am trying to understand the display module (just the basic stuff to set up the screen).
I'm trying to learn pygame and it would help if I could have some example code to see where I could improve on my own.
Does anyone know/have some of these?
» pip install gamesbyexample
I've been following the tutorial series made by KidsCanCode but after episode 6 of the tile-based game my code isn't working the same as his. I have the exact same code as him but I don't know if its because the video is 8 years old or if its because he is using Atom Editor and I'm using VS Code. This is the code used.