def init(self): self.base_resolution = create_point(640, 360) self.window_resolution = create_point( self.base_resolution.x * 2, self.base_resolution.y * 2) self.scale = self.window_resolution.x / self.base_resolution.x self.mouse_point = create_point(0, 0) self.mouse_point_scaled = create_point(0, 0) self.is_mouse_down = False self.is_mouse_held_down = False self.is_mouse_up = False self.is_right_mouse_down = False self.is_right_mouse_held_down = False self.is_right_mouse_up = False self.is_mouse_wheel_up = False self.is_mouse_wheel_down = False self.bgm_audio_volume = 128 / 2 self.se_audio_volume = 128 / 2 self.is_bgm_paused = False self.current_time = 0 self.prev_frame_time = 0 self.delta_time = 0 self.fps = 0 self.quit = False # set to false for i in range(322): self.keys_down.push_value(False) self.keys_held_down.push_value(False) self.keys_up.push_value(False)
def get_random_town_point(self, game: Game, tile_point_hit_box: SDL_Rect) -> SDL_Point: iters = 0 max_iters = 500 p = create_point(0, 0) self_tile_point = create_point( tile_point_hit_box.x, tile_point_hit_box.y) while iters < max_iters: iters += 1 p.x = game.engine.get_rand_int(0, self.move_grid_rows - 1) p.y = game.engine.get_rand_int(0, self.move_grid_cols - 1) # always return p for now, maybe later check to see if the merchant shop would overlap if not(points_are_equal(self_tile_point, p)): return p print("Could not find random unoccupied point.") return create_point(0, 0)
def get_random_unoccupied_move_grid_tile_point(self, game: Game, tile_point_hit_box: SDL_Rect) -> SDL_Point: iters = 0 max_iters = 500 hit_box_cpy = deref(tile_point_hit_box) p = create_point(hit_box_cpy.x, hit_box_cpy.y) while iters < max_iters: iters += 1 p.x = game.engine.get_rand_int(0, self.move_grid_rows - 1) p.y = game.engine.get_rand_int(0, self.move_grid_cols - 1) hit_box_cpy.x = p.x hit_box_cpy.y = p.y if not(self.unit_occupies_tile_point_move_grid(game, hit_box_cpy, -1)): # print("Point found") return p print("Could not find random unoccupied point.") return create_point(0, 0)
def create_initial_maps(self, game: Game): map_handle = self.get_handle(HandleType.Map) map = self.maps.at(map_handle) map.create_initial_overworld(game, 80, 80) map_handle = self.get_handle(HandleType.Map) map = self.maps.at(map_handle) map.create_initial(game, 40, 40, False) map_handle = self.get_handle(HandleType.Map) map = self.maps.at(map_handle) map.create_initial(game, 60, 60, True) building_handle = self.get_handle(HandleType.Building) building = self.buildings.at(building_handle) building_move_grid_tile_point = create_point(200, 200) building.set_to(game, BuildingName.TeleportationStone, building_move_grid_tile_point) map.building_handles.push_value(building_handle) building_handle = self.get_handle(HandleType.Building) building = self.buildings.at(building_handle) building_move_grid_tile_point = create_point(0, 0) building.set_to(game, BuildingName.PlayerLeague, building_move_grid_tile_point) map.building_handles.push_value(building_handle) building_handle = self.get_handle(HandleType.Building) building = self.buildings.at(building_handle) building_move_grid_tile_point = create_point(70, 0) building.set_to(game, BuildingName.Shop0, building_move_grid_tile_point) map.building_handles.push_value(building_handle) building_handle = self.get_handle(HandleType.Building) building = self.buildings.at(building_handle) building_move_grid_tile_point = create_point(140, 0) building.set_to(game, BuildingName.RecruitmentCenter0, building_move_grid_tile_point) map.building_handles.push_value(building_handle) map_handle = self.get_handle(HandleType.Map) map = self.maps.at(map_handle) map.create_initial(game, 40, 40, False)
def set_to(self, game: Game, ability_name: AbilityName): # clear previous ability data self.sprite.srcs.clear() self.portrait.srcs.clear() # set new data self.ability_name = ability_name self.sprite.spawn_time = game.engine.current_time self.sprite.render_dst.is_camera_rendered = True self.sprite.image = game.engine.get_image(ImageName.Abilities) self.portrait.image = game.engine.get_image(ImageName.Items) if ability_name == AbilityName.NA: print("Ability.set_to - attempted to call with AbilityName.NA.") exit(1) elif ability_name == AbilityName.MeleeAttack: self.sprite.anim_speed = 60 self.is_projectile = False self.stats.damage = 20 self.stats.range = 30 self.stats.max_skill_points = 10 portrait_src = create_rect(20, 20, 20, 20) self.portrait.srcs.push(portrait_src) x = 0 w = 30 for i in range(8): src = create_rect(x, 32, w, 30) self.sprite.srcs.push(src) x += w elif ability_name == AbilityName.Fire: self.sprite.anim_speed = 100 self.is_projectile = True self.projectile_speed = 2.0 self.start_offset = create_point(0, -30) self.delay = 500 self.stats.damage = 20 self.stats.range = 100 self.stats.max_skill_points = 10 portrait_src = create_rect(0, 20, 20, 20) self.portrait.srcs.push(portrait_src) src0 = create_rect(64, 0, 16, 21) src1 = create_rect(80, 0, 16, 21) src2 = create_rect(96, 0, 16, 21) self.sprite.srcs.push(src0) self.sprite.srcs.push(src1) self.sprite.srcs.push(src2) else: ability_name_as_int = cast(ability_name, "int") print("Ability.set_to. Ability name not handled. AbilityName:", ability_name_as_int) exit(1)
def create_initial_overworld(self, game: Game, rows: int, cols: int): if rows > game.max_map_size.x: print("Map.create_initial. rows is > game.max_map_size.x", "\nrows:", rows, "\nmax_map_size.x", game.max_map_size.x) exit(1) if cols > game.max_map_size.y: print("Map.create_initial. cols is > game.max_map_size.y", "\ncols:", cols, "\nmax_map_size.y", game.max_map_size.y) exit(1) self.is_town_map = False tile = Tile() warp_point = WarpPoint() self.rows = rows self.cols = cols self.move_grid_rows = rows * game.move_grid_ratio self.move_grid_cols = cols * game.move_grid_ratio for i in range(rows): for j in range(cols): tile_point = create_point(i, j) dst = tile_point_to_world_point(tile_point, game.tile_size) src = create_rect(0, 0, 20, 20) shared_srcs = game.sprite_db.find( game, ImageName.Tiles, src) tile.sprite.shared_srcs = shared_srcs tile.sprite.render_dst.dst.x = dst.x tile.sprite.render_dst.dst.y = dst.y tile.sprite.anim_speed = 100 tile.sprite.render_dst.is_camera_rendered = True self.tiles.push(tile) # create warp points tile_point = create_point(10, 15) warp_to_tile_point = create_point(rows - 2, 15) warp_point.set(game, WarpPointName.Forest, tile_point, warp_to_tile_point, 1) self.warp_points.push(warp_point) tile_point = create_point(22, 8) warp_to_tile_point = create_point(0, 20) warp_point.set(game, WarpPointName.Town, tile_point, warp_to_tile_point, 2) self.warp_points.push(warp_point) tile_point = create_point(32, 18) warp_to_tile_point = create_point(rows - 2, 15) warp_point.set(game, WarpPointName.Forest, tile_point, warp_to_tile_point, 3) self.warp_points.push(warp_point)
def create_initial(self, game: Game, rows: int, cols: int, is_town_map): if rows > game.max_map_size.x: print("Map.create_initial. rows is > game.max_map_size.x", "\nrows:", rows, "\nmax_map_size.x", game.max_map_size.x) exit(1) if cols > game.max_map_size.y: print("Map.create_initial. cols is > game.max_map_size.y", "\ncols:", cols, "\nmax_map_size.y", game.max_map_size.y) exit(1) self.is_town_map = is_town_map tile = Tile() warp_point = WarpPoint() self.rows = rows self.cols = cols self.move_grid_rows = rows * game.move_grid_ratio self.move_grid_cols = cols * game.move_grid_ratio for i in range(rows): for j in range(cols): tile_point = create_point(i, j) dst = tile_point_to_world_point(tile_point, game.tile_size) src = create_rect(0, 0, 20, 20) shared_srcs = game.sprite_db.find( game, ImageName.Tiles, src) tile.sprite.shared_srcs = shared_srcs tile.sprite.render_dst.dst.x = dst.x tile.sprite.render_dst.dst.y = dst.y tile.sprite.anim_speed = 100 tile.sprite.render_dst.is_camera_rendered = True self.tiles.push(tile) # create some warp points if self.handle == 1: tile_point = create_point(rows - 2, 15) warp_to_tile_point = create_point(10 + 1, 15) warp_point.set(game, WarpPointName.Standard, tile_point, warp_to_tile_point, 0) self.warp_points.push(warp_point) elif self.handle == 2: tile_point = create_point(0, 20) warp_to_tile_point = create_point(22 - 1, 8) warp_point.set(game, WarpPointName.Standard, tile_point, warp_to_tile_point, 0) self.warp_points.push(warp_point) elif self.handle == 3: tile_point = create_point(rows - 2, 15) warp_to_tile_point = create_point(32 - 1, 18) warp_point.set(game, WarpPointName.Standard, tile_point, warp_to_tile_point, 0) self.warp_points.push(warp_point) # create some initial units if not(self.is_town_map): num_enemies = game.engine.get_rand_int(20, 40) for i in range(num_enemies): unit_handle = game.world.get_handle(HandleType.Unit) unit = game.world.units.at(unit_handle) rand_unit_enum_int = game.engine.get_rand_int(7, 11) rand_unit_name = cast(rand_unit_enum_int, "UnitName") unit.set_to(game, rand_unit_name, Faction.Enemy) unit.join_map(game, self) unit.set_random_spawn_point(game)
def handle_tween_on_complete(self, game: Game, tween_callback: TweenCallback): callback = TweenCallback() if tween_callback.tween_type == TweenType.NA: print("World - handle_tween_on_complete. tween_type is NA.") exit(1) elif tween_callback.tween_type == TweenType.UnitMoveToShop: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) unit.inside_building = True # basically a set delay for in shop tween_handle = game.world.get_handle(HandleType.TweenXY) tween = game.world.tween_xys.at(tween_handle) callback.tween_type = TweenType.UnitInShop callback.handle = unit.handle duration = cast(2000, "Uint32") delay = cast(0, "Uint32") tween.set(game, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, False, 0.0, duration, delay, callback) elif tween_callback.tween_type == TweenType.UnitInShop: unit = self.units.at(tween_callback.handle) # sell items unit.sell_items(game) unit.inside_building = False success = unit.try_find_and_move_to_merchant_shop(game) if not(success): unit.ai_state = UnitAIState.Battle unit.move_to_overworld_warp_point(game) elif tween_callback.tween_type == TweenType.UnitMoveToTeleporter: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) battle_map = self.maps.at(unit.battle_map_handle) unit.join_map(game, battle_map) unit.set_random_spawn_point(game) elif tween_callback.tween_type == TweenType.UnitMoveToGuildBuilding: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) unit.inside_building = True # basically a set delay for in guild building tween_handle = game.world.get_handle(HandleType.TweenXY) tween = game.world.tween_xys.at(tween_handle) callback.tween_type = TweenType.UnitInGuildBuilding callback.handle = unit.handle duration = cast(2000, "Uint32") delay = cast(0, "Uint32") tween.set(game, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, False, 0.0, duration, delay, callback) elif tween_callback.tween_type == TweenType.UnitInGuildBuilding: unit = self.units.at(tween_callback.handle) unit.inside_building = False # give non-sellable items to the guild's inventory if unit.is_merchant(): unit.merchant_get_sellable_items_from_guild(game) unit.move_to_setup_merchant_shop(game) else: unit.give_items_to_guild(game) unit.move_to_shop(game) elif tween_callback.tween_type == TweenType.UnitMoveToSetupMerchantShop: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) unit.ai_state = UnitAIState.MerchantSelling unit.sprite.play_animation(game, UnitAnimState.Sit) elif tween_callback.tween_type == TweenType.UnitRandomTownMove: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) # start the random move point cycle again unit.move_to_random_town_point(game) elif tween_callback.tween_type == TweenType.UnitMoveToWarpPoint: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) map = self.maps.at(unit.map_handle) warp_point_handle = tween_callback.warp_point_handle warp_point = map.warp_points.at(warp_point_handle) warping_to_map_handle = warp_point.warp_to_map_handle warping_to_map = self.maps.at(warping_to_map_handle) unit.join_map(game, warping_to_map) if warping_to_map.is_town_map or warping_to_map_handle == 0: # town maps or overworld can't get stuck as units dont check for # collissions when pathing. unit.set_spawn_point( game, warp_point.warp_to_tile_point_move_grid) else: # battle maps need a random spawn for now to avoid getting stuck # on each other on top of the warp point when they re-enter the battle # map. unit.set_random_spawn_point(game) if unit.ai_state == UnitAIState.Selling: if warping_to_map.handle == 0: unit.move_to_town_warp_point(game) elif warping_to_map.is_town_map: unit.move_to_guild_building(game) elif unit.ai_state == UnitAIState.Battle: if warping_to_map.handle == 0: unit.move_to_battle_warp_point(game) elif tween_callback.tween_type == TweenType.UnitMoveToBuyAtMerchantShop: if tween_callback.is_final_point_in_path: unit = self.units.at(tween_callback.handle) map = self.maps.at(unit.map_handle) # basically a set delay tween_handle = game.world.get_handle(HandleType.TweenXY) tween = game.world.tween_xys.at(tween_handle) callback.tween_type = TweenType.UnitBuyingAtMerchantShop callback.handle = unit.handle callback.merchant_unit_handle = tween_callback.merchant_unit_handle duration = cast(2000, "Uint32") delay = cast(0, "Uint32") tween.set(game, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, unit.sprite.render_dst.dst, False, 0.0, duration, delay, callback) elif tween_callback.tween_type == TweenType.UnitBuyingAtMerchantShop: unit = self.units.at(tween_callback.handle) merchant_unit = self.units.at(tween_callback.merchant_unit_handle) if not(merchant_unit.is_merchant()): print( "TweenType.UnitBuyingAtMerchantShop. Merchant handle unit is not a merchant.") exit(1) # let other units shop at the merchant merchant_unit.unit_handle_buying_from_merchant = -1 # have the merchant sell some items to the neutral unit merchant_unit.merchant_sell_to_unit(game) # unit can now go back to battle, Guild -> Shop -> Merchant Shop -> Battle unit.ai_state = UnitAIState.Battle unit.move_to_overworld_warp_point(game) elif tween_callback.tween_type == TweenType.PerformAbility: map = self.maps.at(tween_callback.map_handle) ability_handle = tween_callback.handle ability = self.abilities.at(ability_handle) acting_unit_handle = tween_callback.acting_unit_handle acting_unit = self.units.at(acting_unit_handle) receiving_unit = self.units.at( tween_callback.receiving_unit_handle) # remove the ability handle from the map and release the handle find_and_remove_handle(map.ability_handles, ability_handle) self.release_handle(HandleType.Ability, ability_handle) # set attacked by faction to prevent ksing receiving_unit.attacked_by_guild_handle = acting_unit.guild_handle # apply damage if unit is not already dead - prevents items from dropping to multiple # units, only the unit that killed gets the items if not(receiving_unit.stats.hp.value_is_at_min()): receiving_unit.stats.hp.dec(ability.ability.stats.damage) receiving_unit.on_hit(game, acting_unit_handle) if receiving_unit.stats.hp.value_is_at_min(): # normal exp exp = receiving_unit.stats.experience_drop * receiving_unit.stats.level exp_as_uint64 = cast(exp, "Uint64") acting_unit.stats.experience.inc(exp_as_uint64) if acting_unit.stats.experience.value_is_at_max(): # max level is 99, I am not wrapping exp to the next level, seems # to have a lot of problems and I don't think it matters. if acting_unit.stats.level < 99: acting_unit.available_stat_points += get_stat_points_for_level( acting_unit.stats.level) acting_unit.stats.level += 1 acting_unit.stats.experience.set_to_min() # double max exp to get to the next level acting_unit.stats.experience.max *= 2 # job exp job_exp = receiving_unit.stats.job_experience_drop * receiving_unit.stats.level job_exp_as_uint64 = cast(job_exp, "Uint64") acting_unit.stats.job_experience.inc(job_exp_as_uint64) if acting_unit.stats.job_experience.value_is_at_max(): if acting_unit.stats.job_level < 10: acting_unit.available_skill_points += 1 acting_unit.stats.job_level += 1 acting_unit.stats.job_experience.set_to_min() acting_unit.stats.job_experience.max *= 2 receiving_unit.on_dead(game, acting_unit_handle) # damage text damage_text_handle = self.get_handle(HandleType.DamageText) damage_text = self.damage_texts.at(damage_text_handle) sprintf(damage_text.str, "%lu", ability.ability.stats.damage) damage_text_dst = create_point( receiving_unit.sprite.render_dst.dst.x, receiving_unit.sprite.render_dst.dst.y) text_color = create_color(255, 255, 255, 255) text_outline_color = create_color(0, 0, 0, 255) damage_text.text_set_without_str(game, damage_text_dst, FontStyle.Bold, TextAlignment.Left, TextWordWrap.NoWrap, 500, 16, text_color, 1, text_outline_color, False) damage_text.render_dst.is_camera_rendered = True map.damage_text_handles.push_value(damage_text_handle) # damage text tween text_tween_handle = self.get_handle(HandleType.TweenXY) text_tween = self.tween_xys.at(text_tween_handle) start_rect = receiving_unit.sprite.render_dst.dst target_rect = start_rect target_rect.y -= 30 duration = cast(2000, "Uint32") delay = cast(0, "Uint32") callback.tween_type = TweenType.DamageText callback.handle = damage_text_handle callback.receiving_unit_handle = tween_callback.receiving_unit_handle callback.map_handle = tween_callback.map_handle text_tween.set(game, start_rect, damage_text.render_dst.dst, target_rect, False, 0.0, duration, delay, callback) elif tween_callback.tween_type == TweenType.ItemDrop: map = self.maps.at(tween_callback.map_handle) item_handle = tween_callback.handle item = self.items.at(item_handle) receiving_unit_handle = tween_callback.receiving_unit_handle receiving_unit = self.units.at(receiving_unit_handle) receiving_unit.inventory.add_item(game, item.item.item_name, item.quantity) find_and_remove_handle(map.item_handles, item_handle) self.release_handle(HandleType.Item, item_handle) if receiving_unit.ai_state != UnitAIState.Selling: receiving_unit.change_to_sell_item_ai_state(game) elif tween_callback.tween_type == TweenType.DamageText: # remove the damage text handle from the map and release the handle damage_text_handle = tween_callback.handle map = self.maps.at(tween_callback.map_handle) find_and_remove_handle( map.damage_text_handles, damage_text_handle) self.release_handle(HandleType.DamageText, damage_text_handle)
def text_draw_string(game: Game, text: TextLG, str, len: int, dst: SDL_Rect, perform_draw: bool) -> SDL_Point: return create_point(0, 0)
def set_to(self, game: Game, unit_name: UnitName): self.anim_state = UnitAnimState.Idle self.idle_down.clear() self.cast_down.clear() self.sit_down.clear() self.overworld_idle_down.clear() self.render_dst.is_camera_rendered = True # should this be set this here, should be fine I think. self.spawn_time = game.engine.current_time self.idle_anim_speed = 1 self.cast_anim_speed = 1 self.sit_anim_speed = 1 self.overworld_idle_anim_speed = 1 # hit_boxes need to be multiples of game.move_tile_grid_size if unit_name == UnitName.RandomTownsPerson0: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 130 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(260, 0, 20, 40) self.idle_down.push(idle_down_src0) elif unit_name == UnitName.Merchant: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 130 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(220, 0, 20, 40) self.idle_down.push(idle_down_src0) cast_down_src0 = create_rect(80, 0, 20, 40) self.cast_down.push(cast_down_src0) sit_down_src0 = create_rect(240, 0, 20, 40) self.sit_down.push(sit_down_src0) overworld_idle_down_src0 = create_rect(20, 40, 20, 20) overworld_idle_down_src1 = create_rect(40, 40, 20, 20) overworld_idle_down_src2 = create_rect(60, 40, 20, 20) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src1) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src2) elif unit_name == UnitName.Explorer: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 130 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(0, 0, 20, 40) idle_down_src1 = create_rect(40, 0, 20, 40) idle_down_src2 = create_rect(0, 0, 20, 40) idle_down_src3 = create_rect(60, 0, 20, 40) self.idle_down.push(idle_down_src0) self.idle_down.push(idle_down_src1) self.idle_down.push(idle_down_src2) self.idle_down.push(idle_down_src3) cast_down_src0 = create_rect(80, 0, 20, 40) self.cast_down.push(cast_down_src0) sit_down_src0 = create_rect(200, 0, 20, 40) self.sit_down.push(sit_down_src0) overworld_idle_down_src0 = create_rect(20, 40, 20, 20) overworld_idle_down_src1 = create_rect(40, 40, 20, 20) overworld_idle_down_src2 = create_rect(60, 40, 20, 20) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src1) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src2) elif unit_name == UnitName.Mage: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(20, 0, 20, 40) self.idle_down.push(idle_down_src0) cast_down_src0 = create_rect(100, 0, 20, 40) self.cast_down.push(cast_down_src0) sit_down_src0 = create_rect(200, 0, 20, 40) self.sit_down.push(sit_down_src0) overworld_idle_down_src0 = create_rect(80, 40, 20, 20) overworld_idle_down_src1 = create_rect(100, 40, 20, 20) overworld_idle_down_src2 = create_rect(120, 40, 20, 20) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src1) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src2) elif unit_name == UnitName.Wizard: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(120, 0, 20, 40) self.idle_down.push(idle_down_src0) cast_down_src0 = create_rect(160, 0, 20, 40) self.cast_down.push(cast_down_src0) sit_down_src0 = create_rect(200, 0, 20, 40) self.sit_down.push(sit_down_src0) overworld_idle_down_src0 = create_rect(20, 40, 20, 20) overworld_idle_down_src1 = create_rect(40, 40, 20, 20) overworld_idle_down_src2 = create_rect(60, 40, 20, 20) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src1) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src2) elif unit_name == UnitName.Scholar: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 240 self.sit_anim_speed = 100 self.overworld_idle_anim_speed = 130 self.hit_box_size = create_point(20, 40) idle_down_src0 = create_rect(140, 0, 20, 40) self.idle_down.push(idle_down_src0) cast_down_src0 = create_rect(180, 0, 20, 40) self.cast_down.push(cast_down_src0) sit_down_src0 = create_rect(200, 0, 20, 40) self.sit_down.push(sit_down_src0) overworld_idle_down_src0 = create_rect(20, 40, 20, 20) overworld_idle_down_src1 = create_rect(40, 40, 20, 20) overworld_idle_down_src2 = create_rect(60, 40, 20, 20) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src1) self.overworld_idle_down.push(overworld_idle_down_src0) self.overworld_idle_down.push(overworld_idle_down_src2) elif unit_name == UnitName.Slime: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 300 self.sit_anim_speed = 100 self.hit_box_size = create_point(20, 18) idle_down_src0 = create_rect(0, 40, 20, 18) self.idle_down.push(idle_down_src0) self.cast_down.push(idle_down_src0) elif unit_name == UnitName.Bunny: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 300 self.sit_anim_speed = 100 self.hit_box_size = create_point(20, 28) idle_down_src0 = create_rect(0, 64, 20, 28) self.idle_down.push(idle_down_src0) self.cast_down.push(idle_down_src0) elif unit_name == UnitName.Bat: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 300 self.sit_anim_speed = 100 self.hit_box_size = create_point(20, 26) idle_down_src0 = create_rect(0, 96, 20, 26) self.idle_down.push(idle_down_src0) self.cast_down.push(idle_down_src0) elif unit_name == UnitName.Stump: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 300 self.sit_anim_speed = 100 self.hit_box_size = create_point(28, 38) idle_down_src0 = create_rect(0, 128, 28, 37) self.idle_down.push(idle_down_src0) self.cast_down.push(idle_down_src0) elif unit_name == UnitName.Shroomed: self.image = game.engine.get_image(ImageName.Units) self.idle_anim_speed = 100 self.cast_anim_speed = 300 self.sit_anim_speed = 100 self.hit_box_size = create_point(26, 34) idle_down_src0 = create_rect(0, 165, 26, 33) self.idle_down.push(idle_down_src0) self.cast_down.push(idle_down_src0) else: unit_name_as_int = cast(unit_name, "int") print("UnitSprite.set_to. Unit name not handled. UnitName:", unit_name_as_int) exit(1)