• Advertisement
Sign in to follow this  

do not understand why this isn't working

This topic is 1763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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
Sign in to follow this  

  • Advertisement