{"id":20135686,"url":"https://github.com/timhopg/42-so_long","last_synced_at":"2026-05-13T03:03:16.555Z","repository":{"id":257628327,"uuid":"816413934","full_name":"TimHopg/42-so_long","owner":"TimHopg","description":"A 2D game developed using the `minilibx` library for 42 School Lisboa","archived":false,"fork":false,"pushed_at":"2024-09-19T09:20:07.000Z","size":4545,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-02T11:54:38.672Z","etag":null,"topics":["2d-game","42school","clang","minilibx","x11"],"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/TimHopg.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":"2024-06-17T17:44:48.000Z","updated_at":"2024-09-19T09:20:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"c80b3592-963e-4931-8375-9f07d552f007","html_url":"https://github.com/TimHopg/42-so_long","commit_stats":null,"previous_names":["timhopg/42-so_long"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TimHopg/42-so_long","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHopg%2F42-so_long","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHopg%2F42-so_long/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHopg%2F42-so_long/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHopg%2F42-so_long/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimHopg","download_url":"https://codeload.github.com/TimHopg/42-so_long/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHopg%2F42-so_long/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32965784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"online","status_checked_at":"2026-05-13T02:00:07.132Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["2d-game","42school","clang","minilibx","x11"],"created_at":"2024-11-13T21:16:13.085Z","updated_at":"2026-05-13T03:03:16.516Z","avatar_url":"https://github.com/TimHopg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# so_long\n\nA 2D game developed using the `MiniLibX` library for 42 School Lisboa.\n\n![so_long grade](./so_long_grade.png)\n\n![so_long_demo](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExbWdsYW1lNDlqZzJqZTNvemU0Nmlqdndmamw5Njd5anlkdzJmNDd6bCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Od0XMgLsmJhGL4kAa9/giphy.gif)\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Maps](#maps)\n- [Implementation](#implementation)\n  - [Parsing](#parsing)\n  - [Graphics](#graphics)\n  - [Animation](#animation)\n  - [Random](#random)\n- [Improvements](#improvements)\n- [Tips](#tips)\n- [Resources](#resources)\n\n## Introduction\n\nMiniLibX is an add-on library which makes developing in the X-Window (X11) system more approachable. `so_long` is a 2D game developed using this library and is our first graphical project. The objective of the game is to collect all collectibles (fortune cookies) and then reach the treasure chest without being caught by the zombie.\n\nTested on Ubuntu 22 on Linux.\n\n## Installation\n\nGit clone the repository:\n\n```shell\nhttps://github.com/TimHopg/42-so_long.git\n```\n\nIf the `mlx` folder/library is not present, run `make download` from within the directory.  \nRun `make` to compile the game.  \n`make clean` will remove object files.  \n`make fclean` will remove program and object files.  \n\n## Usage\n\n```shell\n./so_long [map_file]\n```\n\n`so_long` takes 1 mandatory argument. It should be the map file in `.ber` format.\n\n`WASD` are used for controls. `esc` or the close icon can be used to exit the game.\n\n### Maps\n\n- `1` - a wall\n- `0` - a background/empty tile\n- `P` - the player (there must be only one)\n- `C` - collectible (fortune cookie)\n- `E` - the exit (there must be only one)\n- `B` - a bad guy (zombie) (there must be a maximum of one)\n\nAll maps should be rectangular and have wall tiles around the perimeter. All coins and the exit should be reachable.  \nA selection of maps are available in the `/maps` directory.\n\n## Implementation\n\nMemory management was taken care of throughout development (not at the end of the project) otherwise it can become harder to manage. All structures and data was intialised using `ft_bzero()` or `ft_calloc()`.\n\n### Parsing\n\nA recursive flood fill function was used to check the validity of the map.\n\n### Graphics\n\n`xpm` file format was used for all graphics. This is a human readable interpretation of images with each different colour in the image's pallette assigned a different code character.\nTransparency issues were avoided by creating a bespoke image processing function that scanned line by line and ignored any pixels that were set to transparent.\n\nAll graphics used were found at [itch.io](http://itch.io).  \nCREDIT: [pixel-boy](https://pixel-boy.itch.io/ninja-adventure-asset-pack)\n\nGraphics were used for the move counter at the bottom of the screen.\nA Game Over, winning/losing splash is displayed if an end state is reached.\n\n### Animation\n\nThe player cannot walk through wall tiles but if they do attempt to the character will turn (the movement counter will not increase). When all collectibles are collected, the chest begins a short animation sequence.\n\nThe Zombie animation continues on a loop with a few repetitions of the idle animation before the attack animation in a random direction.\n\n### Random\n\n`rand()` was used to randomise the enemy movement. `srand(time(0))` was the seed used – without it the zombie's movement would be pseudo-random and the same sequence would be used on each launch.\n\nThe possible movement directions are calculated and then a random direction is selected.\n\n## Improvements\n\n- Instead of re-rendering the entire playable area of the screen on each change, only the section being updated could be rendered to save resources.\n- Include multiple enemies.\n- Other enemies could move towards the player.\n- Add player idle animation.\n\n## Tips\n\n- Remember to `make re` when changing certain aspects of the game.\n- `keysym` is more abstract than `keycode` (which is hardware specific) and thus more portable. Use it. (`X11/keysym.h`)\n- `destroy_display()` is necessary on Linux architecture (after `destroy_window()`). And `free(mlx.ptr)` too.\n- This was the first time I developed on a virtual machine using `ssh` through `VSCode` so I could maintain my usual environment.\n\n## Resources\n\n- [Harm Smits 42 Docs](https://harm-smits.github.io/42docs/libs/minilibx/introduction.html)\n- [42 Cursus Gitbook](https://42-cursus.gitbook.io/guide/rank-02/so_long/understand-so_long)\n- [Reactive.so Guide](https://reactive.so/post/42-a-comprehensive-guide-to-so_long)\n- [Transparency](https://pulgamecanica.herokuapp.com/posts/mlx-transparency)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhopg%2F42-so_long","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimhopg%2F42-so_long","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhopg%2F42-so_long/lists"}