var searchIndex = {}; searchIndex["mold2d"] = {"doc":"The core 2D game engine built from scratch using SDL for graphics and windowing","items":[[3,"ActorData","mold2d","The data contained in an actor",null,null],[12,"id","","The id of the actor given by the actor manager",0,null],[12,"state","","The current state of the actor as a number",0,null],[12,"damage","","The damage that the actor has taken so far",0,null],[12,"collision_filter","","A byte that contains the sides that\nother actors can collide into",0,null],[12,"resolves_collisions","","If true, on collision the actor would be\nmoved away from the collision",0,null],[12,"rect","","The sprite rectangle",0,null],[12,"bounding_box","","The current bounding box for the actor",0,null],[12,"actor_type","","The type of the actor",0,null],[4,"ViewAction","","Actions that the view would want the event loop to do",null,null],[13,"Quit","","Quit the game",1,null],[13,"ChangeView","","Switch to a different view",1,null],[0,"actor_manager","","",null,null],[3,"ActorManager","mold2d::actor_manager","Manages all the actors for the game by hashing actors by id",null,null],[12,"actors","","",2,null],[6,"ActorFromToken","","Handler for creating an actor from a token character",null,null],[11,"new","","",2,{"inputs":[{"name":"actorfromtoken"}],"output":{"name":"actormanager"}}],[11,"add","","Add a new actor into the manager",2,null],[11,"remove","","Remove an actor from the actors",2,null],[11,"temp_remove","","Temporarily remove an actor to appease borrow checker",2,null],[11,"get_mut","","Get a mutable reference to an actor given the id",2,null],[11,"temp_reinsert","","Reinsert a temporarily removed actor",2,null],[0,"cache","mold2d","",null,null],[3,"FontCache","mold2d::cache","A global thread-safe cache for resolving fonts\nfrom file path",null,null],[12,"cache","","",3,null],[3,"SpriteCache","","A global thread-safe cache for resolving sprites\nfrom file path",null,null],[12,"cache","","",4,null],[5,"font_cache","","Returns the font cache as a singleton",null,{"inputs":[],"output":{"name":"fontcache"}}],[5,"sprite_cache","","Returns the sprite cache as a singleton",null,{"inputs":[],"output":{"name":"spritecache"}}],[11,"clone","","",3,null],[11,"clone","","",4,null],[0,"collision","mold2d","",null,null],[4,"CollisionSide","mold2d::collision","",null,null],[13,"Left","","",5,null],[13,"Right","","",5,null],[13,"Top","","",5,null],[13,"Bottom","","",5,null],[4,"BoundingBox","","",null,null],[13,"Rectangle","","",6,null],[5,"rect_contains_rect","","Checks if a rectangle contains another rectangle",null,{"inputs":[{"name":"rect"},{"name":"rect"}],"output":{"name":"bool"}}],[5,"center_point","","Returns the center point of a rectangle as a tuple of decimals",null,null],[5,"print_collision_side_u8","","Prints the collision side as a byte",null,{"inputs":[{"name":"u8"}],"output":null}],[8,"Collision","","Checks collisions for different objects",null,null],[10,"collides_with","","",7,null],[11,"eq","","",5,null],[11,"fmt","","",5,null],[11,"clone","","",5,null],[11,"reverse","","Reverses a collision side",5,{"inputs":[{"name":"collisionside"}],"output":{"name":"u8"}}],[11,"reverse_u8","","Reverses a collision side byte",5,{"inputs":[{"name":"u8"}],"output":{"name":"u8"}}],[11,"print","","",5,null],[11,"bitand","","",5,null],[11,"bitand","","",5,null],[11,"bitor","","",5,null],[11,"bitor","","",5,null],[11,"eq","","",5,null],[11,"from","","",5,{"inputs":[{"name":"u8"}],"output":{"name":"collisionside"}}],[11,"eq","","",6,null],[11,"ne","","",6,null],[11,"clone","","",6,null],[11,"apply_change","","",6,null],[11,"collides_with","","",6,null],[0,"context","mold2d","",null,null],[3,"Window","mold2d::context","Represents a SDL window to render",null,null],[12,"title","","",8,null],[12,"width","","",8,null],[12,"height","","",8,null],[3,"Context","","Contains the main context variables for the game\nlike the renderer and the events triggered",null,null],[12,"events","","",9,null],[12,"renderer","","",9,null],[12,"window","","",9,null],[12,"score","","",9,null],[11,"new","","Creates a new context given the path for the keyboard configuration\nand the sdl renderer",9,{"inputs":[{"name":"window"},{"name":"events"},{"name":"renderer"}],"output":{"name":"context"}}],[11,"drop","","",9,null],[0,"event_loop","mold2d","",null,null],[5,"create_event_loop","mold2d::event_loop","Initializes SDL and creates the window and event loop",null,{"inputs":[{"name":"window"},{"name":"f"}],"output":{"name":"sdlresult"}}],[0,"events","mold2d","",null,null],[3,"Events","mold2d::events","Handles keyboard events through SDL",null,null],[11,"new","","",10,{"inputs":[{"name":"eventpump"},{"name":"str"}],"output":{"name":"events"}}],[11,"poll","","Polls for events and stores them inside a HashSet",10,null],[11,"event_called","","True if the event is currently happening, False otherwise",10,null],[11,"event_called_once","","True if the event is currently happening, False otherwise\ndifference from event_called is that is only called once for an event",10,null],[0,"font","mold2d","",null,null],[5,"text_sprite","mold2d::font","Returns a text sprite with the specified text, font, size, and color",null,{"inputs":[{"name":"renderer"},{"name":"str"},{"name":"str"},{"name":"i32"},{"name":"color"}],"output":{"name":"sdlresult"}}],[5,"render_text","","Renders a text sprite at the specified point",null,null],[0,"level","mold2d","",null,null],[5,"load_level","mold2d::level","Loads a new level and returns an ActorManager with the loaded actors",null,{"inputs":[{"name":"str"},{"name":"actorfromtoken"},{"name":"renderer"},{"name":"window"}],"output":{"name":"result"}}],[17,"GRID_SIZE","","",null,null],[0,"quadtree","mold2d","",null,null],[3,"Quadtree","mold2d::quadtree","A quadtree for minimizing collision checks between actors",null,null],[11,"new","","",11,{"inputs":[{"name":"rect"},{"name":"viewport"}],"output":{"name":"quadtree"}}],[11,"insert","","Inserts an actor into the quadtree",11,null],[11,"retrieve","","Return all objects that could collide",11,null],[11,"len","","Returns the total number of elements in the quadtree",11,null],[0,"raycast","mold2d","",null,null],[3,"Segment","mold2d::raycast","",null,null],[12,"point","","The point that the segment starts out at",12,null],[12,"vector","","The magnitude and the direction of the segment",12,null],[5,"shorten_ray","","Shortens a ray segment agains a polygon",null,{"inputs":[{"name":"segment"},{"name":"p"}],"output":{"name":"option"}}],[8,"Polygon","","",null,null],[10,"sides","","Returns the sides in a polygon shape as a dynamic array of segments",13,null],[10,"collision_from_side","","Given a side number of the polygon, returns the side of the collision",13,null],[11,"eq","","",12,null],[11,"ne","","",12,null],[11,"fmt","","",12,null],[11,"clone","","",12,null],[11,"intersects","","Checks intersection for two segments.\nIf the two segments intersect it returns the intersection point,\notherwise it returns None",12,null],[11,"normalize","","Returns the normalized segment",12,null],[11,"shorten","","Returns a segment with a magnitude shortened by a certain amount",12,null],[11,"len","","Returns the length of the segment",12,null],[11,"render","","",12,null],[0,"score","mold2d","",null,null],[3,"Score","mold2d::score","Maintains multiple updatable scores",null,null],[11,"new","","",14,{"inputs":[],"output":{"name":"score"}}],[11,"add_score","","",14,null],[11,"remove_score","","",14,null],[11,"update_score","","",14,null],[11,"increment_score","","",14,null],[11,"score","","",14,null],[0,"sprite","mold2d","",null,null],[3,"SpriteRectangle","mold2d::sprite","A mutable rectangle for a sprite so it can be moved around",null,null],[12,"x","","",15,null],[12,"y","","",15,null],[12,"w","","",15,null],[12,"h","","",15,null],[3,"Sprite","","A sprite data type that uses reference counting\nto reuse the texture on multiple sub-sprites",null,null],[3,"AnimatedSprite","","Represents an animated sprite with multiple frames",null,null],[3,"SpritesheetConfig","","Contains configuration fields for parsing a spritesheet",null,null],[12,"width","","The width of each animation frame",16,null],[12,"height","","The height of each animation frame",16,null],[12,"sprites_in_row","","The number of frames in each row of the spritesheet",16,null],[12,"path","","The path to the spritesheet file",16,null],[3,"Spritesheet","","A spritesheet manager that returns sprites within a range",null,null],[3,"Animations","","An animation manager that retrieves the animations for a state",null,null],[4,"Direction","","The direction that a sprite is facing",null,null],[13,"Left","","",17,null],[13,"Right","","",17,null],[8,"Renderable","","",null,null],[10,"render","","",18,null],[11,"hash","","",17,null],[11,"fmt","","",17,null],[11,"eq","","",17,null],[11,"clone","","",17,null],[11,"eq","","",15,null],[11,"ne","","",15,null],[11,"clone","","",15,null],[11,"new","","",15,{"inputs":[{"name":"i32"},{"name":"i32"},{"name":"u32"},{"name":"u32"}],"output":{"name":"spriterectangle"}}],[11,"from_rect","","Creates a sprite rectangle from a SDL2 rectangle",15,{"inputs":[{"name":"rect"}],"output":{"name":"spriterectangle"}}],[11,"to_sdl","","Returns a SDL Rect created from the SpriteRectangle\nUsed for rendering SpriteRectangles in SDL",15,null],[11,"apply_change","","Mutates a sprite rectangle based on the position change given",15,null],[11,"clone","","",19,null],[11,"new","","",19,{"inputs":[{"name":"texture"}],"output":{"name":"sprite"}}],[11,"load","","Loads a new sprite from a path string to a sprite image file",19,{"inputs":[{"name":"renderer"},{"name":"str"}],"output":{"name":"option"}}],[11,"region","","Returns a sub-sprite from a rectangle region of the original sprite",19,null],[11,"size","","Returns the dimensions of the sprite",19,null],[11,"render","","Render the sprite image onto the rectangle",19,null],[11,"clone","","",20,null],[11,"with_fps","","",20,{"inputs":[{"name":"vec"},{"name":"f64"}],"output":{"name":"animatedsprite"}}],[11,"add_time","","Updates the animated sprite with the elapsed time",20,null],[11,"render","","Renders the current frame of the animated sprite",20,null],[11,"new","","Loads a spritesheet given a configuration object and a SDL2 renderer",21,{"inputs":[{"name":"spritesheetconfig"},{"name":"renderer"}],"output":{"name":"spritesheet"}}],[11,"range","","Returns a Vec of sprites within a certain range.\nThe number of the start and end ranges are from row to\nrow wrapping around. For example a 3x3 grid would have\nindexes like this:\n```\n0 1 2\n3 4 5\n6 7 8\n```",21,null],[11,"new","","",22,{"inputs":[{"name":"f64"}],"output":{"name":"animations"}}],[11,"add","","",22,null],[11,"anim","","Returns an immutable reference to the animation for the given state",22,null],[11,"anim_mut","","Returns a mutable reference to the animation for the given state",22,null],[11,"bbox","","Returns an immutable reference to the bounding box for the given state",22,null],[11,"bbox_mut","","Returns a mutable reference to the bounding box for the given state",22,null],[11,"map_bbox_mut","","Maps a function that mutates a bounding box over all of the\nbounding boxes in the animation",22,null],[11,"collides_with","","Checks if the animation at the state collides with another bounding box\nand returns the side of the collision if it happens",22,null],[11,"add_time","","Adds time to the current animation",22,null],[11,"render","","Renders an animation in the manager",22,null],[0,"vector","mold2d","",null,null],[3,"Vector2D","mold2d::vector","A two-dimensional vector",null,null],[12,"x","","",23,null],[12,"y","","",23,null],[3,"PositionChange","","Represents a change of position",null,null],[12,"x","","",24,null],[12,"y","","",24,null],[12,"w","","",24,null],[12,"h","","",24,null],[11,"eq","","",23,null],[11,"ne","","",23,null],[11,"fmt","","",23,null],[11,"clone","","",23,null],[11,"len","","Returns the length of a vector",23,null],[11,"normalize","","Returns a normalized vector",23,null],[11,"add","","",23,null],[11,"add","","",23,null],[11,"sub","","",23,null],[11,"sub","","",23,null],[11,"mul","","",23,null],[11,"mul","","",23,null],[11,"div","","",23,null],[11,"div","","",23,null],[11,"eq","","",24,null],[11,"ne","","",24,null],[11,"fmt","","",24,null],[11,"clone","","",24,null],[11,"new","","",24,{"inputs":[],"output":{"name":"positionchange"}}],[11,"from_vector","","",24,{"inputs":[{"name":"vector2d"}],"output":{"name":"positionchange"}}],[11,"left","","",24,null],[11,"right","","",24,null],[11,"up","","",24,null],[11,"down","","",24,null],[11,"shrink_height_top","","",24,null],[11,"grow_height_top","","",24,null],[11,"shrink_height_bot","","",24,null],[11,"grow_height_bot","","",24,null],[11,"shrink_width_left","","",24,null],[11,"grow_width_left","","",24,null],[11,"shrink_width_right","","",24,null],[11,"grow_width_right","","",24,null],[11,"chain","","",24,null],[11,"to_vector","","",24,null],[0,"viewport","mold2d","",null,null],[3,"Viewport","mold2d::viewport","Constrains coordinates from an open world into the current window view\nThis allows for scrolling for levels larger than the current screen",null,null],[12,"x","","The x value of the center coordinate of the viewport",25,null],[12,"y","","The y value of the center coordinate of the viewport",25,null],[12,"window_dimensions","","Width and height of the window",25,null],[12,"map_dimensions","","Width and height of the map",25,null],[11,"clone","","",25,null],[11,"new","","",25,null],[11,"set_position","","",25,null],[11,"in_viewport","","Returns true if the point is inside the viewport, false otherwise",25,null],[11,"relative_point","","Returns the point in the game relative to the viewpoint",25,null],[11,"constrain_to_viewport","","Returns a rectangle in viewport coordinates or None if not in viewport",25,null],[6,"MessageHandler","mold2d","Handler for a view to deal with actor messages",null,null],[8,"View","","",null,null],[10,"render","","Called every frame to render a view",26,null],[10,"update","","Called every frame to update a view",26,null],[8,"Actor","","A game object that supports sending and receiving messages",null,null],[10,"render","","Called every frame to render an actor",27,null],[10,"handle_message","","Handle a message sent by another actor",27,null],[10,"collides_with","","Returns the side of the collision if actor collides with another actor",27,null],[10,"update","","Called every frame to update an actor",27,null],[10,"data","","Gets the actor data",27,null],[11,"eq","","",0,null],[11,"ne","","",0,null],[11,"clone","","",0,null],[14,"block!","","Macro for easily creating block classes",null,null],[11,"collides_with","mold2d::sprite","",15,null],[11,"collides_with","","",15,null]],"paths":[[3,"ActorData"],[4,"ViewAction"],[3,"ActorManager"],[3,"FontCache"],[3,"SpriteCache"],[4,"CollisionSide"],[4,"BoundingBox"],[8,"Collision"],[3,"Window"],[3,"Context"],[3,"Events"],[3,"Quadtree"],[3,"Segment"],[8,"Polygon"],[3,"Score"],[3,"SpriteRectangle"],[3,"SpritesheetConfig"],[4,"Direction"],[8,"Renderable"],[3,"Sprite"],[3,"AnimatedSprite"],[3,"Spritesheet"],[3,"Animations"],[3,"Vector2D"],[3,"PositionChange"],[3,"Viewport"],[8,"View"],[8,"Actor"]]}; initSearch(searchIndex);