{"id":20345787,"url":"https://github.com/izzypt/so_long","last_synced_at":"2025-07-17T17:41:22.961Z","repository":{"id":153026478,"uuid":"626652269","full_name":"izzypt/so_long","owner":"izzypt","description":"This project is a small 2D game. Its purpose is to make you work with textures, sprites, events and validations.","archived":false,"fork":false,"pushed_at":"2023-04-20T19:22:27.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T21:46:32.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izzypt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-11T22:40:16.000Z","updated_at":"2023-04-20T13:21:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3ebf6bf-3907-46f7-8be2-ae31c74bcc5b","html_url":"https://github.com/izzypt/so_long","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2Fso_long","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2Fso_long/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2Fso_long/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzypt%2Fso_long/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izzypt","download_url":"https://codeload.github.com/izzypt/so_long/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241876612,"owners_count":20035396,"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":[],"created_at":"2024-11-14T22:09:47.489Z","updated_at":"2025-03-04T15:44:48.496Z","avatar_url":"https://github.com/izzypt.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# MinilibX - Introduction\n\nMiniLibx is a C small library developed by 42. \n\nProvides an easy way to create graphical software, without any X-Window programming knowledge. \n\nIt provides simple window creation, a drawing tool, image and basic events management.\n\nI found most information to start on 42 docs :\n\nhttps://harm-smits.github.io/42docs/\n\n### About X-Window\nX-Window is a network-oriented graphical system for unix. \n\nFor example this is used when connecting to remote desktops. One of the most common examples of such implementation would be TeamViewer.\n\n# Installation\n\n- To get started setting up MiniLibx, I have downloaded the library from 42 paris :\n\nhttps://github.com/42Paris/minilibx-linux\n\n- Place the folder inside the root folder of your project repo.\n\n- Next, follow the instruction and compile the MiniLibx with \"make\" or \"./config\".\n\nAfter that, in the file you want to use MiniLibx on , you use ```#include \"mlx_linux/mlx.h\"``` or ```#include \u003cmlx.h\u003e``` (try one or the other)\n\n- Also, keep in mind that when compiling you will have to use those flags :\n\n```gcc \u003cyourfile\u003e.c -Lmlx_linux/ -lmlx_Linux -L/usr/lib -lXext -lX11 -lm -lz```\n\n\n# Initialization\n\nWe must execute the mlx_init function to start. \n\nThis will establish a connection to the correct graphical system and will return a void * which holds the location of our current MLX instance. To initialize MiniLibX one could do the following:\n\n```\n#include \u003cmlx.h\u003e\n\nint\tmain(void)\n{\n\tvoid\t*mlx;\n\n\tmlx = mlx_init();\n}\n```\n# Minilibx - The key functions\n\n- ```mlx_init()```\n  - This will establish a connection to the correct graphical system and will return a void * which holds the location of our current MLX instance.\n  -  Exemplo :\n  ```\n\tint\tmain(void)\n\t{\n\t\tvoid\t*mlx;\n\n\t\tmlx = mlx_init();\n\t}\n  ```\n- ```mlx_new_window(void *mlx_ptr, int size_x, int size_y, char *title)``` \n  - It will return a pointer to the window we have just created. \n  - We can give the window height, width and a title.\n  - Exemplo :\n  ```\n    mlx_win = mlx_new_window(mlx, 1920, 1080, \"Hello world!\");\n  ```\n- ```mlx_destroy_window()```  \n  - Is responsible for freeing all the ressources that have been allocated for the window when it is no longer needed.\n  - Exemplo :\n  ```\n    mlx_destroy_window(void *mlx_ptr, void *win_ptr);\n  ```\n- ```mlx_destroy_display()``` \n  - Use it to destroy the display before using ```free()``` on the ```mlx_init()``` pointer.\n  - Exemplo :\n  ```\n    mlx_destroy_display(mlx_ptr);\n  ``` \n- ```mlx_loop()```\n  - This loop will keep our mlx instance running and waiting for inputs.\n  ```\n\tmlx_loop(mlx);\n  ```\n- ```mlx_pixel_put(void *mlx_ptr, void *win_ptr, int x, int y, int color)``` \n  - This function draws a defined pixel in the window \u003cins\u003ewin_ptr\u003c/ins\u003e using the (x, y) coordinates, and the specified color.\n  - The origin (0, 0), is the upper left corner of the window, the x and y axis respectively pointing right and down.\n- ```mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color, char *string)``` \n  - The specified string will be displayed at (x, y)\n  - In both functions above, it is impossbible to display anything outside the specified window.\n\n- ```mlx_key_hook(void *win_ptr, int (*funct_ptr)(), void *param)```\n- ```mlx_mouse_hook(void *win_ptr, int (*funct_ptr)(), void *param)```\n- ```mlx_expose_hook(void *win_ptr, int (*funct_ptr)(), void *param)```\n- ```mlx_loop_hook(void *win_ptr, int (*funct_ptr)(), void *param)```\n- ```int\t\tmlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y);```\n\n\n# Writing pixels to a image \n\nFirst of all, we should start by understanding what type of image ```mlx``` requires. \n\nIf we initiate an image, we will have to pass a few pointers to which it will write a few important variables. \n\nThe first one is the ```bpp```, also called the ```bits per pixel```. \n\nAs the pixels are basically ints, these usually are 4 bytes, however, this can differ if we are dealing with a small endian (which means we most likely are on a remote display and only have 8 bit colors).\n\nNow we can initialize the image with size 1920×1080 as follows:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fso_long","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizzypt%2Fso_long","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzypt%2Fso_long/lists"}