Help ATS with a contribution via PayPal:
learn more

Help with code?

page: 1
0

log in

join

posted on May, 16 2013 @ 10:11 PM
link   
Hey guys ^_^. Anyone here know python and would be willing to help me with this code? I am making code for a text version of pokemon red version for my entertainment, but the error is that I cannot move despite thinking I coded it right. help please? thanks ^_^




posted on May, 16 2013 @ 10:14 PM
link   
For anyone to have the slightest chance of helping you, you'll have to post the code.



posted on May, 16 2013 @ 10:22 PM
link   
www.dropbox.com...

there is the link. the code is too big for ats's reply.



posted on May, 16 2013 @ 10:53 PM
link   
reply to post by locololo
 


The problem is with namespaces. location is defined within the namespace of the function, but you set it as if you want to set the location variable you defined at the beginning.

The right solution - have you ever made a class? It would look like this:

class MyGame:
def __init__(self):
self.location = (1,1) #start location

def move_player(self, direction):
if direction == "up": self.location = (self.location[0], self.location[1]+1)
....

sorry, ATS edits out tabs.
edit on 16-5-2013 by tridentblue because: (no reason given)



posted on May, 17 2013 @ 12:35 AM
link   
reply to post by tridentblue
 


Okay I had set up the commands to work with it, but when running says there is a syntax error with the def_init_(self): colon. is that supposed to be there?



posted on May, 17 2013 @ 12:41 AM
link   
reply to post by locololo
 


How do you run that code, if you're in a window environment? I have python for windows, but never used it nor python before, but I'm interested anyway as it look interesting and I've just never really looked at it.

I'll have to google it and hope !! lol



posted on May, 17 2013 @ 12:52 AM
link   
reply to post by winofiend
 


I run python on either my linux IDLE or the window's IDLE, and it works like a normal compiler, minus the compiling. But yes I figured out one less issue with the class situation and attempting to figure it out now.



posted on May, 17 2013 @ 07:41 PM
link   
Another issue I found after getting the move function to work is with the battle code. It is supposed to pick a random function, using random.choice([scratch(), tailwhip()]) and also it is supposed to each turn give the player the choice of a command, not repeat the same command every time. May I ask how I could get it to work that way? I know it can be done cause an assignment I've done for my programming class, but I am not sure where the difference is. Below is the link to the current version of the code, as well as the assignment's code, maybe someone could help out?

www.dropbox.com...
www.dropbox.com...

thank you guys, and sorry if I'm being a pain.






top topics



 
0

log in

join