{"id":25608035,"url":"https://github.com/deryaxacar/42-lov3d","last_synced_at":"2025-10-19T10:59:01.814Z","repository":{"id":278793045,"uuid":"888575935","full_name":"deryaxacar/42-LOV3D","owner":"deryaxacar","description":"The Cub3d project aims to create a 3D labyrinth game. The player navigates through the maze from a first-person perspective, trying to reach certain goals. This project covers fundamental aspects of game programming, graphics management, and user interaction. Furthermore, it provides experience in basic 3D game mechanics, collision detection, and e","archived":false,"fork":false,"pushed_at":"2025-06-15T09:55:09.000Z","size":864,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T10:48:37.341Z","etag":null,"topics":["3d","3d-game","3d-programming","42-school","42born2code","42cursus","42ecole","42projects","42school","c-language","c-programming","c-programming-language","c-project","c-projects","cub3d","cub3d-42","libxml2","minilibx","project"],"latest_commit_sha":null,"homepage":"https://github.com/deryaxacar/42-LOV3D","language":"C","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/deryaxacar.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-14T16:27:40.000Z","updated_at":"2025-06-15T09:55:12.000Z","dependencies_parsed_at":"2025-02-21T18:43:26.812Z","dependency_job_id":null,"html_url":"https://github.com/deryaxacar/42-LOV3D","commit_stats":null,"previous_names":["deryaxacar/42-lov3d"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deryaxacar/42-LOV3D","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deryaxacar%2F42-LOV3D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deryaxacar%2F42-LOV3D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deryaxacar%2F42-LOV3D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deryaxacar%2F42-LOV3D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deryaxacar","download_url":"https://codeload.github.com/deryaxacar/42-LOV3D/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deryaxacar%2F42-LOV3D/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267827337,"owners_count":24150345,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"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":["3d","3d-game","3d-programming","42-school","42born2code","42cursus","42ecole","42projects","42school","c-language","c-programming","c-programming-language","c-project","c-projects","cub3d","cub3d-42","libxml2","minilibx","project"],"created_at":"2025-02-21T20:17:49.021Z","updated_at":"2025-10-19T10:58:56.762Z","avatar_url":"https://github.com/deryaxacar.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- Project Title --\u003e\n\u003ch1 align=\"center\"\u003e 42 - cub3d 🕹️\u003c/h1\u003e\n\n\u003c!-- Project Description --\u003e\n\u003cp align=\"center\"\u003e\nThe Cub3d project aims to create a 3D labyrinth game. The player navigates through the maze from a first-person perspective, trying to reach certain goals. This project covers fundamental aspects of game programming, graphics management, and user interaction. Furthermore, it provides experience in basic 3D game mechanics, collision detection, and event management.\n\u003c/p\u003e\n\n\u003c!-- Project Logo or Image --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"blank\"\u003e\u003cimg src=\"https://github.com/deryaxacar/42-LOV3D/blob/main/cub3dm.png\" height=\"150\" width=\"150\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Project Purpose 🎯\n\nThe purpose of the Cub3d project is to develop a 3D maze game played from a first-person perspective. In the game, the user controls a character moving through a labyrinth to accomplish certain objectives. This project focuses on 3D project structure, game mechanics, graphics management, and user interaction.\n\nThe labyrinth is built from a series of map files, and the character moves around this environment based on user input. This project aims to develop essential game programming skills such as collision detection, event handling, and user interactions.\n\n### Core Objectives 🏆\n\n- **Maze Creation (3D):** Read map files in a 3D environment and render them correctly on the screen. The map files, which include walls, passable areas, and goal points, define both the visual layout and functionality of the game. 🗺️\n- **Character Movement:** Allow the user to move the character freely from a first-person perspective using arrow keys or similar controls. This movement is crucial for smooth gameplay and interactivity. 🕹️\n- **Collision Detection:** Detect collisions between the character and walls or other objects. This ensures that impassable areas are respected and that game physics are applied. 🚧\n- **Game Events:** Manage events such as game start, end, and various user interactions. These include game flow, player feedback, level transitions, and completing objectives. 🎮\n- **User Interaction:** Optimize the user interface and control mechanisms so that the player can easily adapt to the game and have an enjoyable experience. 🖱️\n- **Game Performance:** Improve the overall performance and efficiency of the game. Smooth graphics rendering and event handling enhance both the technical quality of the game and the player’s experience. ⚡\n\n## Ray Casting Algorithm 🌍\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"blank\"\u003e\u003cimg src=\"https://github.com/deryaxacar/42-LOV3D/blob/main/ray-casting.png\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nThe fundamental method used to achieve the 3D labyrinth view in the Cub3d project is the **Ray Casting** algorithm. This algorithm transforms a 2D map into a first-person 3D view.\n\n**Ray Casting** principles:\n1. The player has a specific position (x, y) and viewing angle (angle) within the game world.\n2. For each vertical “pixel column” on the screen, a “ray” is cast according to the player’s viewing angle.\n3. The ray is extended until it intersects with a wall or obstacle on the map.\n4. The point where the ray first intersects a wall determines the wall height to be drawn in that column.\n5. By calculating wall heights for every column, a 3D perspective is simulated on the screen.\n\nBelow is an example **C** function demonstrating a simple skeleton of the ray casting logic:\n\n```c\n#include \u003cmath.h\u003e\n#include \u003cstdio.h\u003e\n\n#define FOV 60.0      // Player's field of view in degrees\n#define SCREEN_WIDTH 640\n#define SCREEN_HEIGHT 480\n\n// Map definition (0 -\u003e empty space, 1 -\u003e wall)\nint map[8][8] = {\n    {1,1,1,1,1,1,1,1},\n    {1,0,0,0,0,0,0,1},\n    {1,0,1,0,0,0,0,1},\n    {1,0,0,0,0,1,0,1},\n    {1,0,0,0,0,0,0,1},\n    {1,0,0,1,0,0,0,1},\n    {1,0,0,0,0,0,0,1},\n    {1,1,1,1,1,1,1,1},\n};\n\n// Player initial position\nfloat playerX = 3.5, playerY = 3.5;\nfloat playerAngle = 0.0;\n\nvoid cast_rays(void)\n{\n    // Cast a ray for each pixel column on the screen\n    for (int x = 0; x \u003c SCREEN_WIDTH; x++) {\n        // Map the x column on screen to angles between -FOV/2 and +FOV/2\n        float rayAngle = (playerAngle - (FOV / 2.0)) + ((float)x / SCREEN_WIDTH) * FOV;\n        \n        // Convert degrees to radians\n        float rayRad = rayAngle * M_PI / 180.0;\n\n        // Ray marching\n        float stepSize = 0.1;  // Ray step size\n        float distance = 0.0;  // Distance to wall\n        float hitX = playerX;\n        float hitY = playerY;\n        \n        int hitWall = 0;\n\n        // Advance the ray until it hits a wall or reaches the map boundary\n        while (!hitWall \u0026\u0026 distance \u003c 20.0) {  // 20 -\u003e example maximum view distance\n            distance += stepSize;\n            hitX = playerX + cos(rayRad) * distance;\n            hitY = playerY + sin(rayRad) * distance;\n\n            // Check map boundaries\n            if (hitX \u003c 0 || hitX \u003e= 8 || hitY \u003c 0 || hitY \u003e= 8) {\n                hitWall = 1;\n                distance = 20.0;  // Treat this as if a wall is hit\n            } else if (map[(int)hitY][(int)hitX] == 1) {\n                hitWall = 1;  // A wall is found\n            }\n        }\n\n        // Calculate wall height (simple approach)\n        int wallHeight = (int)(SCREEN_HEIGHT / distance);\n        \n        // Here, you could draw the wall for this column:\n        // draw_vertical_line(x, wallHeight); // e.g., a custom drawing function\n    }\n}\n\n```\nBu örnek, ray casting mantığını çok basite indirgenmiş şekilde anlatmaktadır. Gerçekte, duvar çizimi ve texture mapping gibi ek işlemler yaparak daha detaylı bir görüntü elde edebilirsiniz.\n\n## Tools Used 🛠️\n\nKey tools and libraries used in the Cub3d project include:\n- **MiniLibX:** A library for graphics operations and window management.\n- **Xlib:** A library for interacting with the X Window System.\nRequirements 📋\n\n## Requirements 📋\n\nTo run the Cub3d project, you need to meet the following requirements:\n\n- A Unix-based operating system (Linux, macOS)\n- GCC compiler\n- MiniLibX library\n\n---\n\n\u003c!-- License --\u003e\n## License 📜\n\u003cp\u003eThis project is licensed under the \u003ca href=\"LICENSE\"\u003eMIT License\u003c/a\u003e. For more details, please check the license file.\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e2025 This project was created by Derya ACAR \u0026 Mertcan ÇAKIR.\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderyaxacar%2F42-lov3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderyaxacar%2F42-lov3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderyaxacar%2F42-lov3d/lists"}