Taptapir Documentation

Documentation




taptapir
Global functions
set_orientation('vertical' / 'horizontal') set_window_color() set_background_color() set_scale() # scale game view set_fullscreen(False / True)
Global variables
ASSETS_FOLDER = '' entities = [] scene # default parent for entities. camera camera.ui # default parent for ui elements. Not relevant if you never move the camera or change camera.fov. aspect_ratio top_left = [-.5, .5*aspect_ratio] top_right = [.5, .5*aspect_ratio] bottom_left = [-.5, -.5*aspect_ratio] bottom_right = [.5, -.5*aspect_ratio] top = [0, .5*aspect_ratio] bottom = [0, -.5*aspect_ratio] left = [-.5, 0] right = [.5, 0]
Entity
Entity .parent .children .enabled .visible_self .name .position / .xy .x / .y .z # sorting .scale = [1,1] .scale_x / .scale_y .origin .look_at() .color .alpha .texture = 'some_image.png' .roundness # 0 .padding .shadow # False / True .text = '' .text_color .text_size .text_origin .fit_to_text() .on_click .on_enable .on_disable .ignore_collision .draggable # False / True .dragging # to check if it's being currently dragged. .lock_x / .lock_y .min_x / .max_x / .min_y /.max_y .snap_x / .snap_y .tileset_size .tile_coordinate
Classes
Button Text InputField value HealthBar Scene goto_scene('name')
Math
lerp() clamp() random_int() random_choice() random_color() lists_are_equal()

sunsnake
Log
print()
if-statements
if a and b or not c: print('success')
Functions
def my_function(): print('hi')
Arrays
my_list = [6,2,9,0,3]
Range
for i in range(8): print(i)
for i in range(1, 8): # from 1 to 8 print(i)
for i in range(1, 8, 2): # from 1 to 8, with a step of 2 print(i)
Shorthand range:
for i in 8: print(i)
Enumerate
my_list = ['sun', 'snake', 'script'] for i, e in enumerate(my_list): print(i, e) >>> 0 'sun' >>> 1 'snake' >>> 2 'script'
Iterate array
for e in my_list: print(e)
2D Array
Array_2d(width, height)
Macros
# replace the first argument with the second argument sunsnake.define(*style, scale=.2, color=hsv(300,1,1), roundness=.25, text_origin=[0,0]) brush_size = [1,1] # use the defined macro to prevent code duplication plus_button = Entity(*style, x=-.1, text='+') plus_button.on_click = def(): brush_size = [e*1.5 for e in brush_size] minus_button = Entity(*style, x=.1, text='-') minus_button.on_click = def(): brush_size = [e*1/1.5 for e in brush_size]
List Comprehension
my_list = [1, 0, 9, 4, 8] my_list = [e for e in my_list if e < 5] print(my_list) >>> [1, 0, 4]
Coroutines/Delay
e = Button(scale=.2, text='?') e.on_click = def(): after 0.2s: e.text = '!!'