Sign in to follow this  
game of thought

do not understand why this isn't working

Recommended Posts

I have began to use unicurses to make a game but for some reason the score counter will not change in the game 

score = 0

def spawn(iy,ix,char,points):#y coordinate, x coordinate, character and score
	
	mvaddch(iy,ix,char)
	if x == ix and y == iy:#checks to see if player x and y are the same
		global score
		score = score + points#this doesnt work
		mvaddch(ix,iy,' ')#this works


 

for some reason, when i append this to a main function, the counter on score remains at zero, i have done a lot of research on it and cannot find any answers beyond the obvious that i have already tried

 

what is going on?

Share this post


Link to post
Share on other sites

Can you create a minimal example demonstrating this issue? The following code appears to work perfectly on [url="http://codepad.org/5Em5DlLV"]codepad[/url]:

 
score = 0
x = 0
y = 0
 
def spawn(iy, ix, points):
    if x == ix and y == iy:
        global score
        score = score + points
 
print score
spawn(0, 0, 1)
print score
spawn(0, 0, 2)
print score

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this