- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 12
- Posts with Upvotes
- 12
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
- Interests
- Love to bake, read, write, and play video games.
- PC Specs
- Ubuntu Linux
63 Posted Topics
Re: Not unless you are going to use "exec()" and people advise against that. The second way is a good way. [CODE]class Test: def Testing(self): # Run function x = Test() x.Testing()[/CODE] | |
Re: [QUOTE=adanaz;1151545]Thanks for the advice but I'm trying to make my game retro, like the old text based games such as Zork etc. The green text on a black background is classic.[/QUOTE] Honestly, get pygame. Its easy to do a text based game with pygame. It will make a screen, and … | |
Re: 2nd part: Do something like this [CODE]func_dict = {'n':north, 's':south, 'e':east, 'w':west, 'i':inventory} # This dictionary uses the key letter you want, and the function you want to use letter = raw_input('Welcome to Town Square.\n').lower() # Letter is always lowercase by using '.lower()' if func_dict.has_key(letter): func_dict[letter]() else: print 'Invalid key'[/CODE] … | |
Re: I am pretty sure if you don't handle the error, it quits your program. Try this. [CODE]def inputNumber () : x = input (’Pick a number: ’) if x == 17 : raise ValueError, ’17 is a bad number’ return x try: inputNumber() except ValueError: print 'You picked 17'[/CODE] | |
Re: Why is this solved? lol. I was handling the handling of variables (Until my 3rd computer wipe, which caused me to stop working on my RPG) like so [CODE]class Hero: """The hero class""" def __init__(self, name, id, race, stats, level=1): """ Creates the Hero""" self.name = name # Sets the … | |
Re: What do you mean by block? Just don't use it? | |
Re: Change line 8 to [CODE]for line in fin.readlines():[/CODE] | |
Re: I know with Ubuntu, you can install 2.6, 2.7, and 3.0 in addition to the 2.5 it comes with. And since Ubuntu, being a derivative of Debian, shares many packages with Debian, maybe you can too. But Grib is right about the rest of it. | |
Re: Show us some code. [CODE]file1 = open(filname) # Opens a file to read words_in_file = file1.read() # Reads everything in the file[/CODE] | |
This is used for finding the roots of a parabola. The parabola must have a number in front of x2 (x squared), a number in front of the single x, and a following number, or you can have a perfect square parabola. (in the form "number x2 - number") This … | |
Re: Why don't you follow the method already stated on the thread? | |
Re: fixed! [URL="http://stackoverflow.com/questions/242304/where-should-i-download-corflags-exe-from"]http://stackoverflow.com/questions/242304/where-should-i-download-corflags-exe-from[/URL] [URL="http://www.bluej.org/download/download.html"]http://www.bluej.org/download/download.html[/URL] | |
Re: over? You mean on a different line?? If so, you should use a line break. [CODE]out = open('output.jh') towrite = a+'\n'+b out.write(towrite)[/CODE] | |
Re: There is no need to make 2 threads in the span of an hour on the same topic. Also, can you show us some effort on your part? It looks like a simple ceasar cypher to me though. | |
Re: I'd imagine it'd be something like [CODE]import os import glob # If you are running *nix. Looks like you are mypath = '/Desktop/directory/' files_in_directory = glob.glob(mypath) # Creates a list of all the files in your directory '''This a comment. If you only wanted, say text files to show up … | |
![]() | Re: Try this [CODE]import pygame from pygame.locals import * from sys import exit from random import * pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) run = True while run: for event in pygame.event.get(): if event.type == QUIT: run = False # Exits the loop. Not sure if 'exit()' was defined break … |
Re: What isn't working? It looks, at a glance, to be working. | |
Re: A few things. [CODE]int(raw_input())[/CODE] is safer then [CODE]input()[/CODE] And second, what if they input a letter? It will just raise an error. Do you want to do something with it? | |
Re: That is because you are comparing strings. If If all the numbers were integers or floats, 10.24 would be the max. | |
I have recently redid an earlier version of my version of Pong. However, I am having a slight issue with it. Whenever the ball hits the opposing paddle and then hits the bottom, the ball travels along the bottom until the player paddle hits it. I have tried for days … | |
Re: Most video games do benefit the user in some way or another. Hand-eye coordination is a widely known one, for instance. Another, brainstorming and fast planning skills. If you keep dying by getting shot at one point in the story, then you must make up a plan(brainstorming). If you are … | |
Re: Show us some work, and we will help you | |
Re: There is a Clock class. I use it all the time. Go to the pygame documentation, and it will show you all the methods in it. It will be in the 'time' documentation | |
Re: That is because the variable 'celsius' was never defined. [CODE]def get_celsius(celsius): celsius=int(raw_input("Type in the Celsius temperature: " )) # use 'int(raw_input())' instead of 'input()' return celsius def main(celsius): # Pass the variable in new = get_celsius(celsius) # When you return a value, you should store it in a variable farenheit=(9.0/5.0)*new+32 … | |
Re: Why don't you try it? If you are using Idle or another IDE, using the interactive prompt. If you are using Linux, using the command line to get into the python interactive prompt. (For Windows users, does that same thing work in Windows? Never tried it) | |
Re: Right off the bat, I see a common mistake. Don't use 'file' as a variable name. | |
Re: Mac has py2app (not sure the address) Have never used solaris so I have no clue. cx_freeze is for linux (though I have never had any luck with it) | |
Re: 1) You are using those variables to be passed into a function (pygame.draw.rect). This function expects the variables to be in a tuple/list. 2) 639 is one less then the width of the screen. It will make sure that you are not drawing off the screen. The dash is the … | |
Re: gEdit does most of that already. And I am quite happy using Eric IDE. But, I will try it, and comment back here on it | |
Re: I think he meant scores as in rank Like a flush is worth more then a pair. | |
Re: Why do you need separate modules? Its small enough not to really matter... Python is case-sensitive so when you import something, it must follow the same case You use import at the beginning. [CODE]from makeAge import makeAge from makeName import makeName def main(): name = makeAge() age = makeAge() main()[/CODE] | |
Re: I think it would be [CODE]import os os.path.join('root/module1') os.path.join('root/module2') import somescript import someotherscript[/CODE] | |
Re: Use Ubuntu's software installer. I run both on mine so... | |
Re: I am currently doing the same in Python. The key is to plan it out first, then start text-based, then move on to graphics. Much easier that way | |
Re: I thought pygame didn't work with 3.X? If it does, it should still follow the same instructions. 1) Load image (pygame.image.load(image)) 2) Blit onto display screen (screen_variable.blit(image, image.coordinates)) 3) Update display (pygame.display.update()) | |
Re: Well you could do it like this. [CODE]while True: event_list = pygame.event.get() for event in event_list: if event.type == pygame.KEYDOWN and event.key == pygame.K_TAB: event_list.append(pygame.event.Event(pygame.KEYDOWN, {'key':pygame.K_LALT})[/CODE] I think that would work | |
Re: [CODE]int(input('blah blad'))[/CODE] is correct for 3.X for 2.X it is [CODE]int(raw_input('blah blah'))[/CODE] now for your question [CODE]if sum(foo[1:3]) == 11: # do something elif sum(foo[1:3]) == 1: # do something else[/CODE] | |
Re: Try this. [CODE]font1 = pygame.font.SysFont('ActionIsShaded', 12)[/CODE] | |
Re: I just took Algebra 2/ Trig, and this was extremely annoying. I knew to do it in my head, but, just like ultimatebuster, my teacher took off for it. I get Calc next year, and i hope there isn't any of this | |
Re: Moo, how did you get to that? Its very different then it was before. This is a better way to check if a user have entered a "yes" [CODE]if (import_yn in "y yes yeah".split()): #code[/CODE] | |
[CODE]class Test: def __init__(self, number): self.number = number def getnumber(self): return self.number x = Test(54) y = 'number' print x.getnumber() try: print(eval('%s.%s'% (x, y))) except Exception, e: print(e)[/CODE] This isn't the code I want to fix, but it has the same error. I am trying to return a class function … | |
Re: You didn't do it properly the way you set it up. You can do one of a few ways. I will show you the two I use 1) change line 11 to [CODE]self.owner = owner[/CODE] Then when you are running it, create an Owner first, then pass that into the … | |
Re: Because you are checking for a string, when you changed the variable "amount" to a float. change line 11 to [CODE]if amount == 0:[/CODE] or this [CODE]if not amount:[/CODE] | |
Lets say I have a class. It holds other classes in it. ex [CODE]class Test: def__init__(self, name): self.name = name def getname(self): print(self.name) class Holder: def __init__(self, tests): self.tests = tests def getnames(self): for i in self.tests: print( i.getname())[/CODE] so lets say I pickle an instance of Holder with 3 … | |
Re: Pyscripter is the one I use. Its pretty awesome | |
Re: I believe its "\n" that is the newline character | |
Re: [CODE]line = f.readline() # Grabs your line sline = line.split() # Breaks your string into a list, separating it at " " surname = sline[1] # Grabs the second part of the list, which is the surname print surname[/CODE] | |
Re: I for one, am waiting for more 3rd party modules to switch over to 3.X. Then I will start using 3.X more | |
Re: As far as I know, you can't limit what a variable can be. However, you can check if the variable is an instance of class by using [CODE]isinstance(arg1, arg2) # Arg1 is the variable, Arg2 is the class[/CODE] That will return a truth value of True if it is an … |
The End.