def create(screen_width_px, screen_height_px, tile_size_px): joystick_props = controls.get_joystick_properties() origin_xy = (0, joystick_props["h"] * screen_height_px) state = factory.create(screen_width_px, screen_height_px, tile_size_px, origin_xy) user.set_data(state, "n_barrels", 0) user.set_data(state, "n_barriers", 0) controls.add_joystick(state) controls.add_buttons(state, (("Fire", on_fire_button, "right", "big"),)) floor_tile = "assets/img/tiles/dirt_ground.png" tiles.add_tile_def(state, ' ', (floor_tile,)) tiles_helpers.load_walls(state, "", floor_tile, "assets/img/tiles/bricks_walls.png") tiles_helpers.load_walls(state, "/", "assets/img/tiles/grass.png", "assets/img/tiles/bricks_walls.png") tiles.add_tile_def(state, '|', (floor_tile, "assets/img/tiles/road-I.png",)) tiles.add_tile_def(state, '~', (floor_tile, "assets/img/tiles/road-h.png",)) tiles.add_tile_def(state, 'L', (floor_tile, "assets/img/tiles/road-cnr-bl.png",)) tiles.add_tile_def(state, 'T', (floor_tile, "assets/img/tiles/road-cnr-tl.png",)) tiles.add_tile_def(state, 'J', (floor_tile, "assets/img/tiles/road-cnr-br.png",)) tiles.add_tile_def(state, 'j', (floor_tile, "assets/img/tiles/road-cnr-ur.png",)) tiles.add_tile_def(state, '/', ("assets/img/tiles/grass.png",)) tiles.add_tile_def(state, 't', ("assets/img/tiles/grass.png", "assets/img/tiles/tree.png")) tiles.set_area(state, [ ['t', '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/'], ['/', '/.', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/,', '/'], ['t', '/)', '<' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '>' , '/(', 't'], ['/', '/)', '(' , 'T' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , 'j' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , '.' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , ',' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ')' , '/<', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/>', '(' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , ')' , '/(', '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/)', '(' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ')' , '/(', 't' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/)', '(' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , ')' , '/(', '/' , '/' , '/' , '/' , '/' , '/' , '/' , 't' , '/)', '(' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ')' , '/(', 't' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/)', '(' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , ')' , '/(', '/' , '/' , '/' , '/' , '/' , '/' , '/' , 't' , '/)', '(' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ')' , '/(', 't' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/)', '(' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , ')' , '/(', '/' , '/' , '/' , '/' , '/' , '/' , '/' , 't' , '/)', '(' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ')' , '/(', 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , '/)', '(' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , '|' , ')' , '/[', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/]', '(' , '|' , ')' , '/(', 't'], ['/', '/)', '(' , '|' , ':' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , ';' , '|' , ')' , '/(', '/'], ['t', '/)', '(' , 'L' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , 'J' , ')' , '/(', 't'], ['/', '/)', '[' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , '_' , ']' , '/(', '/'], ['t', '/:', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/;', '/'], ['/', 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't' , '/' , 't'], ['/', '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/' , '/'], ] ) play_area_origin = (2.0, 3.0) # text.load_font(state, FONT_NAME, "assets/img/fonts/%s.png" % FONT_NAME, 16, 32) entities.insert(state, ENT_PLAYER_CAR, { "*": { "textures": ( "assets/img/sprites/car/0.png", ), "speed": 0.0, }, "+": { "textures": ( "assets/img/sprites/car/1.png", ), "speed": 0.0, }, "-": { "textures": ( "assets/img/sprites/car/2.png", ), "speed": 0.0, }, }, (play_area_origin[0] + 1.5, play_area_origin[1] + 6.0, 0), (-0.125, -0.25), collision=(("rectangle", 0.0, 0.0, 0.25, 0.5),), ) view.set_viewer(state, relative_viewer.create(state, ENT_PLAYER_CAR)) control_phys_mover.add(state, ENT_PLAYER_CAR, 1.0, 0, 0, 0, 0, 0.9, # IDX_MOVERS_PHYSICAL_FRICTION 0.001, # YAPYG_STD_INELASTICITY, 0, YAPYG_STD_ROT_FRICTION, YAPYG_STD_ROT_DECAY, YAPYG_STD_STICKYNESS, dir_factor=0.005, pos_accel=12.0, neg_accel=4.0, rest_sprite="*", pos_sprite="+", neg_sprite="-" ) for i in xrange(7): add_barrel(state, play_area_origin[0] + 0.5, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(7): add_barrel(state, play_area_origin[0] + 15.25, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(8): add_barrier(state, play_area_origin[0] + 0.5 - 0.125, play_area_origin[1] + 1.0 + 2.0 * i, 90.0) for i in xrange(8): add_barrier(state, play_area_origin[0] + 1.0 + 0.125 + 2.0 * i, play_area_origin[1] + 0.5, 0.0) for i in xrange(7): add_barrier(state, play_area_origin[0] + 1.0 + 0.125 + 2.0 * i, play_area_origin[1] + 15.25, 0.0) for i in xrange(7): add_barrel(state, play_area_origin[0] + 2.0 + 0.125 + 2.0 * i, play_area_origin[1] + 15.25) for i in xrange(6): add_barrel(state, play_area_origin[0] + 2.0 + 0.25 + 2.0 * i, play_area_origin[1] + 13.5) for i in xrange(6): add_barrier(state, play_area_origin[0] + 3.0 + 0.25 + 2.0 * i, play_area_origin[1] + 13.5, 0.0) for i in xrange(7): add_barrel(state, play_area_origin[0] + 2.0 + 0.125 + 2.0 * i, play_area_origin[1] + 0.5) for i in xrange(8): add_barrier(state, play_area_origin[0] + 15.25 - 0.125, play_area_origin[1] + 1.0 + 2.0 * i, 90.0) for i in xrange(1, 6): add_barrel(state, play_area_origin[0] + 2.25, play_area_origin[1] + 2.0 + 2.0 * i) add_barrel(state, play_area_origin[0] + 13.5, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(6): add_barrier(state, play_area_origin[0] + 2.25 - 0.125, play_area_origin[1] + 3.0 + 2.0 * i, 90.0) add_barrier(state, play_area_origin[0] + 13.5 - 0.125, play_area_origin[1] + 3.0 + 2.0 * i, 90.0) for i in xrange(6): add_barrel(state, play_area_origin[0] + 2.25 + 2.0 * i, play_area_origin[1] + 2.25) add_barrier(state, play_area_origin[0] + 3.25 - 0.125 + 2.0 * i, play_area_origin[1] + 2.25, 0.0) timer.create(state, on_timer, 100) return state
def create(screen_width, screen_height, tile_size): state = factory.create(screen_width, screen_height, tile_size) tiles.add_tile_def(state, ".", ("assets/img/tiles/grid_double.png", )) tiles.set_area(state, [["." for x in xrange(10)] for x in xrange(10)]) text.load_font(state, "DroidSansMonoDotted32x64", "assets/img/fonts/DroidSansMonoDotted32x64.png", 32, 64) text.load_font(state, "DroidSansMonoDotted16x32", "assets/img/fonts/DroidSansMonoDotted16x32.png", 16, 32) text.load_font(state, "DroidSansMonoDotted12x24", "assets/img/fonts/DroidSansMonoDotted12x24.png", 12, 24) text.load_font(state, "DroidSansMonoDotted10x16", "assets/img/fonts/DroidSansMonoDotted10x16.png", 10, 16) text.load_font(state, "DroidSansMonoDotted8x12", "assets/img/fonts/DroidSansMonoDotted8x12.png", 8, 12) entities.insert( state, "500_text_1", { "*": { "textures": (("text", "This is text\nSecond line", "DroidSansMonoDotted16x32"), ), }, }, (1, 2, 0)) start_movement(state, None) entities.insert( state, "500_text_2", { "*": { "textures": (("text", "Lorem ipsum dolor sit amet, consectetur adipisici elit,\n" "sed eiusmod tempor incidunt ut labore et dolore magna aliqua.\n" "Ut enim ad minim veniam, quis nostrud exercitation ullamco\n" "laboris nisi ut aliquid ex ea commodi consequat. Quis aute\n" "iure reprehenderit in voluptate velit esse cillum dolore eu\n" "fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non\n" "proident, sunt in culpa qui officia deserunt mollit anim id\n" "est laborum.", "DroidSansMonoDotted8x12"), ), }, }, (0, 4, 0)) entities.insert(state, "500_text_3", { "*": { "textures": (("text", "Title", "DroidSansMonoDotted10x16"), ), }, }, (0, 5, 0)) entities.insert(state, "500_text_4", { "*": { "textures": (("text", "Chapter", "DroidSansMonoDotted12x24"), ), }, }, (0, 5.5, 0)) entities.insert( state, "500_text_time", { "*": { "textures": (("text", get_time_string(), "DroidSansMonoDotted32x64"), ), }, }, (0.0, 0.5, 0)) timer.create(state, on_timer, 1000) return state
def create(screen_width_px, screen_height_px, tile_size_px): joystick_props = controls.get_joystick_properties() origin_xy = (0, joystick_props["h"] * screen_height_px) state = factory.create(screen_width_px, screen_height_px, tile_size_px, origin_xy) user.set_data(state, "n_barrels", 0) user.set_data(state, "n_barriers", 0) controls.add_joystick(state) controls.add_buttons(state, (("Fire", on_fire_button, "right", "big"), )) floor_tile = "assets/img/tiles/dirt_ground.png" tiles.add_tile_def(state, ' ', (floor_tile, )) tiles_helpers.load_walls(state, "", floor_tile, "assets/img/tiles/bricks_walls.png") tiles_helpers.load_walls(state, "/", "assets/img/tiles/grass.png", "assets/img/tiles/bricks_walls.png") tiles.add_tile_def(state, '|', ( floor_tile, "assets/img/tiles/road-I.png", )) tiles.add_tile_def(state, '~', ( floor_tile, "assets/img/tiles/road-h.png", )) tiles.add_tile_def(state, 'L', ( floor_tile, "assets/img/tiles/road-cnr-bl.png", )) tiles.add_tile_def(state, 'T', ( floor_tile, "assets/img/tiles/road-cnr-tl.png", )) tiles.add_tile_def(state, 'J', ( floor_tile, "assets/img/tiles/road-cnr-br.png", )) tiles.add_tile_def(state, 'j', ( floor_tile, "assets/img/tiles/road-cnr-ur.png", )) tiles.add_tile_def(state, '/', ("assets/img/tiles/grass.png", )) tiles.add_tile_def( state, 't', ("assets/img/tiles/grass.png", "assets/img/tiles/tree.png")) tiles.set_area(state, [ [ 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/' ], [ '/', '/.', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/,', '/' ], [ 't', '/)', '<', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '>', '/(', 't' ], [ '/', '/)', '(', 'T', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', 'j', ')', '/(', '/' ], [ 't', '/)', '(', '|', '.', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', ',', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ')', '/<', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/>', '(', '|', ')', '/(', '/' ], [ 't', '/)', '(', '|', ')', '/(', '/', 't', '/', 't', '/', 't', '/', 't', '/)', '(', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ')', '/(', 't', '/', '/', '/', '/', '/', '/', '/', '/)', '(', '|', ')', '/(', '/' ], [ 't', '/)', '(', '|', ')', '/(', '/', '/', '/', '/', '/', '/', '/', 't', '/)', '(', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ')', '/(', 't', '/', '/', '/', '/', '/', '/', '/', '/)', '(', '|', ')', '/(', '/' ], [ 't', '/)', '(', '|', ')', '/(', '/', '/', '/', '/', '/', '/', '/', 't', '/)', '(', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ')', '/(', 't', '/', '/', '/', '/', '/', '/', '/', '/)', '(', '|', ')', '/(', '/' ], [ 't', '/)', '(', '|', ')', '/(', '/', '/', '/', '/', '/', '/', '/', 't', '/)', '(', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ')', '/(', 't', '/', 't', '/', 't', '/', 't', '/', '/)', '(', '|', ')', '/(', '/' ], [ 't', '/)', '(', '|', ')', '/[', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/_', '/]', '(', '|', ')', '/(', 't' ], [ '/', '/)', '(', '|', ':', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', ';', '|', ')', '/(', '/' ], [ 't', '/)', '(', 'L', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', 'J', ')', '/(', 't' ], [ '/', '/)', '[', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', ']', '/(', '/' ], [ 't', '/:', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/-', '/;', '/' ], [ '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't', '/', 't' ], [ '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/', '/' ], ]) play_area_origin = (2.0, 3.0) # text.load_font(state, FONT_NAME, "assets/img/fonts/%s.png" % FONT_NAME, 16, 32) entities.insert( state, ENT_PLAYER_CAR, { "*": { "textures": ("assets/img/sprites/car/0.png", ), "speed": 0.0, }, "+": { "textures": ("assets/img/sprites/car/1.png", ), "speed": 0.0, }, "-": { "textures": ("assets/img/sprites/car/2.png", ), "speed": 0.0, }, }, (play_area_origin[0] + 1.5, play_area_origin[1] + 6.0, 0), (-0.125, -0.25), collision=(("rectangle", 0.0, 0.0, 0.25, 0.5), ), ) view.set_viewer(state, relative_viewer.create(state, ENT_PLAYER_CAR)) control_phys_mover.add( state, ENT_PLAYER_CAR, 1.0, 0, 0, 0, 0, 0.9, # IDX_MOVERS_PHYSICAL_FRICTION 0.001, # YAPYG_STD_INELASTICITY, 0, YAPYG_STD_ROT_FRICTION, YAPYG_STD_ROT_DECAY, YAPYG_STD_STICKYNESS, dir_factor=0.005, pos_accel=12.0, neg_accel=4.0, rest_sprite="*", pos_sprite="+", neg_sprite="-") for i in xrange(7): add_barrel(state, play_area_origin[0] + 0.5, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(7): add_barrel(state, play_area_origin[0] + 15.25, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(8): add_barrier(state, play_area_origin[0] + 0.5 - 0.125, play_area_origin[1] + 1.0 + 2.0 * i, 90.0) for i in xrange(8): add_barrier(state, play_area_origin[0] + 1.0 + 0.125 + 2.0 * i, play_area_origin[1] + 0.5, 0.0) for i in xrange(7): add_barrier(state, play_area_origin[0] + 1.0 + 0.125 + 2.0 * i, play_area_origin[1] + 15.25, 0.0) for i in xrange(7): add_barrel(state, play_area_origin[0] + 2.0 + 0.125 + 2.0 * i, play_area_origin[1] + 15.25) for i in xrange(6): add_barrel(state, play_area_origin[0] + 2.0 + 0.25 + 2.0 * i, play_area_origin[1] + 13.5) for i in xrange(6): add_barrier(state, play_area_origin[0] + 3.0 + 0.25 + 2.0 * i, play_area_origin[1] + 13.5, 0.0) for i in xrange(7): add_barrel(state, play_area_origin[0] + 2.0 + 0.125 + 2.0 * i, play_area_origin[1] + 0.5) for i in xrange(8): add_barrier(state, play_area_origin[0] + 15.25 - 0.125, play_area_origin[1] + 1.0 + 2.0 * i, 90.0) for i in xrange(1, 6): add_barrel(state, play_area_origin[0] + 2.25, play_area_origin[1] + 2.0 + 2.0 * i) add_barrel(state, play_area_origin[0] + 13.5, play_area_origin[1] + 2.0 + 2.0 * i) for i in xrange(6): add_barrier(state, play_area_origin[0] + 2.25 - 0.125, play_area_origin[1] + 3.0 + 2.0 * i, 90.0) add_barrier(state, play_area_origin[0] + 13.5 - 0.125, play_area_origin[1] + 3.0 + 2.0 * i, 90.0) for i in xrange(6): add_barrel(state, play_area_origin[0] + 2.25 + 2.0 * i, play_area_origin[1] + 2.25) add_barrier(state, play_area_origin[0] + 3.25 - 0.125 + 2.0 * i, play_area_origin[1] + 2.25, 0.0) timer.create(state, on_timer, 100) return state
def create(screen_width, screen_height, tile_size): state = factory.create(screen_width, screen_height, tile_size) tiles.add_tile_def(state, ".", ("assets/img/tiles/grid_double.png",)) tiles.set_area(state, [["." for x in xrange(10)] for x in xrange(10)]) text.load_font(state, "DroidSansMonoDotted32x64", "assets/img/fonts/DroidSansMonoDotted32x64.png", 32, 64) text.load_font(state, "DroidSansMonoDotted16x32", "assets/img/fonts/DroidSansMonoDotted16x32.png", 16, 32) text.load_font(state, "DroidSansMonoDotted12x24", "assets/img/fonts/DroidSansMonoDotted12x24.png", 12, 24) text.load_font(state, "DroidSansMonoDotted10x16", "assets/img/fonts/DroidSansMonoDotted10x16.png", 10, 16) text.load_font(state, "DroidSansMonoDotted8x12", "assets/img/fonts/DroidSansMonoDotted8x12.png", 8, 12) entities.insert(state, "500_text_1", { "*": { "textures": (("text", "This is text\nSecond line", "DroidSansMonoDotted16x32"),), }, }, (1, 2, 0)) start_movement(state, None) entities.insert(state, "500_text_2", { "*": { "textures": (("text", "Lorem ipsum dolor sit amet, consectetur adipisici elit,\n" "sed eiusmod tempor incidunt ut labore et dolore magna aliqua.\n" "Ut enim ad minim veniam, quis nostrud exercitation ullamco\n" "laboris nisi ut aliquid ex ea commodi consequat. Quis aute\n" "iure reprehenderit in voluptate velit esse cillum dolore eu\n" "fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non\n" "proident, sunt in culpa qui officia deserunt mollit anim id\n" "est laborum.", "DroidSansMonoDotted8x12"),), }, }, (0, 4, 0)) entities.insert(state, "500_text_3", { "*": { "textures": (("text", "Title", "DroidSansMonoDotted10x16"),), }, }, (0, 5, 0)) entities.insert(state, "500_text_4", { "*": { "textures": (("text", "Chapter", "DroidSansMonoDotted12x24"),), }, }, (0, 5.5, 0)) entities.insert(state, "500_text_time", { "*": { "textures": (("text", get_time_string(), "DroidSansMonoDotted32x64"),), }, }, (0.0, 0.5, 0)) timer.create(state, on_timer, 1000) return state