Re: is coding in python easy? just interested

Hello,
I have been dabbling with this queue problem and delta for the last month or so off and on. I finally figured it out in several ways.
One has 3 options when using a system like pygame or pyglet:
1. give everything its own addition each loop, won't be pretty if you have many objects. But basically, you can add to the object's elapsed time every iteration of the game loop. Just make sure you are sending the sleeping time value to the objects.


2. You can create a queue for all your object (either a set or a list, I don't think it matters), and run a loop each game loop to do: first, add the sleeping time to the time elapsed for each object. second, check if the object now should run and if so, run it. 3rd, if the object should run, it checks if the object should repeat (stay on the queue), or if it should remove the object from the queue. Other than that, it just goes on to the next iteration.

3. You have a built-in queue system you use for keyboard input and system events in pygame already. pygame.event... I have not quite figured out how using this for custom events works, but it is totally possible!


In other news, I found a fantastic tutorial on sighted game programming that I have been going through. I am commenting the code with comments about what each graphic and rendering thing does, I've been using my small amount of sight to see the drawing and text events that happen as well as reading the awesome descriptions in the tutorial of what is supposed to happen. So I hope that I can manage to make incorporating basic graphics (like text and whatnot) second nature. It is really not hard once you figure out all the things you need to do. There is just a ton of initializing, creating objects, drawing to objects then putting those objects into the internal screen, then updating the hardware's screen for each graphic.
I was amusing myself by d rawing heads and lines and making stuff run around the screen.
What I still need to know is:
Can pygame render graphics in half a pixel or less? Because there is this huge complaint by sighted people when graphics are not "smooth", which means that they are jumping too far each frame.


good things I have found out:
When creating the screen for any of my stuff, the normal screen is this really really small box up on the top right corner of the screen that no sane person can see. (well they probably can, it is just like an inch by 2 inches though)
So I keep their values, but here is what I do to make the screen full screen:


displaySurface = pygame.display.set_mode((400, 300), pygame.FULLSCREEN)


This goes right under pygame.init() and replaces the other values they put in pygame.display.set_mode. There is often a 0, 32 after the size tuple and those two numbers are not important, they will default to what they need to be.
second, in the game loop they write something about if event.quit:pygame.quit(). But this does not work with a keyboard. All that does is quit the screen if you can click on the little x at the top of the screen. Instead, make your keyboard loop look like this:
    for event in pygame.event.get():
        if event.type == KEYDOWN and event.key == K_ESCAPE:
            pygame.quit()
            sys.exit()


Press escape to exit. Otherwise, hit alt-tab to get to your command prompt and hit ctrl C to kill the game's operation.

Third, when working with graphics, you need to call the update to your screen each game loop. This line looks like: pygame.display.update(). The tutorial puts in sys.exit() under pygame.quit() and says it is there because the ide they say for you to use crashes without sys.exit(). But the real reason why they need that sys.exit( ) is because there is this pesky video error when you call pygame.display.update() after pygame.quit(). To get around this there are two options:
1. do what they say to do in the tutorial and do:
pygame.quit()
sys.exit()
2. right proper code and make a variable above the while loop that then becomes False when you hit escape and call pygame.quit() at the bottom of the script.
3. just ignore the video error because it really is not going to change how your code runs!

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to