user2970954
user2970954

Reputation: 89

Trouble with pygame.time.get_ticks

I have stated time=pygame.time.get_ticks

then when bliting thing to the screen I try window.blit(time, (0,0))

but where the time is supposed to be it just says built in function. Why is this??

Upvotes: 0

Views: 311

Answers (2)

Bartlomiej Lewandowski
Bartlomiej Lewandowski

Reputation: 11180

Just to add a bit to furas answer.

Since this function is called get_ticks, you need to do the actual action to get the ticks. There is one more thing that troubles me, you are trying to blit a integer to the screen, and this is not possible.

What you need to do is create a surface from the string value of the miliseconds, and blit that.

Upvotes: 0

furas
furas

Reputation: 142711

pygame.time.get_ticks() give you number not surface to blit on screen.

Seems you forgot () in time=pygame.time.get_ticks -> time=pygame.time.get_ticks()


With () you run function and get result. Without () you get reference to function and you can use it as argument in another function

def plus(a,b):
    return a+b

def minus(a,b):
    return a-b

def compute(x, y, function_reference):
    return function_reference(x, y)

print compute(10, 7, plus) # 17
print compute(10, 7, minus) # 3

Upvotes: 3

Related Questions