{"id":21299749,"url":"https://github.com/ericoporto/mode7","last_synced_at":"2026-01-02T08:15:05.236Z","repository":{"id":42023328,"uuid":"472965805","full_name":"ericoporto/mode7","owner":"ericoporto","description":"Adventure Game Studio mode7 script module","archived":false,"fork":false,"pushed_at":"2023-08-18T19:44:45.000Z","size":30642,"stargazers_count":7,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-22T07:44:21.011Z","etag":null,"topics":["adventure-game-studio","ags","ags-modules","ags-script","gamedev","mode7"],"latest_commit_sha":null,"homepage":"https://www.adventuregamestudio.co.uk/forums/index.php?topic=59854.0","language":"AGS Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericoporto.png","metadata":{"files":{"readme":"README.BBCode","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-22T23:05:40.000Z","updated_at":"2025-01-02T01:55:03.000Z","dependencies_parsed_at":"2023-01-19T14:01:58.111Z","dependency_job_id":null,"html_url":"https://github.com/ericoporto/mode7","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericoporto%2Fmode7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericoporto%2Fmode7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericoporto%2Fmode7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericoporto%2Fmode7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericoporto","download_url":"https://codeload.github.com/ericoporto/mode7/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243769986,"owners_count":20345217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adventure-game-studio","ags","ags-modules","ags-script","gamedev","mode7"],"created_at":"2024-11-21T15:05:35.368Z","updated_at":"2026-01-02T08:15:05.205Z","avatar_url":"https://github.com/ericoporto.png","language":"AGS Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"[size=14pt][b]mode7[/b][/size] [color=gray][b] version 0.2.0 [/b][/color]\n\n[url=https://github.com/ericoporto/mode7/releases/download/0.2.0/mode7.scm]Get Latest Release [b]mode7.scm[/b][/url] | [url=https://github.com/ericoporto/mode7]GitHub Repo[/url] | [url=https://github.com/ericoporto/mode7/archive/0.2.0.zip] Download project .zip [/url]\n\nAGS Script Module for Mode7 like graphics. [url=https://ericoporto.github.io/mode7/][b]See demo in here![/b][/url] (Use Firefox, Safari or Chrome 100+, WASD to move)\n\n[img width=640 height=360]https://user-images.githubusercontent.com/2244442/160260167-0f6ab7a0-fd55-472a-839f-5332f3970476.gif[/img]\n\nThis module allows you to project a sprite on the screen with the visual aspect people are familiar from the mode7 graphics of SNES games. Use the Mode7 struct for that!\n\nIf you want to do more, and also want to have other elements in it, similar to Mario Kart, you can leverage Mode7World and Mode7Object functionalities.\n\nThis code is based on original code that was written by [b]Khris[/b] and presented in [url=https://www.adventuregamestudio.co.uk/forums/index.php?topic=45834.msg636452606#msg636452606]this ags forum thread[/url]. I asked Khris for the original code, which was very Kart oriented, I refactored to what I thought was more generic and made this module in the hopes people could pick around the code and make games out of it!\n\nA note, the original code was a bit more performant, I pulled out some specific optimizations to make the code more flexible.\n\n[size=14pt][b]Script API[/b][/size]\n[spoiler]\n\n[size=12pt][b]Mode7[/b][/size]\n\n[b][tt]Mode7.SetCamera[/tt][/b]\n[code=ags]void Mode7.SetCamera(float x, float y, float z, float xa, float ya, float focal_length)[/code]\nSets the camera position, angle and focal length.\n\n[b][tt]Mode7.SetViewscreen[/tt][/b]\n[code=ags]void Mode7.SetViewscreen(int width, int height, optional int x,  optional int y)[/code]\nSets the screen area it will draw in.\n\n[b][tt]Mode7.SetGroundSprite[/tt][/b]\n[code=ags]void Mode7.SetGroundSprite(int ground_graphic)[/code]\nSets the ground sprite, this is the mode7 rendered sprite.\n\n[b][tt]Mode7.SetHorizonSprite[/tt][/b]\n[code=ags]void Mode7.SetHorizonSprite(int horizon_graphic, eHorizonType = eHorizonDynamic)[/code]\nSets a sprite that will roll around in the horizon, you can also make it static.\n\n[b][tt]Mode7.SetBgColor[/tt][/b]\n[code=ags]void Mode7.SetBgColor(int bg_color)[/code]\nSets the color of the background where the ground sprite doesn't reach.\n\n[b][tt]Mode7.SetSkyColor[/tt][/b]\n[code=ags]void Mode7.SetSkyColor(int sky_color)[/code]\nSets the color of the sky.\n\n[b][tt]Mode7.TargetCamera[/tt][/b]\n[code=ags]void Mode7.TargetCamera(float target_x, float target_y, float target_z, float teta_angle, eCameraTargetType camType = eCameraTarget_FollowBehind, bool is_lazy = true)[/code]\nTarget the camera to something.\n\n[b][tt]Mode7.Draw[/tt][/b]\n[code=ags]void Mode7.Draw()[/code]\nDraws the ground sprite and horizon rendered in the Screen sprite.\n\n[b][tt]Mode7.ResetGround[/tt][/b]\n[code=ags]void Mode7.ResetGround()[/code]\nClears the screen sprite.\n\n[b][tt]Mode7.CameraAngleX[/tt][/b]\n[code=ags]float Mode7.CameraAngleX[/code]\nThe camera angle that is normal to the ground plane (e.g.: up and down).\n\n[b][tt]Mode7.CameraAngleY[/tt][/b]\n[code=ags]float Mode7.CameraAngleY[/code]\nThe camera angle that is on the ground plane (e.g.: left and right).\n\n[b][tt]Mode7.Screen[/tt][/b]\n[code=ags]DynamicSprite* Mode7.Screen[/code]\nThe Dynamic Sprite that represents the screen where the Mode7 ground is draw to.\n[hr]\n\n\n[size=12pt][b]Mode7World[/b][/size]\nThis is an extension of Mode7 and gives you tools to present billboard sprites, positioned in the world coordinates, using the concept of Mode7Objects. You don't have to use it to do the drawing, but it should help you if you want to!\n\n[b][tt]Mode7World.AddObject[/tt][/b]\n[code=ags]Mode7Object* Mode7World.AddObject(int x, int z, float factor, int graphic)[/code]\nAdds an object, and sets it's x and z position. The y (vertical position) is always zero. You also must pass a scale factor and it's graphics.\n\n[b][tt]Mode7World.AddExternalObject[/tt][/b]\n[code=ags]void Mode7World.AddExternalObject(int x, int z, float factor, int graphic)[/code]\nAdds an external object that is not managed by the Mode7World. It will still be updated and draw, but removing it from the world will probably not garbage collect it.\n\n[b][tt]Mode7World.RemoveObject[/tt][/b]\n[code=ags]void Mode7World.RemoveObject(int object_i = -1)[/code]\nRemove a specific object from the world by it's index. If you don't pass a value, it will remove the last valid object added.\n\n[b][tt]Mode7World.RemoveAllsObjects[/tt][/b]\n[code=ags]void Mode7World.RemoveAllsObjects()[/code]\nRemoves all objects from the Mode7 World.\n\n[b][tt]Mode7World.GetAngleObjectAndCamera[/tt][/b]\n[code=ags]int Mode7World.GetAngleObjectAndCamera(Mode7Object* m7obj)[/code]\nReturns the angle in degrees between the camera and whatever angle is set to a specific object, pointed by their index. Useful when you want to change the graphic of an object based on their relative angle.\n\n[b][tt]Mode7World.UpdateObjects[/tt][/b]\n[code=ags]void Mode7World.UpdateObjects()[/code]\nUpdate the screen transform of all objects world positions to their screen positions. You must call it before drawing any objects!\n\n[b][tt]Mode7World.DrawObjects[/tt][/b]\n[code=ags]void Mode7World.DrawObjects()[/code]\nDraws only the objects in the screen sprite. You can use when you need to draw additional things between the ground and the objects. Or when you don't need the ground at all.\n\n[b][tt]Mode7World.DrawWorld[/tt][/b]\n[code=ags]void Mode7World.DrawWorld()[/code]\nDraws the ground sprite and the objects over it, in the screen sprite.\n\n[b][tt]Mode7World.DrawWorld2D[/tt][/b]\n[code=ags]DynamicSprite* Mode7World.DrawWorld2D()[/code]\nGets a dynamic sprite with the world draw in top down view, useful for debugging.\n\n[b][tt]Mode7World.Objects[/tt][/b]\n[code=ags]writeprotected Mode7Object* Mode7World.Objects[i][/code]\nLet's you access a specific object in the mode7 world by it's index. Make sure to access a valid position.\n\n[b][tt]Mode7World.ObjectCount[/tt][/b]\n[code=ags]writeprotected int Mode7World.ObjectCount[/code]\nGets how many objects are currently in the mode7 world.\n\n[b][tt]Mode7World.ObjectScreenVisibleCount[/tt][/b]\n[code=ags]writeprotected int Mode7World.ObjectScreenVisibleCount[/code]\nGets how many objects are actually visible in the screen.\n\nYou can iterate through all the screen objects as follows:\n\n[code=ags]for(int i=0; i \u003c m7w.ObjectScreenVisibleCount; i++)\n{\n  // will make sure to access in order from far to closer\n  int index = m7w.ObjectScreenVisibleID[m7w.ObjectScreenVisibleOrder[i]];\n  Obj* m7object = m7w.Objects[index];\n  \n  // do as you you must with you m7object ...\n}[/code]\n[hr]\n\n\n[size=12pt][b]Mode7Object[/b][/size]\nA Mode7Object, you should create objects by using Mode7World.AddObject. After world coordinates are set, you can use Mode7World.UpdateObjects to transform it's coordinates and get updated values in it's Screen prefixed properties.\n\n[b][tt]Mode7Object.SetPosition[/tt][/b]\n[code=ags]void Mode7Object.SetPosition(float x, float y, float z)[/code]\nA helper function to setting the Object world position in a single line.\n\n[b][tt]Mode7Object.Draw[/tt][/b]\n[code=ags]void Mode7Object.Draw(DrawingSurface* ds)[/code]\nDraw the object in a DrawingSurface as it would look in a screen.\n\n[b][tt]Mode7Object.X[/tt][/b]\n[code=ags]float Mode7Object.X[/code]\nObject World X Position on the plane.\n\n[b][tt]Mode7Object.Y[/tt][/b]\n[code=ags]float Mode7Object.Y[/code]\nObject World Y Position, perpendicular to plane.\n\n[b][tt]Mode7Object.Z[/tt][/b]\n[code=ags]float Mode7Object.Z[/code]\nObject World Z Position, orthogonal to X position.\n\n[b][tt]Mode7Object.Factor[/tt][/b]\n[code=ags]float Mode7Object.Factor[/code]\nObject Scaling factor to it's graphics.\n\n[b][tt]Mode7Object.Angle[/tt][/b]\n[code=ags]float Mode7Object.Angle[/code]\nObject angle, parallel to plane, not used for rendering.\n\n[b][tt]Mode7Object.Graphic[/tt][/b]\n[code=ags]int Mode7Object.Graphic[/code]\nObject sprite slot, it's width and height is used to calculate the screen coordinates.\n\n[b][tt]Mode7Object.Visible[/tt][/b]\n[code=ags]bool Mode7Object.Visible[/code]\nObject visibility.\n\n[b][tt]Mode7Object.ScreenX[/tt][/b]\n[code=ags]int Mode7Object.ScreenX[/code]\nOn-Screen Object X position when drawing, if visible. It's regular top, left coordinates, similar to GUI, assumes a Graphic is set.\n\n[b][tt]Mode7Object.ScreenY[/tt][/b]\n[code=ags]int Mode7Object.ScreenY[/code]\nOn-Screen Object Y position when drawing, if visible. It's regular top, left coordinates, similar to GUI, assumes a Graphic is set.\n\n[b][tt]Mode7Object.ScreenWidth[/tt][/b]\n[code=ags]int Mode7Object.ScreenWidth[/code]\nOn-Screen Object Width when drawing, if visible. It's adjusted by the sprite used in Graphic, projection and scaling factor.\n\n[b][tt]Mode7Object.ScreenHeight[/tt][/b]\n[code=ags]int Mode7Object.ScreenHeight[/code]\nOn-Screen Object Height when drawing, if visible. It's adjusted by the sprite used in Graphic, projection and scaling factor.\n\n[b][tt]Mode7Object.ScreenVisible[/tt][/b]\n[code=ags]bool Mode7Object.ScreenVisible[/code]\nTrue if object should be drawn on screen. Gets set to false if object is culled when projecting.\n\n[b][tt]Mode7Object.ScreenZOrder[/tt][/b]\n[code=ags]int Mode7Object.ScreenZOrder[/code]\nZOrder of the object when drawing on screen, smaller numbers are below, bigger numbers are on top.\n[/spoiler]\n\nThis is just a quick initial release, I plan to update this soon with a better demo and polish the API and other stuff!\n\n[list]\n[li]v0.1.0 - initial release.[/li]\n[li]v0.2.0 - added ResetGround, CameraAngleX, CameraAngleY to Mode7, added Visible to Mode7Object, added AddExternalObject and DrawWorld2D to Mode7World, change GetAngleObjectAndCamera api.[/li]\n[/list]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericoporto%2Fmode7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericoporto%2Fmode7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericoporto%2Fmode7/lists"}