Skip to content

A game based on ray casting that got a bit out of hand

License

Notifications You must be signed in to change notification settings

oPisiti/RayCastingGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ray Casting Demo

A game based on ray casting that got a bit out of hand

raycast

How it works

The base of the calculations is the minimap.

On every frame, 1200 lines are created from the player, given a certain angle.

If the line intercepts any wall, their distance is calculated.

Then, a vertical rectangle is drawn on screen. Its x position is determined by the angle. Its size and shade, by the distance. This creates the illusion of depth and a light fog.

For movement, the position of the player is updated accordingly. For the FOV slider, the difference in the angle of the lines is increased or decreased.

Usage

Just clone the repo and open index.html.

WASD is used for walking and the arrow keys left and right move the camera. Space jumps.

The slider on the bottom left corner adjusts the FOV on the fly.

Shooter variation

The Shooter branch enables a mode in which the left mouse button shoots a light beam.

Such beam bounces of the walls and illuminates them for the player.

shooter

P5js library

This project uses the p5js library.

Thank you to all the contributors.

For the latest release, go to https://p5js.org/download/

About

A game based on ray casting that got a bit out of hand

Resources

License

Stars

Watchers

Forks

Packages

No packages published