GithubHelp home page GithubHelp logo

cub3d's Introduction

cub3D

Collaborators

Jenny Boucher

Thuy Linh Nguyen

Description

cub3D is a walking simulator that uses ray-casting similar to Wolfensterin 3D. This project was completed as part of the 42-School Core Curriculum. We chose to keep a cute pixel quality to the images and created some of our own textures to use.

Technologies

cub3D is written in C and uses MiniLibX, a small graphics library maintained by 42-School network.

Focus of Project

  • Use of C
  • Using basic algorithms (flood-fill, DDA)
  • Working with minimal graphics library
  • Rigor
  • Working in team

Features

Mandatory Part:

  • Parsing map files
  • Map validation
  • Rendering and walking through raycast maze
  • Collision detection

View of Mandatory Part

Bonus Part:

  • Minimap system
  • Rotate view with mouse
  • Raycast floor and ceiling
  • Animated ceiling
  • Doors that can be opened and closed View of Bonus Part

How to Use

Requirements

/* Project is currenlty being updated to work with M1 processor and key codes and cannot be used currently unless you have a system installation of minilibx and your system has linux key codes */

You will need a gcc compiler and the minilibx library

Controls

Key Action
W Move forward
A Move left
D Move right
S Move backwards
Left Arrow Turn Left
Right Arrow Turn Right
Space Open/ Close doors
Mouse Turn
ESC Close window


System Compatibility:

These hard-coded key codes have been designed to work within the context of a specific graphics program. They are mapped as follows:

  • 'w' = 13
  • 's' = 1
  • 'a' = 0
  • 'd' = 2
  • 'esc' = 53
  • 'left arrow' = 123
  • 'right arrow' = 124

cub3d's People

Contributors

linhtng avatar jboucher154 avatar

Stargazers

Markus Laaksonen avatar Lionel Clerc avatar  avatar

Watchers

 avatar

cub3d's Issues

Bonus: Issue with closing ./cub3D_bonus by clicking on the red cross

Closing ./cub3D_bonus by clicking on the red cross will print garbage character to the shell:
c3r3p6%./cub3D_bonus maps/good/test_whitespace.cub
MLX should close...
A�����
c3r3p6%

The issue doesn't exist for the mandatory part:
c3r3p6% ./cub3D maps/good/test_whitespace.cub
MLX should close...
c3r3p6%

mouse turning not updating player directions

Fix by adding these two lines along with player angle adjustment (updates player.d.x and player.d.y):
cubed->scene->player.d.x = cos(deg_to_rad(cubed->scene->player.angle)) * 5;
cubed->scene->player.d.y = -sin(deg_to_rad(cubed->scene->player.angle)) * 5;

can tell angle changes but direction does not, causes player movement with WASD not to match current angle.

Screen Shot 2023-08-29 at 3 30 21 PM

Bonus: Should minimap show the outer space outside the map?

For example, when run ./cub3D_bonus maps/good/test_whitespace.cub, the minimap will show gray space to the left but pink space to the right even though both of them are outer spaces, i.e. not belong to the map content. If we want to be consistent, we might want to gray out the space on the right as well.

Bonus: Consider adding protection/Error management for the frame texture

In setup_cubed_bonus.c file, we have in line 24:
((t_cubed_bonus *)cubed)->frame_img =
get_new_xpm_image(cubed, "textures/cub3d_tex/cubed_frame_noshade.xpm");

If there is no "textures/cub3d_tex/cubed_frame_noshade.xpm" file to be found, the progamme will crush. In mandatory part, all the texture xpm files are checked if they are valid files in the parsing. We should add the same error management/protection for any extra texture that we used in bonus.

Texture rendering issue

When viewing WEST textures at a perpendicular angle (0) the texture drawing seems to be a bit shifted down in some cases, not all. Still unsure of the exact conditions that are causing it. It seems to be dependent on the distance to the wall. It seems that the texture y value may be moving too far, leaving transparent pixels behind and drawing the skipped pixels at the bottom of the texture. However the top of the texture is also uneven. Further or closer or at different angles do not show this issue.

Screen shots taken when these out puts printed:
FIRST:
Screen Shot 2023-08-22 at 11 37 03 AM

[DRAW VIEW] player angle: 0.000000, ray angel: 0.041809 ,distance to wall: 76.999992
[DRAW VIEW] player angle: 0.000000, ray angel: 0.085605 ,distance to wall: 77.000000

SECOND:
Screen Shot 2023-08-22 at 11 38 09 AM
[DRAW VIEW] player angle: 0.000000, ray angel: 0.041809 ,distance to wall: 112.000000
[DRAW VIEW] player angle: 0.000000, ray angel: 0.085605 ,distance to wall: 112.000008

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.