python - pygame: drawing font fails in class: -
i have class alert creates popup type feature in pygame. want draw text popup body, doesn't work. tested rendering text , saving bitmap. black box. thing kills me, class (button) below works perfectly, , gets called instance of class alert! @ least know can't parameter passing issue guess
class alert(object): def __init__(self,msg,x,y,dim_x,dim_y,the_game,screen,size=16): self.x = x self.y = y self.e_x = x+dim_x self.e_y = y+dim_y self.dim_x=dim_x self.real_dim_y=dim_y self.dim_y = dim_y self.the_game = the_game self.the_screen = screen self.font = the_game.font.font(none,size) self.bitmap = the_game.surface((dim_x,dim_y)) self.bitmap.fill(alert_body) print "msg: %r" % msg if((msg!=none) , (msg!=false)): text = self.font.render(msg,1,(0,0,0)) the_game.image.save(text,"text-test.bmp") self.bitmap.blit(text,[5, (self.e_y-((3*self.dim_y)/4))]) the_game.image.save(self.bitmap,"alert-test.bmp") newx = self.x+(self.dim_y-45)/2 newy = (self.e_y-(dim_y/6)) self.close_button = button(the_game,newx,newy,45,12,alert_button,"ok",18) ret = self.close_button.setaction(self.btn_quit,false) self.answer = false self.quit=false
this works reason, , don't see difference:
class button(object): def __init__(self,pygame,x,y,dim_x,dim_y,color,phrase,font_size,text_color=(255,255,255)): self.is_clicked = false self.has_next = false self.next = none self.has_prev = false self.prev = none self.enable=true self.x=x self.y=y self.dim_x=dim_x self.dim_y=dim_y self.e_x=x+dim_x self.e_y=y+dim_y self.color=color self.color2=color self.phrase=phrase self.has_action=false self.regularbitmap = pygame.surface((dim_x,dim_y)) self.clickedbitmap = pygame.surface((dim_x,dim_y)) self.regularbitmap.fill(color) self.clickedbitmap.fill((255,255,255)) font = pygame.font.font(none,font_size) text1 = font.render(phrase,1,text_color) text2 = font.render(phrase,1,(240,240,32)) self.regularbitmap.blit(text1,[1, 1]) self.clickedbitmap.blit(text2,[1, 1]) self.currentbitmap = self.regularbitmap
Comments
Post a Comment