2525import tcod .render
2626import tcod .sdl .mouse
2727import tcod .sdl .render
28+ from tcod import libtcodpy
2829
2930# ruff: noqa: S311
3031
@@ -746,76 +747,76 @@ def on_draw(self) -> None:
746747 for y in range (SAMPLE_SCREEN_HEIGHT ):
747748 for x in range (SAMPLE_SCREEN_WIDTH ):
748749 if SAMPLE_MAP [x , y ] != "#" :
749- tcod .console_set_char_background (
750+ libtcodpy .console_set_char_background (
750751 sample_console ,
751752 x ,
752753 y ,
753- tcod .color_lerp ( # type: ignore
754+ libtcodpy .color_lerp ( # type: ignore
754755 LIGHT_GROUND ,
755756 DARK_GROUND ,
756- 0.9 * tcod .dijkstra_get_distance (self .dijkstra , x , y ) / self .dijkstra_dist ,
757+ 0.9 * libtcodpy .dijkstra_get_distance (self .dijkstra , x , y ) / self .dijkstra_dist ,
757758 ),
758759 tcod .BKGND_SET ,
759760 )
760- for i in range (tcod .dijkstra_size (self .dijkstra )):
761- x , y = tcod .dijkstra_get (self .dijkstra , i )
762- tcod .console_set_char_background (sample_console , x , y , LIGHT_GROUND , tcod .BKGND_SET )
761+ for i in range (libtcodpy .dijkstra_size (self .dijkstra )):
762+ x , y = libtcodpy .dijkstra_get (self .dijkstra , i )
763+ libtcodpy .console_set_char_background (sample_console , x , y , LIGHT_GROUND , tcod . constants .BKGND_SET )
763764
764765 # move the creature
765766 self .busy -= frame_length [- 1 ]
766767 if self .busy <= 0.0 :
767768 self .busy = 0.2
768769 if self .using_astar :
769- if not tcod .path_is_empty (self .path ):
770- tcod .console_put_char (sample_console , self .px , self .py , " " , tcod .BKGND_NONE )
771- self .px , self .py = tcod .path_walk (self .path , True ) # type: ignore
772- tcod .console_put_char (sample_console , self .px , self .py , "@" , tcod .BKGND_NONE )
770+ if not libtcodpy .path_is_empty (self .path ):
771+ libtcodpy .console_put_char (sample_console , self .px , self .py , " " , tcod . constants .BKGND_NONE )
772+ self .px , self .py = libtcodpy .path_walk (self .path , True ) # type: ignore
773+ libtcodpy .console_put_char (sample_console , self .px , self .py , "@" , tcod . constants .BKGND_NONE )
773774 else :
774- if not tcod .dijkstra_is_empty (self .dijkstra ):
775- tcod .console_put_char (sample_console , self .px , self .py , " " , tcod .BKGND_NONE )
776- self .px , self .py = tcod .dijkstra_path_walk (self .dijkstra ) # type: ignore
777- tcod .console_put_char (sample_console , self .px , self .py , "@" , tcod .BKGND_NONE )
775+ if not libtcodpy .dijkstra_is_empty (self .dijkstra ):
776+ libtcodpy .console_put_char (sample_console , self .px , self .py , " " , tcod . constants .BKGND_NONE )
777+ self .px , self .py = libtcodpy .dijkstra_path_walk (self .dijkstra ) # type: ignore
778+ libtcodpy .console_put_char (sample_console , self .px , self .py , "@" , tcod . constants .BKGND_NONE )
778779 self .recalculate = True
779780
780781 def ev_keydown (self , event : tcod .event .KeyDown ) -> None :
781782 if event .sym == tcod .event .KeySym .i and self .dy > 0 :
782783 # destination move north
783- tcod .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod .BKGND_NONE )
784+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod . constants .BKGND_NONE )
784785 self .dy -= 1
785786 self .oldchar = sample_console .ch [self .dx , self .dy ]
786- tcod .console_put_char (sample_console , self .dx , self .dy , "+" , tcod .BKGND_NONE )
787+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , "+" , tcod . constants .BKGND_NONE )
787788 if SAMPLE_MAP [self .dx , self .dy ] == " " :
788789 self .recalculate = True
789790 elif event .sym == tcod .event .KeySym .k and self .dy < SAMPLE_SCREEN_HEIGHT - 1 :
790791 # destination move south
791- tcod .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod .BKGND_NONE )
792+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod . constants .BKGND_NONE )
792793 self .dy += 1
793794 self .oldchar = sample_console .ch [self .dx , self .dy ]
794- tcod .console_put_char (sample_console , self .dx , self .dy , "+" , tcod .BKGND_NONE )
795+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , "+" , tcod . constants .BKGND_NONE )
795796 if SAMPLE_MAP [self .dx , self .dy ] == " " :
796797 self .recalculate = True
797798 elif event .sym == tcod .event .KeySym .j and self .dx > 0 :
798799 # destination move west
799- tcod .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod .BKGND_NONE )
800+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod . constants .BKGND_NONE )
800801 self .dx -= 1
801802 self .oldchar = sample_console .ch [self .dx , self .dy ]
802- tcod .console_put_char (sample_console , self .dx , self .dy , "+" , tcod .BKGND_NONE )
803+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , "+" , tcod . constants .BKGND_NONE )
803804 if SAMPLE_MAP [self .dx , self .dy ] == " " :
804805 self .recalculate = True
805806 elif event .sym == tcod .event .KeySym .l and self .dx < SAMPLE_SCREEN_WIDTH - 1 :
806807 # destination move east
807- tcod .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod .BKGND_NONE )
808+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod . constants .BKGND_NONE )
808809 self .dx += 1
809810 self .oldchar = sample_console .ch [self .dx , self .dy ]
810- tcod .console_put_char (sample_console , self .dx , self .dy , "+" , tcod .BKGND_NONE )
811+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , "+" , tcod . constants .BKGND_NONE )
811812 if SAMPLE_MAP [self .dx , self .dy ] == " " :
812813 self .recalculate = True
813814 elif event .sym == tcod .event .KeySym .TAB :
814815 self .using_astar = not self .using_astar
815816 if self .using_astar :
816- tcod .console_print (sample_console , 1 , 4 , "Using : A* " )
817+ libtcodpy .console_print (sample_console , 1 , 4 , "Using : A* " )
817818 else :
818- tcod .console_print (sample_console , 1 , 4 , "Using : Dijkstra" )
819+ libtcodpy .console_print (sample_console , 1 , 4 , "Using : Dijkstra" )
819820 self .recalculate = True
820821 else :
821822 super ().ev_keydown (event )
@@ -824,11 +825,11 @@ def ev_mousemotion(self, event: tcod.event.MouseMotion) -> None:
824825 mx = event .tile .x - SAMPLE_SCREEN_X
825826 my = event .tile .y - SAMPLE_SCREEN_Y
826827 if 0 <= mx < SAMPLE_SCREEN_WIDTH and 0 <= my < SAMPLE_SCREEN_HEIGHT and (self .dx != mx or self .dy != my ):
827- tcod .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod .BKGND_NONE )
828+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , self .oldchar , tcod . constants .BKGND_NONE )
828829 self .dx = mx
829830 self .dy = my
830831 self .oldchar = sample_console .ch [self .dx , self .dy ]
831- tcod .console_put_char (sample_console , self .dx , self .dy , "+" , tcod .BKGND_NONE )
832+ libtcodpy .console_put_char (sample_console , self .dx , self .dy , "+" , tcod . constants .BKGND_NONE )
832833 if SAMPLE_MAP [self .dx , self .dy ] == " " :
833834 self .recalculate = True
834835
0 commit comments