do not understand why this isn't working

Started by
2 comments, last by rip-off 11 years ago

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?

Advertisement

And you're sure that points is not 0?

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

yes, it is a random integer between 1 and 100

Can you create a minimal example demonstrating this issue? The following code appears to work perfectly on codepad:

 
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

This topic is closed to new replies.

Advertisement