40 Posted Topics
Re: python is a little funky when it comes to certain number calculations. try rounding your answer: [CODE=python]print round(500-499.99,2) [/CODE] this will tell python to get to original answer (0.00999999999999 ), and round it to the second decimal (the second argument in round() is the number of decimals to round to) … | |
Re: What library are you using? This can be easily accomplished in pygame. google something like 'pygame image fade' | |
Hey everyone, as the title suggests I'm trying to find a function or some code that'll execute a string of code in Lua. If anyone is familiar with Python, It would be the eval function. ex: [CODE=python] eval("y=1") print(y) >>> 1[/CODE] Essentially, I'd like to do that same thing in … | |
Re: I dont know about livewires, but did you type it all correctly? :p also, if you want todo games in python, i would just learn pygame directly. its powerful yet easy to understand ![]() | |
Hey everyone. Just recently I have been messing around with some files on my pc, trying to find a specific driver updater-program that was giving me some trouble. I went into add or remove programs, selected "NVIDIA Drivers" (I'm using a basic Nvidia graphics card), and removed it, thinking that … | |
Re: try running files using terminal/cmd commands: [CODE=python]import os os.system("file.py arg1 arg2 arg3")[/CODE] also, if you wanted to run a python file without command line arguments, (don't quote me on this but im pretty sure you can't use CMAs this way) try this: [CODE=python]#import the file import myfile # run a … | |
| |
Here I have a simple range function that can use floats as steps or increments. In a time test (using Psyco 1.6, python 2.5, and a basic PC), the normal frange function was able to go up to 1,000,000 from 0, by .3 , and finish that in about 0.5929 … | |
Re: I don't have numpy, but try replacing all of the other 'ifs' with 'elif' and see if that works. | |
Re: Hey there Sri. For ending processes, you can check out the command 'taskkill' ([url]http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskkill.mspx?mfr=true[/url]) Your version of windows may or may not have a copy of taskkill.exe in C:\WINDOWS\system32\ ,which is the actual command itself. If not, don't fear! There's tons of copeies of batch commands just like this one … | |
Hi all. Just today I had been on the computer for some hours. I turned it off, and then on again, and got an error saying that the NTLDR is missing. I did my research and apparently I need to restore my XP Home Edition with my Windows XP CD. … | |
Re: even faster would be: [CODE=python]key = pygame.key.get_pressed() event = pygame.event.poll() # exit if event.type == QUIT or key[K_ESCAPE]: pygame.quit(); sys.exit() # left arrow if key[K_LEFT]: # do something pass [/CODe] | |
Hi everyone. I'm currently working on a project with c#, and had some questions about classes. I'm a python programmer, so bear with me ;) How would I make a class that has pre defined arguments? I.e. even if the user doesn't pass that arguement, the default value of it … | |
Re: Hey if you guys would like another developer, I could be of some help. I would consider myself to be intermediate at python (with a little knowledge of c++), and have a pretty strong background in pygame (if that helps at all :D) I'm the kind of programmer that loves … | |
Re: what specific type of 2d math are your trying to make? please give more detail | |
Re: here are some tips. First off, after stating class person, you must have three spaces for each following line. 3 for each semicolon. As for init, it needs two under scores __ like so: [CODE=python]class person: def __init__(self): print('__init__ not _init_ :)')[/CODE] just like functions, classes can pass arguments. Use … | |
Re: i don't know much about Image library, but it's quite easy todo with pygame: [CODE=python] # import pygame import pygame from pygame.locals import * # import our picture image = pygame.image.load('picture.bmp') for x in image.get_width(): for y in image.get_height(): # for each pixel in the image, print out it's RGB … | |
Re: I don't think there is a lib that can cover all operating systems that use python, because they are all coded differently (I could be wrong, though :p) I know that you can grab key+mouse(and mouse wheel) input (outside of the main window) with pyhook [url]http://sourceforge.net/apps/mediawiki/pyhook/index.php?title=Main_Page[/url] It's pretty resourcful; I … | |
Re: hehe, i kinda got carried away.. [CODE=python]# import all of our needed random functions import random won = False def guess_7_times(): global won print('Welcome to the number guessing game!') # our random number real_number = random.randint(1,100) # how may guesses we have until we loop out of the function and … | |
Hi everyone. So I have your average Windows XP emachines PC. Just a few days ago, I booted and installed Ubuntu 9.10 32-bit on my pc, to make it dual booted. I just wanted to see what ubuntu was like. Pretty nifty, nice graphics, etc. So I go to uninstall … | |
Re: um, all of those you can do in cmd, but if you want to do direct cmd/system calls, use os.system() (note: these are windows system commands; these wont work an a non microsoft operating system) [CODE=python]import os,sys # change shell window os.system('title whatever u want here') # to view all … | |
hi everyone. Say I have my project directorys set up like so: /glider /libs classes.py /graphics /rooms room images go here I'm trying to access a image from graphics/rooms, but from classes.py. I'm using pygame, and I know to go back a folder in a dir; you use: [CODE=python]# go … | |
Re: you can use the list.remove function [CODE=python]list = ['sp','am',' and', ' eggs'] list.remove(' eggs') print(list)[/CODE] | |
Re: say if n was circle, this is what python interprets: [CODE=python]pygame.draw."circle"(screen, (random.randrange(255), random.randrange(255), random.randrange(255)), (random.randrange(640), random.randrange(480)), 50 )[/CODE] now thats not code; its a string. you could add if statements like so: [CODE=python]if z == 'circle': pygame.draw.circle(arguements_go_here) elif z == 'line': # code for drawing line here[/CODE] | |
hi everyone. Just out of curiosity more than anything; does anyone know of a library that can grab microphone input (on windows)? I'm looking into how to write a kind of VoIP (voice ip) program. I know how to use sockets for sending/receiving data, but I just need the microphone … | |
Re: when you draw a circle on the screen w/ pygame, you are not making a class instance. you are calling a function. you would need to have a seperate x and y variable incrementing up every game loop to make it look like it is moving | |
Re: to get your computers ip, try [CODE=python]>>> import socket >>> socket.gethostbyname(socket.gethostname())[/CODE] | |
Re: try: [CODE=python]if car_pos.x >= the_screens_length: car_pos.x = 0[/CODE] | |
hi everyone. to put it plainly, I was writing some python code that used the itunes scripting interface to control itunes. so I got all of my functions down, and now I wanted to have these actions occur on a specific mouse press. thanks to Tech B, I used the … | |
hi everyone. just recently I've been messing around with controlling itunes with python (you should check it out on google; some pretty fun stuff to mess with :D). I've already got all of my functions down, but my questions is that how would I go about grabbing keyboard/mouse input (mouse … | |
hello everyone. Right now i'm currently working on a 3d engine in python and pygame. it supports images that can (will) be mapped and transformed to look 3d. in pygame, you can load your basic image, do rotations and scales, etc. But the only thing it lacks (perhaps b/c it's … | |
Hi all. I recently wrote a python program that takes a screenshot of the current active window. After taking that screenshot, it saves it as a bmp (using PIL), and then goes thru each pixel, looking for a certain color. If it finds that color, it moves the mouse to … | |
hi all. This might be more of a math problem then anything, but i'll give it a shot. I have an idea for a game i am working on, in which the player must advanced thru a level my the means of propelling a cube in the air (across the … | |
Hi all. I'm working on a python file that will be included in a project I am working on. Unfortunately, I ran into some problems when it came to passing arguments from a function, to another function. Let me explain; I have two functions: dist and return_mouse_angle. dist returns the … | |
Hi all. I'm having a bit of trouble (maybe it's easier than I think..) finding the lowest and highest number in a tuple of lists. Here is my main tuple: [CODE=python]list_of = ([0,7],[100,25],[150,59],[300,189]) [/CODE] so pretty much, I need python to return the lowest and highest number for each 'item' … | |
Re: as for creating your own terrain, thats gets really deep into the mechanics of the game. You would have to have the tools that the artists/programmers have at blizzard. I'm sure they have to make a level, add a bunch of crazy collision algorithms (prolly written in c++), then compile … | |
Re: I think what you are looking for is: [CODE=python]background = pygame.image.load(bif).convert() # notice that pygame surfaces use 'convert' not 'covert'. # it's just a simple syntax error. also, out of curiosity, why are you # converting your background to support alpha transparency? # Unless you are drawing image behind 'background', … | |
Re: you know, pygame has it's own rect collision system: [CODE=python]g=Rect(0,0,50,50) h=Rect(30,30,60,60) if Rect.colliderect(g,h)==1: print "g and h have collided!" else: print "g and h have not collided yet" [/CODE] hope that helps! | |
Hi all. I'm not sure if this is the correct place to post this, but whatever. I have a simple .reg file that adds the command 'Open Dos Box' to the menu that pops up when you right click a file (on windows) I want it to open a DOS … | |
hi all. I know that when you create a class, you put all arguements for that class in a __init__ functions, but what about for actaully making classes? confused? this is what I mean: [CODE=python]class Aclass(Object): insert code here...[/CODE] what is the purpose of 'Object'? |
The End.