How do you determine the system requirements of your own game? - python

I was planning on making clones of simple 8-bit era games to start my 'career' in using pygame. I've almost finished my clone of snake. I was planning on putting these games on my laptop so I could play them on the go, but honestly, I don't know if the laptop could handle it.
While developing my snake clone, I noticed that the game would experience increasing lag as the game progressed. I was surprised at this, seeing as I'm running this on a high-end gaming computer. I determined the problem was that my algorithm for recording the snake's path (which I use for drawing the tail) was filling up insanely fast with coordinates. I fixed this by having the game only allow the list of coordinates to be as long as the snake's current length. This did a lot to fix the lag, but I still experience some slow down if I get the snake really long.
I don't understand why the game would lag on my computer just from a (relatively) small list of variables. This machine can run Skyrim on full graphics, yet it can't handle a game that uses over a few dozen variables? This has made me worried for my laptop, since, obviously that is NOT a gaming machine.
However, I have no clue how to determine if my laptop could run my game or not. Normally I just go to 'can you run it?' if I need to figure this out, but obviously I can't do that for my game. I don't know how to determine what kind of system a person would need to run any game I make. I wasn't expecting such primitive games to cause performance issues on my machine. I mean, if I can run Skyrim at full graphics, then why does my Snake game slow down as it progresses? It makes no sense. And I'm using pygame.draw for graphics, so I'm not having to load and draw proper sprites either. Honestly, the only game out there that's less graphics intensive than mine is pong. How could something so basic have issues on a modern gaming computer of all things?

Related

How can I implement a TcP connection on my turtle based Pong game, to create a 2 player game?

I'm trying to create a 2 person Pong game, that can be played by 2 different clients (possibly on 2 different machines) using a TCP connection (sockets). I have made my Pong with Turtle. I've also practised a bit with the server-client connections by sending messaged back and forth. The problem is that I can't seem to be able to implement this method in my game. I think I have too little knowledge of the socket-structure.
I have already tried to put my code into classes first, as that would make it easier to implement the socket connections, but that didn't really work out so I kept it easier for now. Also tried to make the code with pygame, but for some reason, that is bugged on my computer.
http://christianthompson.com/sites/default/files/Pong/pong.py
My code is based on this youtuber's code.
I expect/hope that this is a solvable problem and that you can help me move forward with this. I don't expect any fully written code or anything like that, just a nudge in the right direction, where to implement the sending/receiving, where to put the game code (client or server), what to look out for etc.

Python Master Volume Control

I want to make a small program that changes the volume levels of programs based on what programs are open and possibly given audio detection, for example if im running a game window, and I have music in the background, I'd want it to lower the music volume if it detects audio being sent from the game window.
I usually play with game volumes turned off, but I usually watch cutscenes, so my goal is to have the music playing and mute if a cutscene comes up.
I dont know how doable it is with python, but I have the most knowledge of python thus Im asking for that if possible, I could do it in another language if anyone has suggestion.
So more or less, I just need some direction on what libraries of languages would be useful for making this program.
OS involved - Windows 10

Playback of at least 3 music files at one in python

I am searching for a way/framework to play at least 3 music files at one in a python application. It should run at least under ubuntu and mac as well as on the raspberry pi.
I need per channel/music file/"deck" that is played:
Control of the Volume of the Playback
Control of the start position of the playback
Play and Pause/Resume functionality
Should support mp3 (Not a must but would be great!)
Great would be built in repeat functionality really great would be a fade to the next iteration when the song is over.
If I can also play at least two video files with audio over the same framework, this would be great, but is not a must.
Has anyone an Idea? I already tried pygame but their player can play just one music file at once or has no control over the playback position.
I need that for a theatre where a background sound should be played (and started simultaneosly with the light) and when it is over, a next file fades over. while that is happening there are some effects (e.g. a bell) at a third audio layer.
I finally got an answer/workaround.
I am using pythons multiprocessing class/functionality to run multiple pygame instances.
So i can play more than one music file at a time with fully control over playmode and playback position.

Is it possible to detect when the system is recording a sound and then perform some action on Python?

I began learning Python a few days ago, and i was wondering about a practical use for a program.
Then i came up with the following: if my brother is in his room recording himself playing guitar, a led plugged to the usb and wired so it's outside his door lights up, and then i'll know he's recording and i'll take care not to make any noises.
The main questions are:
How Python can detect any recording going on in the system?
How would i interface with the usb so i can actually turn the led on?
to interact with USB, you can read this related question.
to detect recording, you will have to tell us on which operating system your program is intented to run (but i am not sure it is possible to detect that another application is recording)

Precise response to tablet/mouse events in Windows

How can I tell Windows not to do unhelpful pre-processing on tablet pen events?
I am programming in Python 2.6, targetting tablet PCs running Windows 7 (though I would like my program to work with little modification on XP with a SMART interactive whiteboard, and for mouse users on Linux/Mac). I've written a program which hooks into the normal Windows mouse events, WM_MOUSEMOVE etc., and writes on a canvas.
The problem is that the mouse messages are being fiddled with before they reach my application. I found that if I make long strokes and pause between strokes then the mouse messages are sent properly. But if I make several rapid short strokes, then something is doing unhelpful pre-processing. Specifically, if I make a down-stroke about 10 pixels long, and then make another downstroke about five pixels to the right of the first, then the second WM_MOUSEDOWN reports that it comes from exactly the same place as the first.
This looks like some sort of pre-processing, perhaps so that naive applications don't get confused about double-clicks. But for my application, where I want very faithful response to rapid gestures, it's unhelpful.
I found a reference to the MicrosoftTabletPenServiceProperty atom, and to CS_DBLCLKS window style, and I turned them both off with the following piece of Python code:
hwnd = self.GetHandle()
tablet_atom = "MicrosoftTabletPenServiceProperty"
atom_ID = windll.kernel32.GlobalAddAtomA(tablet_atom)
windll.user32.SetPropA(hwnd,tablet_atom,1)
currentstyle = windll.user32.GetClassLongA(hwnd, win32con.GCL_STYLE)
windll.user32.SetClassLongA(hwnd, win32con.GCL_STYLE, currentstyle & ~win32con.CS_DBLCLKS)
But it has no effect.
I tried writing a low-level hook for the mouse driver, with SetWindowsHookEx, but it doesn't work -- obviously the mouse messages are being pre-processed even before they are sent to my low-level Windows hook.
I would be very grateful for advice about how to turn off this pre-processing. I do not want to switch to RealTimeStylus -- first because it won't work on Windows XP plus SMART interactive whiteboard, second because I can't see how to use RealTimeStylus in CPython, so I would need to switch to IronPython, and then my code would no longer run on Linux/Mac.
Damon.
For raw mouse messages, you can use WM_INPUT on XP and later. Seven added some touch specific stuff: WM_GESTURE and WM_TOUCH

Categories